Prompt Learning MCP Server
Provides stateful prompt optimization using research-backed techniques like APE and OPRO, learning from historical performance data via a vector database. It enables users to automatically refine prompts, retrieve high-performing examples, and track performance analytics through iterative feedback.
README
Prompt Learning MCP Server
Stateful prompt optimization that learns over time.
An MCP (Model Context Protocol) server that optimizes your prompts using research-backed techniques (APE, OPRO, DSPy patterns) and learns from performance history via embedding-based retrieval.
Features
- 🧠 Smart Optimization: Uses actual LLM-based evaluation, not heuristics
- 📚 Learns Over Time: Stores prompt performance in vector database
- 🔍 RAG-Powered: Retrieves similar high-performing prompts
- ⚡ Pattern-Based Quick Wins: Instant improvements without API calls
- 📊 Analytics: Track what's working across domains
Quick Install
curl -fsSL https://someclaudeskills.com/install/prompt-learning.sh | bash
Or manually:
cd ~/mcp-servers/prompt-learning
npm install
npm run build
npm run setup
Requirements
- Node.js 18+
- Docker (for Qdrant and Redis)
- OpenAI API key (for embeddings)
Usage
Once installed, use these tools in Claude Code:
optimize_prompt
Optimize a prompt using pattern-based and RAG-based techniques:
"optimize this prompt: summarize the document"
Returns the optimized prompt with improvement details.
retrieve_prompts
Find similar high-performing prompts:
"find similar prompts for: code review feedback"
record_feedback
Record how a prompt performed (enables learning):
"record that my last prompt succeeded with quality score 0.9"
suggest_improvements
Get quick suggestions without full optimization:
"suggest improvements for this prompt: [your prompt]"
get_analytics
View performance trends:
"show prompt analytics for the last 30 days"
How It Works
Cold Start (No History)
- Pattern-based improvements: Adds structure, chain-of-thought, constraints
- OPRO-style iteration: LLM generates candidates, evaluates, selects best
- APE-style generation: Creates multiple instruction variants
Warm Start (With History)
- Embed the prompt: Creates vector representation
- Retrieve similar: Finds high-performing prompts from database
- Learn from winners: Synthesizes improvements from what worked
- Iterate with feedback: Uses evaluation to guide optimization
Evaluation
All prompts are scored by an LLM evaluator on:
- Clarity (25%): How unambiguous
- Specificity (25%): Appropriate guidance level
- Completeness (20%): Covers all requirements
- Structure (15%): Well-organized
- Effectiveness (15%): Likely to produce desired output
Architecture
Claude Code
│
│ MCP Protocol
▼
┌─────────────────────────────┐
│ prompt-learning MCP Server │
│ │
│ Tools: │
│ • optimize_prompt │
│ • retrieve_prompts │
│ • record_feedback │
│ • suggest_improvements │
│ • get_analytics │
└─────────┬───────────────────┘
│
┌─────┴─────┐
▼ ▼
┌───────┐ ┌───────┐
│Qdrant │ │ Redis │
│(Vector│ │(Cache)│
│ DB) │ │ │
└───────┘ └───────┘
Configuration
Claude Code Config (~/.claude.json)
{
"mcpServers": {
"prompt-learning": {
"command": "node",
"args": ["~/mcp-servers/prompt-learning/dist/index.js"],
"env": {
"VECTOR_DB_URL": "http://localhost:6333",
"REDIS_URL": "redis://localhost:6379",
"OPENAI_API_KEY": "sk-..."
}
}
}
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
VECTOR_DB_URL |
http://localhost:6333 |
Qdrant server URL |
REDIS_URL |
redis://localhost:6379 |
Redis server URL |
OPENAI_API_KEY |
(required) | For embeddings |
Development
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run setup (starts Docker, initializes DB)
npm run setup
# Run tests
npm test
Troubleshooting
MCP Server Not Starting
Check Docker containers are running:
docker ps | grep prompt-learning
Vector DB Connection Failed
# Check Qdrant health
curl http://localhost:6333/health
# Restart Qdrant
docker restart prompt-learning-qdrant
No Improvements Seen
- Ensure OPENAI_API_KEY is set correctly
- Check Claude Code logs:
~/.claude/logs/mcp.log - Try with a simple prompt first
Research Foundation
This server implements techniques from:
- APE (Zhou et al., 2022): Automatic Prompt Engineer
- OPRO (Yang et al., 2023): Optimization by Prompting
- DSPy (Khattab et al., 2023): Programmatic prompt optimization
- Contextual Retrieval (Anthropic, 2024): Enhanced embedding retrieval
License
MIT
Links
- Documentation: https://www.someclaudeskills.com/skills/automatic-stateful-prompt-improver
- Skill Definition: Part of the Some Claude Skills collection
- GitHub: https://github.com/erichowens/prompt-learning-mcp
- Issues: https://github.com/erichowens/prompt-learning-mcp/issues
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。