npm package: @modelpilot/mcp-server
Description: Model Context Protocol server for ModelPilot - enables AI assistants to integrate ModelPilot
Author: ModelPilot
Latest version: 1.0.3

# ModelPilot MCP Server

Model Context Protocol server for ModelPilot - enables AI coding assistants to integrate ModelPilot directly into developer workflows.

## Features

- 🔄 **Code Migration** - Convert OpenAI/Anthropic code to ModelPilot
- 🎯 **Router Management** - Create and configure AI model routers
- 🧪 **Live Testing** - Test routers with real requests and see cost breakdowns
- 📊 **Usage Analytics** - Track spending and get optimization tips
- 💰 **Cost Optimization** - Get recommendations to reduce AI costs
- 🔍 **Model Comparison** - Compare models on cost, quality, and speed
- 💳 **Balance Checking** - View credits and subscription status
- 💻 **Code Generation** - Generate production-ready integration code

## Installation

```bash
npm install -g @modelpilot/mcp-server
```

## Usage

### 1. Get your ModelPilot API Key

Sign up at [modelpilot.app](https://modelpilot.app) and create an API key in the dashboard.

### 2. Configure in your AI Assistant

#### For Cascade / Windsurf

Add to your MCP settings:

```json
{
  "mcpServers": {
    "modelpilot": {
      "command": "modelpilot-mcp",
      "env": {
        "MODELPILOT_API_KEY": "mp-your-api-key-here"
      }
    }
  }
}
```

#### For Cline

Add to `~/.cline/mcp.json`:

```json
{
  "mcpServers": {
    "modelpilot": {
      "command": "npx",
      "args": ["-y", "@modelpilot/mcp-server"],
      "env": {
        "MODELPILOT_API_KEY": "mp-your-api-key-here"
      }
    }
  }
}
```

### 3. Start Using!

Talk to your AI assistant:

```
"Migrate this OpenAI code to ModelPilot"
"Create a cost-optimized router for my chatbot"
"Test my router with this prompt and show me the cost"
"How can I reduce my AI costs?"
```

## Available Tools

### migrate_code
Convert OpenAI or Anthropic SDK code to ModelPilot. Shows converted code and estimated cost savings.

**Example:**
```
User: "Migrate this code to ModelPilot: [paste OpenAI code]"
AI: [Shows converted code] "This will save you ~45% on costs"
```

### create_router
Create a new AI model router with guided configuration.

**Example:**
```
User: "Create a cost-optimized router for my chatbot"
AI: "What models would you like to include?"
User: "GPT-4o-mini and Claude 3.5 Sonnet"
AI: [Creates router] "Router created! Here's your sample code..."
```

### test_request
Test a router with a real request. Returns response, cost, latency, and model used.

**Example:**
```
User: "Test my router 'chatbot-123' with: Hello, how are you?"
AI: [Shows response] "Cost: $0.0008 | Model: gpt-4o-mini | Latency: 450ms"
```

### get_usage_summary
View usage statistics and costs for the last 24h, 7d, or 30d.

**Example:**
```
User: "Show my usage for the last 7 days"
AI: "Total: $12.45 | 1,234 requests | Top model: GPT-4o-mini (65%)"
```

### optimize_router
Get cost-saving recommendations for a router.

**Example:**
```
User: "How can I optimize my chatbot router?"
AI: "Switch to GPT-4-Turbo → Save $45/month | Enable cost-optimized routing"
```

### compare_models
Compare models side-by-side on cost, quality, and speed.

**Example:**
```
User: "Compare GPT-4o vs Claude 3.5 Sonnet vs Gemini Pro"
AI: [Shows comparison table] "Gemini Pro is cheapest, Claude 3.5 Sonnet has best quality"
```

### get_balance
Check current credit balance and subscription status.

**Example:**
```
User: "What's my balance?"
AI: "Balance: $45.67 | Subscription: Pro | This month: $12.34 spent"
```

### generate_integration_code
Generate production-ready code in Python, JavaScript, or TypeScript.

**Example:**
```
User: "Generate Python code for my router with error handling and retries"
AI: [Generates complete code with retries, error handling, and examples]
```

## Documentation

The MCP server includes 10 comprehensive documentation resources:

- **Quickstart Guide** - Get started in 5 minutes
- **OpenAI Migration** - Complete migration guide from OpenAI
- **Anthropic Migration** - Complete migration guide from Anthropic
- **Router Configuration** - Best practices for router setup
- **Python SDK** - Full Python SDK reference
- **JavaScript SDK** - Full JavaScript SDK reference
- **Routing Strategies** - Understanding cost/quality/speed optimization
- **Cost Optimization** - Top strategies for reducing costs
- **Chatbot Example** - Production chatbot implementation
- **Pricing Guide** - Understanding billing and pricing

Access via:
```
User: "Show me the OpenAI migration guide"
AI: [Displays modelpilot://migration/openai]
```

## Development

### Setup

```bash
cd modelpilot-mcp
npm install
```

### Development Mode

```bash
npm run dev
```

### Build

```bash
npm run build
```

### Test Locally

```bash
MODELPILOT_API_KEY=mp-your-key npm start
```

## Requirements

- Node.js 18+
- ModelPilot API key

## Support

- **Documentation**: [docs.modelpilot.app](https://docs.modelpilot.app)
- **Dashboard**: [modelpilot.app/dashboard](https://modelpilot.app/dashboard)
- **Support**: support@modelpilot.app

## License

MIT