mcp-gateway
MCP Gateway is a reverse proxy and management layer for Model Context Protocol (MCP) servers, designed for Kubernetes environments. It facilitates session-aware traffic routing and lifecycle management of MCP servers. The project offers enterprise-ready features such as telemetry, access control, and observability, making it suitable for scalable AI development platforms.
GitHub Stars
180
User Rating
Not Rated
Favorites
0
Views
281
Forks
19
Issues
3
Installation
Difficulty
IntermediateEstimated Time
10-20 minutes
Requirements
.NET SDK 6.0以上Kubernetes 1.18以上Installation
Installation
Prerequisites
Please specify required software and versions:.NET SDK: 6.0 or higher
Kubernetes: 1.18 or higher
Installation Steps
1. Clone Repository
bash
git clone https://github.com/microsoft/mcp-gateway.git
cd mcp-gateway
2. Restore Dependencies
bash
dotnet restore
3. Build Application
bash
dotnet build
4. Run Application
bash
dotnet run
Troubleshooting
Common Issues
Issue: Application won't start Solution: Check .NET SDK version and reinstall dependencies. Issue: Unable to connect to Kubernetes cluster Solution: Verify Kubernetes configuration file and ensure the correct context is set.Configuration
Configuration
Basic Configuration
MCP Gateway Setup
Editappsettings.json to add MCP server settings:
json
{
"MCPServers": [
{
"Name": "example-server",
"Url": "http://localhost:5000"
}
]
}
Environment Variables
Set the following environment variables as needed:bash
export MCP_SERVER_URL="http://localhost:5000"
export LOG_LEVEL="info"
Advanced Configuration
Security Settings
Store API keys in environment variables or secure configuration files
Set appropriate file access permissions
Performance Tuning
Configure timeout values
Limit concurrent executions
Configuration Examples
Basic Configuration
json
{
"MCPServers": [
{
"Name": "my-mcp",
"Url": "http://my-mcp-server:5000"
}
]
}
Advanced Configuration
json
{
"MCPServers": [
{
"Name": "advanced-mcp",
"Url": "http://advanced-mcp-server:5000",
"Timeout": 30,
"Retries": 3
}
]
}
Examples
Examples
Basic Usage
Here are basic usage examples for MCP Gateway:Deploying an MCP Server
bash
curl -X POST http://localhost:5000/adapters -H "Content-Type: application/json" -d '{"name":"example-server","url":"http://localhost:5000"}'
Checking MCP Server Status
bash
curl -X GET http://localhost:5000/adapters/example-server/status
Retrieving MCP Server Logs
bash
curl -X GET http://localhost:5000/adapters/example-server/logs
Programmatic Usage
csharp
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using var client = new HttpClient();
var response = await client.GetStringAsync("http://localhost:5000/adapters/example-server");
Console.WriteLine(response);
}
}
Use Cases
Deploying and managing MCP servers in Kubernetes environments
Implementing session-based data streaming
Monitoring MCP server status and retrieving logs
Distributing traffic across multiple MCP servers
Implementing access control in enterprise applications