learning-it by example

Back to the video

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

  1. 0:00 Seven calls
  2. 0:21 The idea
  3. 0:50 Setup
  4. 1:10 The shop's tools
  5. 1:28 The policy
  6. 1:50 The check
  7. 2:14 The gateway
  8. 3:48 What this does not show
  9. 4:20 Mistakes to avoid
  10. 4:42 My take and next steps
  11. 5:08 Recap

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)

Download the code (zip)

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.