Skip to main content

MCP-Bastion security middleware for FastMCP servers. Prompt injection, PII, and rate-limit protection.

Project description

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

Project details


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-3.1.2.tar.gz (3.5 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-3.1.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_bastion_fastmcp-3.1.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcp_bastion_fastmcp-3.1.2.tar.gz
Algorithm Hash digest
SHA256 ab53c332bc09da5cc02fe1d061c25ec24acc6497892d580371d04d30d3993eb4
MD5 9ab8d294ff9e907168645275901e323f
BLAKE2b-256 245c6c0e0472628c1045d4785b1d7b0010404c500eea2202c60aaf9a77af5387

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_bastion_fastmcp-3.1.2.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-3.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_bastion_fastmcp-3.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9edcac6e17e72e5ea16b653228fd808ef4be4bbabac7c9ef00e957af665fb20c
MD5 77a28f2e369e6de81250b8c62d9e8c1c
BLAKE2b-256 8090316397bea3503c66b3ce547e8fd00f8cadd9c8b54588d98eabff7cac5f08

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_bastion_fastmcp-3.1.2-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page