mcpwarden-gate
A policy gateway for the Model Context Protocol. It sits between your AI client (Claude Desktop, Cursor, VS Code, your own agent) and the MCP servers it uses, and decides every tool call. The model proposes. The gateway decides.
AI Client ──stdio──▶ mcpwarden-gate ──stdio──▶ mail server
│ ──stdio──▶ file server
│ ──stdio──▶ weather server
gateway.toml
mcp.lock.json
audit.jsonl
Companion code to the "Notes on agentic AI security" working-paper series by A+43 Studios. MIT licence.
What it stops
| Control | What it blocks |
|---|---|
| Pinning | A changed tool description (rug pull), a new tool or a swapped start command is quarantined until a human reviews and re-locks it. The model only sees the pinned definition — never a live, possibly-poisoned one. |
| Least privilege | Each task runs under a profile. Tools outside it are neither shown to the model nor callable — the model cannot even ask for them. |
| Egress allowlist | Recipients and URLs in arguments must point to allowed domains. Encoded forms, backslash variants, //host, scheme-less URLs and hidden fields like bcc, reply_to, host are all checked. Arguments outside the reviewed schema are refused. |
| Flow rules (taint) | Tracks untrusted input (U) and private data (D). Sending data out after U+D, or changing state after U, requires a human approval. |
| Approvals | Raised through MCP elicitation or the local inbox (--inbox). The prompt names recipients and hosts before the arguments — a long argument cannot push them out of view. The decision is signed, call-bound, and single-use. |
| Sanitising | Strips hidden HTML, invisible characters, scripts and off-screen elements from tool results. |
| Outbound filter | Removes markdown and HTML images and links to foreign hosts from results (the rendering-exfiltration channel). |
| Audit + circuit breaker | Every decision in audit.jsonl with a hash chain. Call budgets per session and per tool; the session is locked after too many rejections. |
Demo result — directly connected, a gullible agent sends 4 emails to the attacker (3 with secrets), deletes 4 and leaks an image. Behind the gateway: 0 emails, 0 deleted, no leak, task completed.
Install
From PyPI (recommended):
pip install mcpwarden-gate # gateway only
pip install "mcpwarden-gate[ui]" # gateway + dashboard (mcpwarden-ui + mcpwarden-mcp)
From source:
git clone https://github.com/A043-studios/mcpwarden-gate.git
cd mcpwarden-gate
pip install -e . # Python 3.11+, no runtime dependencies
pip install -e ui/ # dashboard (mcpwarden-ui + mcpwarden-mcp)
Get started in 3 steps
Step 1 — Initialise (reads your existing client configs, writes gateway.toml):
mcpwarden-gate init
Step 2 — Add a server (starts it once in quarantine, shows its tools, locks them on your approval):
mcpwarden-gate add myserver
Step 3 — Point your AI client at the gateway
Add this to your MCP client config. --profile controls which tools the AI is allowed to call (defined in gateway.toml).
Claude Desktop — edit claude_desktop_config.json:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"gateway": {
"command": "mcpwarden-gate",
"args": ["run", "--policy", "/path/to/gateway.toml", "--profile", "default"]
}
}
}
VS Code / Cursor — see docs/Integrations.md for IDE-specific snippets.
After any server update: mcpwarden-gate update myserver — it shows what changed and asks before locking the new state.
Dashboard
mcpwarden-ui --policy gateway.toml # read-only dashboard
mcpwarden-ui --policy gateway.toml --inbox # + live approvals inbox
Opens at http://127.0.0.1:8421 with a bearer-token link. No data leaves your machine.
1 · Übersicht (Overview)
The landing page: session counts, call timeline, top tools by call volume, egress targets, the most recent sessions with their label strip, and the last label events.
What you see:
- Sessions — how many ran and how many are still active
- Aufrufe / Blockiert / Gefragt / Aktiv — total calls, blocks, approval requests, active sessions at a glance
- Aufrufe über die Zeit — stacked area chart: allowed / blocked / approval-requested / unknown / stamp
- Blockierungen nach Kontrolle — donut chart: which controls blocked how many calls
- Top-Tools — horizontal bar: the busiest tools this run
- Ziele — egress hosts seen, with allowlist status
- Letzte Sessions — sortable table linking to individual session timelines
- Label-Verlauf — when taint labels (U, D, E) entered or left each session
2 · Live feed
Real-time stream of every gateway decision as it happens. Pause/resume, search by session or tool, label badges on each row.
Each row shows:
- Timestamp and session ID (clickable → session detail)
- Tool called, arguments summary
- Decision:
erlaubt/blockiert/gefragt/gestempelt/unbekannt - The control that triggered the decision (e.g.
egress_allowlist,pinning,integrity) - Current label state: U (untrusted input), D (private data), E (egress seen)
3 · Sessions
All sessions in one sortable, searchable table. Click any session ID to open its full timeline.
Columns: Session ID · State (running / ended) · Start · End · Profile · Events · Calls · Blocked · Asked (approvals) · Stamped
4 · Session Detail — Timeline
Every event of one session in chronological order. The label strip at the top shows when taint labels arrived. The flow-status panel explains whether the session's information-flow rules were satisfied.
What you see per row:
- Relative timestamp from session start
- Session and sequence number
- Tool name and decision badge (colour-coded)
- Control that decided it, with the exact reason from the audit log
- Label change: which labels were on this call (U, D, E) and after which labels are set
- Flow-rule evaluation icon per call
5 · Blockierungen (Blocks)
Summary view: for each control, how many calls it blocked, which tools, and the exact reasons — verbatim from the audit log.
Columns: Control · Count · Tools · Reasons (with occurrence counts)
Useful for diagnosing over-tight policies: if least_privilege blocks a tool you expected to allow, the reason column tells you exactly which profile was active and which tool was missing from its allowlist.
6 · Ziele (Egress targets)
All hosts that appeared as destinations in tool arguments across all sessions — with allowlist status and a link to the first occurrence.
Columns: Host · Calls with this target · Of those forwarded · Allowlist status · First seen (session + seq)
Hosts not on the egress allowlist are highlighted in red. Click the session link to jump straight to that event.
7 · Freigaben (Approvals)
Aggregated approval statistics per control: how many were requested, how many granted by a human, how many stamped (auto-approved without review), and the grant rate.
8 · Quarantäne
All tools and servers the gateway refused to start because their definition changed, they are new, or they have not been reviewed yet.
Columns: Session · Seq · Type · Server / Tool · Reason (changed / new / not_reviewed)
After running mcpwarden-gate review and locking the new state, the tool leaves quarantine in the next session.
9 · Policy
Full view of the loaded gateway.toml: gateway settings, all controls with their current state, every server with its tools and their effect/label/path annotations, and all profiles with their allowlists.
Sections:
- Gateway settings — owner, egress allowlist, max calls per session, max calls per tool
- Controls — which of the 8 controls are on/off, approval mode
- Servers — per server: transport, trust level, lock status, every tool with effect annotation, labels, path_args, recipient_args, and whether it is in the profile allowlist
- Profiles — the full
allow = [...]list of each profile
When started with --policy, the policy page also lets you edit the config: add/remove servers and profiles, toggle controls, change allowlists — all written atomically to gateway.toml.
10 · Inbox (Approvals — live, with --inbox)
When the gateway is started with approval = "inbox" in its policy, approval requests arrive here in real time. A human reads the structured prompt (recipient and host shown before the arguments) and clicks Grant or Deny.
Each decision is signed, call-bound, and single-use: a replay, a swap, a tamper, or an expiry check all fail. The decision is written to the state directory as a .json file — not on the MCP channel, so a prompt-injected model cannot forge it.
MCP server bridge — mcpwarden-mcp
Lets a Claude model control the dashboard via MCP — read audit data, edit the policy, and decide approval requests, all through tool calls.
Claude Desktop / Claude Code
│ stdio
▼
mcpwarden-mcp ←─ --url http://127.0.0.1:8421 --token <token>
│ HTTP + Bearer
▼
mcpwarden-ui :8421
Setup in claude_desktop_config.json:
{
"mcpServers": {
"mcpwarden": {
"command": "mcpwarden-mcp",
"args": ["--url", "http://127.0.0.1:8421", "--token", "<token-from-ui-startup>"]
}
}
}
The token is printed by mcpwarden-ui at startup in the #t=… fragment of the URL.
Tools
| Group | Tool | What it does |
|---|---|---|
| Read | get_health |
Dashboard health + capability flags (config_editable, read_errors) |
get_model |
Full dashboard model: sessions, call counts, egress events | |
get_stats |
Call statistics for a time window (bucket: hour/day/week, optional profile filter) | |
get_session |
Event timeline of one session (paginated by cursor) | |
get_policy |
Current policy: servers, profiles, controls, gateway settings | |
get_clients |
AI-client routing status (Claude Desktop, Claude Code, Cursor, VS Code) | |
get_inbox |
Open approval requests (requires --inbox) |
|
| Config writes | add_server |
Add a server block to gateway.toml |
(requires --policy) |
delete_server |
Remove a server and all its tool policies |
update_gateway |
Change owner, egress allowlist, max_calls, initial_labels | |
update_controls |
Toggle any of the 8 controls, set approval mode | |
add_profile |
Add a new profile | |
update_profile |
Replace a profile's allowlist | |
delete_profile |
Remove a profile | |
add_tool_policy |
Add a [servers.S.tools.T] block (effect, labels, path_args, …) |
|
update_tool_policy |
Replace a tool policy block | |
| Inbox | decide |
Grant or deny one approval request (requires --inbox) |
Resources
| URI | Content |
|---|---|
mcpwarden://health |
Live health and capability flags |
mcpwarden://policy |
Current policy as JSON |
mcpwarden://sessions |
Live dashboard model (sessions, egress, counts) |
Prompts
| Name | Purpose |
|---|---|
audit_review |
Step-by-step audit review of one session (sid + focus area) |
security_check |
Full security posture review — controls, trust surface, egress, client coverage |
add_server_guided |
Guided dialog to add a new server: collects transport, trust, tools and effects before writing |
What you can connect
| Server type | Supported |
|---|---|
| Local stdio servers (files, mail, git, databases, most npm/pip community servers) | Yes — needs a policy entry and a reviewed lock |
Remote servers over Streamable HTTP/SSE (url = "https://…") with a static token |
Yes — configure via http_headers / env_passthrough |
| Tools, resources, prompts, logging through the gateway | Yes — same controls apply |
| Servers that require OAuth | No — static tokens only |
| AI clients that connect to a URL (some web-chat connectors) | No — client side is stdio only |
Working-paper series
| # | Paper | Capability added |
|---|---|---|
| 2 | Who Decides (2026-02) | mcpwarden-gate run · review · lock |
| 3 | What Holds (2026-03) | mcpwarden-gate probe: attacks your own policy |
| 4 | Who Says Yes (2026-04) | mcpwarden-gate approve: human-readable approvals |
| 5 | Who Writes the Rules (2026-05) | mcpwarden-gate derive · test · export · evidence |
Each paper is reproducible from its release tag. See papers/ for reproduction scripts.
Layout
src/mcpwarden_gate/ gateway · policy · pinning · approval · inbox
sanitize · audit · config · stdio · http_upstream
scan · report · evidence · logmodel · logstats · __main__
ui/
src/mcpwarden_ui/ server.py (HTTP) · api.py (data) · mcp_server.py (MCP bridge)
frontend/ React 18 + Vite 6 + Tailwind v4 (build checked in)
ops/ Docker · backup · demo audit log
demo/ mail/files/weather servers · agent · run_demo · ablation · bench
tests/ policy · pinning · approvals · proxy · end-to-end · SDK interop
docs/ threat-model · SPEC-base-hardening · ui limits
MIT · Tim Gelzleichter, A+43 Studios · a043.xyz
Metadata
Release files for mcpwarden-gate 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcpwarden_gate-1.1.0.tar.gz | 673.1 kB | Without provenance | Details for mcpwarden_gate-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcpwarden_gate-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcpwarden_gate-1.1.0-py3-none-any.whl |
Total release size: 995.7 kB
Release files / mcpwarden_gate-1.1.0.tar.gz
| Download URL | mcpwarden_gate-1.1.0.tar.gz |
|---|---|
| Size | 673.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
562859316c588296884209e64d51fa1ab746013b91542e873c3f211f8fb4705c
|
|
BLAKE2b-256 checksum How to use checksums |
47195be938bd638da66a1c9e8c69cd47d4e2954073d3ab19c5f649cf9660bd6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / mcpwarden_gate-1.1.0-py3-none-any.whl
| Download URL | mcpwarden_gate-1.1.0-py3-none-any.whl |
|---|---|
| Size | 322.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9232e6eca0b9d7ba86fe2ea2bc249e6b8ec583aac7799d345453435499f93f5
|
|
BLAKE2b-256 checksum How to use checksums |
e2b67fe847f40ed2cc9dc8f2505f631eb23ca3a36c45635a8ceaca00b02e2200
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for mcpwarden-gate 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.