Skip to content

Agent Interface Contract

Assertions

AIF-001 - One immutable registry owns every agent operation

Contract: Every MCP transport MUST derive tool names, schemas, effects, and handlers from one ordered immutable registry and invoke handlers through one validating executor. Every registered tool MUST declare a known read, write, or destructive effect and use only the supported JSON Schema subset. HTTP adapters MUST NOT maintain a second operation list or bypass schema validation and failure classification.

Evidence:

AIF-002 - MCP follows its advertised HTTP and stdio lifecycles

Contract: mcp serve MUST expose MCP Streamable HTTP on loopback /mcp by default. mcp stdio MUST exchange one JSON-RPC message per line over stdin/stdout, write no non-protocol content to stdout, open no MCP, health, or readiness listener, require no bearer credential for those absent interfaces, and stop cleanly at stdin EOF. Both transports MUST negotiate only supported protocol versions, implement initialize/initialized, tools/list, and tools/call, and return both text content and structuredContent. The server MUST advertise both transports through CLI capabilities and MUST NOT require a Markdown workspace.

Evidence:

AIF-003 - MCP exposes complete Joplin object workflows

Contract: MCP MUST support validated note, notebook, tag, and resource read/write workflows, relationship traversal, search, trash/restore for notes and notebooks, and permanent deletion only where Joplin has no trash API. Binary content MUST enter and leave as bounded base64 data, never a server-side path. Explicit create operations MUST compare their normalized natural identity before mutation, including matching trashed objects, and MUST return a non-retryable *_ALREADY_EXISTS error with every existing ID and the matching update tool rather than create or silently reuse a duplicate. Create preflight and mutation MUST be serialized within one bridge process.

Evidence:

AIF-004 - Invalid operations fail before side effects

Contract: Tool definitions and instances MUST pass the supported JSON Schema subset before handler execution. Unknown objects, invalid content, unsupported combinations, and Joplin failures MUST return structured stable domain errors rather than transport crashes or partial writes.

Evidence:

AIF-005 - Joplin outages do not terminate the bridge

Contract: Binding the agent listener MUST NOT require Joplin availability. Each call MAY perform a bounded availability wait and retry reads. An outage MUST return a retryable structured tool error and later calls MUST recover. Writes MUST be sent once after preflight; ambiguous outcomes MUST be non-retryable and exposed for operator inspection.

Evidence:

AIF-008 - Public transports enforce bounded resource use

Contract: MCP MUST bound request size, decoded resource size, JSON nesting, active handlers, and stalled connections, and MUST reject an oversized request or resource before any side effect.

Evidence:

AIF-009 - Standard GitHub OAuth shares one listener and tool executor

Contract: The standard package and native executable MUST include the GitHub OAuth runtime. mcp serve --github-oauth MUST enable /oauth/mcp and OAuth endpoints on the existing listener and port, preserving legacy MCP authentication. OAuth tools MUST use the common registry, dispatcher, executor and Joplin service with the same schemas, annotations and structured results. Concurrent creates across all interfaces MUST retain the existing duplicate prevention. The OAuth transport MUST remain stateless and MUST NOT require a second service or listener.

Evidence:

AIF-010 - OAuth rejection and execution remain bounded

Contract: OAuth MUST deny anonymous requests with a protected-resource metadata challenge. One process MUST bound accepted sockets before headers, incoming request deadlines, public flow bodies/rate, execution capacity and state. Authentication and framing rejection MUST precede tool side effects. Cancelling a request MUST NOT replay a mutation or release its execution slot before the underlying work finishes. Late worker failures after cancellation MUST NOT leak private exception details into asyncio logs. Temporary GitHub identity and token-endpoint failures, including rate limits, MUST fail closed with 503 and a safe Retry-After while legacy credentials remain independent. Invalid grants MUST NOT be treated as a temporary GitHub outage. Each established client MUST have its own token-endpoint budget, so anonymous token requests or another client cannot block its refresh.

Evidence: