Skip to content

feat: add exact raw JSON request handling - #273

Open
steipete wants to merge 1 commit into
modelcontextprotocol:mainfrom
steipete:codex/exact-raw-json
Open

feat: add exact raw JSON request handling#273
steipete wants to merge 1 commit into
modelcontextprotocol:mainfrom
steipete:codex/exact-raw-json

Conversation

@steipete

Copy link
Copy Markdown

Summary

  • add RawJSONValue and ExactJSONObject for ordered members, duplicate keys, exact Unicode-scalar identity, exact number lexemes, and strings that never auto-decode as data URLs
  • add a source-compatible two-argument Server.withMethodHandler overload that receives the normal typed request alongside RawRequestContext
  • route raw-aware single and batch requests with zero-copy, cancellation-aware parsing and explicit document/string/depth/entry limits while leaving legacy handlers, notifications, and inbound responses on their existing decoding path
  • keep malformed batch documents as top-level parse errors while isolating structurally invalid or over-limit items so valid siblings still run and available request IDs are retained
  • preflight programmatic data URL sizes with overflow-checked base64 length arithmetic before allocation

Validation

  • swift test (575 tests on macOS)
  • swift build -c release
  • swift package generate-documentation --target MCP --warnings-as-errors
  • Swift 6.1.2 Linux: swift test (494 tests) and swift build -c release
  • Swift 6.1.2 static Linux SDK: upstream install-and-build-with-sdk.sh --static

Documentation

  • document exact JSON method handlers and custom RawJSONLimits in the README

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