A security proxy for the Model Context Protocol (MCP). Sits between your AI agent and MCP tool servers, inspecting every tool call for secrets and policy violations in real time.
AI Agent → MCPShield (:4444) → MCP Server
↓
secret detection
policy enforcement
audit log
Requests and responses are scanned. Violations are blocked before they reach the upstream server.
| Pattern | Examples |
|---|---|
| Known credentials | AWS keys, GitHub tokens, OpenAI/Anthropic keys, GCP API keys, Stripe live keys |
| Private keys | RSA, EC, OpenSSH PEM blocks |
| Tokens | JWTs |
| Unknown secrets | High-entropy strings via Shannon entropy scoring |
| Rule match | Action |
|---|---|
| Known credential | Block — JSON-RPC error returned, upstream never called |
| JWT / high-entropy | Flag — allowed through, logged as warning |
1. Clone and install
git clone https://github.com/yourhandle/mcpshield cd mcpshield pip install -e .
2. Configure your upstream MCP server
# config.yaml proxy: host: "127.0.0.1" port: 4444 upstream: url: "http://localhost:3000" # your MCP server
3. Run from the project root
# must be run from repo root where config.yaml lives
python -m mcpshieldProxy is live at http://127.0.0.1:4444. Point your AI agent or Claude Desktop here instead of your MCP server directly.
Secret blocked:
curl -s -X POST http://127.0.0.1:4444 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "write_file", "arguments": {"content": "key=AKIAIOSFODNN7EXAMPLE"} } }' | jq
Expected response:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32600,
"message": "Detected 'aws_access_key' in method=tools/call. Request blocked."
}
}Clean request (proxied through):
curl -s -X POST http://127.0.0.1:4444 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | jq
pip install -e ".[dev]"
pytest tests/ -vSee ARCHITECTURE.md for transports (HTTP + stdio), policy pipeline, and session taint.
stdio mode (Claude Desktop / Cursor):
cp config.yaml.example config.yaml
# set upstream.command / upstream.args and taint.enabled
python -m mcpshield stdio- Week 1: Transparent proxy with real-time secret detection
- Week 2: Policy-as-config, PII detection, redaction
- Week 3: Session-level taint propagation (v1, in-memory)
- Week 4: Audit dashboard
Pattern contributions welcome — add detection rules to mcpshield/detectors/secrets.py and open a PR.