Logo: MCP 网关

MCP 网关

Organisatioun
lucky-aeon

The MCP gateway is a reverse proxy server that forwards requests from clients to the MCP server or uses all MCP servers under the gateway through a unified portal.

Editeurlucky-aeon
Repositorymcp-gateway
SproochGo
Forks
15
Stären
34
Disponibel Tools
0
Transporttypstreamable-http
Kategorien
Linken
  • Tools mat KI-Workflows verbannen

    MCP 网关 bitt MCP-Funktiounen un, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • Disponibel Tools: 0

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an deem MCP-Client ze konfiguréieren, deen Dir am léifste benotzt.

  • Interessi vun der Communautéit um Open-Source-Projet

    Zuele vum verlinkte Repository – Stären: 34, Forks: 15.

MCP Gateway

Description

The MCP gateway is a reverse proxy server that forwards requests from clients to the MCP server or uses all MCP servers under the gateway through a unified portal.

Supports two transport protocols (switchable at startup):

  • SSE (default, legacy MCP transport)
  • Streamable HTTP (MCP spec 2025-03-26)

Features

  • Deploy multiple MCP servers
  • Connect to MCP server
  • Use gateway to call MCP servers
  • Get all MCP servers' SSE streams
  • Get all MCP servers' tools
  • Streamable HTTP aggregated endpoint with session management via Mcp-Session-Id header
  • Dynamic capability aggregation (gateway only advertises capabilities that at least one downstream MCP supports)
  • MCP OAuth 2.1 resource server authentication with Protected Resource Metadata discovery

Installation

  1. pull github package
bash
docker pull ghcr.io/lucky-aeon/mcp-gateway:latest
  1. self build docker image
bash
docker build -t mcp-gateway .

Usage

run github docker container

bash
docker run -d --name mcp-gateway -p 8080:8080 ghcr.io/lucky-aeon/mcp-gateway

run self build docker container

bash
docker run -d --name mcp-gateway -p 8080:8080 mcp-gateway

Configuration

The gateway reads config.json from the config directory (defaults to ./vm when present, otherwise .). A minimal example:

json
{
    "LogLevel": 0,
    "Bind": "[::]:8080",
    "Auth": {
        "Enabled": true,
        "AuthorizationServers": ["https://auth.example.com"],
        "TokenIssuer": "https://auth.example.com",
        "TokenJWKSURI": "https://auth.example.com/.well-known/jwks.json",
        "TokenAudience": "http://localhost:8080/stream",
        "RequiredScopes": ["mcp:read"],
        "ScopesSupported": ["mcp:read"]
    },
    "GatewayProtocol": "all",
    "McpServiceMgrConfig": {
        "McpServiceRetryCount": 3
    }
}

Key fields:

FieldDefaultDescription
Bind[::]:8080Server listen address.
GatewayProtocolallExposed gateway protocols: all, sse, or streamhttp. Also overridable via --protocol flag.
Auth.EnabledtrueWhether to enforce authentication. Set false for local unauthenticated MCP use.
Auth.ApiKey123456Legacy single-key management API login token; not used as MCP auth.
Auth.Modesingle-keysingle-key or saas. SaaS mode uses MCP Gateway accounts and password login.
Auth.AuthorizationServersemptyOptional external OAuth issuer URLs. Empty in SaaS mode means the gateway advertises itself as the authorization server.
Auth.TokenIssuerfirst authorization serverExpected iss claim for MCP OAuth access tokens.
Auth.TokenJWKSURIdiscovered from issuerJWKS URL used to verify JWT access tokens.
Auth.TokenIntrospectionURLemptyRFC 7662 introspection endpoint for opaque access tokens. If set, introspection is used instead of JWKS.
Auth.TokenAudiencerequest resource URLExpected aud claim. Configure to the MCP resource indicator used by your authorization server.
Auth.RequiredScopesemptyScopes required for MCP requests and advertised in WWW-Authenticate.
Auth.ScopesSupportedemptyScopes advertised in Protected Resource Metadata.
SessionGCInterval10sInterval for garbage-collecting idle proxy sessions.
ProxySessionTimeout1mTimeout for idle proxy sessions before GC.
McpServiceMgrConfig.McpServiceRetryCount3Max retries for a failed MCP service before marking it failed.

Selecting the gateway protocol

Either set GatewayProtocol in config.json:

json
{ "GatewayProtocol": "all" }

Or pass the CLI flag (takes precedence):

bash
./mcp-gateway --protocol=streamhttp

Valid values: all (default), sse, or streamhttp.

Authentication

When Auth.Enabled is true, every MCP protocol request must present a Bearer token:

http
Authorization: Bearer <access-token>

The gateway no longer treats api_key, sessionId, Mcp-Session-Id, or X-Session-Id as authentication credentials. Mcp-Session-Id remains a transport session identifier and must be sent together with the Bearer token on authenticated Streamable HTTP requests.

For MCP OAuth discovery, the gateway exposes OAuth Protected Resource Metadata:

http
GET /.well-known/oauth-protected-resource
GET /.well-known/oauth-protected-resource/stream

Unauthorized MCP requests return 401 with a WWW-Authenticate: Bearer ... resource_metadata="..." challenge when OAuth discovery is available. For local unauthenticated development, set Auth.Enabled to false.

In Auth.Mode = "saas" with no external Auth.AuthorizationServers, the gateway uses its own account system for MCP login. Discovery advertises the gateway origin as the authorization server and exposes:

http
GET /.well-known/oauth-authorization-server
POST /oauth/token
POST /oauth/register

/oauth/token accepts form-encoded grant_type=password with username/password and returns the same gateway JWT used by /api/v1/auth/login. Configure Auth.AuthorizationServers only when you want Keycloak, Auth0, or another external OAuth provider.

Browser-based MCP clients can also use the advertised authorization endpoint:

http
GET /oauth/authorize

The built-in authorization endpoint renders a Gateway account login form and completes the OAuth authorization-code flow, including PKCE. /oauth/register implements minimal dynamic client registration for clients such as MCP Inspector.

API

Deploy

support: uvx, npx. or sse url

http
POST /deploy HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{
    "mcpServers": {
        "time": {
            "url": "http://mcp-server:8080",  // url 和 command 二选一
            "command": "uvx",  // url 和 command 二选一
            "args": ["mcp-server-time", "--local-timezone=America/New_York"],  // 可选,command 的参数
            "env": {  // 可选,环境变量
                "KEY1": "VALUE1",
                "KEY2": "VALUE2"
            }
        }
    }
}

Use MCP (SSE Mode)

Available when GatewayProtocol is all (default) or sse.

GET SSE

http
GET /{mcp-server-name}/sse HTTP/1.1
Host: localhost:8080

POST Message

http
POST /{mcp-server-name}/message HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{
    "method": "tools/call",
    "params": {
        "name": "get_current_time",
        "arguments": {
            "timezone": "Asia/Seoul"
        }
    },
    "jsonrpc": "2.0",
    "id": 2
}

Use Gateway (SSE Mode)

Available when GatewayProtocol is all (default) or sse.

网关和直连MCP的区别在于,只需要与网关交互,网关会自动将请求转发到对应的MCP服务器。在call 时,需要在method前面添加 mcpServerName 内容,标识该请求来自哪个 MCP 服务器。

GET SSE

http
GET /sse HTTP/1.1
Host: localhost:8080

这里 sse 是整个网关下所有的 MCP 服务器的 SSE 流。

当客户端订阅 sse 时,网关会为每个 MCP 服务器创建一个 SSE 连接,并将所有 MCP 服务器的 SSE 流合并到一起。

在响应的所有tools/call 的结果中,会在method前面添加 mcpServerName 内容,标识该结果来自哪个 MCP 服务器。

POST Message

http
POST /message HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{
    "method": "tools/call",
    "params": {
        "name": "{mcp-server-name}-get_current_time",
        "arguments": {
            "timezone": "Asia/Seoul"
        }
    },
    "jsonrpc": "2.0",
    "id": 2
}

获取网关下所有工具

http
POST /message HTTP/1.1
Host: localhost:8080
Content-Type: application/json

{
    "method": "tools/list",
    "jsonrpc": "2.0",
    "id": 1
}

# SSE 响应 message event

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "tools": [
      {
        "name": "{mcpServerName}-get_current_time",
        "description": "Get current time in a specific timezones",
        "inputSchema": {
          "type": "object",
          "properties": {
            "timezone": {
              "type": "string",
              "description": "IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use 'America/New_York' as local timezone if no timezone provided by the user."
            }
          },
          "required": [
            "timezone"
          ]
        }
      },
      {
        "name": "{mcpServerName}-convert_time",
        "description": "Convert time between timezones",
        "inputSchema": {
          "type": "object",
          "properties": {
            "source_timezone": {
              "type": "string",
              "description": "Source IANA timezone name (e.g., 'America/New_York', 'Europe/London'). Use 'America/New_York' as local timezone if no source timezone provided by the user."
            },
            "time": {
              "type": "string",
              "description": "Time to convert in 24-hour format (HH:MM)"
            },
            "target_timezone": {
              "type": "string",
              "description": "Target IANA timezone name (e.g., 'Asia/Tokyo', 'America/San_Francisco'). Use 'America/New_York' as local timezone if no target timezone provided by the user."
            }
          },
          "required": [
            "source_timezone",
            "time",
            "target_timezone"
          ]
        }
      }
    ]
  }
}

Use Gateway (Streamable HTTP Mode)

Available when GatewayProtocol is all (default) or streamhttp.

Implements the MCP Streamable HTTP transport defined in spec 2025-03-26. The gateway exposes a single aggregated endpoint /stream that accepts POST, GET and DELETE. Session identifiers are carried in the Mcp-Session-Id HTTP header.

1. Establish a session (initialize)

http
POST /stream HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access-token>
Accept: application/json, text/event-stream
Content-Type: application/json

{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {
        "protocolVersion": "2025-03-26",
        "capabilities": {},
        "clientInfo": {"name": "my-client", "version": "1.0.0"}
    }
}

Response:

http
HTTP/1.1 200 OK
Content-Type: application/json
Mcp-Session-Id: 7782f2f9-563c-4379-b961-df06e49e54c0

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "protocolVersion": "2025-03-26",
        "serverInfo": {"name": "mcp-gateway", "version": "1.0.0"},
        "capabilities": { /* OR-merged from all downstream MCP servers */ },
        "instructions": "MCP Gateway aggregates multiple MCP servers. Tools are namespaced as <serverName>_<toolName>."
    }
}

Keep the returned Mcp-Session-Id and send it on every subsequent request.

2. Complete the handshake (notification)

http
POST /stream HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access-token>
Content-Type: application/json
Mcp-Session-Id: 7782f2f9-563c-4379-b961-df06e49e54c0

{"jsonrpc": "2.0", "method": "notifications/initialized"}

Response: 202 Accepted (empty body).

3. Call tools or list resources

http
POST /stream HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access-token>
Accept: application/json, text/event-stream
Content-Type: application/json
Mcp-Session-Id: 7782f2f9-563c-4379-b961-df06e49e54c0

{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
        "name": "{mcp-server-name}_get_current_time",
        "arguments": {"timezone": "Asia/Seoul"}
    }
}

Aggregated tool names follow the pattern <serverName>_<toolName>, same rule as the SSE gateway mode.

The response arrives synchronously in the HTTP response body:

json
{"jsonrpc": "2.0", "id": 2, "result": { /* ... */ }}

Notifications (JSON-RPC messages without id) are answered with 202 Accepted and forwarded asynchronously.

4. Subscribe to server-initiated events (optional)

http
GET /stream HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access-token>
Accept: text/event-stream
Mcp-Session-Id: 7782f2f9-563c-4379-b961-df06e49e54c0

The gateway keeps the connection open and emits event: message frames for server → client JSON-RPC requests and notifications (e.g. progress updates, log messages). JSON-RPC responses are never pushed here — they are returned in the HTTP response of the originating POST /stream request.

Lines starting with : are SSE keepalive comments and can be ignored.

5. Close the session

http
DELETE /stream HTTP/1.1
Host: localhost:8080
Authorization: Bearer <access-token>
Mcp-Session-Id: 7782f2f9-563c-4379-b961-df06e49e54c0

Response: 200 OK.

Single-server passthrough

In Streamable HTTP mode you can also reach an individual MCP server directly:

http
POST /{mcp-server-name} HTTP/1.1
GET  /{mcp-server-name} HTTP/1.1

The gateway forwards the request to the target MCP's message endpoint. Session management in this mode is the responsibility of the downstream server.

Connecting with MCP Inspector

  1. In Inspector select Transport Type: Streamable HTTP.
  2. URL: http://localhost:8080/stream.
  3. Complete the OAuth flow in your authorization server and provide Authorization: Bearer <access-token>.
  4. Click Connect. The Inspector handles the Mcp-Session-Id exchange automatically.

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "lucky-aeon-mcp-gateway": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-gateway"
      ]
    }
  }
}

MCP 网关 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal MCP 网关 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun verbënnt sech an TypingMind iwwer d'URL vun engem gehoste MCP-Server.

Eng MCP-Server-URL derbäisetzen

Benotzt dës Optioun, wann MCP 网关 schonn op engem externe Server gehost gëtt oder Är Ekipp ee gemeinsame Connector wëllt, op dee méi Benotzer kënne zougräifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbäisetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbäisetzen“.
TypingMind-Formulaire, fir eng benotzerdefinéiert MCP-Server-URL derbäizesetzen
2

Déi kopéiert Server-URL asetzen

Gitt Är Server-URL am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinéiert HTTP-Headeren oder OAuth-Clientastellungen derbäi, wann de Server se erfuerdert.

  1. Setzt Är Server-URL an d'Feld „Server-URL“ an.
  2. Gitt en Numm fir d'Verbindung mat MCP 网关 an.
  3. Wann Dir d'Verbindung méi einfach erëmerkenne wëllt, setzt eng Beschreiwung an e Symbol derbäi.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbäi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zeréck op d'Plugin-Lëscht a kontrolléiert, ob déi nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat MCP 网关 als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen, ouni MCP nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivéiert d'Tools vun der Integratioun MCP 网关 ënner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-Aarbechtsberäich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. Aktivéiert d'Tools vun der Integratioun MCP 网关 ënner „Plugins“.
  4. Biet de Modell, d'Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat MCP 网关 bei dëser Aufgab hëllefen?
MCP 网关
Jo. Ech hunn et gelies.
Dat hunn ech mat MCP 网关 fonnt.

Heefeg gestallte Froen

Fir wat gëtt den MCP-Server MCP 网关 benotzt?

MCP 网关 ass en MCP-Server, deen et kompatibele KI-Clienten erlaabt, op extern Tools a Kontextinformatioune zouzegräifen. An TypingMind kënnt Dir dësen MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech MCP 网关 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir MCP 网关 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni den MCP-Server fir all Modell separat anzeriichten.

Firwat MCP 网关 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann MCP 网关 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Ären Aarbechtsoflaf beim Chatten an TypingMind organiséieren.

Wéi verbannen ech MCP 网关 MCP mat TypingMind?

Dir kënnt MCP 网关 mat TypingMind verbannen, andeems Dir d'URL vu sengem gehosten MCP-Server derbäisetzt. Dat ass nëtzlech, wann Dir eng Remote-MCP-Verbindung wëllt, op déi Dir vun Ärem TypingMind-Aarbechtsberäich aus zougräife kënnt.

Wéi eng Tools stellt MCP 网关 MCP an TypingMind zur Verfügung?

MCP 网关 stellt MCP-Funktioune zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agente zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir MCP 网关 MCP ze benotzen?

Nee. TypingMind ass nom Local-first-Prinzip opgebaut a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann MCP 网关 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir deen MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇