What is MCP?
Model Context Protocol (MCP) is a standard for AI agents to call tools on external servers. Each tool invocation is a structured request that your server handles. Veto integrates at the MCP layer — authorization is evaluated before any tool handler executes. If a call is denied, your handler code never runs.Installation
Integration options
- createVetoGuard (recommended)
- vetoMiddleware (manual)
createVetoGuard returns a protect function that wraps your tool handler. When authorization is denied, the handler never executes — Veto returns an MCP-compatible error response directly.protect returns this response to the MCP client instead of calling your handler:VetoMcpOptions
BothcreateVetoGuard and vetoMiddleware accept a VetoMcpOptions object as their second argument.
Fail-closed behavior
If the Veto API is unreachable (network error, timeout, 5xx), tool calls are blocked by default. This ensures your agent cannot take unauthorized actions simply because authorization is temporarily unavailable.Fail-closed is the right default for production. A momentary network partition should not become a security gap.
How it works
- An MCP client sends a
tools/callrequest. createVetoGuard(orvetoMiddleware) intercepts the call before your handler runs.- It sends an authorization check to the Veto API with the agent ID, tool name, and parameters.
- Allowed — your tool handler executes and returns its result.
- Denied — Veto returns
{ isError: true }without executing your handler. (vetoMiddlewarethrows instead.) - Veto API unreachable — tool call is blocked (fail-closed by default).