Prompt Optimizer MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
๐ Prompt Optimizer MCP
A Model Context Protocol (MCP) server that provides intelligent tools for optimizing and scoring LLM prompts using deterministic heuristics.
๐ฏ Overview
The Prompt Optimizer MCP server offers two powerful tools:
optimize_prompt- Generate 3 optimized variants of a raw LLM prompt in different stylesscore_prompt- Evaluate the effectiveness of an improved prompt relative to the original
Perfect for developers, content creators, and AI practitioners who want to improve their prompt engineering workflow.
Related MCP server: Promptheus
โจ Features
๐จ Prompt Optimization Styles
Creative: Enhanced with descriptive adjectives and engaging language
Precise: Concise and focused, removing redundant words
Fast: Optimized for quick processing with shorter synonyms
๐ Intelligent Scoring Algorithm
The scoring system evaluates prompts based on:
Length optimization (40%): Prefers shorter, more concise prompts
Keyword preservation (30%): Maintains important terms from the original
Clarity improvement (30%): Reduces redundancy and improves structure
๐ง Technical Features
โ Stateless: No external dependencies or state management
โ Deterministic: Same inputs always produce same outputs
โ Error-free: Comprehensive input validation and error handling
โ Fast: Simple heuristics for quick processing
โ Extensible: Easy to add new styles and scoring metrics
โ Dual Transport: Supports both STDIO (MCP) and HTTP (deployment)
๐ Project Structure
prompt-optimizer-mcp/
โโโ ๐ README.md # This file
โโโ ๐ server.py # Main MCP server (STDIO transport)
โโโ ๐ http_server.py # HTTP server for deployment
โโโ ๐ start.py # Startup script (auto-detects mode)
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ test_server.py # Test script
โโโ ๐ deploy.py # Deployment script
โโโ ๐ Dockerfile # Container configuration
โโโ ๐ .gitignore # Git ignore rules
โโโ ๐ tools/
โ โโโ ๐ __init__.py # Package initialization
โ โโโ ๐ optimize.py # Core optimization logic
โโโ ๐ tests/
โ โโโ ๐ __init__.py # Test package initialization
โ โโโ ๐ test_optimize.py # Unit tests
โโโ ๐ .github/
โโโ ๐ workflows/
โโโ ๐ ci.yml # CI/CD pipeline๐ Quick Start
1. Clone the Repository
git clone https://github.com/Mahad-007/Prompt-Optimizer-MCP-for-LLMs.git
cd Prompt-Optimizer-MCP-for-LLMs2. Install Dependencies
pip install -r requirements.txt3. Run Tests
python test_server.py4. Start the Server
# For local development (STDIO mode)
python server.py
# For deployment (HTTP mode)
python start.py๐ ๏ธ Installation
Prerequisites
Python 3.11 or higher
pip package manager
Install Dependencies
# Install from requirements.txt
pip install -r requirements.txtโ๏ธ Configuration
For Cursor IDE
Create .cursor/mcp.json:
{
"mcpServers": {
"prompt-optimizer": {
"command": "python",
"args": ["server.py"],
"env": {}
}
}
}For Other MCP Clients
Configure your MCP client to use:
Command:
python server.pyTransport: STDIO (default)
๐ Usage Examples
Using the MCP Server
Once configured, you can use the tools through any MCP client:
Optimize a Prompt
# Generate creative variants
variants = optimize_prompt(
raw_prompt="Write a story about a cat",
style="creative"
)
# Returns: [
# "Craft a compelling story about a cat",
# "Imagine you're an expert in this field. Write a story about a cat",
# "Write a story about a cat. in a way that captivates and inspires"
# ]
# Generate precise variants
variants = optimize_prompt(
raw_prompt="Please write a very detailed explanation about machine learning",
style="precise"
)
# Returns: [
# "Write a detailed explanation about machine learning",
# "โข Write a detailed explanation about machine learning",
# "Write a detailed explanation about machine learning Be specific and concise."
# ]Score a Prompt
score = score_prompt(
raw_prompt="Please write a very detailed explanation about machine learning",
improved_prompt="Write an explanation about machine learning"
)
# Returns: 0.85 (high score due to length reduction and clarity improvement)HTTP API Usage
When deployed, the server also provides HTTP endpoints:
# Health check
curl http://localhost:8000/health
# Optimize prompt
curl -X POST http://localhost:8000/optimize \
-H "Content-Type: application/json" \
-d '{"raw_prompt": "Write about AI", "style": "creative"}'
# Score prompt
curl -X POST http://localhost:8000/score \
-H "Content-Type: application/json" \
-d '{"raw_prompt": "Write about AI", "improved_prompt": "Write about artificial intelligence"}'Direct Python Usage
from tools.optimize import optimize_prompt, score_prompt
# Optimize a prompt
variants = optimize_prompt("Write about AI", "creative")
print(f"Optimized variants: {variants}")
# Score a prompt
score = score_prompt("Write about AI", "Write about artificial intelligence")
print(f"Score: {score}")๐งช Testing
Run the comprehensive test suite:
# Run all tests
python test_server.py
# Run unit tests
python -m unittest tests.test_optimize -v
# Run specific test classes
python -m unittest tests.test_optimize.TestOptimizePrompt
python -m unittest tests.test_optimize.TestScorePrompt
python -m unittest tests.test_optimize.TestIntegration๐ Deployment
Automated Deployment
Use the deployment script:
python deploy.pyThis will:
Run all tests
Install dependencies
Run linting checks
Build Docker image (if available)
Create deployment package
Manual Deployment
Deploy to Smithery
Install Smithery CLI:
npm install -g @smithery/cliAuthenticate:
smithery auth loginDeploy:
# Windows .\deploy.bat # Linux/macOS chmod +x deploy.sh ./deploy.sh
Deploy with Docker
# Build the image
docker build -t prompt-optimizer-mcp:latest .
# Run the container
docker run -p 8000:8000 prompt-optimizer-mcp:latestDeploy to Other Platforms
The server supports both STDIO (for MCP clients) and HTTP (for web deployment) transports:
STDIO Mode:
python server.py(for MCP clients)HTTP Mode:
python start.py(for web deployment)
Your MCP server will be available at: https://prompt-optimizer-mcp.smithery.ai
For detailed deployment instructions, see DEPLOYMENT.md.
๐ง Development
Adding New Optimization Styles
Add the new style to the
Literaltype inserver.pyImplement the style function in
tools/optimize.pyAdd corresponding tests in
tests/test_optimize.py
Extending the Scoring Algorithm
Modify the score_prompt function in tools/optimize.py to include additional metrics or adjust weights.
Running Locally
# Start the MCP server (STDIO mode)
python server.py
# Start the HTTP server (deployment mode)
python http_server.py
# Auto-detect mode based on environment
python start.py๐ Performance
Response Time: < 100ms for most operations
Memory Usage: ~50MB typical
CPU Usage: Minimal (stateless operations)
Scalability: Auto-scales from 1-5 replicas on Smithery
๐ค Contributing
We welcome contributions! Please follow these steps:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Development Setup
# Clone your fork
git clone https://github.com/yourusername/Prompt-Optimizer-MCP-for-LLMs.git
cd Prompt-Optimizer-MCP-for-LLMs
# Install dependencies
pip install -r requirements.txt
# Run tests
python test_server.py
# Make your changes and test
python demo.py๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
Model Context Protocol for the MCP specification
MCP Python SDK for the server framework
Smithery for deployment platform
๐ Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Documentation: DEPLOYMENT.md
โญ Star History
Made with โค๏ธ for the AI community
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
This server cannot be deployed
Maintenance
Related MCP Connectors
Manage, version, and publish LLM prompts with blocks, variables, and evaluations.
Generate contextual prompts and reusable agent skills, evaluate prompts with the 16-dimension Prompt Score, and manage saved work in PromptDrive. Twelve MCP tools also provide authorized access to private Memory for source-grounded answers. Connect over Streamable HTTP using OAuth 2.1 and PKCE. Generation consumes account quota and automatically saves successful results; Memory access follows account permissions and plan limits.
A prompt engineer you talk to. It writes prompts, sharpens yours, and keeps them on your shelf.
Test and compare prompts across any AI provider. Bring your own keys.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnhances and cleans raw prompts using AI to make them more clear, actionable, and effective. Provides quality assessment, suggestions, and supports both general and code-specific optimization modes.1MIT
- AlicenseNot gradedqualityBmaintenanceRefines and optimizes prompts for LLMs through adaptive questioning and intelligent clarification workflows. Supports multiple AI providers (Google, OpenAI, Anthropic, Groq, Qwen) with interactive prompt enhancement and targeted modifications.17MIT
- AlicenseAqualityDmaintenanceEnables prompt optimization loops and regression test suites for Claude Code, with a companion web UI for real-time visualization of scores and prompt revisions.19MIT
- AlicenseAqualityDmaintenanceEnables storage, versioning, and retrieval of prompts with rich metadata via MCP tools, supporting stdio and SSE transports.33ISC