CLI/proxy that merges multiple MCP (Model Context Protocol) servers behind a single load-balanced endpoint, similar to Nginx for Gen-AI services.
https://github.com/tigranbs/mcgravityIf you're running MCP servers in production, you've probably hit the same scaling wall everyone else has: one server per client connection. McGravity changes that by putting a proper load-balancer in front of your MCP infrastructure, just like Nginx does for web servers.
Instead of juggling separate connections to each MCP server, McGravity gives you a single endpoint that automatically distributes requests across your fleet. Your applications connect to one URL, and McGravity handles the rest.
Before McGravity:
// Managing connections to multiple MCP servers
const mcpClient1 = new MCPClient('http://mcp-server-1:3001');
const mcpClient2 = new MCPClient('http://mcp-server-2:3001');
const mcpClient3 = new MCPClient('http://mcp-server-3:3001');
// Manual load balancing logic
const server = getRandomServer([mcpClient1, mcpClient2, mcpClient3]);
With McGravity:
// Single connection, automatic load balancing
const mcpClient = new MCPClient('http://mcgravity-proxy:3001');
/health endpointAPI Gateway for MCP Services: Route requests from your web app to a pool of specialized MCP servers, each handling different capabilities (file operations, database queries, external APIs).
Development Environment: Run multiple versions of your MCP server for A/B testing while keeping your client applications unchanged.
Production Scaling: Start with one MCP server, then add capacity by spinning up additional instances behind McGravity without touching your application code.
Install globally:
npm install -g mcgravity
Create a config file:
# mcgravity.yaml
servers:
- url: http://mcp-server-1:3001
weight: 2
- url: http://mcp-server-2:3001
weight: 1
- url: http://mcp-server-3:3001
weight: 1
Start the proxy:
mcgravity --config mcgravity.yaml --port 8080
That's it. Your applications can now connect to http://localhost:8080 and McGravity will distribute requests across all three servers with the specified weights.
McGravity is designed for containerized deployments:
docker run -p 8080:8080 \
-v $(pwd)/mcgravity.yaml:/app/config.yaml \
tigranbs/mcgravity --config /app/config.yaml
Or use environment variables for simpler setups:
docker run -p 8080:8080 \
-e MCGRAVITY_SERVERS="http://mcp1:3001,http://mcp2:3001" \
tigranbs/mcgravity
/health endpoint returns 200 when at least one upstream server is healthyMcGravity fills the infrastructure gap that every serious MCP deployment eventually needs. Instead of building your own load balancing logic, you get a battle-tested solution that follows proven patterns from the web server world.
Ready to scale your MCP infrastructure? Check out the repository and start load-balancing your MCP servers today.