Protocol compliance architecture

Copy Markdown View Source

Claim boundary

This project implements and tests a slice of MCP 2026-07-28. It does not claim full revision conformance.

The profile, internal contract, released-client interoperability check, and official conformance suite answer different questions and remain separate in code and reports:

Evidence laneWhat it provesCurrent status
Exact protocol profileWhich core methods exist in the pinned revision and which capabilities, methods, transports, and limitations this build implementsComplete catalog; implemented slice explicit
Core internal contractLiteral wire requests plus HTTP and generic extension acceptance obey the declared core slice33 evidence groups passing
Tasks package contractThe independent child package obeys its Tasks wire, lifecycle, subscriptions, HTTP, descriptor, durable-store, and recovery contract10 evidence groups passing
Released-client interopA real official TypeScript client can discover, list, call, cancel, and call again over stdioPassing with the client pinned in interop/official_client/package.json
Target application acceptanceThe hexpm-mcp server's catalog, tool outcomes, prompts, completions, and resource reads work with seeded domain responses over stdio and native HTTPOptional local check; scope and commands
MRTR client acceptanceOrdinary tool/resource/prompt elicitation, signed state, automatic retries, and URL consent work over stdio and HTTPPassing with the client pinned in interop/official_client/package.json; scope and commands
Official server requirementsThe implementation passes the frozen upstream scenarios for the released revision37/37 exercised whole scenarios pass on the frozen alpha.12 runner (2026-10-22); the runner's score, not full revision conformance
Ordinary progressCorrelated progress precedes normal/error/MRTR terminal messages; cancellation and no-token behavior are checked over stdio and HTTPPassing wire and controlled client checks; SDK callback caveat
Independent wire-schema corpusRepresentative real emissions validate against named definitions and concrete result, input-request, and error branches in the pinned official schema using AJV99 emissions across direct/stdio/HTTP; 99 negative mutations and 9 unit controls; not every possible message

The repository's snodo.contract Mix task prints the core buckets without converting internal evidence or unsupported features into an official score. The one-way-dependent Tasks package owns its local evidence and runs it with mix tasks.contract from extensions/tasks.

Each evidence group is attached to one or more ExUnit tests with a stable ID. The core and Tasks contract tasks independently refuse to pass if their executed modules do not cover their exact local inventories. For core automation, --output writes only the rendered report to the named file; this remains parseable even when a fresh Mix build emits compiler progress before the task starts.

Architecture adopted from tower-mcp

The useful idea in tower-mcp 0.22.1 at 10ada1d is a two-stage admission boundary: validate JSON-RPC structure, then inspect one exact MCP revision before semantic routing. Its protocol policy also keeps known wire profiles, compiled implementations, and a runtime allowlist distinct.

The Elixir translation is:

decoded JSON value
  -> Snodo.Envelope                    JSON-RPC structure
  -> Snodo.Protocol.Registry           explicitly enabled dialect
  -> Snodo.Protocol.Inspector          exact profile and method contract
  -> dialect context/operation       lifecycle and metadata semantics
  -> Extension.Registry middleware     advertised exact-compatible augmentation
  -> Snodo.Router / Extension.Registry   core or negotiated out-of-tree execution
  -> dialect wire shaping

Snodo.Protocol.Profile is the exact-revision catalog and implementation manifest. It records:

  • the exact revision and lifecycle;
  • batching and request-metadata policy;
  • method kind, direction, top-level/MRTR placement, active/deprecated lifecycle, params policy, capability, validator, and implementation status;
  • supported standard capability keys;
  • transport evidence and explicit limitations.

The protocol registry rejects a dialect whose version/0 or era/0 drifts from its profile. Runtime construction accepts only capability keys implemented by every enabled profile plus the explicit open registries. An extensions advertisement is valid only when each identifier has an installed extension.

Discovery on 2026-07-28 and session-backed initialize on 2025-11-25 filter advertised extensions by exact protocol version. Sessionless 2025-11-25 servers omit the extensions capability. The 2025-11-25 dialect reads the client's extension settings from initialize.params.capabilities.extensions and uses the stored settings on subsequent session requests. Literal compliance vectors cover initialize with and without extensions. The 2025-06-18 dialect omits the extensions capability.

Nested standard settings are also tied to their directional methods. The final profile implements the list-change and resource subscription methods, while runtime construction additionally requires an application subscription_source before any listChanged: true or resources.subscribe: true advertisement is accepted. Discovery projects capabilities through the selected profile. Completion is additionally derived from registered opt-in prompt/resource-template callbacks, preventing an empty router from advertising completions.

The pinned 2026-07-28 catalog contains 21 unique core method strings and 22 directional rules. The extra rule represents the two directions of notifications/cancelled, whose server-side implementation status differs by direction. Request-shaped elicitation/create, roots/list, and sampling/createMessage are marked MRTR-embedded rather than top-level RPCs. Tasks is extension-only and is absent from the core catalog.

A literal frozen table in the contract tests compares all 22 rules across name, kind, direction, params presence, capability, implementation status, placement, and lifecycle. It also asserts that the four Tasks extension methods are absent from the core profile.

Inspection deliberately retains implemented, unsupported, and extension classifications, but the server admission gate executes only implemented methods. Thus resources/list and completion/complete are implemented core methods, subscriptions/listen is implemented as a stream-opening request, and com.example/custom is an extension candidate. A candidate executes only when an exact-versioned route is installed, advertised by the server, advertised by the client, and accepted by the extension's negotiation callback.

The subscription path is deliberately separate from router dispatch after the request has opened. The application implements Snodo.Subscription.Source and owns any hub, database cursor, PubSub process, and backlog. The framework narrows the requested core filter to advertised capabilities, rejects a source that acknowledges anything outside that subset, and then pulls at most one event at a time in a dedicated worker. Protocol shaping stamps the listen request ID on the acknowledgement, every event, and the graceful terminal response. Stdio owns multiplexing and response-free client cancellation; native HTTP owns SSE headers, acknowledgement ordering, keepalives, socket disconnect cleanup, and graceful source completion. Neither long-lived stream counts against the executor's concurrency or queue after open/3 returns. Each transport bounds open streams with :max_subscriptions; the HTTP transports keep that count in the executor as a slot the stream's process holds.

Snodo.Subscription.Hub is an optional application-supervised implementation of that same source contract. It accepts only events selected by each listener's negotiated filter, bounds every listener queue, reports per-publication drops, and offers explicit newest- or oldest-retention overflow policies. It remains outside the runtime and router: applications decide when domain or registry state changed and publish protocol-neutral core or extension events.

Instrumentation is evidence about implementation behavior, not an additional protocol claim. The optional dependency-free sink observes dispatch outcomes, subscription pressure, and extension-owned Tasks runner/store transitions without changing wire messages, capability admission, routing, or the official conformance score. Event metadata deliberately excludes request and task payloads; the complete catalog is in instrumentation.md.

The extension registry is deliberately narrower than the protocol registry. Extension-owned routes support top-level client-to-server requests only and reject collisions against the complete core catalog, including unsupported and MRTR-only names. An extension module owns semantic validation, dispatch, success shaping, and error shaping; the server still enforces JSON-RPC correlation and JSON-safe output. Separate optional callbacks can wrap core dispatch or adapt the selected dialect's transport policy, but only for a server-advertised, exact-compatible extension. A module omitted from an explicit capabilities map is installed but inert. Callback faults become safe internal errors.

The Beta Tasks extension exercises that split. Its independently compiled :snodo_tasks package depends one-way on snodo, wraps tools/call, owns tasks/get, tasks/update, and tasks/cancel, and requires Mcp-Name mirrored from params.taskId without adding any Task-specific branch or dependency to the core profile, router, or HTTP adapter. Direct, stdio, and HTTP acceptance vectors therefore show that optional behavior can remain outside the dialect module and core package.

The persistence proof stays behind that same extension boundary. A Task and its versioned, JSON-safe Work descriptor are stored atomically before the creation result is returned. The generic store contract supplies exact claiming, claim-next recovery, renewal, release, worker-scoped reads, transitions, and reaping. An application-owned WorkExecutor resolves descriptors on both initial and recovered claims. A custom work_builder may project only the stable tenant or principal identity needed for recovery; request contexts, transport handles, and complete authentication structures are intentionally not persisted.

Claims fence stale commits by generation, but recovery is at-least-once. The application must use the descriptor's stable idempotency key for external side effects. Accepted mid-task input is also durable: an identical recovered request replays the persisted response without another input event, while changing the request under an issued key is rejected. The DETS implementation proves reopen and boot-epoch fencing on one node; it is deliberately not evidence for distributed production claims. Both adapters make the entire aggregate eligible for reaping at createdAt + ttlMs and preserve ttlMs: nil indefinitely. Removal depends on explicit or scheduled cleanup, which a runner schedules every minute by default. Reads and request mutations treat a Task as unknown from createdAt + ttlMs; claims are not an exact-deadline expiry fence. That is this project's permitted expiration policy, not a claim that the protocol mandates eager physical deletion for every server.

This work reimplements the architecture in Elixir; no tower-mcp source was copied. tower-mcp is licensed MIT OR Apache-2.0.

Independent contract vectors

The tests under test/compliance use literal _meta keys and wire values. They do not use Snodo.Test.dispatch(protocol: ...), because that helper obtains metadata from the same dialect being tested and could allow request generation and admission to drift together.

The current matrix covers:

  • discovery, deterministic tool listing, text/structured/error tool results;
  • exact profile method kind, direction, params, and metadata admission;
  • standard and custom capability overclaim rejection plus separate known-core, unsupported, and extension method classification;
  • unknown methods, malformed arguments, missing metadata, unsupported versions, header/body mismatch, and batch rejection;
  • response-free cancellation notifications;
  • direct/stdio wire equivalence and explicit null IDs for uncorrelatable stdio parse errors;
  • deterministic static-resource and URI-template listing, explicit application matching, text/JSON/blob reads, cache hints, missing-resource errors, and direct/stdio wire equivalence;
  • exact prompt and resource-template completion references, flat string context, definition-owned callback dispatch, bounded result validation, truthful capability admission, and direct/stdio/HTTP wire equivalence;
  • Streamable HTTP origin, media type, mirrored-header, path, concurrency, cancellation, and application-owned-executor behavior;
  • extension registration collisions, bilateral negotiation, context projection, validation/dispatch/result/error shaping, callback isolation, DSL integration, ordered core-operation middleware, application options, transport-policy composition, and direct/stdio parity; and
  • in the Tasks package, flat creation/detail shapes, capability gating, sync fallback, tool vs protocol error semantics, partial mid-task input, deterministic accepted-input replay, scoped access, unknown IDs, immutable cancellation/completion races, idempotent terminal cancellation, task-specific HTTP headers, JSON-safe work/event/snapshot round trips, CAS conflicts, event-ID replay, action-scoped access, renewable generation-fenced claims, recovery after worker and store restarts, DETS corruption/version rejection, creation-based TTL reaping, and detached execution context.

Run it with:

mix snodo.contract
mix snodo.contract --format json
mix snodo.contract --format json --output mcp-contract.json
mix snodo.contract --format markdown

Run the independent Tasks evidence lane with:

cd extensions/tasks
mix tasks.contract

Ordinary MRTR evidence

Five internal groups now cover ordinary elicitation wire behavior, the deprecated sampling and roots input requests, result placement and peer-capability admission, request-bound signed state, and extension middleware composition. The profile marks elicitation/create, sampling/createMessage, and roots/list implemented only in their embedded placement; the last two carry the deprecated lifecycle from SEP-2577. Literal requests cover malformed and partial input, repeated retries, mixed request kinds in one result, the merged -32021 requiredCapabilities object, and all three permitted core operations. An independent pinned TypeScript client exercises automatic elicitation, sampling, and roots round trips over stdio and native HTTP, including one result that asks for all three kinds.

The 2026-09-14 external run now exercises nine additional ordinary MRTR scenarios. See the MRTR guide for supported schema limits, state security, the Tasks boundary, and the empty-input-map SDK caveat.

Official conformance lane

The native Streamable HTTP fixture has been exercised by the frozen official server runner. All 37 required scenarios were attempted. The score is 37/37 exercised whole scenarios passed in the 2026-10-22 run on the alpha.12 runner, the same score as the 2026-09-29 alpha.11 run. All 37 have semantic successes and no failure, warning, or skipped checks. The five scenarios that failed on 2026-09-26 needed the deprecated sampling and roots input requests, which the fixture now serves. This is the frozen runner's score for its own 37 scenarios, not full conformance to the revision.

The required checks total 120 SUCCESS, 0 FAILURE, 0 SKIPPED, 0 WARNING, and 1 INFO; alpha.12 adds the passing tools-list-deterministic-order check. The subscription checks in server-stateless run against a fixture subscription hub. Three pending, not-scored scenarios pass completely: json-schema-2020-12 (8/8), http-header-validation (14/14), and http-custom-header-server-validation (10/10). The exact pass list, raw no-failure list, and exclusion reasons are checked in as both JSON and Markdown, with per-check outcomes. The September 29, September 26, September 14, and August 25 alpha.11 summaries are retained as historical evidence, not current scores.

The runner's client leg measures Snodo.Client separately, through a harness that drives it against each scenario server, with Snodo.OAuth.Client from snodo_oauth as the token provider. The 2026-10-22 alpha.12 run passes 31 of 32 required client scenarios, as the 2026-09-30 alpha.11 run did, including all 25 that cover OAuth: metadata discovery, client identity, PKCE, scope selection and step-up, resource indicators, and the iss checks. The one other is excluded from the score because a 2026-07-28 client sends no initialize. The harness installs input handlers for all four kinds, so the client declares the deprecated sampling and roots capabilities and request-metadata passes whole, as it did on 2026-09-29 when 7 of 32 passed. DPoP, enterprise-managed authorization, and workload identity federation are not implemented; their unscored scenarios stay in the baseline. A second client lane pins Snodo.Client to 2025-11-25 and runs the frozen 2025-11-25 client set: the 2026-10-22 run passes 16 of 18 required scenarios, initialize, tools_call, and all 14 that cover OAuth, up from 2 of 18 on 2026-09-29. The elicitation scenario depends on the standalone GET event stream, which the client does not open, and the reconnection scenario negotiates 2025-03-26, which the client does not speak. See the client leg notes for the remaining gaps.

More server lanes run in CI. The same fixture served through Snodo.Transport.Plug on Bandit matches the native listener check for check. With sessions on, the initialize-era dialects pass all 30 required scenarios of the frozen 2025-11-25 set, natively and through the Plug, and all 27 unscored 2025-06-18 scenarios. A sessionless lane keeps the default gated: 23 of 30 pass, and the failures are the scenarios that need a session. See the additional server lanes.

The frozen 2026-07-28 requirement manifest contains 37 scored server scenarios. The manifest declares conformance@0.2.0-alpha.10 as its historical anchor, but was added retrospectively and first shipped with the alpha.11 runner. This project vendors the alpha.11 artifact from commit c321dd3, which alpha.12 ships unchanged, and verifies its exact SHA-256 ae2f4f6210fd729e2e318edd5bbfa31a43cee0bc608e48052fa26dbf1d939b57 before every core contract run. The combined frozen fixture includes Tasks and the Plug adapter, so start it from the conformance/fixture Mix project, then use the pinned runner with the frozen manifest:

cd conformance/fixture
MCP_PORT=3001 mix run ../fixture_server.exs
npx -y @modelcontextprotocol/conformance@0.2.0-alpha.12 server \
  --url http://127.0.0.1:3001/mcp \
  --requirements 2026-07-28 \
  --output-dir conformance-results

--requirements 2026-07-28 is preferable to a moving --suite all claim: it fixes scenario membership and the wire revision. The upstream manifest is the canonical definition of the score.

The managed lane locks the runner and its complete dependency graph, verifies the frozen manifest digest, starts an ephemeral loopback fixture, retains raw artifacts, and applies a reviewed per-check regression baseline. The official runner exits 0 when the scored scenarios pass (see the honest baseline policy); any failures remain failures in the report. The baseline pins every check occurrence across the required and unscored scenarios:

  • an unexpected failure breaks CI;
  • a passing baselined check also breaks CI because the baseline is stale;
  • any missing/new occurrence or changed status breaks CI, including a success becoming skipped inside an already-failing or unscored scenario. Repeated check IDs retain their ordered occurrences.

An expected failure remains a conformance failure; the baseline only stages CI adoption.

Tasks extension probe

The ten frozen alpha.11 Tasks scenarios are extension-only and do not contribute to the 37-scenario core score above. They were run separately against the same native HTTP fixture:

  • all 35 Tasks-specific assertions passed;
  • the one upstream status-notification assertion was skipped pending the runner's subscriptions/listen rewrite;
  • one generic wire-schema check passed and eight failed; and
  • the runner therefore exited non-zero.

Every generic failure rejects a flat Tasks CreateTaskResult as though it were the core CallToolResult schema, which requires content. The extension specification and the scenario-specific assertions require the flat resultType: "task" shape instead. The checked-in summary keeps those failures visible and claims only the 35 Tasks assertions:

The alpha.12 runner accepts the flat Tasks result. In the 2026-10-22 run of the combined server lane, the same 35 Tasks-specific assertions pass, the status-notification assertion is still skipped, and all nine generic wire-schema checks pass.

Independent full-schema engine lane

interop/schema_validation pins the official artifact and provenance, uses AJV 2020-12, and validates 99 actual serialized emissions from 81 operations over direct, stdio, and native HTTP. It selects 31 named definitions and concrete result, input-request, and error branches: the generated schema's root is not an envelope validator, its permissive MRTR union alone can accept malformed complete results, and the generic error envelope accepts any data. Negative controls demonstrate each trap. The original upstream schema bytes are retained unchanged with their license.

This is independent of JSV application argument validation and of the client and external runner. The checked-in CI job executes the corpus; no remote CI pass is inferred. The corpus intentionally excludes Tasks, among other paths documented in its README. It does not establish universal wire validity or encode every prose requirement in JSON Schema.

Tasks store soak evidence

Snodo.Extensions.Tasks.Stress runs the same deterministic workload against any Tasks store: a CAS race in which every writer of a Task holds a valid lease, a lease-fencing pass in which a released lease must be refused for a transition and a renewal after a second owner claims the Task, and Runner rounds that hold a full batch of workers open at once. Each contended and fenced Task is checked on its own: the writer the store reported as applied must be the only ledger entry and the completed result, and a refused stale lease must leave the Task unchanged. Pass or fail comes only from exact invariants; throughput and latency are observations. stress-testing.md describes the report. The SQLite and PostgreSQL entry points are repository Mix tasks, not part of the published packages.

StoreCommandWhere it runs
Memorymix tasks.stress in extensions/tasksBy hand; a small run is in the snodo_tasks suite
SQLitemix tasks.sqlite.stress in extensions/tasks_sqliteBy hand and in the scheduled soak workflow; a small run is in the snodo_tasks_sqlite suite
PostgreSQLmix tasks.postgres.stress in extensions/tasks_postgres, with SNODO_TASKS_DATABASE_URLBy hand and in the scheduled soak workflow on PostgreSQL 14, 16, and 18; a four-Task run is in mix quality.postgres, which the Compatibility workflow runs on 14, 16, and 18 for every pull request

SQLite results, recorded on 2026-11-20 on a 12-core Linux workstation with Elixir 1.20 and exqlite 0.43, file-backed WAL database in a temporary directory:

RunCAS attemptsCAS p50 / p95 / p99Fencing claim p50 / p95 / p99Runner jobsBusyUnexpectedInvariants
200 tasks, 16 writers, 10 rounds, pool 53,200 (876/s)7.2 / 18.7 / 30.7 ms14.2 / 37.9 / 53.0 ms2,000 (150/s)00all 11 passed
500 tasks, 32 writers, 20 rounds, pool 1016,000 (1,294/s)9.0 / 22.7 / 60.5 ms16.7 / 65.0 / 99.3 ms10,000 (227/s)00all 11 passed
200 tasks, 32 writers, 3 rounds, pool 10, 10 ms busy timeout, 100 ms store timeout6,400 (2,171/s)5.8 / 13.6 / 25.3 ms11.8 / 59.2 / 109.8 ms600 (150/s)31 CAS losses, 175 retries0all 11 passed

In every run each contended Task had exactly one applied writer, whose event was the Task's only ledger entry and its completed result. Every stale lease was refused for both the transition and the renewal and left its Task unchanged, and every live lease's event was the only ledger entry. Every Runner job started, stopped, completed with an applied transition, and released its lease; peak live jobs reached the batch size, and the Runner held no jobs at the end. The third run forces {:error, :database_busy}: busy CAS attempts lost without a hidden commit, and setup and fencing calls retried until they succeeded. Runner throughput includes the harness polling every Task in the batch, so it is a lower bound, not the store's commit rate.

No PostgreSQL soak results are recorded yet. They will come from the first run of the Tasks store soak workflow after this harness is merged, whether scheduled (weekly) or started by hand with gh workflow run tasks-soak.yml. Each run uploads each version's JSON report and log and writes the report to the job summary. Until then, the only PostgreSQL run of the harness is the four-Task soak in the pull request live lane on 14, 16, and 18, which checks the invariants but is not sustained load. To run the full soak locally:

docker run --rm -d --name snodo-pg -p 55432:5432 \
  -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=snodo_tasks \
  postgres:18-alpine
cd extensions/tasks_postgres
SNODO_TASKS_DATABASE_URL=ecto://postgres:postgres@127.0.0.1:55432/snodo_tasks \
  mix tasks.postgres.stress --tasks 200 --writers 16 --rounds 10 --json

These runs are single-node correctness evidence under load. They are not a capacity claim and do not cover multi-node Runner scheduling, crash recovery during load, or migration under load.

Next compliance increments

  1. Preserve the checked-in honest core summary as the runner and its requirement set evolve; never promote a warning-only or missing-fixture result to a pass, and never describe the frozen runner's score as full revision conformance.
  2. Maintain the exact per-check CI inventory: fail unexpected/stale failures, missing/new occurrences, and all status drift. Never increase a conformance score through baselining.
  3. Extend the pinned independent schema corpus as new response/notification surfaces land, retaining concrete-branch checks and negative controls.
  4. Keep the implemented retry policy and optional PostgreSQL and SQLite Tasks adapters in their own evidence lanes. Run and retain the checked-in PostgreSQL-version and migration-upgrade matrix and the scheduled store soak described above. Soak under crash recovery, migration, and more than one Runner node is still open, and is needed before a production-readiness claim.
  5. Add property/adversarial wire generation, a transport matrix, more official SDKs, and differential structural checks as separate lanes.

Sources