Skip to main content
Glama

MCPGate

轻量级 MCP 网关 — 聚合、过滤并观测您的 MCP 工具。

MCPGate 位于您的 MCP 客户端(Claude Desktop、Claude Code、Cursor、VS Code)与多个 MCP 服务器之间。它提供了一个统一的 MCP 端点,同时让您可以细粒度地控制哪些工具被暴露。

功能特性

  • 工具聚合 — 连接多个 MCP 服务器,通过一个端点暴露所有工具

  • 工具过滤 — 通过简单的 YAML 配置,按服务器允许/阻止特定工具

  • 工具前缀 — 自动命名空间(如 github.create_issue)以避免冲突

  • Web 仪表板 — 实时状态页面,显示服务器、工具和请求日志

  • 双重传输 — Stdio(Claude Desktop)或 HTTP/SSE(远程客户端)

  • 审计跟踪 — 记录每个工具调用的耗时;支持可选的 PostgreSQL 持久化

  • 自托管 — 可部署在 Railway、Docker 上或本地运行

Related MCP server: MCPHub

快速开始

本地(stdio — 适用于 Claude Desktop)

npx mcp-gate start --config mcpgate.yaml

添加到您的 claude_desktop_config.json 中:

{
  "mcpServers": {
    "mcpgate": {
      "command": "npx",
      "args": ["-y", "mcp-gate", "start", "--config", "/path/to/mcpgate.yaml"]
    }
  }
}

本地(HTTP — 带仪表板)

npx mcp-gate start --config mcpgate.yaml
# Dashboard at http://localhost:3000
# MCP endpoint at http://localhost:3000/mcp

Docker

docker compose up
# Dashboard at http://localhost:3000
# Includes PostgreSQL for persistent audit trail

或独立运行:

docker run -p 3000:3000 \
  -e MCPGATE_CONFIG=$(cat mcpgate.yaml | base64 -w 0) \
  -e GITHUB_TOKEN=$GITHUB_TOKEN \
  ghcr.io/mprezz/mcpgate

Railway

Deploy on Railway

添加 PostgreSQL 插件以实现持久化审计跟踪 — MCPGate 会自动检测 DATABASE_URL

配置

创建一个 mcpgate.yaml

gateway:
  name: "my-gateway"
  transport: "stdio" # stdio | http | both
  port: 3000
  toolPrefix: true # prefix tools with server name

servers:
  - name: "github"
    transport: "stdio"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-github"]
    env:
      GITHUB_TOKEN: "${GITHUB_TOKEN}"
    tools:
      allow:
        - "create_issue"
        - "search_repos"

  - name: "filesystem"
    transport: "stdio"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"]
    tools:
      block:
        - "write_file"
        - "delete_file"

logging:
  level: "info"

查看 mcpgate.example.yaml 获取完整参考。

支持的上游传输方式

  • stdio — MCPGate 在本地启动上游进程

  • http — MCPGate 通过 Streamable HTTP 连接到远程 MCP 服务器

HTTP 上游示例:

servers:
  - name: "remote-api"
    transport: "http"
    url: "https://remote-mcp.example.com/mcp"
    headers:
      Authorization: "Bearer ${REMOTE_MCP_TOKEN}"

工具过滤

每个服务器支持 allowblock(互斥):

  • allow — 仅暴露这些工具(白名单)

  • block — 暴露除这些工具之外的所有工具(黑名单)

  • 无配置 — 暴露所有工具

身份验证

添加 Bearer Token 以保护 HTTP 传输:

gateway:
  auth:
    token: "${MCPGATE_AUTH_TOKEN}"

配置身份验证后:

  • 所有端点都需要 Authorization: Bearer <token> 请求头

  • /health 保持公开(用于 Railway/Docker 健康检查)

  • MCP 客户端通过其传输配置中的自定义请求头传递 Token

若未配置身份验证,所有端点均为开放状态(适用于本地/私有使用)。

环境变量插值

在 YAML 中使用 ${VAR}${VAR:-default} 来引用环境变量:

env:
  GITHUB_TOKEN: "${GITHUB_TOKEN}"
  API_URL: "${API_URL:-https://api.example.com}"

仪表板

在 HTTP 模式下运行时,MCPGate 会在根 URL 提供 Web 仪表板:

  • / — 状态页面,包含上游服务器、工具和请求日志

  • /api/status — 用于程序化访问的 JSON API

  • /health — 健康检查端点(用于 Railway/Docker)

  • /mcp — MCP 协议端点(Streamable HTTP)

存储

MCPGate 会记录每个工具调用的耗时和错误信息。

  • 默认 — 内存存储(无需设置,重启后丢失)

  • PostgreSQL — 设置 DATABASE_URL 环境变量(自动创建表)

# Local development with Docker Compose
docker compose up postgres -d
export DATABASE_URL=postgresql://mcpgate:mcpgate@localhost:5432/mcpgate
npx mcp-gate start --config mcpgate.yaml

环境变量

变量

必需

默认值

描述

PORT

3000

HTTP 端口(Railway 会自动设置)

MCPGATE_CONFIG

Base64 编码的 YAML 配置(用于 Railway/Docker)

DATABASE_URL

PostgreSQL 连接字符串(启用持久化审计跟踪)

LOG_LEVEL

info

debug / info / warn / error

MCPGATE_AUTH_TOKEN

HTTP 身份验证的 Bearer Token(在 YAML 中通过 ${MCPGATE_AUTH_TOKEN} 引用)

开发

git clone https://github.com/mprezz/mcpgate.git
cd mcpgate
npm install

npm run dev          # development with hot reload
npm run build        # compile TypeScript
npm run test         # run tests (vitest)
npm run lint         # eslint
npm run typecheck    # tsc --noEmit

架构

Client (Claude, Cursor)
    │
    ▼ stdio or HTTP/SSE
┌──────────────────────────────┐
│         MCPGate              │
│                              │
│  ┌─────────────────────┐     │
│  │   Tool Registry     │     │  ← filters + namespaces tools
│  └─────────────────────┘     │
│  ┌─────────────────────┐     │
│  │   Tool Router       │     │  ← routes calls to correct server
│  └─────────────────────┘     │
│  ┌─────────────────────┐     │
│  │  Upstream Manager   │     │  ← manages server connections
│  └─────────────────────┘     │
│  ┌─────────────────────┐     │
│  │   Storage           │     │  ← memory or PostgreSQL
│  └─────────────────────┘     │
└──────────────────────────────┘
    │           │           │
    ▼           ▼           ▼
 Server A    Server B    Server C
 (GitHub)  (Filesystem)  (Custom)

许可证

Apache 2.0 — 参见 LICENSE

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    A powerful gateway for the Model Context Protocol (MCP) that unifies AI toolchains by federating multiple MCP servers, wrapping REST APIs as MCP tools, and supporting multiple transport methods with an admin dashboard.
    1
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A unified gateway and dashboard that aggregates multiple MCP servers into a single endpoint for streamlined management by AI clients. It features a centralized YAML configuration, a web-based monitoring dashboard, and hot-reload support for managing filesystem, GitHub, and database tools.
  • F
    license
    Not graded
    quality
    D
    maintenance
    A centralized management platform that aggregates multiple Model Context Protocol (MCP) servers into a single unified endpoint for AI agents. It provides a web interface for hot-swappable tool management, proxying of existing servers, and AI-powered generation of custom MCP plugins.
    1
  • A
    license
    Not graded
    quality
    C
    maintenance
    A unified gateway and web dashboard that aggregates multiple MCP servers into a single Streamable HTTP endpoint. It supports stdio, SSE, and HTTP protocols, featuring optimized tool exposure modes to reduce token consumption for AI clients.
    5
    MIT

View all related MCP servers

Related MCP Connectors

  • Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.

  • MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.

  • MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/martin-santiago/mcpgate'

If you have feedback or need assistance with the MCP directory API, please join our Discord server