Skip to content

Use monotonic integer IDs for ID.random by default#259

Open
JamieScanlon wants to merge 1 commit into
modelcontextprotocol:mainfrom
JamieScanlon:integer-request-ids
Open

Use monotonic integer IDs for ID.random by default#259
JamieScanlon wants to merge 1 commit into
modelcontextprotocol:mainfrom
JamieScanlon:integer-request-ids

Conversation

@JamieScanlon

Copy link
Copy Markdown

Summary

  • Change ID.random to allocate monotonic JSON integer ids (.number) instead of UUID strings.
  • Keep the previous UUID behavior available as ID.randomUUID.
  • Integer ids remain JSON-RPC 2.0 valid and work with servers that only accept numeric id values.

Motivation

Apple's xcrun mcpbridge (Xcode) never responds to JSON-RPC requests whose id is a string, null, or float — it only answers integer ids. With the current UUID-string default, clients built on this SDK hang forever on initialize when talking to mcpbridge, while ad-hoc clients that use integer ids work.

String/UUID ids are legal per JSON-RPC 2.0; mcpbridge is non-compliant. Defaulting to integers preserves legality and maximizes real-world server compatibility.

Test plan

  • Unit: ID.random yields unique .number values; encoding produces a bare JSON number
  • Unit: ID.randomUUID still yields UUID strings
  • Unit: string/number Codable round-trips unchanged
  • Manual (macOS + Xcode): connect client to xcrun mcpbridge; initialize completes; tools/list returns tools

Made with Cursor

UUID string request IDs are JSON-RPC valid but cause Apple mcpbridge
to hang silently. Default to monotonic .number IDs for broader server
compatibility; keep UUID generation via ID.randomUUID.

Co-authored-by: Cursor <cursoragent@cursor.com>
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