keelgate.adapters.mcp¶
Stability of each symbol (stable or provisional) is listed in the API contract. Narrative and semantics are in the integration contract.
Model Context Protocol adapter. MCP tool output is untrusted data.
Serve governed tools to MCP clients with :class:GovernedMCPServer, and admit external MCP tools
into a registry, under an allowlist, with :class:GovernedMCPClient.
Discovery
dataclass
¶
What was found on the server, and what happened to each tool.
ExternalArgs
¶
Bases: BaseModel
Passthrough arguments for an external tool; the remote JSON schema is enforced separately.
ExternalOutput
¶
Bases: BaseModel
What a governed external MCP tool returns, wrapped so it stays labelled untrusted.
ExternalToolError
¶
Bases: Exception
The external server reported an error, or returned something unusable.
ExternalToolMapping
dataclass
¶
How one external tool is admitted: the capability and side effect you assign.
GovernedMCPClient
¶
Wraps an MCP client (anything with list_tools and call_tool).
register
async
¶
Discover, then register the vetted tools into registry.
GovernedMCPServer
¶
Serve governed tools as an MCP server over stdio or streamable HTTP.
Every call goes through the gateway, handlers never raise, and output is labelled untrusted.
__init__
¶
__init__(
toolset: GovernedToolset,
*,
name: str = "keelgate",
instructions: str | None = None,
toolset_for_request: Callable[
[CallToolRequestParams], GovernedToolset
]
| None = None,
) -> None
toolset_for_request lets a deployment pick a per-caller toolset (and so a
per-caller grant). Without it, every caller shares toolset's grant.
http_app
¶
An ASGI app serving streamable HTTP. Read the confused-deputy note before using it.
schema_digest
¶
The pin for a remote tool: a hash over its name, description and input schema.