@agenticprimitives/mcp-protocol
v0.0.0-alpha.1
Published
Conformant MCP protocol primitive (spec 293): stateless JSON-RPC lifecycle + protocol-version negotiation, Streamable-HTTP request integrity, result envelopes (CacheableResult, structured output), method dispatch + error mapping, and extensions-map negoti
Downloads
75
Maintainers
Readme
@agenticprimitives/mcp-protocol
The conformant, stateless MCP protocol primitive (spec 293). It gives a server the wire-protocol semantics of the MCP 2026-07-28 revision — JSON-RPC lifecycle + protocol-version negotiation, Streamable HTTP request integrity, result envelopes, method dispatch + error mapping, and extensions-map negotiation — generated from primitives, not hand-rolled in an app.
We conform to the published MCP spec everywhere except one declared area: Authorization. We do not run an
OAuth 2.1 authorization server. Our authorization is the Web3 custodian + delegation model (ERC-4337 Smart
Accounts, ERC-1271/6492 signatures, delegation tokens, invocation proof), advertised through the MCP
extensions framework as io.agentictrustlabs.authority. That is a spec-sanctioned substitution, not a
gap — and it is the differentiated advantage over OAuth-based servers: SA-bound, signature-verified,
on-chain-revocable delegation instead of an issuer-granted opaque scope.
Install
pnpm add @agenticprimitives/mcp-protocolRing-0, dependency-free core (the wire types are defined here; the official @modelcontextprotocol/sdk is the
reference, not a build dependency — its 1.x types predate the stateless 2026-07-28 model).
What it does
| Area | API |
| --- | --- |
| Version negotiation | negotiateProtocolVersion(requested) → the agreed version, or null (no overlap → reject) |
| Per-request _meta | parseRequestMeta(meta, headerProtocolVersion) — stateless: version + clientInfo + caps + W3C trace |
| Discovery | buildServerDiscover({ serverInfo, capabilities, extensions }) — the initialize-less capability payload |
| Request integrity | checkRequestIntegrity(headers, body) — Mcp-Method/Mcp-Name vs the body (SEP-2243) |
| Dispatch | new MethodRegistry().register(method, handler), .dispatch(req, ctx); parseJsonRpc(raw) |
| Errors | RpcError(code, msg) for explicit codes; any other throw → one generic internal error (no leak) |
| Envelopes | withCacheable / readCacheable (SEP-2549), structuredResult (SEP-2106), orderListItems |
| Extensions | authorityExtensionEntry, negotiateExtensions, hasAuthorityExtension |
The authority is injected — never imported
This package never imports delegation, mcp-runtime, mcp-oauth, or any chain/auth library. The app
registers method handlers that call its own authority pipeline (e.g. mcp-runtime.withDelegation). So the
protocol layer stays pure + conformant, and the Web3 authority stays the app's injected decision:
const registry = new MethodRegistry({ onError: logInternal })
.register('server/discover', () => buildServerDiscover({ serverInfo, capabilities, extensions }))
.register('tools/call', async (params, ctx) => runToolWithDelegation(params, ctx)); // authority injectedConformance
The conformance target is the MCP 2026-07-28 revision, negotiating down to 2025-11-25. The single
declared exception (Authorization → the Web3 extension) is tracked in the conformance matrix
(docs/architecture/mcp-conformance-matrix.md, W4). See specs/293-mcp-protocol-conformance.md.
License
MIT.
