feat(officialmcp): reconnecting session via ClientSession anti-corruption interface#889
Open
hi-pender wants to merge 6 commits into
Open
feat(officialmcp): reconnecting session via ClientSession anti-corruption interface#889hi-pender wants to merge 6 commits into
hi-pender wants to merge 6 commits into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
feat
Check the PR title.
(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
officialmcpfor URL-based (streamable-http / SSE) and stdio MCP servers.Latest commit (reconnecting session):
modelcontextprotocol/go-sdkto v1.6.1.Config.Cliis now aClientSessioninterface (ListTools/CallTool/Ping/Close) acting as an anti-corruption boundary.*mcp.ClientSessionsatisfies it directly, so existing callers are unaffected.mcp.ErrConnectionClosed/mcp.ErrSessionMissing) are taggedErrorKindConnectionand exposed viaIsConnectionError, 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.Sessionimplements 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_clientcommits: 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: