Skip to content

mcp: CallToolResult structuredContent loses large integer precision #1236

Description

@CaliLuke

Describe the bug

mcp.ClientSession.CallTool silently rounds large JSON integers in a tool result's structuredContent field.

This is the result-side equivalent of #1201. It also affects users of the low-level Server.AddTool API, so avoiding the typed tool argument path does not avoid this result decode.

Environment

  • Go MCP SDK: v1.7.0
  • Go: go1.27.0

Observed behavior

A server returns this valid JSON value in structuredContent:

{"id":9007199254740993}

The official SDK client exposes the value as a float64 with the value 9007199254740992. No error is returned.

The loss occurs while the SDK decodes the JSON-RPC result into CallToolResult.StructuredContent any. Application code cannot recover the original integer after this decode.

Expected behavior

Generic JSON numbers in structuredContent retain their exact wire value. A decoder that uses json.Number or an exact raw JSON representation would avoid silent rounding.

Why this needs an SDK fix

A server bridge cannot repair the value after the official SDK has decoded the request or result envelope. Re-reading HTTP bodies would violate transport ownership and does not help in-memory transports. The SDK needs an exact-number decode path for generic JSON fields in parsed protocol envelopes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions