Skip to main content
Glama
mcp-gateway
by thargy

通用 MCP 网关(mcp-gateway)

一个基于 @thargy/mcp-server-core 构建的高性能、多租户模型上下文协议(MCP)反向代理与网关服务。


为什么选择 mcp-gateway?

大多数第三方 MCP 服务器(如 github-mcp-server、Brave Search、SQLite、PostgreSQL)主要是为通过 stdio 进行本地桌面执行而构建的。当它们通过 HTTP 或 Cloudflare Zero Trust 隧道暴露时,往往存在以下不足:

  1. Cloudflare SSE 流预热:立即发送 : heartbeat\n\n 注释,以绕过反向代理缓冲。

  2. 现代 MCP 握手兼容性:支持 subscriptions/listen、server/discover 以及无状态 JSON-RPC 分发。

  3. 会话生命周期管理:正确的 Mcp-Session-Id 标头跟踪与令牌认证。

mcp-gateway 充当一个单一的多租户适配器,位于远程 MCP 客户端(如 Antigravity IDE、Cloudflare Zero Trust、Cursor)与一个或多个上游第三方 MCP 后端(容器、HTTP API 或 stdio CLI 工具)之间。

Related MCP server: Shared MCP Gateway

架构

graph TD
    subgraph Clients ["MCP Clients"]
        AG["Antigravity IDE / Agents"]
        CFPortal["Cloudflare Zero Trust MCP Portal"]
    end

    subgraph Ingress ["Cloudflare Tunnel (mcp.thargy.com)"]
        Tunnel["cloudflared (HA Server)"]
    end

    subgraph Gateway ["mcp-gateway Container (:3007 -> :3008)"]
        App["@thargy/mcp-server-core Router"]
        GHRoute["/gh/mcp -> HttpProxyAdapter"]
        BraveRoute["/brave/mcp -> StdioProxyAdapter"]
    end

    subgraph Backends ["3rd-Party Backends"]
        GHContainer["github-mcp-backend (:8082)"]
        BraveCLI["@modelcontextprotocol/server-brave-search"]
    end

    Clients --> Ingress
    Ingress --> Gateway
    App --> GHRoute --> GHContainer
    App --> BraveRoute --> BraveCLI

配置(config.yaml)

port: 3008

routes:
  gh:
    type: http
    name: "github-mcp-server"
    description: "GitHub Model Context Protocol Server (repositories, commits, issues, PRs)"
    targetUrl: "http://github-mcp-backend:8082"
    authHeaderEnv: "GITHUB_PERSONAL_ACCESS_TOKEN"

  # brave:
  #   type: stdio
  #   name: "brave-search"
  #   description: "Brave Search MCP Server"
  #   command: "npx"
  #   args: ["-y", "@modelcontextprotocol/server-brave-search"]
  #   env:
  #     BRAVE_API_KEY: "${BRAVE_API_KEY}"

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Aggregates multiple shared MCP servers into a single HTTP gateway, providing a unified, observable, and reusable MCP access layer for multiple AI clients like Codex, OpenCode, and OpenClaw. It centralizes configuration management, logging, health checks, and circuit breaking to simplify multi-client MCP deployments.
    5
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    A universal MCP server that acts as a unified gateway for dynamically connecting and managing multiple MCP servers via a single HTTP endpoint.
    4 npm
    6
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    A universal MCP gateway that aggregates multiple MCP servers into a single endpoint, providing features like hot-reload, auto-healing, and a hook system for request/response mutation.
    1
    MIT