
Sovereign Gateway
io.github.mattijsmoens由 GitHub 帳號 mattijsmoens 發布v0.3.0更新於 Oct 24, 2026
Gating proxy for MCP servers: policy, verification and one audit trail across upstreams.
概覽
在本機執行的 MCP 閘道代理,把多個上游伺服器的工具整合到一處,並對每次呼叫執行政策、注入過濾與稽核。
- 可以做什麼
- 把多個上游 MCP 伺服器的工具目錄合併成單一具命名空間的入口(例如 git__git_status)。依拒絕清單、允許清單與 PII 政策攔截工具呼叫。比對參數型別與啟動時凍結的工具定義,並過濾參數中的提示注入文字。檢查回傳結果的結構、欺騙、PII 與內容,並可套用自訂一致性規則。把每次允許或拒絕的呼叫寫入雜湊鏈稽核日誌。可選擇讓多個模型對同一結果做共識比對。
- 適用情境
- 當助理需要同時存取多個 MCP 伺服器,而你希望集中管理哪些工具可用、攔截參數中的提示注入,並保留一份統一的呼叫稽核紀錄時使用;特別適合無法修改原始碼的第三方伺服器。
- 執行需求
- 需要本機 Python 環境並以 pip 安裝此套件,透過 stdio 執行。需要一份列出上游伺服器的 gateway.json,可由現有的 Claude Desktop、Claude Code、Cursor、VS Code 或 Windsurf 設定產生。文字過濾、意圖檢查、輸出規則與共識為選用附加套件;共識需至少兩個不同模型供應商,託管供應商的金鑰從指定環境變數讀取。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Sovereign Gateway,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
sovereign-mcp-gateway
A gating proxy for Model Context Protocol servers. Point your MCP client at the gateway instead of at your servers. It connects to every upstream you list, merges their tool catalogues into one, and puts every call through a verification chain before it reaches the server that would execute it.
[Built on patent-pending components]
--init reads the MCP configuration you already have (Claude Desktop, Claude Code, Cursor, VS Code or Windsurf) and writes a gateway.json that proxies those same servers, so the first run produces a working config rather than a configuration error. It will not import the gateway's own entry, because that would make it proxy itself.
The gateway is itself an MCP server, so any client that speaks MCP works with no changes.
That base install is a working gateway. Four optional extras add further layers on top — see Installing.
What it stops
An agent reads a GitHub issue whose body carries an instruction aimed at the model rather than at you. It is persuaded, and calls git_commit.
Same tool, same arguments, same server. The difference is whether anything was in a position to refuse.
Read the walkthrough: Your agent reads an issue — or run it:
Why a proxy and not a library
A library has to be adopted by whoever wrote the server. A proxy protects servers you cannot modify — which is most of them, because the useful MCP servers are published packages someone else maintains.
It also gives you one place to hold policy and one audit trail across every server an agent can reach, rather than per-server configuration nobody keeps in sync.
Configure
Start from what you already run
Four things it will not do: import itself, import a remote server it cannot launch as a subprocess, overwrite an existing file without --force, or write a deny_tools list you did not choose. It writes the file, tells you what it took and what it left, and stops.
Pass --config PATH alongside --init to write somewhere other than ./gateway.json.
After running it, replace those servers in your client with a single entry for the gateway. Leaving both means your agent talks to them directly as well as through the proxy, and the audit trail will only show half the traffic.
Check the wiring before a client ever sees it:
The chain
Installing
The base install is a working gateway, not a stub:
That gives you policy → frozen-verify → audit, which already refuses a tool no upstream exposes, an argument of the wrong type, an undeclared parameter, a tool on your deny list, and prompt injection in an argument. Nothing else needed.
Each extra adds a layer on top:
Combine what you want, or take everything:
All four extras are small pure-Python packages — [all] adds no compiled dependencies and no service to run.
A partial install degrades visibly. The gateway prints its active layers at startup, so you can always see what is actually running:
If a layer isn't on that line, it isn't running — whatever you think you installed.
Verified end to end
Against mcp-server-git and mcp-server-sqlite running as real upstreams, driven by a real MCP client:
Afterwards the repository still holds one commit and the database holds exactly the row it should — checked by opening them directly, not by trusting the gateway's own report. Eleven audit records for ten calls; editing any one of them breaks the chain.
Those cases are the test suite, not a screenshot: pytest tests/ -v.
Layer C: N-model consensus
Every other layer is deterministic and local. Layer C is the exception: it asks several independent models to extract the same structured document from a tool's result, canonicalises each answer, and compares the SHA-256 hashes. Agreement is decided by hash, not by prose.
It is off unless configured, because it is the only layer that costs money and latency per call, and the only one that sends tool output to a model.
Two provider types: local (any OpenAI-compatible endpoint — Ollama, vLLM, LM Studio; base_url defaults to http://localhost:11434/v1) and openrouter (the key is read from the named environment variable, never written in the config).
Three rules the gateway enforces at startup rather than discovering at runtime:
- At least two providers. One model cannot disagree with itself; a consensus of one reports agreement on every call, which is worse than no layer because it looks like verification.
- No duplicate models. Two instances of the same model agreeing is not independent verification.
- A missing API key refuses to start. It does not fall back to running without the layer.
All providers run at temperature = 0, enforced in the constructor.
Check your models agree before you trust the layer
--check runs one real consensus call against your configured models and tells you what happened. This matters more than it sounds:
Consensus compares canonical hashes, so two models that are both semantically right but structurally different never agree. A weaker model that echoes the schema back —
— mismatches on every call, forever, and the gateway refuses everything with a reason that correctly reads "the models disagreed". Because they did.
The probe distinguishes the three outcomes:
Install sovereign-mcp-gateway[consensus] or [all] — the HTTP providers need requests, which the core library deliberately does not depend on.
--check also lists the active layers, so you can confirm at a glance:
If consensus is absent from that line, it is not running, whatever the config says.
Namespacing
With namespace on (the default) a tool is exposed as git__git_status. Two upstreams offering the same tool name cannot collide, shadow each other, or be reached through the wrong namespace. Turn it off only when you have a single upstream.
Policy
deny_toolsmatches either the exposed name (git__git_reset) or the upstream tool name (git_reset, on every upstream that has it).allow_tools, when set, refuses everything not listed.pii_policydefaults towarn, notblock. Real tools return personal data as normal output — everygit logentry carries an author email — and blocking those makes the gateway unusable. Setblockwhen your tools should never emit PII.fail_closeddecides what happens when a layer itself errors. Default: refuse.rate_limit_intervalis0, which disables the behavioural floor's own inter-action delay. That delay is right for one agent taking deliberate steps and wrong for a proxy, where a burst of tool calls is ordinary traffic.entropy_policydefaults towarn. The text filter's entropy heuristic hunts for encoded payloads hidden in prose, but tool arguments are routinely structured — paths, identifiers, hashes — where high entropy is normal. A temporary directory path alone was enough to have a legitimate call refused. Setblockwhen your arguments really are prose.
What this does not do
It verifies calls against frozen definitions and inspects arguments and results. It does not read your servers' source, so it cannot see a check that is present, is called, and silently does nothing. That still takes someone reading the implementation.
It also cannot protect against a compromised upstream returning correct-looking data — Layer C consensus in sovereign-mcp addresses that, and requires model providers you configure yourself.
Licence
Business Source License 1.1 — see LICENSE.
The source is public. You may read it, modify it, create derivative works and use it for development, evaluation and any other non-production purpose at no cost.
Production use is also free for an individual, or an organisation of four or fewer people — that is written into the licence as an Additional Use Grant, not just stated here. Larger organisations need a commercial licence.
Each version converts to Apache 2.0 on its Change Date, four years after publication.
To license it for production, or to ask whether your use needs one: [email protected]
來源:README.md,提交 d9f215e
工具
0版本歷史
1- v0.3.0最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。