MCP Proxy
April 17, 2025 ยท View on GitHub
A Go service that connects to MCP (Model Context Protocol) servers and exposes their tools via a RESTful HTTP API and OpenAPI specification.
Overview
This application:
- Reads a configuration file that specifies MCP servers
- Launches each MCP server as a child process
- Connects to each server using the mcp-go client library
- Exposes the tools provided by each server via a RESTful HTTP API
- Generates OpenAPI specifications for the API
Configuration
Create a config.json file in the same directory as the application with the following structure:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
]
}
}
}
Each entry in the mcpServers object defines an MCP server:
- The key is the name of the server (used in the API endpoints)
commandis the command to runargsis an array of arguments to pass to the command
API Endpoints
The application exposes the following endpoints:
GET /swagger/*any- Swagger UI for the APIGET /api/v1/servers- List all available serversGET /api/v1/openapi.json- Get the combined OpenAPI specificationGET /api/v1/servers/:server- Get information about a specific serverGET /api/v1/servers/:server/tools- List all tools provided by a serverGET /api/v1/servers/:server/openapi.json- Get the OpenAPI specification for a serverPOST /api/v1/servers/:server/tools/:tool- Call a tool on a server
Usage
- Create a
config.jsonfile with your MCP server configurations - Run the application:
go run main.go - Visit
http://localhost:8080/swagger/index.htmlto explore the API
Requirements
- Go 1.23 or later
- The commands specified in the configuration file must be available on the system path
Dependencies
This project uses:
- mcp-go - Go client for MCP
- gin - HTTP web framework
- gin-swagger - Swagger UI for Gin