Retrieved article excerpt
Open article Β· Retrieved 2026-10-27T14:29:59.334053+00:00
# Bouncer
[CI](https://github.com/Ezed9/mcp-bouncer/actions/workflows/ci.yml)
[PyPI](https://pypi.org/project/bouncer-mcp/)
[Python 3.12+](https://github.com/Ezed9/mcp-bouncer/blob/main/pyproject.toml)
[License: MIT](https://github.com/Ezed9/mcp-bouncer/blob/main/LICENSE)
**A local MCP proxy that denies an agent's send and share calls to destinations
that first appeared in untrusted tool output. The rules are deterministic, no
LLM decides anything, and every decision is logged.**
[Terminal recording: an agent that read a poisoned helpdesk ticket tries to email the customer list to an attacker, write an SSH key and delete customers through Bouncer. The email and the SSH key write are denied, the first delete runs and the second is stopped by the call budget, a send to a new address is approved by a human, and a security review pack is written from the audit log.](https://github.com/Ezed9/mcp-bouncer/blob/main/docs/assets/demo.gif)
*Scripted tool calls from a hijacked agent, sent through the real proxy to a
real MCP server: three attack calls denied (one delete ran first, within its
call budget), one new recipient approved by a human,
a review pack written from the audit log. No API keys; reproduce it in the
[quickstart](https://github.com/Ezed9/mcp-bouncer#see-it-in-60-seconds). [MP4](https://github.com/Ezed9/mcp-bouncer/blob/main/docs/assets/demo.mp4) Β·
[what the demo runs](https://github.com/Ezed9/mcp-bouncer/blob/main/examples/demo/README.md) Β·
[the review pack it writes](https://github.com/Ezed9/mcp-bouncer/blob/main/examples/demo/sample-review-pack.md)*
**The cost:** in the [AgentDojo run](https://github.com/Ezed9/mcp-bouncer#benchmark) Bouncer allowed no send at
all, so legitimate tasks that send email or share files went from 4/6 to 0/6.
It covers MCP calls only ([limits](https://github.com/Ezed9/mcp-bouncer#limits)).
- **Blocks sends to addresses that came from untrusted data.** If an agent tries
to email, post or share to a destination that appeared earlier in the same
server's output (a poisoned email, ticket or document), the call is denied.
The match is literal. A destination Bouncer can't trace, an encoded one
included, goes to a human; allowlisted or approved ones pass.
- **Puts hard limits on write tools.** Path confinement, regex checks on
arguments, per-session call budgets, and tools that weren't there at startup
are refused.
- **Leaves evidence.** Every `allow`, `deny` and `ask` is a JSON line in
`~/.bouncer/audit.jsonl`, and `bouncer report` turns it into a review pack.
Bouncer does not detect prompt injection. It assumes the agent will sometimes
be fooled and limits what a fooled agent can do through MCP.
**Status:** v0.1.4, early. MCP over stdio, one machine. Read the
[limits](https://github.com/Ezed9/mcp-bouncer#limits) before relying on it.
## See it in 60 seconds
From a clone, with [uv](https://docs.astral.sh/uv/) (no API keys, nothing
outside the repo is touched):
```
git clone https://github.com/Ezed9/mcp-bouncer.git && cd mcp-bouncer
uv sync --all-packages
uv run python examples/demo/run_demo.py
```
This is the recording above. It starts the real `bouncer run` proxy in front of
a small helpdesk MCP server with real side effects, then checks the server's
state afterwards: no mail reached the attacker and no file was written outside
the workspace. Output goes to `examples/demo/out/`.
## Use it with your MCP client
```
uv tool install bouncer-mcp # or: pipx install bouncer-mcp (Python 3.12+)
```
Back up your client config, then wrap its servers:
```
cp .mcp.json .mcp.json.bak
bouncer init --config .mcp.json # add --server <name> to wrap only some servers
```
Any config with an `mcpServers` block works, for example Claude Code's
`.mcp.json`, Cursor's `~/.cursor/mcp.json`, or Claude Desktop's
`"~/Library/Application Support/Claude/claude_desktop_config.json"` on macOS.
`init` prints the rewritten config and asks before writing. Each server entry
now launches `bouncer run`, and the original entry (command, args, `env`,
`cwd`) is kept under `x-bouncer-upstream`, which is how `run` starts the real
server and how you undo the change by hand. Restart your client.
Three things to know on the first run:
- **Your client must find `bouncer`.** The rewritten entry uses
`"command": "bouncer"`. Desktop apps may not see your shell's `PATH`; if the
server fails to start, replace it with the output of `which bouncer`.
- **`ask` needs MCP elicitation.** A send to an unknown destination asks the
human through the client. If your client does not support elicitation, every
`ask` becomes a `deny`, so list your usual recipients in
`trusted_destinations` (see [Policy](https://github.com/Ezed9/mcp-bouncer#policy)).
- **Run `bouncer` with a subcommand.** With none, it starts Bouncer's own MCP
server on stdio and waits for a client.
## How it works
```
agent / MCP client
β tool call β² result, or
βΌ β "[bouncer blocked] <reason>"
ββ bouncer run: one per server, stdio βββββββββββββββ
β 1. tool present at startup? no β deny β
β 2. within the call budget? no β deny β
β 3. path / regex checks pass? no β deny β
β 4. sending somewhere? where did the destination β
β come from? β
β seen in this server's output β deny β
β allowlisted or approved β allow β
β can't tell β ask human β
β (no answer or no support β
β for asking = deny) β
β every verdict β ~/.bouncer/audit.jsonl β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β allowed calls only β² every output is
βΌ β recorded as untrusted
your MCP server (filesystem, gmail, slack, β¦)
```
`bouncer run` starts the real server as a subprocess, records its tool list at
startup, and checks every call before forwarding it. A denied call is never
forwarded, so it has no side effects. Everything the server returns (text and
structured content) is recorded as untrusted, and a later destination that
appears in it is denied. An approval is remembered for the rest of the session.
The check is plain Python: normalize case and whitespace, then look for the
destination inside what the server has returned this session. A miss means
`ask`, never a silent `allow`.
Decision order, policy layering, the audit format and a live transcript against
the reference filesystem server: [`docs/how-it-works.md`](https://github.com/Ezed9/mcp-bouncer/blob/main/docs/how-it-works.md).
## Policy
Built-in packs in [`src/bouncer/packs/`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/packs) name the sending
and writing tools of five servers. The filesystem pack is verified against the
reference server's `tools/list`; the gmail, slack, github and gdrive packs
follow those servers' documented schemas and are not yet verified live. Check
them against your server's `tools/list`. A tool with no pack entry gets a
fallback that treats destination-shaped arguments (`to`, `url`, `channel`, β¦)
as destinations.
Add your own rules in YAML:
```
send_email:
exfiltrating: true
sink_params: [to, cc, bcc]
trusted_destinations: [[email protected]]
write_file:
write_params: [path]
allowed_path_prefixes: ["/abs/path/to/project/out"]
delete_file:
max_calls: 2 # 0 forbids the tool outright
```
Add `"--policy", "/abs/path/bouncer.yaml"` to the wrapped server's `args`. A
user entry **replaces** the pack entry for that tool, so restate
`exfiltrating` and `sink_params` when you override a sending tool, or the
destination check is off for it. Use absolute path prefixes: a relative one is
resolved against whatever directory your client starts the proxy in. Start
from [`examples/bouncer.yaml`](https://github.com/Ezed9/mcp-bouncer/blob/main/examples/bouncer.yaml).
## Why not just β¦
- **β¦ approve each tool call?** Per-tool approval answers "may the agent send
email?". Bouncer answers "may it send email to this address, given where the
address came from?", refuses outright when the answer is "from untrusted
data", and only interrupts you for destinations it can't place. Use both.
- **β¦ add an LLM-based injection detector?** A detector is probabilistic and
can be worded around; Bouncer doesn't try to spot the injection. It checks
the action, and the same call with the same history always gets the same
verdict, which you can test and audit. The two can run together.
- **β¦ sandbox the agent or remove its send tools?** Do that where you can. Bouncer
is for agents that need send and write tools to be useful.
- **β¦ scan my MCP servers?** Scanners vet what a server declares. Bouncer
assumes the server is honest and the data passing through it is hostile.
## For security reviewers
**Threat model.** The agent is well-meaning but reads attacker-controlled data
through MCP tools (an email, a ticket, a document) and may follow instructions
in it. The attacker controls tool output only; they cannot change Bouncer, its
policy, the client config or the server. Trusted: you (policy author and
approver), the MCP client, the upstream server and the local machine.
What the code and tests pin down, for MCP tool calls that go through it:
| Behaviour | Code | Tests |
| --- | --- | --- |
| No model or classifier in the enforcement path | [`engine.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/engine.py) | |
| A denied call is never forwarded upstream | [`proxy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/bouncer-mcp/src/bouncer_mcp/proxy.py) | [`test_proxy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/bouncer-mcp/tests/test_proxy.py) |
| A destination seen in this server's earlier output is denied, including one inside a list of recipients | [`taint.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/taint.py) | [`test_engine_sink_gate.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/tests/test_engine_sink_gate.py) |
| Path traversal (`..`) can't escape an allowed prefix; budgets and regex checks deny | [`engine.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/engine.py) | [`test_engine_constraints.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/tests/test_engine_constraints.py) |
| Fails closed: an unanswered `ask` is a deny; a sending tool with no declared destination arguments has all arguments checked; a malformed policy stops startup; a tool added after startup is refused | [`proxy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/bouncer-mcp/src/bouncer_mcp/proxy.py), [`policy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/policy.py) | [`test_policy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/tests/test_policy.py), [`test_proxy.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/bouncer-mcp/tests/test_proxy.py) |
| Every verdict is written to the audit log | [`audit.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/src/bouncer/audit.py) | [`test_audit.py`](https://github.com/Ezed9/mcp-bouncer/blob/main/tests/test_audit.py) |
**The audit log** is one JSON line per verdict with a UTC timestamp, tool,
full arguments, verdict, reason and the rule that fired. `ask` is an
escalation: an approved one is followed by an `allow` line for the same call;
a declined one has no further line. A tool that wasn't present at startup is
logged as `ask` and blocked. The file is plaintext and contains whatever the
agent passed as arguments (email bodies included). Bouncer only appends to it,
but nothing makes it tamper-evident.
**Review pack.** `bouncer report` writes a Markdown pack: each tool and the
controls on it, an audit log summary, findings, what it does and doesn't
cover, and an OWASP LLM Top 10 mapping.
```
bouncer report --policy bouncer.yaml