Prompt Learning MCP Server

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.

Category
Visit Server

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)

  1. Pattern-based improvements: Adds structure, chain-of-thought, constraints
  2. OPRO-style iteration: LLM generates candidates, evaluates, selects best
  3. APE-style generation: Creates multiple instruction variants

Warm Start (With History)

  1. Embed the prompt: Creates vector representation
  2. Retrieve similar: Finds high-performing prompts from database
  3. Learn from winners: Synthesizes improvements from what worked
  4. 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Prompt Learning MCP Server