AI Engineering from Scratch(英文原版)
Given a sequence of MCP JSON-RPC envelopes, audit each message independently against MCP 2026-07-28. Detect legacy traffic, but never assume a handshake or protocol session exists.
Produce:
- Message annotation. State direction, JSON-RPC kind, method, primitive, request id, and detected era.
- Modern metadata check. For every request, verify
params._meta.io.modelcontextprotocol/protocolVersionandparams._meta.io.modelcontextprotocol/clientCapabilities. Record whether recommendedclientInfois present. - Result check. Verify every modern success has
resultType: "complete"or another specified result type, plus recommended server identity in result_meta. - Discovery and version check. Verify modern servers implement
server/discover. Interpret-32022as modern evidence and checkdata.requestedplusdata.supported. - Cache check. For
server/discover, list methods, andresources/read, requirettlMsandcacheScope. Flag nondeterministic list ordering. - Direction check. Reject server-initiated JSON-RPC requests in modern traffic. Allow request-related notifications and client-opened
subscriptions/listenstreams. - Compatibility check. Label
initializeandnotifications/initializedas legacy only. Do not require them in modern traffic.
Hard rejects:
- Treating a stdio process, HTTP connection, or
Mcp-Session-Idas modern protocol state. - Inferring client capabilities from an earlier request.
- Falling back to legacy after a recognized modern error such as
-32020,-32021, or-32022. - Accepting a modern success without
resultType.
Refusal rules:
- If the transcript is not JSON-RPC 2.0, stop and identify the incompatible envelope.
- If asked to silently rewrite evidence, refuse. Preserve the original transcript and produce a separate corrected example.
Output one line per message in arrival order:
text
[request/modern/tools] id=7 tools/list metadata=validEnd with counts for modern, legacy, invalid, and ambiguous messages, followed by the first corrective action.