prompt-enhancement-mcp-server

prompt-enhancement-mcp-server

Enables users to enhance rough prompts into more detailed, clear, and effective versions using multiple AI providers like Anthropic, OpenAI, and Gemini. Supports custom templates and integrates with any MCP-compatible client.

Category
访问服务器

README

Prompt Enhancement MCP Server

An MCP (Model Context Protocol) server that enhances user prompts using AI. It takes a rough prompt and returns a more detailed, clear, and effective version. Works with any MCP-compatible client like Claude Desktop or Claude Code.

Quick Start

  1. Install and set your API key:

    export ANTHROPIC_API_KEY=sk-ant-...
    
  2. Add to your MCP client config (e.g. Claude Desktop):

    {
      "mcpServers": {
        "prompt-enhancer": {
          "command": "npx",
          "args": ["-y", "prompt-enhancement-mcp-server"],
          "env": {
            "ANTHROPIC_API_KEY": "your-key-here"
          }
        }
      }
    }
    
  3. Use the enhance_prompt tool to improve any prompt.

Installation

# Run directly with npx (recommended)
npx -y prompt-enhancement-mcp-server

# Or install globally
npm install -g prompt-enhancement-mcp-server

# Or install locally
npm install prompt-enhancement-mcp-server

Supported Providers

Provider Env Variable Default Model
Anthropic ANTHROPIC_API_KEY claude-sonnet-4-5-20250929
OpenAI OPENAI_API_KEY gpt-4o
OpenRouter OPENROUTER_API_KEY anthropic/claude-sonnet-4-5-20250929
Gemini GEMINI_API_KEY gemini-2.0-flash
OpenAI-compatible OPENAI_COMPATIBLE_API_KEY gpt-3.5-turbo

Set at least one API key as an environment variable.

Configuration

Environment Variables

# API keys (set at least one)
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
OPENROUTER_API_KEY=sk-or-...
GEMINI_API_KEY=...

# Optional settings
PROMPT_ENHANCER_DEFAULT_PROVIDER=anthropic   # Which provider to use by default
PROMPT_ENHANCER_CONFIG=/path/to/config.json  # Custom config file path
PROMPT_ENHANCER_LOG_LEVEL=info               # debug, info, warn, error

Optional Config File

Create ~/.config/prompt-enhancer/config.json for model defaults, custom templates, or OpenAI-compatible endpoints:

{
  "defaultProvider": "anthropic",
  "providers": {
    "anthropic": {
      "model": "claude-sonnet-4-5-20250929",
      "temperature": 0.7,
      "maxTokens": 4096
    },
    "openai": {
      "model": "gpt-4o"
    },
    "openrouter": {
      "model": "anthropic/claude-sonnet-4-5-20250929",
      "baseUrl": "https://openrouter.ai/api/v1"
    },
    "gemini": {
      "model": "gemini-2.0-flash"
    }
  },
  "templates": {
    "default": "Generate an enhanced version of this prompt (reply with only the enhanced prompt - no conversation, explanations, lead-in, bullet points, placeholders, or surrounding quotes):\n\n${userInput}"
  },
  "options": {
    "maxContextMessages": 10,
    "contextTruncateLength": 500
  }
}

API keys are never stored in the config file -- always use environment variables.

Tool: enhance_prompt

The server exposes a single MCP tool:

Parameter Type Required Description
text string Yes The prompt text to enhance
provider string No Provider to use (anthropic, openai, openrouter, gemini, openai-compatible)
model string No Model override (e.g. gpt-4-turbo)
context array No Conversation history ([{role, content}]) for context
template string No Custom template. Use ${userInput} as placeholder

Claude Desktop Integration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "prompt-enhancer": {
      "command": "npx",
      "args": ["-y", "prompt-enhancement-mcp-server"],
      "env": {
        "ANTHROPIC_API_KEY": "your-key-here"
      }
    }
  }
}

Claude Code Integration

Add to ~/.claude/claude_code_config.json or your project's .mcp.json:

{
  "mcpServers": {
    "prompt-enhancer": {
      "command": "npx",
      "args": ["-y", "prompt-enhancement-mcp-server"],
      "env": {
        "OPENAI_API_KEY": "your-key-here",
        "PROMPT_ENHANCER_DEFAULT_PROVIDER": "openai"
      }
    }
  }
}

Custom Templates

Override the default enhancement template via the config file or the template tool parameter:

{
  "templates": {
    "default": "Rewrite this prompt to be more specific and actionable:\n\n${userInput}"
  }
}

Or pass inline when calling the tool:

{
  "text": "write a web app",
  "template": "Add technical details and edge cases to this prompt:\n\n${userInput}"
}

OpenAI-Compatible Endpoints

Connect to Ollama, LM Studio, vLLM, or any OpenAI-compatible API:

{
  "providers": {
    "openai-compatible": {
      "baseUrl": "http://localhost:11434/v1",
      "model": "llama3"
    }
  }
}

Then use it:

{
  "text": "write a function",
  "provider": "openai-compatible"
}

Troubleshooting

"Unsupported provider" error Check that the provider name is one of: anthropic, openai, openrouter, gemini, openai-compatible.

"API key is required" / authentication errors Make sure the corresponding environment variable is set. API keys are loaded from env vars, not the config file.

Timeouts or rate limit errors The server retries transient errors up to 3 times with exponential backoff. If you're consistently hitting rate limits, try a different provider or model.

No output / server won't start Check PROMPT_ENHANCER_LOG_LEVEL=debug for detailed logging. Logs go to stderr (MCP protocol reserves stdout for communication).

Development

git clone <repo-url>
cd prompt-enhancement-mcp-server
npm install
npm run build
npm test

License

Apache-2.0

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选