Expand description
Model Context Protocol dialect: JSON-RPC tools/call requests in,
isError tool results out.
MCP is the common tool bus emerging across agent hosts (Claude, IDEs,
OpenAI-compatible runtimes). Guarding it guards every server behind it —
including tools you don’t control. The typesec mcp-gate CLI subcommand
builds a full stdio proxy on this codec.
Constants§
- DIALECT
- Dialect name used in error messages and the Python bindings.
Functions§
- denial
- Render a denied/undecided call as a complete JSON-RPC response carrying
an MCP tool result with
isError: true, so the client receives the refusal as tool output. Acall_idthat parses as an integer is restored to a numeric id; usedenial_with_idto echo the original id exactly. ReturnsNonefor allowed calls. - denial_
with_ id - Like
denial, but echoing the JSON-RPCidverbatim — the form a proxy that still holds the original request should use. - filter_
tools - Filter a
tools/listresult ({"tools": [...]}or a bare array) down to the definitionskeepaccepts, returning the same shape it was given. - is_
tools_ call trueif this JSON-RPC message is atools/callrequest.- parse_
tool_ calls - Parse
tools/callinvocations from a single JSON-RPC request object or a bare array of requests. Requests with other methods (initialize, tools/list, notifications) yield no calls — they are not errors.