An MCP (Model Context Protocol) server that analyzes prompts, compares them with relevant data, and uses OpenRouter (Claude 3.7 Sonnet) to refactor them.
- Prompt Analysis: Analyze prompts to identify strengths, weaknesses, and suggested improvements
- Prompt Refactoring: Refactor prompts using AI to improve their effectiveness
- Context Integration: Incorporate relevant context and chat history into the analysis and refactoring process
- Technique Application: Apply specific prompt engineering techniques to improve prompts
- Clone the repository
- Install dependencies:
npm install - Create a
.envfile with your OpenRouter API key:OpenRouter_API_KEY=your-api-key - Build the project:
npm run build
To securely manage your OpenRouter API key:
- Never hard-code API keys in files that might be committed to version control
- Use environment variables to store sensitive credentials
- Add
.envto your.gitignorefile to prevent accidentally committing it - Consider using a secrets manager for production deployments
# On Windows
setx OPENROUTER_API_KEY "your-api-key"
# On macOS/Linux
export OPENROUTER_API_KEY="your-api-key"npm start
A template configuration file is provided in reprompter-mpc-config.template.json. Copy this file to reprompter-mpc-config.json and update it with your specific paths:
{
"mcpServers": {
"reprompter": {
"command": "node",
"args": ["build/index.js"],
"cwd": "PATH_TO_YOUR_REPROMPTER_MPC_DIRECTORY",
"env": {
"OpenRouter_API_KEY": "${OPENROUTER_API_KEY}"
},
"alwaysAllow": [
"analyze_prompt",
"refactor_prompt"
]
}
}
}Important:
- Replace
PATH_TO_YOUR_REPROMPTER_MPC_DIRECTORYwith the absolute path to your reprompter-mpc directory - Set up your OpenRouter API key using environment variables as described in the security section below
- Add this configuration to your MCP settings file
Analyzes a prompt and provides structured feedback on its strengths, weaknesses, and suggested improvements.
Input Schema:
{
"prompt": "The prompt to analyze",
"context": "Optional context relevant to the prompt",
"chatHistory": [
{
"role": "user|assistant|system",
"content": "Content of the message",
"timestamp": "Optional timestamp"
}
]
}Output:
{
"strengths": ["strength1", "strength2", ...],
"weaknesses": ["weakness1", "weakness2", ...],
"suggestedTechniques": ["technique1", "technique2", ...],
"contextRelevance": {
"missingContext": ["item1", "item2", ...],
"irrelevantContext": ["item1", "item2", ...]
},
"complexity": "low|medium|high",
"clarity": "low|medium|high",
"specificity": "low|medium|high"
}Refactors a prompt using AI to improve its effectiveness based on analysis and suggested techniques.
Input Schema:
{
"prompt": "The prompt to refactor",
"analysis": {
// Optional analysis from analyze_prompt tool
"strengths": ["strength1", "strength2", ...],
"weaknesses": ["weakness1", "weakness2", ...],
"suggestedTechniques": ["technique1", "technique2", ...],
"contextRelevance": {
"missingContext": ["item1", "item2", ...],
"irrelevantContext": ["item1", "item2", ...]
},
"complexity": "low|medium|high",
"clarity": "low|medium|high",
"specificity": "low|medium|high"
},
"techniques": ["Optional specific techniques to apply"],
"context": "Optional context relevant to the prompt",
"chatHistory": [
{
"role": "user|assistant|system",
"content": "Content of the message",
"timestamp": "Optional timestamp"
}
]
}Output: The refactored prompt text.
// Example of using the analyze_prompt tool
const analysis = await use_mcp_tool({
server_name: "reprompter",
tool_name: "analyze_prompt",
arguments: {
prompt: "Tell me about the history of artificial intelligence.",
context: "The user is a beginner in AI concepts."
}
});
// Example of using the refactor_prompt tool
const refactoredPrompt = await use_mcp_tool({
server_name: "reprompter",
tool_name: "refactor_prompt",
arguments: {
prompt: "Tell me about the history of artificial intelligence.",
analysis: analysis, // Result from analyze_prompt
techniques: ["Chain-of-Thought", "Few-Shot Examples"],
context: "The user is a beginner in AI concepts."
}
});Contributions are welcome! Here's how you can contribute to this project:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature-name) - Make your changes
- Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature-name) - Open a Pull Request
Please make sure your code follows the existing style and includes appropriate tests.
If you encounter any bugs or have feature requests, please open an issue on GitHub. When creating an issue, please provide:
- A clear and descriptive title
- A detailed description of the issue or feature request
- Steps to reproduce the issue (if applicable)
- Any relevant logs or error messages
- Your environment (OS, Node.js version, etc.)
Pull requests are welcome! Please see the Contributing section for guidelines.
ISC - See LICENSE file for details.