fix(mcp): 2026-07-28 protocol conformance

Draft
BU
1mo ago
+1803-72

What

Brings Sure's MCP 2026-07-28 (stateless) dialect in line with the spec. Split out of #3580 at @jjmata's suggestion, so the OAuth least-privilege change can ship without waiting on this.

Stacked on #3580: until that merges, this PR's diff also shows its commits. Only the last commit (fix(mcp): bring the 2026-07-28 dialect in line with the spec) is new here; the earlier ones restore the dialect code that #3580 no longer carries.

Changes (each backed by the spec text)

  • Every request must carry _meta["io.modelcontextprotocol/protocolVersion"] and ["io.modelcontextprotocol/clientCapabilities"]; otherwise -32602, 400 (basic/index, per-request protocol fields).
  • A header/_meta version mismatch, or a missing MCP-Protocol-Version header, is HeaderMismatch -32020 (was -32600).
  • An unsupported version is -32022 with data.supported and data.requested (was -32600 without data), 400.
  • An unknown method in a modern request is 404 with a -32601 body; the legacy dialects still answer 200.
  • server/discover returns ttlMs and cacheScope, like tools/list.
  • docs/hosting/mcp.md documents the above.

Testing

mcp_controller, oauth_metadata, oauth_registration, settings/mcp and test/models/assistant: 605 runs, 0 failures; i18n_test, rubocop and brakeman clean. Existing tests that pinned the old codes were updated, and new ones cover missing _meta, missing clientCapabilities, the 404, and a version only present in _meta.

Not covered: MCP Inspector / real-client end-to-end.

šŸ¤– Generated with Claude Code