mcpcompat drops entire tool/prompt result when it contains an embedded resource
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #171 de @jhrozek — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
Línea de trabajo
Comienza con EmbeddedResource y UnmarshalContent; después, sigue CallToolResult.UnmarshalJSON y la ruta convertResult descrita en el issue. Reproduce el fallo con el payload de wire proporcionado y verifica que el contenido compuesto únicamente por recursos y el contenido mixto de herramientas se decodifiquen correctamente sin perder elementos hermanos; comprueba también la ruta prompts/get.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
mcpcompat.EmbeddedResource has a Resource ResourceContents field where ResourceContents is a non-empty interface, and EmbeddedResource has no custom UnmarshalJSON. So json.Unmarshal of any "type":"resource" content item errors:
json: cannot unmarshal object into Go struct field EmbeddedResource.resource of type mcp.ResourceContents
Because CallToolResult.UnmarshalJSON (and the client's convertResult) propagate that error, any tool result — or prompt message — containing an embedded resource is lost in its entirety, including any sibling text/image parts in the same content array.
Impact
Discovered from a ToolHive vMCP MCP-conformance run (the mcp-go → mcpcompat swap). Two conformance scenarios regressed:
tools-call-embedded-resource→ "No resource content found"tools-call-mixed-content→ "Expected multiple content items; Missing image content; Missing resource content"
The prompts/get path is affected too, since convertGetPromptResult also decodes content via mcp.UnmarshalContent.
Call chain
client.CallToolconverts the go-sdk result via the genericconvertResult→jsonConvert.- That runs
CallToolResult.UnmarshalJSON, which callsUnmarshalContentper item. UnmarshalContent, caseContentTypeResource, doesjson.Unmarshal(data, &EmbeddedResource{})— stdlib cannot populate theResourceContentsinterface field → error.- The error aborts the whole decode;
convertResultdiscards the partially-decoded result.
ReadResource and GetPrompt were hand-written to avoid this exact trap (convertReadResourceResult maps concrete text/blob types explicitly); CallTool was left on the generic path.
Fix
Add a custom UnmarshalJSON to EmbeddedResource that resolves the polymorphic Resource field to a concrete TextResourceContents/BlobResourceContents (blob-precedence, mirroring convertReadResourceResult). UnmarshalContent is the single chokepoint backing both tools/call and prompts/get.
Repro
wire := []byte(`{"type":"resource","resource":{"uri":"file:///x.txt","mimeType":"text/plain","text":"body"}}`)
_, err := mcp.UnmarshalContent(wire)
// err: json: cannot unmarshal object into Go struct field EmbeddedResource.resource of type mcp.ResourceContents
- Lenguaje dominante
- Go
- Estrellas
- 2
- Forks
- 6
- Merge medio
- 23 h 44 min
- PR fusionados (30 d)
- 133
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stacklok/toolhive-core
-
needs-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
stacklok/toolhive-core#466 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
stacklok/toolhive-core#426 ·
Los mantenedores suelen responder en 1 día
-
mcpcompat/server: refuse dispatch of a request whose per-request context is gonePosiblemente ocupada @jhrozek la tomó hace 15 días. Abiertoneeds-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
stacklok/toolhive-core#414 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
stacklok/toolhive-core#343 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
stacklok/toolhive-core#342 ·
Los mantenedores suelen responder en 1 día
Todos los issues de stacklok/toolhive-core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
--info inline-right:PREFIX leaves the first character of the prefix when the info gets shorterAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
-
[BUG] EphemeralJob matches every pod in the namespace when spec.selector is emptyPosiblemente ocupada @vishnums2k5 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
openkruise/kruise#2656 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Support kubevirt CRDsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
rancher/rancher-ai-mcp#206 ·
Los mantenedores suelen responder en 1 día
-
test: make command and stdio startup tests portablePosiblemente ocupada @dajiaohuang la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
mark3labs/mcp-go#1220 · 1 comentario ·
Los mantenedores suelen responder en 1 día