Welcome to the MCP Gateway project! This repository hosts a robust and efficient gateway designed to facilitate seamless communication and interaction within the Model Context Protocol (MCP) ecosystem. 🌐
- Secure Authentication: Integrates with OAuth2 and JWT for secure access control. 🔐
- Flexible Configuration: Easily configurable via YAML. ⚙️
- State Management: Persistent state handling for reliable operations. 💾
- Internationalization (i18n): Supports multiple languages for broader accessibility. 🌍
- MCP Proxy: Handles MCP-specific protocols and interactions. 🤝
- API Server: Provides a robust API for external services. 🔗
- Go (version 1.18 or higher recommended)
- Redis (for session and auth storage, if configured)
- Clone the repository:
git clone https://github.com/tf1997/mcp-gateway.git cd mcp-gateway - Install dependencies:
go mod tidy
- gRpc proto generation(Option):
export PATH=$PATH:$(go env GOPATH)/bin && protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/rpc/proto/generic_rpc.proto
The gateway can be configured using configs/mcp-gateway.yaml and other JSON configuration files in the configs/ directory. Adjust these files to suit your environment and requirements.
To start the MCP Gateway:
go run cmd/main.go -c ./configs/mcp-gateway.yamlThe MCP Gateway exposes a configuration API at http://127.0.0.1:5235/api/v1/configs for managing router configurations.
curl -X POST \
'http://127.0.0.1:5235/api/v1/configs' \
--header 'Accept: */*' \
--header 'User-Agent: HTTP Client' \
--header 'Content-Type: application/json' \
--data-raw '[
{
"name": "test",
"tenant": "",
"createdAt": "2025-08-09T00:00:00Z",
"updatedAt": "2025-08-09T00:00:00Z",
"routers": [
{
"server": "baidu",
"prefix": "/gateway/baidu",
"ssePrefix": "",
"cors": {
"allowOrigins": [],
"allowMethods": [],
"allowHeaders": [],
"exposeHeaders": [],
"allowCredentials": false
}
}
],
"servers": [
{
"name": "baidu",
"description": "Baidu search service",
"allowedTools": [
"search"
],
"config": {}
}
],
"tools": [
{
"name": "search",
"description": "Baidu search service, search by keyword",
"method": "GET",
"endpoint": "https://www.baidu.com/s",
"headers": {
"Content-Type": "application/json"
},
"args": [
{
"name": "wd",
"position": "query",
"required": true,
"type": "string",
"description": "Search content",
"default": "",
"items": {
"type": "",
"enum": [],
"properties": {},
"items": null,
"required": []
}
}
],
"requestBody": "",
"responseBody": "{{.Response.Body}}",
"inputSchema": {}
}
]
}
]'curl -X GET \
'http://127.0.0.1:5235/api/v1/configs' \
--header 'Accept: */*' \
--header 'User-Agent: HTTP Client'curl -X DELETE \
'http://127.0.0.1:5235/api/v1/configs' \
--header 'Accept: */*' \
--header 'User-Agent: HTTP Client' \
--header 'Content-Type: application/json' \
--data-raw '[
"/gateway/baidu"
]'Contributions are welcome! Please feel free to open issues or submit pull requests.
This project is licensed under the Apache License 2.0. See the LICENSE file for more details.
Made with ❤️ by the MCP Gateway Team