Sponsored by Deepsite.site

Claude Mcp Server Gateway

Created By
bzsasson2 months ago
Discover the power of the “CLGateway”, an the open-source Claude MCP Server Gateway (available on GitHub). Built for users of Claude Desktop, Claude API or Claude Code, this Python-based gateway smartly manages your MCP (Model Context Protocol) servers and dramatically slashes token usage, cutting MCP context bloat by roughly 95%. Rather than forcing Claude to load every tool from all configured MCP servers (often thousands of tokens wasted upfront), the gateway exposes just three core tools initially. When you need a specific MCP server (GitHub, Google Workspace, DataForSEO, etc.), the gateway dynamically loads only what’s required, reducing tokens used, improving context clarity, and boosting performance.
Content

Claude MCP server gateway

A Python MCP server gateway for Claude Desktop, Claude Code, Cline and Roo. Instead of loading all MCP tools at startup, it loads them on demand.

Works with: Claude Desktop (app), Claude Code (terminal), Cline and Roo (VSCode extensions)

Compatibility

PlatformConfig FileSupported
Claude Desktopclaude_desktop_config.jsonYes
Claude Code.claude.json or .mcp.jsonYes
Cline (VSCode)cline_mcp_settings.jsonYes

The MCP server problem

When you connect multiple MCP servers to Claude:

  • GitHub MCP server: 51 tools
  • Slack MCP server: 20 tools
  • Google Drive MCP: 15 tools
  • Filesystem MCP: 12 tools

That's 100+ MCP tool definitions loaded before you even start. Each tool's JSON schema eats up tokens.

What this Claude MCP server gateway does

The gateway acts as a single MCP server with 3 tools:

  1. list_available_mcps - shows configured MCP servers
  2. load_mcp_tools - loads tools from a specific MCP server
  3. call_mcp_tool - executes the tool

Model Context Protocol servers only start when Claude actually needs them.

Setup

Requirements

  • Python 3.11+ (for MCP Python SDK)
  • Claude Desktop, Claude Code, or Cline/Roo
  • MCP servers you want to use

Install

git clone https://github.com/bzsasson/claude-mcp-server-gateway.git
cd claude-mcp-server-gateway

python3.11 -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate

pip install mcp python-dotenv

Configure API keys

cp .env.example .env
# Edit .env with your tokens

Claude Desktop MCP server configuration

Add to your Claude Desktop config:

Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "gateway": {
      "command": "/path/to/.venv/bin/python",
      "args": ["/path/to/claude-mcp-server-gateway/dcl_wrapper.py"]
    }
  }
}

Restart Claude Desktop.

How to add MCP server to Claude Code

Claude Code MCP server setup uses a similar config with one additional field.

User-level configuration (all projects)

Edit ~/.claude.json:

{
  "mcpServers": {
    "gateway": {
      "type": "stdio",
      "command": "/path/to/.venv/bin/python",
      "args": ["/path/to/claude-mcp-server-gateway/dcl_wrapper.py"]
    }
  }
}

Project-level configuration

For project-specific MCP servers, create .mcp.json in your project root:

{
  "mcpServers": {
    "gateway": {
      "type": "stdio",
      "command": "/path/to/.venv/bin/python",
      "args": ["/path/to/claude-mcp-server-gateway/dcl_wrapper.py"]
    }
  }
}

Claude Code will prompt for approval when using project-scoped servers.

Alternative: Claude Code CLI

# Add the gateway using CLI
claude mcp add gateway --scope user \
  --command /path/to/.venv/bin/python \
  -- /path/to/claude-mcp-server-gateway/dcl_wrapper.py

# Verify it's added
claude mcp list

Cline/Roo MCP server configuration

For Cline and Roo (VSCode extensions), the MCP server gateway configuration goes in:

Mac: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Windows: %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

{
  "mcpServers": {
    "gateway": {
      "command": "/path/to/.venv/bin/python",
      "args": ["/path/to/claude-mcp-server-gateway/dcl_wrapper.py"],
      "disabled": false
    }
  }
}

Restart VSCode after updating.

How it works

  1. Claude starts - sees gateway (3 tools)
  2. You ask about GitHub - Claude calls list_available_mcps
  3. Claude sees GitHub available - calls load_mcp_tools("github")
  4. Gateway returns GitHub's tool list
  5. Claude picks the right tool - calls call_mcp_tool("github", "search_repositories", {...})
  6. Gateway spins up GitHub MCP, runs the tool, returns results

Adding MCP servers to the gateway

Edit dcl_wrapper.py and add to the MCP_SERVERS dict:

MCP_SERVERS = {
    "your-server": {
        "command": "npx",
        "args": ["-y", "your-mcp-package"],
        "env": {
            "API_KEY": os.getenv("YOUR_API_KEY", "")
        },
        "description": "What it does"
    }
}

Currently configured servers

  • github
  • slack
  • google-drive
  • filesystem
  • postgres
  • memory
  • brave-search

(Check dcl_wrapper.py for the full list)

Limitations

  • Small delay on first tool use (server startup)
  • Each MCP server connection is temporary
  • No persistence between calls

Troubleshooting

Gateway not appearing

  • Check Python path in config points to virtual environment
  • Verify dcl_wrapper.py path is correct
  • Restart Claude Desktop/Code/VSCode completely

MCP server connection errors

  • Check API keys in .env file
  • Verify MCP server package is installed
  • Check gateway logs for errors

Claude Code specific issues

  • Make sure to include "type": "stdio" in config
  • For project configs, approve when prompted
  • Use claude mcp list to verify installation

Files

  • dcl_wrapper.py - The gateway server
  • .env - Your API keys
  • requirements.txt - Python dependencies

License

MIT

Server Config

{
  "mcpServers": {
    "claude-mcp-server-gateway": {
      "command": "/path/to/your/.venv/bin/python",
      "args": [
        "/path/to/claude-mcp-server-gateway/dcl_wrapper.py"
      ],
      "env": {}
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Serper MCP ServerA Serper MCP Server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Playwright McpPlaywright MCP server
DeepChatYour AI Partner on Desktop
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
CursorThe AI Code Editor
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Tavily Mcp
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
ChatWiseThe second fastest AI chatbot™