Promptheus

io.github.abhichandra21由 GitHub 账号 abhichandra21 发布v0.3.1更新于 Oct 24, 2026

AI-powered prompt refinement with adaptive questioning and multi-provider support (6+ LLM backends)

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

一个本地 MCP 服务器,借助自适应澄清问题,使用已配置的某个 LLM 提供商来优化和微调 LLM 提示词。

可以做什么
优化提示词并可附带澄清问题,返回优化后的提示词,或返回需要回答的问题,再按问题 ID 映射答案重新提交(refine_prompt)。对现有提示词做针对性修改,例如让它更简短(tweak_prompt)。查询已配置提供商可用的模型(list_models)。检查哪些提供商已配置以及各自使用的模型(list_providers)。校验环境配置,并可选测试 API 连通性(validate_environment)。
适用场景
适合在正式使用前,把粗略或信息不足的提示词改写成详细、结构清晰的提示词,或对已有提示词做小幅精准修改。也适合需要结构化问答步骤来收集受众、语气、篇幅等要求的工作流。
运行要求
以 Python 包形式在本地运行(pip install promptheus),通过 stdio 通信,用 promptheus mcp 或 python -m promptheus.mcp_server 启动。需安装 mcp 包。至少需要一个提供商 API 密钥,可在 .env 文件或环境变量中设置:ANTHROPIC_API_KEY、GLM_API_KEY、GOOGLE_API_KEY、GROQ_API_KEY、OPENAI_API_KEY 或 QWEN_API_KEY。可用 PROMPTHEUS_PROVIDER 和 PROMPTHEUS_MODEL 覆盖提供商与模型。访问提供商 API 需要网络。
安装前请注意
需要至少一个第三方 LLM API 密钥,提示词和问题会发送给所选提供商,可能在你的账户上产生费用。README 还提到 OpenRouter 支持及清单中未列出的 OPENROUTER_MODEL 设置。匿名使用与性能遥测数据保存在本地,可用 PROMPTHEUS_TELEMETRY_ENABLED=0 关闭。会话历史保存在本地,可用 PROMPTHEUS_HISTORY_DIR 更改位置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Promptheus,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Promptheus

Refine and optimize prompts for LLMs

[Python Version] [PyPI Version] [Release Version] [License: MIT] [GitHub Stars]

[Deploy GitHub Pages] [Docker Build & Test] [Publish Python Package]

Quick Start

bash
pip install promptheus
bash
# Interactive sessionpromptheus
# Single promptpromptheus "Write a technical blog post"
# Skip clarifying questionspromptheus -s "Explain Kubernetes"
# Use web UIpromptheus web

Python library usage

python
from promptheus import refine_prompt
result = refine_prompt("Write a technical blog post", skip_questions=True)print(result["refined_prompt"])

If you're already in an async application (e.g., FastAPI), call refine_prompt_async instead of the sync helper.

What is Promptheus?

Promptheus analyzes your prompts and refines them with:

  • Adaptive questioning: Smart detection of what information you need to provide
  • Multi-provider support: Works with Google, OpenAI, Anthropic, Groq, Qwen, and more
  • Interactive refinement: Iteratively improve outputs through natural conversation
  • Session history: Automatically track and reuse past prompts
  • CLI and Web UI: Use from terminal or browser

Supported Providers

ProviderModelsSetup
Google Geminigemini-2.0-flash, gemini-1.5-proAPI Key
Anthropic Claudeclaude-3-5-sonnet, claude-3-opusConsole
OpenAIgpt-4o, gpt-4-turboAPI Key
Groqllama-3.3-70b, mixtral-8x7bConsole
Alibaba Qwenqwen-max, qwen-plusDashScope
Zhipu GLMglm-4-plus, glm-4-airConsole
OpenRouteropenrouter/auto (auto-routing)Dashboard

OpenRouter integration in Promptheus is optimized around the openrouter/auto routing model:

  • Model listing is intentionally minimal: Promptheus does not expose your full OpenRouter account catalog.
  • You can still specify a concrete model manually with OPENROUTER_MODEL or --model if your key has access.

Core Features

🧠 Adaptive Task Detection Automatically detects whether your task needs refinement or direct optimization

⚡ Interactive Refinement Ask targeted questions to elicit requirements and improve outputs

📝 Pipeline Integration Works seamlessly in Unix pipelines and shell scripts

🔄 Session Management Track, load, and reuse past prompts automatically

📊 Telemetry & Analytics Anonymous usage and performance metrics tracking for insights (local storage only, can be disabled)

🌐 Web Interface Beautiful UI for interactive prompt refinement and history management

Configuration

Create a .env file with at least one provider API key:

bash
GOOGLE_API_KEY=your_key_hereANTHROPIC_API_KEY=your_key_hereOPENAI_API_KEY=your_key_here

Or run the interactive setup:

bash
promptheus auth

Examples

Content Generation

bash
promptheus "Write a blog post about async programming"# System asks: audience, tone, length, key topics# Generates refined prompt with all specifications

Code Analysis

bash
promptheus -s "Review this function for security issues"# Skips questions, applies direct enhancement

Interactive Session

bash
promptheus/set provider anthropic/set model claude-3-5-sonnet# Process multiple prompts, switch providers/models with /commands

Pipeline Integration

bash
echo "Create a REST API schema" | promptheus | jq '.refined_prompt'cat prompts.txt | while read line; do promptheus "$line"; done

Testing & Examples: See sample_prompts.md for test prompts demonstrating adaptive task detection (analysis vs generation).

Telemetry & Analytics

bash
# View telemetry summary (anonymous metrics about usage and performance)promptheus telemetry summary
# Disable telemetry if desiredexport PROMPTHEUS_TELEMETRY_ENABLED=0
# Customize history storage locationexport PROMPTHEUS_HISTORY_DIR=~/.custom_promptheus

MCP Server

Promptheus includes a Model Context Protocol (MCP) server that exposes prompt refinement capabilities as standardized tools for integration with MCP-compatible clients.

What the MCP Server Does

The Promptheus MCP server provides:

  • Prompt refinement with Q&A: Intelligent prompt optimization through adaptive questioning
  • Prompt tweaking: Surgical modifications to existing prompts
  • Model/provider inspection: Discovery and validation of available AI providers
  • Environment validation: Configuration checking and connectivity testing

Starting the MCP Server

bash
# Start the MCP serverpromptheus mcp
# Or run directly with Pythonpython -m promptheus.mcp_server

Prerequisites:

  • MCP package installed: pip install mcp (included in requirements.txt)
  • At least one provider API key configured (see Configuration)

Available MCP Tools

refine_prompt

Intelligent prompt refinement with optional clarification questions.

Inputs:

  • prompt (required): The initial prompt to refine
  • answers (optional): Dictionary mapping question IDs to answers {q0: "answer", q1: "answer"}
  • answer_mapping (optional): Maps question IDs to original question text
  • provider (optional): Override provider (e.g., "google", "openai")
  • model (optional): Override model name

Response Types:

  • {"type": "refined", "prompt": "...", "next_action": "..."}: Success with refined prompt
  • {"type": "clarification_needed", "questions_for_ask_user_question": [...], "answer_mapping": {...}}: Questions needed
  • {"type": "error", "error_type": "...", "message": "..."}: Error occurred
tweak_prompt

Apply targeted modifications to existing prompts.

Inputs:

  • prompt (required): Current prompt to modify
  • modification (required): Description of changes (e.g., "make it shorter")
  • provider, model (optional): Provider/model overrides

Returns:

  • {"type": "refined", "prompt": "..."}: Modified prompt
list_models

Discover available models from configured providers.

Inputs:

  • providers (optional): List of provider names to query
  • limit (optional): Max models per provider (default: 20)
  • include_nontext (optional): Include vision/embedding models

Returns:

  • {"type": "success", "providers": {"google": {"available": true, "models": [...]}}}
list_providers

Check provider configuration status.

Returns:

  • {"type": "success", "providers": {"google": {"configured": true, "model": "..."}}}
validate_environment

Test environment configuration and API connectivity.

Inputs:

  • providers (optional): Specific providers to validate
  • test_connection (optional): Test actual API connectivity

Returns:

  • {"type": "success", "validation": {"google": {"configured": true, "connection_test": "passed"}}}

Prompt Refinement Workflow with Q&A

The MCP server supports a structured clarification workflow for optimal prompt refinement:

Step 1: Initial Refinement Request
json
{  "tool": "refine_prompt",  "arguments": {    "prompt": "Write a blog post about machine learning"  }}
Step 2: Handle Clarification Response
json
{  "type": "clarification_needed",  "task_type": "generation",  "message": "To refine this prompt effectively, I need to ask...",  "questions_for_ask_user_question": [    {      "question": "Who is your target audience?",      "header": "Q1",      "multiSelect": false,      "options": [        {"label": "Technical professionals", "description": "Technical professionals"},        {"label": "Business executives", "description": "Business executives"}      ]    }  ],  "answer_mapping": {    "q0": "Who is your target audience?"  }}
Step 3: Collect User Answers

Use your MCP client's AskUserQuestion tool with the provided questions, then map answers to question IDs.

Step 4: Final Refinement with Answers
json
{  "tool": "refine_prompt",   "arguments": {    "prompt": "Write a blog post about machine learning",    "answers": {"q0": "Technical professionals"},    "answer_mapping": {"q0": "Who is your target audience?"}  }}

Response:

json
{  "type": "refined",  "prompt": "Write a comprehensive technical blog post about machine learning fundamentals targeted at software engineers and technical professionals. Include practical code examples and architectural patterns...",  "next_action": "This refined prompt is now ready to use. If the user asked you to execute/run the prompt, use this refined prompt directly with your own capabilities..."}

AskUser Integration Contract

The MCP server operates in two modes:

Interactive Mode (when AskUserQuestion is available):

  • Automatically asks clarification questions via injected AskUserQuestion function
  • Returns refined prompt immediately after collecting answers
  • Seamless user experience within supported clients

Structured Mode (fallback for all clients):

  • Returns clarification_needed response with formatted questions
  • Client responsible for calling AskUserQuestion tool
  • Answers mapped back via answer_mapping dictionary

Question Format: Each question in questions_for_ask_user_question includes:

  • question: The question text to display
  • header: Short identifier (Q1, Q2, etc.)
  • multiSelect: Boolean for multi-select options
  • options: Array of {label, description} for radio/checkbox questions

Answer Mapping:

  • Question IDs follow pattern: q0, q1, q2, etc.
  • Answers dictionary uses these IDs as keys: {"q0": "answer", "q1": "answer"}
  • answer_mapping preserves original question text for provider context

Troubleshooting MCP

MCP Package Not Installed

Error: The 'mcp' package is not installed. Please install it with 'pip install mcp'.

Fix: pip install mcp or install Promptheus with dev dependencies: pip install -e .[dev]

Missing Provider API Keys

json
{  "type": "error",  "error_type": "ConfigurationError",   "message": "No provider configured. Please set API keys in environment."}

Diagnosis: Use list_providers or validate_environment tools to check configuration status

Provider Misconfiguration

json
{  "type": "success",  "providers": {    "google": {"configured": false, "error": "GOOGLE_API_KEY not found"},    "openai": {"configured": true, "model": "gpt-4o"}  }}

Fix: Set missing API keys in .env file or environment variables

Connection Test Failures

json
{  "type": "success",   "validation": {    "google": {      "configured": true,      "connection_test": "failed: Authentication error"    }  }}

Fix: Verify API keys are valid and have necessary permissions

Full Documentation

Quick reference: promptheus --help

Comprehensive guides:

Development

bash
git clone https://github.com/abhichandra21/Promptheus.gitcd Promptheuspip install -e ".[dev]"pytest -q

See CLAUDE.md for detailed development guidance.

License

MIT License - see LICENSE for details

Contributing

Contributions welcome! Please see our development guide for contribution guidelines.


Questions? Open an issue | Live demo: promptheus web

来源:README.md,提交 a2fa5dd

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.3.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分