ADR-0027: MCP imports pinned Connector operations ​
Context ​
MCP servers can describe tools and their JSON Schemas, but discovery says only that a server advertised a protocol capability at one moment. It does not decide whether an application release imports that capability, whether an LLM may call it, whether it is a Query or Command, or which authority and replay semantics apply.
TPF already has the required ownership boundaries: canonical v3 types, Connector provider and operation metadata, named configured bindings, release-pinned callable catalogues, Query capture, Command effects, and binding-aware dynamic invocation. A separate MCP-shaped Agent execution path would duplicate those boundaries and make protocol transport state model-visible.
Decision ​
MCP is one external source of Connector operation contracts. An explicit Maven refresh connects to a configured MCP server, discovers all tool pages, and imports only author-selected mappings into the standard Connector provider manifest under provider mcp.client. Each mapping explicitly owns the TPF operation ID, Query or Command kind, major version, and canonical input/output type names. MCP annotations are not authority.
The refresh also writes a private execution pin from the imported TPF identity to the exact MCP tool name, original schemas, and explicit projection/result selection. Deterministic hashes cover both the schema content and complete selection. Normal builds consume these committed resources and do not contact an MCP server. The adapter checks final outbound arguments against the pinned external schema before dispatch, supplementing ordinary canonical validation. Different pins for one operation identity are an error; discovery cannot replace a committed contract. The importer-v1 JSON Schema subset is deliberately lossless: unsupported schema forms fail refresh with path diagnostics. Those restrictions are importer limitations; they do not narrow or weaken canonical v3.
An author may explicitly select a narrower input graph at refresh time. Selected parent objects retain every external required field and their original constraints; only optional fields can be omitted. The importer rejects unknown, overlapping or incomplete paths and records the sorted selection alongside the private execution mapping. Canonical contributed types expose only the selected graph, preserving its external names and nesting for ordinary typed serialization. This selection is a contract decision, not an additional callable grant. The private pin hashes the full original schema and sorted selection. Import and runtime share the selection algorithm: validation enforces the selected closed graph, retaining parent constraints and required fields, without interpreting unsupported schemas in omitted optional subtrees.
When a tool declares no output schema, its canonical result is the connector-owned <tpf.connector.JsonPayload>: content type, schema hint, and a JSON body, all strings. MCP content is preserved as data in that body and flows through ordinary Query capture and operation observation. The result mode is fixed at import time. A declared typed result that is missing or invalid remains a provider failure; it never silently changes mode. Runtime JSON trees and MCP SDK classes remain adapter details. Application-authored parsing or an explicit LLM Query may interpret the body later.
At runtime, the existing named binding selects mcp.client. A host ConnectionResolver supplies an initialized McpClientConnection. The host owns credentials, sessions, transports, an STDIO process when used, and client/process shutdown. The connector neither creates nor closes them. Query operations declare LIVE_ONLY, which disables cache reuse but does not bypass Query capture or captured replay. Command results pass through the ordinary effect state machine, and uncertain post-dispatch outcomes remain ambiguous.
The three admission stages remain distinct:
discovered MCP tool -> explicitly imported Connector operation -> explicitly exposed callableOnly the final release-pinned callable catalogue authorizes model selection. Runtime MCP discovery is absent from this first slice, so no runtime snapshot identity is required.
Rationale ​
Normalizing at import time preserves one Agent protocol and one execution model for native and MCP-backed capabilities. It keeps releases reproducible and reviewable while allowing the bridge to contain protocol adaptation. Explicit classification prevents discovery metadata or prompt text from acquiring authority over Query, Command, policy, or confirmation semantics.
Consequences ​
- MCP credentials, endpoints, headers, sessions, transport objects, and client handles never enter callable metadata,
AgentCall, orOperationObservation. - Imported operations use canonical v3 contracts and the ordinary Connector binding/configuration boundary.
- A discovered-only or imported-but-unexposed tool cannot execute through dynamic Agent dispatch.
- Runtime-varying discovery or grants require a separately designed immutable snapshot seam before committed proposals can safely refer to them.
- Supporting more JSON Schema and MCP extensions expands the importer; it does not create an MCP-specific public Connector schema vocabulary.