promptrix-mcp
Version:
MCP Server for Promptrix - AI prompt enhancement and optimization for Claude Code
192 lines (142 loc) • 4.56 kB
Markdown
[](https://www.npmjs.com/package/promptrix-mcp)
A Model Context Protocol (MCP) server that provides AI prompt enhancement and optimization capabilities to Claude Code and other MCP-compatible clients.
## Features
- **enhance_prompt**: Enhance individual prompts using advanced prompt engineering techniques
- **auto_analyze_prompt**: Analyze prompt quality and suggest improvements
- Configurable enhancement parameters (style, format, language, complexity level)
- Integration with the Promptrix API using API key authentication
- Full TypeScript support with comprehensive error handling
## Quick Start
### Installation
No installation required! Use `npx` to run directly:
```json
{
"mcpServers": {
"promptrix": {
"type": "stdio",
"command": "npx",
"args": ["-y", "promptrix-mcp"],
"env": {
"PROMPTRIX_API": "https://api.promptrix.co",
"PROMPTRIX_API_KEY": "${PROMPTRIX_API_KEY}"
}
}
}
}
```
Sign up at [promptrix.co](https://promptrix.co) to get your API key, or run the Promptrix API locally:
```bash
export PROMPTRIX_API_KEY="prx_live_your_api_key_here"
```
Add the MCP server to your Claude Code configuration file (`.mcp.json` or `claude_desktop_config.json`):
```json
{
"mcpServers": {
"promptrix": {
"type": "stdio",
"command": "npx",
"args": ["-y", "promptrix-mcp"],
"env": {
"PROMPTRIX_API": "https://api.promptrix.co",
"PROMPTRIX_API_KEY": "${PROMPTRIX_API_KEY}"
}
}
}
}
```
**For local development:**
```json
{
"mcpServers": {
"promptrix": {
"type": "stdio",
"command": "npx",
"args": ["-y", "promptrix-mcp"],
"env": {
"PROMPTRIX_API": "http://localhost:8787",
"PROMPTRIX_API_KEY": "${PROMPTRIX_API_KEY}"
}
}
}
}
```
Once configured, you can use the prompt enhancement tools directly in Claude Code:
```
Can you enhance this prompt: "how to add 2 numbers in node"
```
Or analyze prompt quality:
```
Can you analyze the quality of this prompt: "make a function"
```
Enhances a single prompt with optional parameters:
- **prompt** (required): The original prompt to enhance
- **style** (optional): Style preference - detailed, concise, creative, technical, professional, casual
- **format** (optional): Output format - markdown, json, structured, list, paragraph
- **language** (optional): Target language (e.g., en, es, fr, de)
- **level** (optional): Complexity level - beginner, intermediate, advanced, expert
- **constraints** (optional): Specific constraints or requirements
### auto_analyze_prompt
Analyzes prompt quality and suggests improvements:
- **prompt** (required): The prompt to analyze for quality issues
- **threshold** (optional): Quality threshold (0-100). Prompts below this score will trigger enhancement suggestions. Default: 70
## Configuration
### Environment Variables
- **PROMPTRIX_API**: URL of the Promptrix API server (default: http://localhost:8787)
- **PROMPTRIX_API_KEY**: Your Promptrix API key (required for authentication)
- **PROMPTRIX_AUTO_THRESHOLD**: Quality threshold for auto-analysis (default: 70)
### API Requirements
The MCP server requires the Promptrix API to be running with API key authentication enabled. The API should expose a `/api/optimize` endpoint that accepts POST requests with Bearer token authentication:
```json
{
"prompt": "string",
"style": "string (optional)",
"format": "string (optional)",
"language": "string (optional)",
"level": "string (optional)",
"constraints": "string (optional)"
}
```
```bash
npm run dev
npm run typecheck
npm run lint
npm run format
```
```
enhance_prompt({
"prompt": "how to use React hooks",
"style": "detailed",
"format": "structured"
})
```
```
auto_analyze_prompt({
"prompt": "make a function",
"threshold": 70
})
```
The server provides comprehensive error handling for:
- Invalid parameters
- API connectivity issues
- Malformed responses
- Network timeouts
- Authentication failures
All errors are returned as structured MCP error responses with appropriate error codes and descriptive messages.
MIT