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

Aperta
#1,303 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@po-et ci sta già lavorando.

Dal 9/10/2026.

  • #1363 di @po-et — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
5.4k
Fork
623
Merge medio
22h 10m
PR unite (30g)
30

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/go-sdk

Tutte le issue di modelcontextprotocol/go-sdk

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.