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:
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.
Describe the bug
mcp.ClientSession.CallToolsilently rounds large JSON integers in a tool result'sstructuredContentfield.This is the result-side equivalent of #1201. It also affects users of the low-level
Server.AddToolAPI, so avoiding the typed tool argument path does not avoid this result decode.Environment
v1.7.0go1.27.0Observed behavior
A server returns this valid JSON value in
structuredContent:{"id":9007199254740993}The official SDK client exposes the value as a
float64with the value9007199254740992. 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
structuredContentretain their exact wire value. A decoder that usesjson.Numberor 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.