Non-object RootModel return type (RootModel[list[str]]) breaks the whole tools/list on 2025-11-25 sessions
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
Start in src/mcp/server/mcpserver/utilities/func_metadata.py, especially _create_output_model around the lines linked in the issue, and check how it handles plain scalar and list return types versus BaseModel subclasses. Reproduce with a RootModel[list[str]] tool and a legacy 2025-11-25 tools/list session. Done when non-object-root RootModel outputs are wrapped compatibly, object-root models retain their behavior, and the tool listing succeeds.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Initial Checks
- I confirm that I'm using the newest release of my line (the latest 2.x, or the latest 1.x if I'm still on v1)
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Release line
2.x (current stable)
Description
This is the case left out of #3376. A tool whose return type is a RootModel with a non-object root (RootModel[list[str]], RootModel[int], ...) publishes outputSchema with "type": "array" (or a scalar) at the root. On a 2025-11-25 session ListToolsResult validation then fails on tools.0.outputSchema.type Input should be 'object', and the client gets Handler returned an invalid result for the whole listing, so every other tool on the server is gone too. 2026-07-28 sessions are fine.
_create_output_model takes any BaseModel subclass as is (func_metadata.py L536-538), so RootModel never gets the {"result": ...} wrapping that list[str] or int returns get. The PR description there said a separate issue would be opened for this, I couldn't find one so filing it.
I'd expect a RootModel whose root isn't an object to be wrapped the same way as the plain list[...] / scalar return types, while RootModel[dict[...]] or RootModel[SomeModel] keep the current behaviour. The tools/list of other tools definitely shouldn't depend on it.
Example Code
import anyio, logging
from pydantic import RootModel
from mcp import Client
from mcp.server.mcpserver import MCPServer
logging.disable(logging.CRITICAL)
class Tags(RootModel[list[str]]):
pass
mcp = MCPServer("demo")
@mcp.tool()
def tags() -> Tags:
return Tags(["a", "b"])
@mcp.tool()
def other() -> int:
return 1
async def main():
print("outputSchema:", (await mcp.list_tools())[0].output_schema)
async with Client(mcp) as c: # 2026-07-28
print("2026-07-28 tools/list:", [t.name for t in (await c.list_tools()).tools])
print("2026-07-28 structuredContent:", (await c.call_tool("tags", {})).structured_content)
try:
async with Client(mcp, mode="legacy") as c: # 2025-11-25
print("legacy tools/list:", [t.name for t in (await c.list_tools()).tools])
except BaseException as e:
while isinstance(e, BaseExceptionGroup):
e = e.exceptions[0]
print("legacy tools/list raised:", type(e).__name__, e)
anyio.run(main)
Output (same on v2.3.0 and on main 77001c9)
outputSchema: {'items': {'type': 'string'}, 'title': 'Tags', 'type': 'array'}
2026-07-28 tools/list: ['tags', 'other']
2026-07-28 structuredContent: ['a', 'b']
legacy tools/list raised: MCPError Handler returned an invalid result
Python & MCP Python SDK
Python 3.12 with mcp 2.3.0 from PyPI, and Python 3.14.4 with main @ 77001c9
pydantic 2.12.5 in the main checkout
- Lenguaje dominante
- Python
- Estrellas
- 25k
- Forks
- 4.2k
- Merge medio
- 10 min
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 modelcontextprotocol/python-sdk
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3978 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Client serves cached tools after its context exits with an exceptionPosiblemente ocupada @jonxsong la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
modelcontextprotocol/python-sdk#3968 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
modelcontextprotocol/python-sdk#3957 ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
modelcontextprotocol/python-sdk#3934 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug v1
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
modelcontextprotocol/python-sdk#3929 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de modelcontextprotocol/python-sdk
Issues similares
-
soup prune-prompt exits 1 after writing its output on a file over 100,000 rows, and reports a capped row count otherwisePosiblemente ocupada @abdulwaarith0 la tomó hoy. Abiertoneeds-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
MakazhanAlpamys/Soup#3690 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug data-types native-format
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
ClickHouse/clickhouse-connect#1320 ·
Los mantenedores suelen responder en 1 día
-
Public benchmark import end-to-end test fails when the test stack's worker runs the parity jobAbiertoaccepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
future-agi/future-agi#6392 ·
Los mantenedores suelen responder en 1 día