bastiongate
MCP security gateway. An inline proxy that sits between an AI agent and its MCP servers and enforces security on every call:
- scans
tools/listand drops tools whose definitions carry prompt injection or hidden unicode (via bastionsupply) - enforces a tool allow/deny policy — the agent can only call what you permit
- scans tool-call results and blocks any that carry indirect prompt injection before the agent ever reads them
- logs every message as a JSONL trace for forensics
The runtime-enforcement leg of the bastion family:
| tool | job |
|---|---|
| bastiongate | gate — enforce security inline on live MCP traffic |
| bastionsupply | scan an MCP server before you trust it |
| agentbastion | prevent — firewall around a running agent |
| bastionprobe | attack — pentest your agent with injections |
| bastiontrace | investigate — forensics on an agent trace |
Install
pip install bastiongateway
(The PyPI distribution is bastiongateway; the import package and bastiongate
CLI keep that name.)
Use
The gate is an MCP server to your agent, and a client to the real one. Point
your MCP client's command at the gate and put the real server after --:
// mcp.json
{
"mcpServers": {
"docs": {
"command": "bastiongate",
"args": ["run", "--policy", "policy.yaml", "--log", "gate.jsonl",
"--", "npx", "-y", "@some/mcp-server"]
}
}
}
Everything the agent sends flows through the gate to the server and back, with the checks applied in between.
Policy
Drop in the same YAML bastionsupply harden emits:
default: deny
allow:
- get_weather
- search_docs
deny:
- run_command
# behavior knobs (defaults shown)
scan_tools: true # scan tools/list
on_poisoned_tool: block # drop poisoned tools from the listing
scan_results: true # scan tool-call results
on_injected_result: block # block results carrying injection
So the pipeline is: scan the server with bastionsupply → harden a policy →
run it live behind bastiongate.
Try it
bastiongate run --log gate.jsonl -- python examples/echo_server.py
The example server offers a poisoned tool and an injected result; the gate drops
the first and blocks the second. Watch gate.jsonl.
Library
from bastiongate import Gate, GatePolicy
gate = Gate(GatePolicy(deny={"run_command"}))
forward, reply = gate.handle_client_msg(msg) # agent -> server
out = gate.handle_server_msg(response) # server -> agent
Gate is a pure message transform — easy to embed or test.
Notes
- stdio transport only for now (the common locally-installed case). HTTP/SSE is the next transport.
- Result scanning reuses bastionsupply's static injection signatures. Swapping
in agentbastion's
Firewall(LLM judge, semantic detector, PII scrub) is the planned deeper-inspection upgrade.
MIT.
Release files for bastiongateway 0.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 | |
|---|---|---|---|
| bastiongateway-0.1.0.tar.gz | 12.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bastiongateway-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.4 kB
Release files / bastiongateway-0.1.0.tar.gz
| Download URL | bastiongateway-0.1.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c61380d9fb8378159ae515fcc95856c6894cea64b317d44ad18801dc5fe72504
|
|
BLAKE2b-256 checksum How to use checksums |
aa0bff49864a3ca8b6591ceef0aa7ae33c96196e3a95ed4cc6e8bcf3d98b232e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logRelease files / bastiongateway-0.1.0-py3-none-any.whl
| Download URL | bastiongateway-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ad5bb7c47fa7c973b1526ed86eb35ab5d4c4226d67d85d1db3b8da8da6b80c2
|
|
BLAKE2b-256 checksum How to use checksums |
7a68d74c8d04982dc9aa1ec35e9219ba79b33dc3b0afc5eb9aa81d5ee5f4bc18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency log