Wymcp. Plugs. Pipeline
(Wymcp v0.4.0)
View Source
The POST plug chain: every check and stage a POST passes through, in the one order that makes each stage's precondition true.
Wymcp.Plugs.OriginCheck # wire check 1 — before anything is parsed
parse_body # Plug.Parsers, JSON
Wymcp.Plugs.Classify # message kind
Wymcp.Plugs.Auth # wire check 2
Wymcp.Plugs.SingletonHeaders # wire check 3
Wymcp.Plugs.Era # era classification
Wymcp.Plugs.ProtocolFields # modern-lane enforcement
Wymcp.Plugs.Session # legacy-lane session resolution
Wymcp.Plugs.Validate # MCP schema
Wymcp.Plugs.Dispatch # method → its answering moduleWhy that order. The origin check runs first because nothing has validated
Origin when it runs — Wymcp.Router's wire-check invariant. Parsing and
classification sit between it and the other two checks so their rejections
can carry the body's id and know the message kind. Wymcp.RouterTest pins
that placement end to end — its authentication describe proves the tag is
present when the auth check, the first consumer, reads it, and its
singleton-header check describe proves the same at the next site;
Wymcp.Plugs.AuthTest and Wymcp.Plugs.SingletonHeadersTest call their
plug directly rather than routing a request, so neither sees the order. Era
classification runs after the singleton-header check, which guarantees at
most one Mcp-Session-Id for it to read. Validation runs last before
dispatch, so the wire and session checks answer first.
Body parsing is an inline function rather than a plug so that a malformed
body answers in wymcp's own dialect: Plug.Parsers.ParseError is rescued and
answered HTTP 400 plus -32700 with data.reason, instead of propagating as
Plug's own error.
GET and DELETE do not run this pipeline. Wymcp.Router runs the same three
wire checks in those route bodies, in the same order, speaking the
plain-JSON dialect.
Summary
Functions
Callback implementation for Plug.call/2.
Callback implementation for Plug.init/1.