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

オープン
#184 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
go
領域
api, backend

調査の方向性

mcpcompat/server/session.go の syncSessionTools から始め、その削除の再調整処理を syncSessionResources、syncSessionResourceTemplates、syncSessionPrompts と比較します。SetSessionResources、SetSessionResourceTemplates、SetSessionPrompts の REPLACE-style のパスを追跡し、省略されたエントリが削除され、list_changed が発行されることを確認します。下流のガードケースは stacklok/toolhive#5969 の serve_session_test.go にあります。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Go
スター
2
フォーク
6
平均マージ
23時間 44分
マージ済み PR(30日)
133

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stacklok/toolhive-core のほかの issue

stacklok/toolhive-core の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。