Enables access to OpenAI's models including GPT-4 and GPT-3.5-turbo through the OpenAI API, supporting both creative tasks and fast responses for simple queries.
MCP AI Gateway
A unified MCP (Model Context Protocol) server that enables AI assistants to intelligently select and switch between different AI models within the same conversation to complete tasks.
šÆ Core Concept
Intelligent Model Selection
The core value of MCP AI Gateway lies in enabling AI assistants to automatically choose the most suitable model based on task requirements:
Code Tasks: Let AI choose Claude Opus 4 for advanced code analysis
Quick Q&A: Let AI choose GPT-4o for fast, reliable responses
Creative Writing: Let AI choose GPT-5 or Gemini 2.5 Pro for superior creativity
Multimodal Processing: Let AI choose vision-capable models like GPT-4o
Workflow Example
Within a single conversation, AI might:
Use Claude Opus 4 to analyze complex code logic
Use GPT-5 to generate creative solutions
Use Gemini 2.5 Pro for quick verification
All achieved through a unified MCP tool, no manual switching required!
š Quick Start
1. Installation and Configuration
No installation needed, use directly with npx:
2. Claude Desktop Configuration
Add to your Claude Desktop MCP configuration:
3. Start Using Immediately
After configuration, restart Claude Desktop and you can interact with AI like this:
"Please use the most suitable model to analyze this code, then use another model to generate test cases"
AI will automatically select appropriate models for different subtasks!
š Detailed Configuration Guide
Environment Variables
Variable | Required | Description | Example |
| ā | API format |
or
|
| ā | API key |
|
| āŖ | Custom endpoint |
|
| āŖ | Default model |
|
| āŖ | Custom model description | See examples below |
| āŖ | HTTP request timeout in seconds |
(default) |
API Format Support
OpenAI Format
Supports OpenAI, Azure OpenAI, and various OpenAI API-compatible services:
Anthropic Format
Direct support for Anthropic Claude models:
OpenRouter Format
Access 400+ AI models through OpenRouter's unified API:
Custom Description Examples
Through the DESCRIPTION
environment variable, you can provide detailed model selection guidance for AI:
š ļø Advanced Configuration
Enterprise Proxy Support
Default Parameter Settings
Multi-Provider Configuration Example
You can configure multiple MCP AI Gateway instances to connect to different providers:
š§ Technical Features
š Plug & Play: Use directly via npx, no installation required
š Multi-API Support: OpenAI, Anthropic, OpenRouter (400+ models), custom endpoints
šļø Extensible Architecture: Easy to add new API format support
š”ļø Enterprise Ready: Proxy support, error handling, secure authentication
ā” High Performance: Direct HTTP calls, no additional overhead
š Fully Typed: Written in TypeScript, type-safe
š° Cost Optimization: OpenRouter integration with automatic fallbacks
šÆ Use Cases
1. Development Workflow
Use Claude Opus 4 for code review and optimization suggestions
Use GPT-5 for technical documentation generation
Use fast models for syntax checking
2. Content Creation
Use creative models for draft generation
Use analytical models for content optimization
Use fast models for proofreading
3. Research & Analysis
Use reasoning models for complex data analysis
Use specialized models for report generation
Use fast models for summary generation
4. Third-Party Model Access in AI Clients
Access premium models through official AI clients:
Claude Desktop with OpenAI Models: Use your OpenAI API key to access GPT-5, GPT-4o in Claude Desktop interface
OpenRouter Integration: Access 400+ models through one API with automatic fallbacks and cost optimization
Third-Party API Integration: Connect expensive or specialized models (like Claude Opus 4) through custom endpoints
Cost Optimization: Use cheaper third-party API providers while maintaining the familiar Claude Desktop/Gemini CLI experience
Model Comparison: Test different providers' implementations of the same model within one interface
Enterprise Solutions: Access internal or fine-tuned models through your organization's API gateway
Example Configuration for accessing OpenAI models in Claude Desktop:
Example Configuration for OpenRouter access in Claude Desktop:
š API Reference
chat_completion Tool Parameters
Parameter | Type | Description |
| string | Specify the model to use |
| array | Array of conversation message objects |
| number | Control randomness (0-2) |
| number | Maximum output length |
| boolean | Whether to stream output |
| number | Nucleus sampling parameter |
| number | Frequency penalty |
| number | Presence penalty |
| string/array | Stop sequences |
| object | NEW : Format of the response (OpenAI only) |
Response Format Support
The response_format
parameter enables structured outputs from OpenAI-compatible models:
Note: This parameter is only supported for OpenAI-format APIs and will be ignored for Anthropic-format requests.
š§ Troubleshooting
Common Issues
"Cannot find module" Errors with npx
This error typically occurs when using npx mcp-ai-gateway
due to incomplete dependency downloads in the npx cache. You might see errors like:
Cannot find module 'node_modules/es-set-tostringtag/index.js'
Cannot find module 'axios'
Cannot find module '@modelcontextprotocol/sdk'
Solution:
Why this happens: npx sometimes fails to download all transitive dependencies, especially on slower network connections or when the package has many dependencies. Clearing the cache forces a fresh, complete download.
API Key Not Found
Make sure you've set the required environment variables in your MCP client configuration:
Connection Timeouts
If you're experiencing timeout issues, increase the request timeout:
š Documentation
Comprehensive guides and tutorials for getting the most out of MCP AI Gateway:
Getting Started
How to Access OpenRouter's Free Gemini Models in Claude Desktop - Save up to 80% on AI costs while enjoying Claude Desktop's interface
How to Use ChatGPT Models in Gemini CLI - Access OpenAI's latest models directly within your Gemini CLI workflow
Advanced Workflows
How to Create Multi-Model Workflows in Claude Desktop - Master intelligent model orchestration for complex projects
How to Reduce AI Costs by 80% with Smart Model Routing - Transform your AI spending through intelligent cost optimization
Use Cases & Examples
Client integration tutorials
Enterprise deployment guides
Cost optimization strategies
Workflow automation patterns
More tutorials and guides coming soon! Check back regularly or
š Documentation & Guides
Comprehensive how-to guides for getting the most out of MCP AI Gateway:
Integration Guides
How to Access OpenRouter's Free Gemini Models in Claude Desktop - Save up to 80% on AI costs while using Claude Desktop's interface
How to Use ChatGPT Models in Gemini CLI - Break free from Google's model limitations and access OpenAI's latest models in Gemini CLI
Advanced Workflows
How to Create Multi-Model Workflows in Claude Desktop Using Sub-Agent Descriptions - Master intelligent model orchestration for complex projects
Coming Soon
How to Build AI-Powered Code Review Pipelines
How to Set Up Cost-Effective Multi-Team AI Access
How to Create Custom Model Selection Strategies
Enterprise Deployment and Security Best Practices
š¤ Contributing
Issues and Pull Requests are welcome!
GitHub: kinhunt/mcp-ai-gateway
NPM: mcp-ai-gateway
š License
MIT License - See LICENSE file for details
Make AI assistants smarter at choosing models and boost your productivity! š
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables AI assistants to intelligently select and switch between different AI models (OpenAI, Anthropic, etc.) within the same conversation based on task requirements. Provides a unified interface for accessing multiple AI providers through a single MCP tool.
Related MCP Servers
- -securityFlicense-qualityFacilitates interaction and context sharing between AI models using the standardized Model Context Protocol (MCP) with features like interoperability, scalability, security, and flexibility across diverse AI systems.Last updated -1
- AsecurityAlicenseAqualityAn MCP server that enables AI applications to access 20+ model providers (including OpenAI, Anthropic, Google) through a unified interface for text and image generation.Last updated -223MIT License
- -securityFlicense-qualityA service that converts OpenAPI specifications into MCP tools, enabling AI assistants to interact with your API endpoints through natural language.Last updated -
- AsecurityAlicenseAqualityAn MCP server that retrieves and provides AI model information from OpenAI, Anthropic, and Google through a unified interface.Last updated -332MIT License