Skip to content

feat(mcp): serve MCP 2026-07-28 only, with origin checks and tool rate limits - #336

Merged
vishr merged 1 commit into
mainfrom
fix/mcp-conformance
Oct 17, 2026
Merged

vishr merged 1 commit into
mainfrom
fix/mcp-conformance

Conversation

@vishr

@vishr vishr commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Fanout now serves MCP protocol version 2026-07-28 only, over stateless Streamable HTTP. There is no backward compatibility: requests without MCP-Protocol-Version or with an earlier version are rejected, and sessions, initialize and GET streams are removed. The browser MCP client and the in-process agent use the modern protocol, and MCP Apps support is read from request-scoped client capabilities.

  • Origin validation: requests to /mcp and /api/mcp with an untrusted or malformed Origin receive 403 before authentication. The trusted origin is the RFC 6454 serialization of FANOUT_PUBLIC_URL; without one, only same-authority loopback origins are accepted. Requests without Origin are unaffected.
  • Tool rate limit: tools/call is limited per user and OAuth client (20 per second, burst 100, bounded and evicted when idle), answered with 429 and Retry-After (MCP 2026-07-28 tools security considerations; RFC 6585 §4). The in-process agent is not limited.
  • Authorization input: scope checks and the limiter read Mcp-Method and Mcp-Name, which the SDK requires to match the decoded body. This replaces a second, case-insensitive body parse that a case-variant key could steer. Dashboard tools keep their own dashboard:manage check.
  • Scope challenge: insufficient_scope lists every scope the call needs.
  • Cancellation: client disconnects cancel in-flight tool calls down to DuckDB.
  • Docs: the MCP guide describes the protocol version, origin rule and rate limit.

Verification

  • Go tests through a real SDK client over HTTP with OAuth bearer tokens: discovery, tool listing, a tool call and a ui:// resource read; older protocol versions rejected.
  • Origin, rate-limit, scope-challenge and cancellation tests on both mounts, including case-variant body keys and header/body mismatches.
  • go test ./..., race tests on the MCP, API, agent and auth packages, just check, just e2e (68 passed).
  • Two Codex adversarial reviews; the second found no remaining defects.

…e limits

Fanout now serves MCP protocol version 2026-07-28 over stateless
Streamable HTTP. Requests without the protocol header or with an earlier
version are rejected; sessions, initialize and GET streams are gone. The
browser MCP client and the in-process agent use the modern protocol, and
MCP Apps support is read from request-scoped client capabilities.

- Requests to /mcp and /api/mcp with an untrusted or malformed Origin
  receive 403 before authentication. The trusted origin is the RFC 6454
  serialization of FANOUT_PUBLIC_URL; without one, only same-authority
  loopback origins are accepted.
- tools/call is rate limited per user and OAuth client (20 per second,
  burst 100, bounded and evicted when idle) with 429 and Retry-After. The
  in-process agent is not limited.
- Scope checks and the limiter read the Mcp-Method and Mcp-Name headers,
  which the SDK requires to match the decoded body, instead of a second,
  case-insensitive body parse.
- The insufficient_scope challenge lists every scope the call needs.
- Client disconnects cancel in-flight tool calls down to DuckDB.

Claude-Session: https://claude.ai/code/session_018HfyEXHyGD1utmKF4CQtyQ
@vishr
vishr merged commit 5b56e16 into main Oct 17, 2026
16 checks passed
@vishr
vishr deleted the fix/mcp-conformance branch October 17, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant