mcp: 2026-07-28 client runs elicitation and sampling handlers for standalone server requests
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #1554 @luiacuaniello による — マージされずにクローズ
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- go
調査の方向性
Start by comparing the client handling for elicitation/create and sampling/createMessage with the rejection behavior for standalone ping and roots/list mentioned in the issue. Add tests that send these requests over an in-memory connection and verify the handlers are not called and the client returns -32601. The issue says a fix and test are ready, and a linked pull request is already closed without merging.
索引モデルが issue の本文から書いたものです。
説明
Checklist
- I searched the existing issues, and this has not been reported before.
- This is a real problem that I ran into myself, using the latest release of the SDK.
- I ran into it in a production system, not in a toy example, a benchmark, or an automated or AI-driven scan of the code.
- I (a human) examined the relevant SDK code, and wrote or reviewed every line of this report. It is not unreviewed AI output.
- This report is brief and concise, and sticks to the facts needed to understand the problem.
What happened?
On a 2026-07-28 session the client still runs ElicitationHandler and CreateMessageHandler when the server sends a standalone elicitation/create or sampling/createMessage, and replies with the result. In 2026-07-28 these should only arrive as MRTR input requests. #1537 and #1540 already make the client reject a standalone ping and roots/list with -32601, but these two still go through, so a misbehaving server can start sampling or prompt the user outside any request the client made.
I'd expect -32601 without calling the handler, same as ping and roots/list. I have a fix and a test ready if you want a PR.
Found and written with help from Claude Code.
How to reproduce
The program wraps the server's end of an in-memory connection and, after the handshake, sends the client a standalone elicitation/create and sampling/createMessage.
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/modelcontextprotocol/go-sdk/jsonrpc"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
// tap wraps the server's end of the connection, so that main can send the
// client a request of its own, as a non-conforming server would, and read
// the client's answer.
type tap struct {
mcp.Transport
conn mcp.Connection
answers chan *jsonrpc.Response
}
func (t *tap) Connect(ctx context.Context) (mcp.Connection, error) {
c, err := t.Transport.Connect(ctx)
if err != nil {
return nil, err
}
t.conn = c
return tapConn{c, t}, nil
}
type tapConn struct {
mcp.Connection
t *tap
}
func (c tapConn) Read(ctx context.Context) (jsonrpc.Message, error) {
for {
msg, err := c.Connection.Read(ctx)
if r, ok := msg.(*jsonrpc.Response); ok && err == nil {
if s, _ := r.ID.Raw().(string); s == "standalone" {
c.t.answers <- r
continue
}
}
return msg, err
}
}
func main() {
ctx := context.Background()
client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v1"}, &mcp.ClientOptions{
ElicitationHandler: func(context.Context, *mcp.ElicitRequest) (*mcp.ElicitResult, error) {
fmt.Println("ElicitationHandler ran")
return &mcp.ElicitResult{Action: "accept", Content: map[string]any{"name": "Ada"}}, nil
},
CreateMessageHandler: func(context.Context, *mcp.CreateMessageRequest) (*mcp.CreateMessageResult, error) {
fmt.Println("CreateMessageHandler ran")
return &mcp.CreateMessageResult{Model: "m", Role: "assistant", Content: &mcp.TextContent{Text: "hi"}}, nil
},
})
server := mcp.NewServer(&mcp.Implementation{Name: "server", Version: "v1"}, nil)
ct, st := mcp.NewInMemoryTransports()
t := &tap{Transport: st, answers: make(chan *jsonrpc.Response, 1)}
ss, err := server.Connect(ctx, t, nil)
if err != nil {
panic(err)
}
defer ss.Close()
cs, err := client.Connect(ctx, ct, nil)
if err != nil {
panic(err)
}
defer cs.Close()
fmt.Println("protocol", cs.InitializeResult().ProtocolVersion)
id, _ := jsonrpc.MakeID("standalone")
for _, req := range []struct {
method string
params any
}{
{"elicitation/create", map[string]any{
"message": "What is your name?",
"requestedSchema": map[string]any{"type": "object", "properties": map[string]any{"name": map[string]any{"type": "string"}}},
}},
{"sampling/createMessage", map[string]any{
"maxTokens": 10,
"messages": []any{map[string]any{"role": "user", "content": map[string]any{"type": "text", "text": "hi"}}},
}},
} {
params, _ := json.Marshal(req.params)
if err := t.conn.Write(ctx, &jsonrpc.Request{ID: id, Method: req.method, Params: params}); err != nil {
panic(err)
}
r := <-t.answers
fmt.Printf("%s: result %s, error %v\n", req.method, r.Result, r.Error)
}
}
Output with v1.8.0 (same with v1.9.0-pre.1 and main at 4b1a524):
protocol 2026-07-28
ElicitationHandler ran
elicitation/create: result {"action":"accept","content":{"name":"Ada"}}, error <nil>
CreateMessageHandler ran
sampling/createMessage: result {"content":{"type":"text","text":"hi"},"model":"m","role":"assistant"}, error <nil>
Where did you hit this?
Found while reading the code; I then reproduced it on a production service that uses the SDK.
Go MCP SDK version
v1.8.0, also v1.9.0-pre.1 and main at 4b1a524
Go version
go1.26.0 darwin/arm64
Logs
No response
- 主要言語
- Go
- スター
- 5.4k
- フォーク
- 623
- 平均マージ
- 22時間 10分
- マージ済み PR(30日)
- 30
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/go-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
modelcontextprotocol/go-sdk#1557 ·
メンテナーはふだん 1 日以内に返信
-
Streamable HTTP (2026-07-28): tools/call with an out-of-range number in arguments fails because extractName decodes Arguments into any再び着手できるかも @beiryu が 10 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/go-sdk#1534 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Expose generic `SendNotification` on `ServerSession` for custom protocol extensions再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンneeds investigation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelcontextprotocol/go-sdk#745 · コメント 13 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
modelcontextprotocol/go-sdk#1555 ·
メンテナーはふだん 1 日以内に返信
-
mcp: stateless subscriptions/listen stream can start with an unrequested tools/list_changed再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
modelcontextprotocol/go-sdk#1551 ·
メンテナーはふだん 1 日以内に返信
modelcontextprotocol/go-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
apache/dubbo-admin#1659 ·
メンテナーはふだん 8 日以内に返信
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind対応中かも @arshil42 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100