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).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_bastion_fastmcp-5.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_bastion_fastmcp-5.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file mcp_bastion_fastmcp-5.1.0.tar.gz.

File metadata

  • Download URL: mcp_bastion_fastmcp-5.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mcp_bastion_fastmcp-5.1.0.tar.gz
Algorithm Hash digest
SHA256 5d9cef80a7e32af2a79beb2d6da51ffa7dc4830559eddb4942dfe399600e2128
MD5 68c3ec4adba5a8109c0cd2d893bfd9b7
BLAKE2b-256 e2331bdf8b21963ba09f65011b1f4d16ef9d9b65d660acebf0061c5a25339219

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_bastion_fastmcp-5.1.0.tar.gz:

Publisher: publish-integrations.yml on vaquarkhan/MCP-Bastion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_bastion_fastmcp-5.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_bastion_fastmcp-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9dadcd09bfdb7cf0e2f941226a1843b9179c9c34299cb79c50c9e6a1e8056ca
MD5 beb341c73535494809fc6ae66fc4c6c0
BLAKE2b-256 dfdb1cb7e21a10c6b956e582211362070358022566d4c81fde80f6514f6e4b9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_bastion_fastmcp-5.1.0-py3-none-any.whl:

Publisher: publish-integrations.yml on vaquarkhan/MCP-Bastion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 files

5.0.0

2 files

4.0.0

2 files

3.3.1

2 files

3.3.0

2 files

3.2.0

2 files

3.1.2

2 files

3.1.1

2 files

3.1.0

2 files

3.0.1

2 files

3.0.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

0.1.3

2 files

0.1.0

2 files

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