Repository navigation
Apply MCPClient prefix and carry tool annotations in TemporalMCPClient - #148
Merged
brianstrauch merged 1 commit intoOct 23, 2026
Merged
brianstrauch merged 1 commit into
brianstrauch merged 1 commit into
Conversation
TemporalMCPClient listed tools under their server-side names, so the MCPClient(prefix=...) a worker factory configures was ignored: the model saw `echo` instead of `gh_echo`, a call to `gh_echo` failed with "Unknown tool", and same-named tools from two servers collided. The list-tools activity now records the agent-facing name next to the server-side one, and the call-tool activity still receives the server-side name. Tool annotations (readOnlyHint and friends) are carried into the tool spec as plain Strands does. Both new fields default to None, so list-tools results recorded earlier still decode.
campoy
added a commit
that referenced
this pull request
Oct 26, 2026
Since #148, _tool_infos hands each tool to Strands' MCPAgentTool, which reads the schema field names of the installed mcp line. Build the unit test's tools as real mcp Tool objects, and keep mcp 2's next_cursor on its pages. The prefix tests' server imports MCPServer on mcp 2, like the echo server, so test_mcp_prefix.py also runs with mcp 2.
campoy
added a commit
that referenced
this pull request
Oct 28, 2026
Since #148, _tool_infos hands each tool to Strands' MCPAgentTool, which reads the schema field names of the installed mcp line. Build the unit test's tools as real mcp Tool objects, and keep mcp 2's next_cursor on its pages. The prefix tests' server imports MCPServer on mcp 2, like the echo server, so test_mcp_prefix.py also runs with mcp 2.
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 was changed
_MCPToolInfogainsagent_nameandannotations, both defaulting toNone._tool_infosfills them from theMCPAgentToolit already builds to evaluate the tool filters:agent_nameis its prefixedtool_name,annotationsis theannotationsentry of itstool_spec, so the shape matches plain Strands.TemporalMCPTool.tool_nameandtool_spec["name"]useagent_name(falling back toname), andtool_specincludesannotationswhen there are any. The tool still sendsinfo.name, the server-side name, to the{server}-call-toolactivity.tests/test_mcp_prefix.pyand a smalltests/labeled_mcp_server.py(an annotatedechotool that tags its reply with the server's label).Why?
The README says a worker-side factory can pass
prefixto itsMCPClient, butTemporalMCPClientlisted the tools under their server-side names. The model sawechoinstead ofgh_echo, callinggh_echofailed with "Unknown tool", and two servers exposing the same tool name collided so one server's tool was lost. The annotations Strands puts in the tool spec were also dropped. Both fields are optional, so a list-tools result recorded before this change still decodes and keeps the old name.Checklist
Closes [Bug] strands_agents: TemporalMCPClient ignores MCPClient(prefix=...) and drops MCP tool annotations #147
How was this tested:
New tests in
tests/test_mcp_prefix.py: unit tests for_tool_infos/TemporalMCPToolwith a prefix, without one (name and spec unchanged, noannotationskey), with annotations, with a filter plus a prefix (filter matches the server-side name), and decoding a list-tools payload that has none of the new fields; and one workflow test with two real stdio MCP servers that both exposeecho(prefixesghandgl): the model is offeredgh_echoandgl_echowith their annotations, each call reaches its own server (which only knowsecho), and the history replays with theReplayer. Onmain(install rebuilt withmake syncand checked against the source) all 6 new tests fail; with the changemake lintis clean andmake testpasses (58, 6 of them new). The repro in the issue now printsgh_echo/gl_echowith the annotations andsuccess: hi. A trial merge with fix(strands): close a failed Python MCP connection only after in-flight calls finish #137 (git merge-tree) is clean.Any docs updates needed?
No. The README already says
prefixcan be passed to the worker-sideMCPClient; it now holds.