Skip to content

feat(officialmcp): reconnecting session via ClientSession anti-corruption interface#889

Open
hi-pender wants to merge 6 commits into
mainfrom
feat/mcp_client
Open

feat(officialmcp): reconnecting session via ClientSession anti-corruption interface#889
hi-pender wants to merge 6 commits into
mainfrom
feat/mcp_client

Conversation

@hi-pender

Copy link
Copy Markdown
Contributor

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.

(Optional) Translate the PR title into Chinese.

feat(officialmcp): 通过 ClientSession 防腐层接口提供可重连的会话

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
This branch upgrades officialmcp for URL-based (streamable-http / SSE) and stdio MCP servers.

Latest commit (reconnecting session):

  • Bump modelcontextprotocol/go-sdk to v1.6.1.
  • Config.Cli is now a ClientSession interface (ListTools/CallTool/Ping/Close) acting as an anti-corruption boundary. *mcp.ClientSession satisfies it directly, so existing callers are unaffected.
  • Error classification: connection-level failures (mcp.ErrConnectionClosed / mcp.ErrSessionMissing) are tagged ErrorKindConnection and exposed via IsConnectionError, kept distinct from protocol-level rejections (unknown tool / invalid params, ErrorKindCallTool) and application-level tool errors (result.IsError, ErrorKindServerToolError). This prevents a model that repeatedly calls a tool with bad arguments from triggering reconnect churn.
  • session.Session implements the interface and transparently rebuilds the underlying go-sdk session on connection-level errors. A go-sdk session is terminal once its connection fails, so recovery requires discarding and reconnecting; concurrent failures collapse into a single reconnect.

Also includes the prior mcp_client commits: original officialmcp upgrade (tool name mapping, session management, result/description policies) and two adk streaming/execute-mode fixes.

zh(optional):
本分支增强 officialmcp。最新提交将 Config.Cli 改为 ClientSession 防腐层接口(*mcp.ClientSession 原生满足,向后兼容),区分连接级 / 协议级 / 应用级三类错误(连接级为 ErrorKindConnection,避免下游用错参数反复调用导致重连 churn),并在 session 包提供连接级失败时自动重建底层会话的 Session(并发失败只重连一次)。

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

shentongmartin and others added 6 commits June 1, 2026 16:29
… management, and result policies

Add ToolNameMapper, MetadataMode, ListToolsMode, ResultPolicy, DescriptionPolicy,
and ToolCallResultHandler/V2 to officialmcp Config. Introduce session sub-package
for streamable HTTP and stdio transport lifecycle management.

Change-Id: Ie23aee61a185672106680f73998a4093d7bfb40f
Change-Id: I46254284516e09606572fb5da57f108446270db7
ExecuteStreaming now bridges to executeRich via a single-frame stream
when Mode=auto or Mode=background with WaitMS>0, ensuring symmetric
exit-code propagation and timer-based backgrounding semantics with the
non-streaming Execute path. Adds attack regression tests covering
default wait, non-zero exit, context cancellation, timer backgrounding,
background+wait completion, and early receiver close.

Change-Id: Idbca60aae9827e4139f618bd54d779202a67a7ea
…tion interface

Bump go-sdk to v1.6.1 and make Config.Cli a ClientSession interface
(ListTools/CallTool/Ping/Close) that *mcp.ClientSession satisfies directly.
Classify connection-level failures (ErrConnectionClosed/ErrSessionMissing) as
ErrorKindConnection, distinct from protocol-level rejections, so bad-args tool
calls cannot cause reconnect churn. The session package's Session implements the
interface and transparently rebuilds the underlying go-sdk session on
connection-level errors (single reconnect under concurrent failures).

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants