mcp: requests to the client aren't checked against the capabilities it declared

Abierto
#1,303 1 comentario 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@po-et ya está trabajando en esto.

Desde el 9/10/2026.

  • #1363 de @po-et — 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

Línea de trabajo

Start with ServerSession.Elicit and compare its capability check with CreateMessageWithTools, CreateMessage, and ListRoots. Then inspect the client handlers for sampling and elicitation, including form versus URL mode; done means unsupported requests are rejected before sending or invoking handlers, with the specified errors such as -32602.

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

Descripción

The spec has a rule on each side of some requests a server sends to a client. From client/sampling (2025-11-25), servers MUST NOT send tool-enabled sampling requests to a client that hasn't declared sampling.tools, and the schema says the client MUST return an error for such a request. From client/elicitation, "Error Handling": a client MUST answer a request for a mode it didn't declare with -32602.

Only ServerSession.Elicit checks the client's capabilities today. CreateMessageWithTools sends tools to any client, and a client with only a CreateMessageHandler, which declares sampling without tools, drops tools and toolChoice and answers anyway, so the server gets an answer produced without the tools it asked for. CreateMessage and ListRoots don't check sampling and roots either. On the client side, a url-mode elicitation reaches the handler of a client that declared only form mode, which is the default.

This came up in the review of #699 (https://github.com/modelcontextprotocol/go-sdk/pull/699#discussion_r2810556445), with the suggestion to cover all capability-gated server→client requests consistently. I have a change that does that: those server methods return an error before sending, as Elicit does, and the client answers -32602 before calling its handler. I can send it as a PR if that's the direction you want.

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.