Skip to content

mcp: preserve structured content number precision - #1239

Open
CaliLuke wants to merge 1 commit into
modelcontextprotocol:mainfrom
CaliLuke:codex/issue-1236-structured-content-numbers
Open

mcp: preserve structured content number precision#1239
CaliLuke wants to merge 1 commit into
modelcontextprotocol:mainfrom
CaliLuke:codex/issue-1236-structured-content-numbers

Conversation

@CaliLuke

@CaliLuke CaliLuke commented Sep 4, 2026

Copy link
Copy Markdown

CallToolResult currently decodes structuredContent through an any field, which converts JSON numbers to float64 and silently rounds integers outside the IEEE-754 safe range.

This change decodes structuredContent separately with UseNumber, preserving wire numbers as json.Number while retaining the existing decoded object, array, and primitive shapes. The field documentation now describes that representation.

An end-to-end in-memory client/server regression covers 9007199254740993 from a low-level Server.AddTool result, and existing numeric structured-content assertions now exercise the exact-number behavior.

Verification:

  • gofmt -l .
  • go test ./...
  • go vet ./...

Fixes #1236

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.

mcp: CallToolResult structuredContent loses large integer precision

1 participant