MCP Gateway: Per-Tool Policy for Agent Tools (Python)
Seven tool calls worked directly. Through a small gateway, four were blocked.
Video #231 ยท Enterprise architecture and AI agents
Steps in the video
Files
- agent.py (32 lines)
- edge.py (16 lines)
- gateway.py (53 lines)
- policy.py (30 lines)
- show_audit.py (7 lines)
- upstream.py (38 lines)
Tested with
Python 3.12.15 | mcp==2.3.0
What this does not show
A made-up shop and no model. No caller identity, rate limit, output cleaning or human approval, a crude email check, and an audit log that keeps arguments. Nothing here forces calls through the gateway.
Sources
Learning IT by Example.