A local-first control plane for your AI agent's tools — cap spend, rate-limit, and audit every MCP tool call.
Project description
Bastion
A local-first control plane for your AI agent's tools. Bastion is a gateway that sits between an AI agent (Claude Code, Cursor, Claude Desktop, …) and the MCP servers it uses — capping spend, rate-limiting, enforcing per-action permissions, and auditing every tool call.
Status: early development. Bastion is being built in the open, milestone by milestone. Today it proxies your MCP servers, writes a full audit log of every tool call, and enforces per-tool permissions; rate limits, budgets, and argument guards land over the next milestones — see the roadmap.
Why
Model Context Protocol won — every major AI vendor ships it and there are 17,000+ MCP servers. But agents call those servers with no spend caps, no rate limits, no permissions, and no audit trail. A looping agent can burn real money in minutes, and you have no record of what it did.
Bastion is the missing control layer. One config file, one command, no cloud, no database.
How it works
Your agent points at Bastion instead of at its MCP servers directly. Bastion is
both an MCP server (to the agent) and an MCP client (to the real "upstream"
servers). It aggregates your upstreams behind one endpoint and enforces rules on
every tools/call:
AI agent ──MCP──▶ Bastion ──MCP──▶ upstream server A
(policy + upstream server B
audit) upstream server C
Install
pip install bastion-mcp
This installs the bastion command. To run it without installing globally,
use uv:
uvx --from bastion-mcp bastion --help
To hack on Bastion itself, see CONTRIBUTING.md.
Quickstart
Create bastion.yaml:
upstreams:
files:
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
Validate it:
bastion validate
Point your agent at the gateway — e.g. for Claude Code:
claude mcp add --transport stdio bastion -- bastion run --config ./bastion.yaml
Your agent now reaches the filesystem server through Bastion. With a single
upstream, tools keep their original names; configure several and Bastion
namespaces each tool by its upstream key (files_read_file, search_query, …)
so they never collide.
Configuration
bastion.yaml — upstreams is required; everything else is optional.
gateway:
transport: stdio # stdio | http
upstreams: # each key names an upstream MCP server
files:
command: npx # `command` ⇒ stdio upstream
args: ["-y", "@modelcontextprotocol/server-filesystem", "/data"]
search:
url: https://search.example.com/mcp # `url` ⇒ http upstream
audit: # every tool call is logged here (JSON Lines)
enabled: true
path: ./bastion-audit.jsonl
policy: # per-tool allow/deny (most-specific rule wins)
default: allow
permissions:
- { tool: "files_read_*", action: allow }
- { tool: "files_delete_*", action: deny }
A denied call is blocked before it reaches the upstream and recorded in the
audit log. The cost section (budgets) is documented as it lands — see the
roadmap below.
Dashboard
bastion dashboard serves a local web view of the audit log — every tool call,
live, with arguments, outcomes, and timings:
bastion dashboard --config bastion.yaml # then open http://127.0.0.1:8787
Roadmap
Bastion is built in milestones; each adds one capability. The first PyPI release comes early — right after permissions — and every milestone after ships a release.
- M0 — multi-upstream proxy (stdio + HTTP), config schema, CLI
- M1 — audit log: every tool call recorded to JSONL
- M2 — permissions: per-tool allow/deny rules
- M3 — first PyPI release (
pip install bastion) - M4 — rate limiting: per-tool / per-client / global token buckets
- M5 — budgets: call-count and cost caps that survive restarts
- M6 — argument guards: block dangerous tool arguments
- M7 — live log viewer (
bastion tail) and CLI polish - M8 — docs, examples,
v1.0.0
Contributing
Issues and PRs welcome — see CONTRIBUTING.md.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bastion_mcp-0.1.0.tar.gz.
File metadata
- Download URL: bastion_mcp-0.1.0.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
015de99af001832fc5c21d1ddfd52eb842bbdadcedc567215284878b137e5574
|
|
| MD5 |
2dd983c804fede52a333326a5640793b
|
|
| BLAKE2b-256 |
eaa35e7991194484d41b20be3ad5bd1cb75a19ffe6c9be344930ecc490650c1a
|
Provenance
The following attestation bundles were made for bastion_mcp-0.1.0.tar.gz:
Publisher:
release.yml on SoumilBhandari/Bastion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bastion_mcp-0.1.0.tar.gz -
Subject digest:
015de99af001832fc5c21d1ddfd52eb842bbdadcedc567215284878b137e5574 - Sigstore transparency entry: 1575224185
- Sigstore integration time:
-
Permalink:
SoumilBhandari/Bastion@251ce92fd967bffb2a70b8cb8e800fe34e4fdc2c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/SoumilBhandari
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@251ce92fd967bffb2a70b8cb8e800fe34e4fdc2c -
Trigger Event:
release
-
Statement type:
File details
Details for the file bastion_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bastion_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e8dd5296983ea6d8893884edca84cff9517748faa8c68e57990fc7a09dc0c41
|
|
| MD5 |
6f0c0e231da3eebbda6bcee7a10c8449
|
|
| BLAKE2b-256 |
5a0aeb50c52b49b6f31a4ec9c9b900546094588051cbe58452b10068f4e54c9a
|
Provenance
The following attestation bundles were made for bastion_mcp-0.1.0-py3-none-any.whl:
Publisher:
release.yml on SoumilBhandari/Bastion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bastion_mcp-0.1.0-py3-none-any.whl -
Subject digest:
5e8dd5296983ea6d8893884edca84cff9517748faa8c68e57990fc7a09dc0c41 - Sigstore transparency entry: 1575224208
- Sigstore integration time:
-
Permalink:
SoumilBhandari/Bastion@251ce92fd967bffb2a70b8cb8e800fe34e4fdc2c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/SoumilBhandari
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@251ce92fd967bffb2a70b8cb8e800fe34e4fdc2c -
Trigger Event:
release
-
Statement type: