mcp-bastion-fastmcp
Security middleware for FastMCP servers powered by MCP-Bastion.
Protect any FastMCP server from prompt injection, PII leakage, and resource exhaustion with a single import.
Install
pip install mcp-bastion-fastmcp
Usage
from mcp.server.fastmcp import FastMCP
from mcp_bastion_fastmcp import secure_fastmcp
mcp = FastMCP("My Secure Server")
# Add MCP-Bastion security to your server
secure_fastmcp(mcp)
@mcp.tool()
def get_weather(city: str) -> str:
return f"Weather in {city}: 22C, sunny"
if __name__ == "__main__":
mcp.run(transport="streamable-http")
What it protects
- Scans all tool arguments through the same
MCPBastionMiddlewarepath as the core Python package (see defaults on the three toggles above) - For full
bastion.yamlfeatures (semantic firewall, OPA/Cedar, allowlists, session limits, etc.), usebuild_middleware_from_config()with the low-level MCPServer- FastMCP does not expose a native hook for the entire policy surface
Implementation note: secure_fastmcp patches FastMCP._tool_manager.call_tool so every tool invocation flows through Bastion. Call it right after FastMCP(...) and before run().
License
Licensed under the Apache License 2.0. Commercial and non-commercial use are both permitted.
Metadata
Release files for mcp-bastion-fastmcp 4.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 |
|---|---|---|---|---|
| mcp_bastion_fastmcp-4.1.0.tar.gz | 3.4 kB | With provenance | Details for mcp_bastion_fastmcp-4.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_bastion_fastmcp-4.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcp_bastion_fastmcp-4.1.0-py3-none-any.whl |
Total release size: 7.0 kB
Release files / mcp_bastion_fastmcp-4.1.0.tar.gz
| Download URL | mcp_bastion_fastmcp-4.1.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7081bef9719eaf642b5916a206dabeeb021dab35acceccb3292417ccb93cb850
|
|
BLAKE2b-256 checksum How to use checksums |
b6c37415724c3c5eede229db47fedf61bf8b611a86fd7e5730453d3876119f92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 24, 2026.
Transparency logRelease files / mcp_bastion_fastmcp-4.1.0-py3-none-any.whl
| Download URL | mcp_bastion_fastmcp-4.1.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d297dff3c1c541272c26ad7d997bbce80d60c31c048efe2c768fa1186fcf30ce
|
|
BLAKE2b-256 checksum How to use checksums |
9c5041783890621e0a83724a56c0981b8f289e613e4a3c6d79e08396463586bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 24, 2026.
Transparency logSecurity for mcp-bastion-fastmcp 4.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mcp_bastion_fastmcp-4.1.0.tar.gz
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 Oct 24, 2026.
Transparency logA 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.