Integration
Python MCP handler example
async def check_tool(tool_name, args, capabilities):
resp = await client.post(
"https://trapdefense.com/api/v1/decide",
headers={"Authorization": f"Bearer {TRAPDEFENSE_KEY}"},
json={
"tool_name": tool_name,
"args": args,
"capabilities": capabilities,
"policy_preset": "mcp-server",
},
)
return resp.json()
decision = await check_tool(
"send_email",
{"to": to, "subject": subject, "body": body},
["email_send", "network_send"],
)
False positives
How to tune safely
Normal tool call blocked: add the domain to domain_allowlist or pass a custom policy.
Needed capability blocked: move the capability from block to warn during rollout.
Too much PII masking: specify only the profiles you actually need instead of scanning every type.
Need a special workflow: pass a custom policy object for that route or tool.