mcp: tool schemas and metadata lose JSON number precision

Abierto
#1,310 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Tangerg ya está trabajando en esto.

Desde el 28/9/2026.

  • #1311 de @Tangerg — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
go
Área
api

Línea de trabajo

Start at the Tool and CallToolResult wire decoding entry points and inspect the existing UnmarshalUseNumber helper. Reproduce the issue over the serialized in-memory NDJSON transport and Streamable HTTP, then verify that schema and metadata numbers retain their original precision while structuredContent remains unchanged.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

On upstream main at 7cb505cc11ed7bda8b8db8b12cd62fec22e0e1f8 (Go 1.27.0, darwin/arm64), tools/list schema numbers and tool/result/content _meta numbers are rounded before the client receives them. structuredContent already preserves these numbers.

For example, register a tool with the low-level Server.AddTool API using this raw input/output schema:

{"type":"object","properties":{"id":{"const":9007199254740993}},"required":["id"]}

Return structuredContent: {"id":9007199254740993} and _meta: {"revision":9007199254740993}. After client/server transport, the schema constant and metadata revision re-marshal as 9007199254740992, while structured content still contains 9007199254740993. The same loss affects tool metadata, text content metadata, resource-link metadata, and embedded resource metadata. Negative large integers and high-precision decimals are also affected.

Expected: preserve numeric values in these arbitrary JSON fields at the protocol decode boundary, so consumers can use their original schemas and metadata. This is about descriptor/result fidelity, not implementing a new schema validator.

A regression reproduces this over both the SDK's serialized in-memory NDJSON transport and Streamable HTTP. It does not involve a downstream fork or custom transport decoder.

This differs from #1201 / #1244 / #1302, which address server-side applySchema, and from the explicit-null fix in #1285.

Proposed change: decode Tool and the CallToolResult wire object with the existing UnmarshalUseNumber helper. This keeps exported fields intact but changes decoded dynamic numeric types from float64 to json.Number for the affected fields. Callers asserting float64 need to adapt; maintainer agreement on this behavioral compatibility change is needed. No new compatibility switch or alternate value format is proposed. The current schema-validation dependency's precision limitations remain a separate concern.

Lenguaje dominante
Go
Estrellas
5.4k
Forks
623
Merge medio
22 h 10 min
PR fusionados (30 d)
30

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/go-sdk

Todos los issues de modelcontextprotocol/go-sdk

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.