MCP Prompt Optimizer

MCP Prompt Optimizer

This MCP server provides research-backed prompt optimization tools and professional domain templates designed to improve AI performance through strategies like Tree of Thoughts and Medprompt. It enables users to analyze, auto-optimize, and refine prompts using advanced reasoning patterns and safety-critical alignment techniques.

Category
访问服务器

README

MCP Prompt Optimizer

Python 3.8+ License: MIT MCP Compatible

A professional-grade MCP (Model Context Protocol) server that provides cutting-edge prompt optimization tools with research-backed strategies delivering 15-74% performance improvements.

✨ Features

🎯 Basic Optimization Strategies

  • Clarity: Simplifies prompts for directness and precision
  • Specificity: Adds detailed constraints and requirements
  • Chain of Thought: Incorporates step-by-step reasoning
  • Few-Shot: Includes example formats for guidance
  • Structured Output: Defines clear output organization
  • Role-Based: Adds expert role context

🚀 Advanced Optimization Strategies

  • Tree of Thoughts (ToT): Multi-path reasoning with 74% success rate on complex tasks
  • Constitutional AI: Self-critique and alignment with safety principles
  • Automatic Prompt Engineer (APE): AI-discovered optimal instruction patterns
  • Meta-Prompting: AI generates its own optimized prompts
  • Self-Refine: Iterative improvement with 20% performance gains
  • TEXTGRAD: Natural language feedback as optimization gradients
  • Medprompt: Multi-technique ensemble achieving 90%+ accuracy
  • PromptWizard: Feedback-driven self-evolving prompts

📋 Professional Domain Templates

Production-ready templates across 11 domains:

  • Business Analysis: Competitive analysis frameworks
  • Product Management: User research synthesis
  • Content Creation: Technical blog posts with SEO optimization
  • Development: Comprehensive code review checklists
  • Communication: Stakeholder updates and project reports
  • Strategy: OKR planning frameworks
  • Operations: Standard Operating Procedures (SOPs)
  • Legal: Contract termination and compliance
  • Customer Experience: Feedback surveys and insights
  • Data Analysis: Data insights and reporting
  • Meeting Management: Effective meeting agendas

🛠️ Installation

Quick Setup

# Clone the repository
git clone <repository-url>
cd mcp-prompt-optimizer

# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
./install.sh

# Or install manually
pip install -r requirements.txt

# Configure Claude Desktop
python3 setup_interactive.py

Manual Configuration

Add to your Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "prompt-optimizer": {
      "command": "python3",
      "args": ["/path/to/mcp-prompt-optimizer/prompt_optimizer.py"],
      "env": {}
    }
  }
}

🎮 Usage

Basic Commands

# Analyze prompt quality
"Analyze this prompt: write a blog post about AI"

# Apply specific optimization
"Optimize this prompt using chain_of_thought: explain machine learning"

# Auto-select best strategy
"Auto-optimize: help me debug this code"

# Get domain template
"Get domain template for code_review_checklist"

Advanced Commands

# Use Tree of Thoughts for complex problems
"Apply advanced optimization with tree_of_thoughts: design a microservices architecture"

# Use Constitutional AI for safety-critical tasks
"Apply advanced optimization with constitutional_ai: create content moderation guidelines"

# Use Medprompt for high-accuracy classification
"Apply advanced optimization with medprompt: categorize customer support tickets"

# List available templates
"List all domain templates"

🏗️ Architecture

mcp-prompt-optimizer/
├── prompt_optimizer.py      # Main MCP server
├── advanced_strategies.py   # Research-backed optimization strategies
├── domain_templates.py      # Professional domain templates
├── examples.py              # Usage examples and demonstrations
├── setup_interactive.py     # Automated setup script
└── README.md               # This file

🧪 Testing

# Run basic tests
./test.sh

# Run usage examples
python3 examples.py

📊 Performance Benchmarks

Strategy Use Case Performance Improvement
Tree of Thoughts Complex reasoning 70-74% success rate
Medprompt Classification tasks 90%+ accuracy
Self-Refine Iterative improvement 20% per iteration
Constitutional AI Safety alignment High compliance
Chain of Thought Step-by-step tasks 15-25% improvement

🔧 Available Tools

Core Tools

  1. analyze_prompt: Analyzes prompt quality and identifies issues
  2. optimize_prompt: Applies specific optimization strategies
  3. auto_optimize: Automatically selects optimal strategy
  4. get_prompt_template: Returns basic templates

Advanced Tools

  1. advanced_optimize: Applies research-backed strategies
  2. get_domain_template: Returns professional domain templates
  3. list_domain_templates: Lists available templates by domain

🎯 Strategy Selection Guide

Prompt Type Recommended Strategy
Complex problems tree_of_thoughts
Classification tasks medprompt
Safety-critical constitutional_ai
Vague requirements meta_prompting
Needs refinement self_refine
General optimization auto

🤝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Update documentation
  5. Submit a pull request

Adding New Features

  • New Strategy: Add to advanced_strategies.py
  • New Template: Add to domain_templates.py
  • Examples: Add to examples.py

🐛 Troubleshooting

Common Issues

MCP not working?

  • Check Python version: python3 --version (requires 3.8+)
  • Install dependencies: Run ./install.sh or pip install -r requirements.txt
  • Verify MCP installation: pip show mcp
  • Check Claude Desktop logs
  • Restart Claude Desktop

Commands not recognized?

  • Verify configuration file location
  • Check file paths in configuration
  • Run setup script again

Debug Mode

# Test server directly
python3 prompt_optimizer.py

# Verbose logging
export MCP_LOG_LEVEL=debug
python3 prompt_optimizer.py

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Research from Princeton, Google DeepMind, Microsoft Research
  • Anthropic's Constitutional AI framework
  • Stanford's DSPy framework
  • OpenAI's prompt engineering guidelines

📈 Citation

If you use this tool in your research or projects, please cite:

@software{mcp_prompt_optimizer,
  title={MCP Prompt Optimizer: Research-Backed Prompt Optimization for AI Systems},
  author={Bubobot},
  year={2024},
  url={https://github.com/Bubobot-Team/mcp-prompt-optimizer}
}

Built with ❤️ for the AI community

For questions, issues, or contributions, please visit our GitHub repository.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选
MCP Prompt Optimizer