Skip to main content

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 MCPBastionMiddleware path as the core Python package (see defaults on the three toggles above)
  • For full bastion.yaml features (semantic firewall, OPA/Cedar, allowlists, session limits, etc.), use build_middleware_from_config() with the low-level MCP Server - 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

Same terms as the MCP-Bastion project: see LICENSE. Non-commercial use is free with required citation/attribution; copyright terms apply. Commercial use as defined in the License may need a separate agreement (COMMERCIAL_LICENSE.md).

Metadata

Release files for mcp-bastion-fastmcp 5.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-bastion-fastmcp 5.1.0
File Size Uploaded Provenance Actions
mcp_bastion_fastmcp-5.1.0.tar.gz 4.1 kB With provenance Details for mcp_bastion_fastmcp-5.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-bastion-fastmcp 5.1.0
File Interpreter ABI Platform Actions
mcp_bastion_fastmcp-5.1.0-py3-none-any.whl Python 3 none any Details for mcp_bastion_fastmcp-5.1.0-py3-none-any.whl

Total release size: 8.4 kB

Release files / mcp_bastion_fastmcp-5.1.0.tar.gz

Download URL mcp_bastion_fastmcp-5.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d9cef80a7e32af2a79beb2d6da51ffa7dc4830559eddb4942dfe399600e2128
BLAKE2b-256 checksum
How to use checksums
e2331bdf8b21963ba09f65011b1f4d16ef9d9b65d660acebf0061c5a25339219
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 Aug 16, 2026.

Transparency log

Release files / mcp_bastion_fastmcp-5.1.0-py3-none-any.whl

Download URL mcp_bastion_fastmcp-5.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9dadcd09bfdb7cf0e2f941226a1843b9179c9c34299cb79c50c9e6a1e8056ca
BLAKE2b-256 checksum
How to use checksums
dfdb1cb7e21a10c6b956e582211362070358022566d4c81fde80f6514f6e4b9b
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 Aug 16, 2026.

Transparency log

Security for mcp-bastion-fastmcp 5.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.

Select from 2 files

Attestation for mcp_bastion_fastmcp-5.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 Aug 16, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page