Wymcp.Plugs.ProtocolFields (Wymcp v0.6.1)

View Source

Modern-lane enforcement of the protocol fields. On a modern-classified request, params._meta must carry io.modelcontextprotocol/protocolVersion as a string and io.modelcontextprotocol/clientCapabilities as an object — a missing or wrong-typed field answers -32602 + 400 — and the version must be a modern revision wymcp serves — anything else answers -32022 + 400 with data.supported naming every version either era serves (so a legacy-capable client sees its initialize fall-back in the same answer) and data.requested echoing the offer. The fall-back clause is legacy-only: it points a rejected client at an initialize handshake, and it goes at the legacy decommission.

Notifications are exempt: JSON-RPC forbids error responses to notifications, and the modern core defines no client→server notifications over HTTP — Wymcp.Plugs.Dispatch answers them 202 and drops them. Legacy-classified messages pass through untouched. That pass-through is legacy-only: it exists only because a second era does, and it goes at the legacy decommission.

The MCP-Protocol-Version header is deliberately not read here: the protocol fields are authoritative, and comparing the mirrored headers against the body they mirror is the header-binding check's (Wymcp.Plugs.HeaderBinding), which runs directly after this plug — with a body value this one has just proven.