Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

mcp: Client.Connect never falls back to initialize when a stdio server ignores server/discover

Đang mở
#1,332 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@crossxr đang làm issue này rồi.

Từ ngày 2/10/2026.

  • #1334 của @crossxr — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
api

Hướng nghiên cứu

Start at Client.Connect and the ClientSessionOptions handling for the server/discover probe, then reproduce the timeout with the silent Python stdio server described in the issue. Review the API decision around DiscoverTimeout or a transport-specific default; done means a silent handshake-era server reaches initialize instead of waiting for the caller context to expire.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

For protocol ≥ 2026-07-28, Client.Connect sends server/discover first and falls back to initialize on an error, or on a non-modern error from the server. Some handshake-era stdio servers silently ignore requests they don't recognize before initialize, and the stdio transport spec permits that. With such a server, server/discover never gets a reply, so Connect blocks until the caller's context ends and then fails. It never reaches the initialize fallback.

Setting ClientSessionOptions{ProtocolVersion: "2025-11-25"} connects immediately, but then the client can't use 2026-07-28 with any server.

To Reproduce

A stdio server that only answers initialize and tools/list and drops everything else:

import sys, json
for line in sys.stdin:
    m = json.loads(line)
    if m.get("method") == "initialize":
        r = {"protocolVersion": "2025-11-25", "capabilities": {"tools": {}}, "serverInfo": {"name": "silent", "version": "1"}}
    elif m.get("method") == "tools/list":
        r = {"tools": []}
    else:
        continue
    print(json.dumps({"jsonrpc": "2.0", "id": m["id"], "result": r}), flush=True)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err := client.Connect(ctx, &mcp.CommandTransport{Command: exec.Command("python3", "silent.py")}, nil)
// v1.8.0 and main at 53effc0: returns after 5s with context deadline exceeded

Expected behavior

This needs an API decision, so raising it before any PR. One option: bound the discover probe and treat "no reply in time" as a handshake-era server on transports where silence is possible, e.g. ClientSessionOptions.DiscoverTimeout, or a short default for CommandTransport.

Additional context

Found while moving PromptKit's MCP client onto go-sdk v1.8.0 (AltairaLabs/PromptKit#2141). We work around it by restarting the stdio server and connecting with the handshake-era protocol version when discover times out: client.go. Our interop matrix runs the silent server above as a fixture: silent_stdio.py.

Ngôn ngữ chính
Go
Star
5.2k
Fork
568
Merge trung bình
1 ngày 18 giờ
Pull request đã merge (30 ngày)
36

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/go-sdk

Tất cả issue của modelcontextprotocol/go-sdk

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.