Metadata-Version: 2.4
Name: mcp-bastion-fastmcp
Version: 3.3.0
Summary: MCP-Bastion security middleware for FastMCP servers. Prompt injection, PII, and rate-limit protection.
Project-URL: Homepage, https://github.com/vaquarkhan/MCP-Bastion
Project-URL: Repository, https://github.com/vaquarkhan/MCP-Bastion
Author: Vaquar Khan
License: See LICENSE and COMMERCIAL_LICENSE.md in the MCP-Bastion repository.
Keywords: bastion,fastmcp,llm,mcp,mcp-server,pii,prompt-injection,security
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Requires-Python: >=3.10
Requires-Dist: mcp-bastion-python>=2.0.0
Requires-Dist: mcp>=1.0.0
Description-Content-Type: text/markdown

﻿# mcp-bastion-fastmcp

Security middleware for FastMCP servers powered by [MCP-Bastion](https://pypi.org/project/mcp-bastion-python/).

Protect any FastMCP server from prompt injection, PII leakage, and resource exhaustion with a single import.

## Install

```bash
pip install mcp-bastion-fastmcp
```

## Usage

```python
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](https://github.com/vaquarkhan/MCP-Bastion) project: see [LICENSE](https://github.com/vaquarkhan/MCP-Bastion/blob/main/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](https://github.com/vaquarkhan/MCP-Bastion/blob/main/COMMERCIAL_LICENSE.md)).
