
ahsansuryana/mcp-gateway
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
Aggregated MCP gateway: one POST /mcp endpoint in front of many remote and local MCP upstreams
概要
An aggregated MCP gateway. It presents one POST /mcp endpoint that fans out to many upstream MCP servers — remote over Streamable HTTP, or local as npx-spawned stdio processes — and namespaces what it returns. - are namespaced _ (D4). - are rewritten gw:// / (D5). - (D8): a broken upstream's tools disappear from tools/list and the reason shows in GET /status. - : the gateway is an OAuth toward upstreams (Sprint 5) and an OAuth for inbound callers (Sprint 6). They share no credentials. That is the whole quick start. There is no config to write first: if none exists anywhere, mcp-gateway writes a starter one to /.mcp-gateway/gateway.json, generates an inbound API key, and prints both: Edit the config, add upstreams under mcp, and it reloads on save. The generated host is 127.0.0.1; --hostname 0.0.0.0 widens it to the network. If npm i -g fails with a permissions error, npm's global prefix is not writable by your user.
README
以下は原文 README の抜粋です。原文を見る。
MCP Gateway
Satu endpoint MCP yang menggabungkan banyak MCP server (stdio, HTTP, SSE). Agen cukup tersambung ke gateway, dan gateway meneruskan panggilan ke backend yang sesuai.
Fitur utama:
- Satu endpoint, banyak backend. Tool diberi awalan nama server:
github__search_issues,vercel__get_deployment. - Hemat konteks. Backend bermode lazy disembunyikan dari daftar tool dan diakses lewat tiga meta-tool pencarian.
- Profil.
/mcp/hanya menampilkan sebagian server. - OAuth ke backend. Backend seperti Vercel cukup diberi
"auth": { "type": "oauth" }. Login sekali, token disimpan dan di-refresh otomatis. - OAuth dari agen. Gateway sendiri adalah authorization server OAuth 2.1, jadi agen/klien MCP bisa tersambung dengan login password, tanpa token statis.
- Reconnect otomatis dengan backoff dan cache daftar tool.
Daftar isi
- Prasyarat dan instalasi
- Menjalankan
- Menyambungkan agen
- Referensi konfigurasi (schema)
- Mode expose: full, lazy, auto
- Profil
- OAuth
- Endpoint HTTP
- Menjalankan di produksi
- Keamanan
- Pemecahan masalah
- Batasan
Prasyarat dan instalasi
- Node.js 18 atau lebih baru (diuji di Node 22).
- Paket
@modelcontextprotocol/sdkversi 1.x.
git clone mcp-gateway && cd mcp-gateway
npm install
npm run build
Project ini ditulis dalam TypeScript (ES module). Hasil build ada di dist/.
Struktur project
src/
index.ts entry CLI (-c / --config)
app.ts merakit komponen, start, shutdown
config/ tipe dan loader konfigurasi
backend/ koneksi ke backend: pool, OAuth client, token store
gateway/ katalog tool, filter allow/deny, mode lazy, compact
oauth-server/ authorization server OAuth 2.1 milik gateway
http/ server HTTP (/mcp, /health, /oauth/callback)
utils/ logger, glob, crypto, html
test/ unit test (npm test)
Skrip npm: npm run dev (watch, tanpa build), npm run build, npm start, npm run typecheck, npm test.
Menjalankan
-
Salin contoh konfigurasi dan sesuaikan:
cp gateway.example.json gateway.json -
Atur variabel lingkungan yang dirujuk konfigurasi (
${NAMA}):export GATEWAY_TOKEN="$(openssl rand -hex 32)" # token statis untuk skrip/curl export GATEWAY_PASSWORD="password-login-oauth-anda" # password halaman persetujuan OAuth -
Jalankan:
npm start # memakai ./gateway.json node dist/index.js -c /path/conf.json # konfigurasi lain npm run dev # mode pengembangan (tsx watch)
Contoh log saat start:
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →