MCP AI Gateway
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.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP AI Gatewayanalyze this Python code for performance bottlenecks and suggest optimizations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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!
Related MCP server: Vox MCP
š Quick Start
1. Installation and Configuration
No installation needed, use directly with npx:
npx mcp-ai-gateway2. Claude Desktop Configuration
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"ai-gateway": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "openai",
"API_KEY": "your-api-key-here",
"API_ENDPOINT": "https://api.openai.com/v1",
"DEFAULT_MODEL": "gpt-4o",
"DESCRIPTION": "Available models:\n- gpt-5: Latest OpenAI model with superior reasoning and creativity\n- gpt-4o: Multimodal model with fast responses\n- claude-opus-4: World's best coding model with extended thinking"
}
}
}
}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 |
|
| ā | API key |
|
| āŖ | Custom endpoint |
|
| āŖ | Default model |
|
| āŖ | Custom model description | See examples below |
| āŖ | HTTP request timeout in seconds |
|
API Format Support
OpenAI Format
Supports OpenAI, Azure OpenAI, and various OpenAI API-compatible services:
{
"API_FORMAT": "openai",
"API_KEY": "sk-your-openai-key",
"API_ENDPOINT": "https://api.openai.com/v1"
}Anthropic Format
Direct support for Anthropic Claude models:
{
"API_FORMAT": "anthropic",
"API_KEY": "sk-ant-your-anthropic-key",
"API_ENDPOINT": "https://api.anthropic.com",
"ANTHROPIC_VERSION": "2023-06-01"
}OpenRouter Format
Access 400+ AI models through OpenRouter's unified API:
{
"API_FORMAT": "openai",
"API_KEY": "sk-or-your-openrouter-key",
"API_ENDPOINT": "https://openrouter.ai/api/v1",
"DEFAULT_MODEL": "anthropic/claude-3.5-sonnet",
"DESCRIPTION": "OpenRouter models:\n- anthropic/claude-3.5-sonnet: Latest Claude with enhanced reasoning\n- openai/gpt-4o: GPT-4o with multimodal capabilities\n- google/gemini-pro-1.5: Google's advanced Gemini model\n- meta-llama/llama-3.1-405b: Meta's largest Llama model"
}Custom Description Examples
Through the DESCRIPTION environment variable, you can provide detailed model selection guidance for AI:
export DESCRIPTION="Available AI models and their strengths:
š§ Reasoning & Analysis:
- claude-opus-4: World's best coding model with 72.5% on SWE-Bench
- gpt-5: Latest model with deep reasoning capabilities and lowest error rates
ā” Speed & Efficiency:
- gpt-4o: Fast multimodal responses with near-instant processing
- claude-sonnet-4: Quick processing with extended thinking capabilities
- gemini-2.5-flash: Ultra-fast responses for simple queries
šØ Creativity & Writing:
- gpt-5: Superior creative writing and content generation
- gemini-2.5-pro: Excellent balance of creativity and factual accuracy
- claude-opus-4: Advanced reasoning for complex creative tasks
š” Choose the model that best fits your specific task requirements!"š ļø Advanced Configuration
Enterprise Proxy Support
export HTTP_PROXY=http://your-proxy:8080
export HTTPS_PROXY=https://your-proxy:8080Default Parameter Settings
export DEFAULT_TEMPERATURE=0.7
export DEFAULT_MAX_TOKENS=2000
export OPENAI_ORGANIZATION=org-your-org-id # OpenAI only
export REQUEST_TIMEOUT=60 # HTTP timeout in seconds (default: 60)Multi-Provider Configuration Example
You can configure multiple MCP AI Gateway instances to connect to different providers:
{
"mcpServers": {
"openai-gateway": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "openai",
"API_KEY": "sk-your-openai-key",
"DESCRIPTION": "OpenAI models: GPT-5, GPT-4o, GPT-4.5"
}
},
"claude-gateway": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "anthropic",
"API_KEY": "sk-ant-your-key",
"DESCRIPTION": "Anthropic models: Claude Opus 4, Claude Sonnet 4"
}
},
"openrouter-gateway": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "openai",
"API_KEY": "sk-or-your-openrouter-key",
"API_ENDPOINT": "https://openrouter.ai/api/v1",
"DEFAULT_MODEL": "anthropic/claude-3.5-sonnet",
"DESCRIPTION": "400+ models via OpenRouter:\n- anthropic/claude-3.5-sonnet: Enhanced reasoning\n- openai/gpt-4o: Multimodal capabilities\n- google/gemini-pro-1.5: Advanced Gemini\n- meta-llama/llama-3.1-405b: Largest open model\n- Cost-effective with automatic fallbacks"
}
}
}
}š§ 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:
{
"mcpServers": {
"openai-access": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "openai",
"API_KEY": "sk-your-openai-key",
"API_ENDPOINT": "https://api.openai.com/v1",
"DESCRIPTION": "Access OpenAI's latest models:\n- gpt-5: Most advanced reasoning\n- gpt-4o: Multimodal capabilities\n- Compare with Claude's built-in models"
}
}
}
}Example Configuration for OpenRouter access in Claude Desktop:
{
"mcpServers": {
"openrouter-access": {
"command": "npx",
"args": ["mcp-ai-gateway"],
"env": {
"API_FORMAT": "openai",
"API_KEY": "sk-or-your-openrouter-key",
"API_ENDPOINT": "https://openrouter.ai/api/v1",
"DEFAULT_MODEL": "anthropic/claude-3.5-sonnet",
"DESCRIPTION": "Access 400+ models via OpenRouter:\n- Choose from OpenAI, Anthropic, Google, Meta models\n- Automatic cost optimization and fallbacks\n- Unified pricing and billing across providers\n- Real-time model availability and performance"
}
}
}
}š 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:
// JSON object mode
{
"response_format": {
"type": "json_object"
}
}
// JSON schema mode (with strict validation)
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "user_profile",
"strict": true,
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"},
"email": {"type": "string", "format": "email"}
},
"required": ["name", "age"]
}
}
}
}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:
# Clear npx cache completely
rm -rf ~/.npm/_npx
npm cache clean --force
# Then retry
npx mcp-ai-gatewayWhy 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:
{
"env": {
"API_KEY": "your-api-key-here",
"API_FORMAT": "openai"
}
}Connection Timeouts
If you're experiencing timeout issues, increase the request timeout:
{
"env": {
"REQUEST_TIMEOUT": "120"
}
}š 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 suggest topics you'd like to see covered.
š 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! š
Available Tools
1 toolchat_completionB
Send a chat completion request to the configured AI API provider (ANTHROPIC). Supports parameters like model, messages, temperature, max_tokens, stream, etc. Returns the raw response from the API without format conversion.
Custom AI model for enterprise use
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model to use for completion (default: claude-3-sonnet-20240229) | |
| messages | Yes | Array of message objects with role and content | |
| temperature | No | Controls randomness in the response (default: 0.7) | |
| max_tokens | No | Maximum number of tokens to generate (default: 4096) | |
| stream | No | Whether to stream the response | |
| top_p | No | Controls diversity via nucleus sampling | |
| frequency_penalty | No | Penalizes new tokens based on their frequency | |
| presence_penalty | No | Penalizes new tokens based on whether they appear in the text | |
| stop | No | Up to 4 sequences where the API will stop generating further tokens | |
| response_format | No | Format of the response (OpenAI only). Supports json_object and json_schema types. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It adds some context: it specifies the API provider (ANTHROPIC), notes it returns 'raw response without format conversion,' and mentions 'enterprise use.' However, it lacks critical details like authentication requirements, rate limits, error handling, or whether it's a read/write operation. The description doesn't contradict annotations (none exist), but it's incomplete for a complex tool with 10 parameters.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is reasonably concise but poorly structured. The first sentence is clear and front-loaded, but the second sentence ('Custom AI model for enterprise use') feels tacked on and doesn't integrate well with the rest. It could be more cohesive, and some phrases (like 'etc.') are vague. Overall, it's adequate but not optimally organized.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (10 parameters, nested objects, no output schema), the description is minimally adequate. It covers the basic purpose and some behavioral aspects, but lacks depth for a tool of this scopeāno output details, error handling, or advanced usage notes. With no annotations and no output schema, more context would be beneficial, but it's not completely inadequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description mentions 'supports parameters like model, messages, temperature, max_tokens, stream, etc.' but adds no meaningful semantics beyond what the schema provides (e.g., no explanations of trade-offs or typical values). This meets the baseline of 3 when schema coverage is high, but doesn't compensate with extra insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool 'sends a chat completion request to the configured AI API provider (ANTHROPIC)' and mentions it 'returns the raw response from the API without format conversion.' This specifies the verb (send request), resource (chat completion), and key behavioral trait (raw response). However, it lacks explicit differentiation from siblings (though none exist), and the second sentence about 'Custom AI model for enterprise use' is somewhat vague and disconnected.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It mentions the provider (ANTHROPIC) and that it's for 'enterprise use,' but this is too vague to serve as practical usage guidance. No explicit when/when-not statements or alternative tools are referenced.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'chat_completion' has a clear, distinct purpose of sending chat completion requests to an AI API provider.
The single tool name 'chat_completion' follows a clear and consistent verb_noun pattern. Since there is only one tool, there is no inconsistency to evaluate, and the naming convention is appropriate for its function.
A single tool is generally too few for a server's purpose, as it limits functionality and may indicate an incomplete or overly narrow scope. For an 'MCP AI Gateway' that presumably handles AI interactions, one tool feels insufficient for typical enterprise use cases.
The tool surface is severely incomplete for an AI gateway domain. While 'chat_completion' covers basic chat requests, there are obvious gaps such as tools for managing models, handling different API providers, processing responses, or supporting other AI tasks beyond chat completions.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Connect MCP clients to 2,000+ AI models without managing provider API keys.
One MCP endpoint for Claude, GPT & Gemini: 100+ tools + no-code connectors + agent workers.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that enables AI applications to access 20+ model providers (including OpenAI, Anthropic, Google) through a unified interface for text and image generation.230MIT
- AlicenseAqualityAmaintenanceEnables MCP clients like Claude Code and Cursor to use multiple AI models (Gemini, GPT, Grok, DeepSeek, Kimi, Ollama) via a unified chat tool with conversation memory.31Apache 2.0
- AlicenseBqualityFmaintenanceEnables orchestrating multiple AI CLI agents (Claude Code, Codex, Gemini CLI, Copilot CLI) through a unified MCP interface for task delegation, cross-agent comparison, and specialized tools like code review and debugging.141314MIT
- AlicenseNot gradedqualityBmaintenanceMCP server that enables agents to dynamically switch between multiple AI models (OpenAI, Anthropic, Google, etc.) with unified protocol-driven configuration and capability discovery.Apache 2.0
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/kinhunt/mcp-ai-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server