mcpcompat: reconcile removals in per-session resource/template/prompt sync

Aperta
#184 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go
Ambito
api, backend

Direzione di ricerca

Inizia in mcpcompat/server/session.go con syncSessionTools e confronta la relativa riconciliazione delle rimozioni con syncSessionResources, syncSessionResourceTemplates e syncSessionPrompts. Traccia i percorsi in stile REPLACE di SetSessionResources, SetSessionResourceTemplates e SetSessionPrompts, quindi verifica che le voci omesse vengano rimosse e che venga emesso list_changed; i casi di guardia downstream si trovano in serve_session_test.go in stacklok/toolhive#5969.

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

Descrizione

needs-triage

Context

In mcpcompat/server/session.go, syncSessionTools reconciles the per-session go-sdk server against the overlay by both adding new tools and removing ones no longer present (srv.RemoveTools(removed...)). The sibling syncs for the other capability kinds are add-only:

  • syncSessionResources
  • syncSessionResourceTemplates
  • syncSessionPrompts

None of them removes entries that are absent from the new overlay, even though go-sdk exposes RemoveResources / RemoveResourceTemplates / RemovePrompts.

Impact (downstream in toolhive)

toolhive's vMCP list_changed propagation (stacklok/toolhive#5965 for tools, stacklok/toolhive#5969 for resources/prompts) re-derives a session's advertised capabilities on a backend list_changed and applies them with the REPLACE-style SetSessionResources/SetSessionResourceTemplates/SetSessionPrompts. Because the underlying sync is add-only:

  • Additions to a backend's resources/templates/prompts propagate to the client correctly.
  • Removals do not — a resource/prompt the backend dropped stays registered on the session's go-sdk server and keeps appearing in resources/list / resources/templates/list / prompts/list until the session re-initializes.

Tools do not have this problem because their sync reconciles removals.

Note: read-time access is unaffected downstream (toolhive re-derives admission per call), so this is a stale-list / name-disclosure issue, not an access bypass.

Proposed change

Mirror syncSessionTools' removal reconciliation in syncSessionResources, syncSessionResourceTemplates, and syncSessionPrompts: track the previously-synced names/URIs and call the corresponding go-sdk Remove* for entries absent from the new overlay.

Acceptance

  • A REPLACE-style SetSessionResources/SetSessionResourceTemplates/SetSessionPrompts that omits a previously-present entry results in that entry being removed from the session's go-sdk server (and a downstream list_changed emitted).
  • After a toolhive-core release + bump, the add-only guard tests in stacklok/toolhive#5969 (serve_session_test.go, which currently assert removed entries still appear) can be flipped to assert removal, and the NOTE comments at resyncSessionResources/resyncSessionPrompts removed.

Reported from stacklok/toolhive#5969.

Lingua principale
Go
Stelle
2
Fork
6
Merge medio
23h 44m
PR unite (30g)
133

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 stacklok/toolhive-core

Tutte le issue di stacklok/toolhive-core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.