Repository navigation
Description
Summary
The {server}-list-tools Activity reads ListToolsResult.nextCursor, Tool.inputSchema and
Tool.outputSchema. MCP Python SDK 2 renamed these fields to next_cursor, input_schema and
output_schema, so with mcp 2.x every listing fails with
AttributeError: 'ListToolsResult' object has no attribute 'nextCursor' and MCP agent runs stop
at the listing. temporalio.contrib.strands in temporalio 1.33.0 and 1.34.0 declares no mcp
range, and strands-agents 1.55.0 and later allow mcp<2.2, so a fresh install gets mcp 2.1.1.
temporalio-strands-agents 0.1.0 avoids the failure by declaring mcp>=1.9.4,<2, which keeps
applications that need MCP 2 from installing it at all. Strands' own MCPClient works with both.
Versions
temporalio-strands-agents 0.1.0 and main at 495e507 (the listing code reads the same fields);
strands-agents 1.62.0 with mcp 2.1.1 (the pair a fresh install resolves), and strands-agents
1.56.0 with mcp 1.30.0 (the lock); Python 3.13.16.
Reproduction
One file, no Temporal server. It starts a stdio echo server (written for the installed mcp) and
lists its tools four ways: Strands' MCPClient.list_tools_sync(), mcp's own
ClientSession.list_tools(), and the plugin's registered echo-list-tools and echo-call-tool
Activity functions, called directly. With mcp 2 it exits 0 when the plugin listing fails with the
nextCursor error.
mcp_check.py, echo_v2_server.py
"""Minimal check: does the Strands plugin's MCP list-tools Activity work with the installed mcp?
python mcp_check.py <server python> <server script>
Runs four clients against one stdio echo server, in this order, each in a fresh connection:
native - Strands' own MCPClient.list_tools_sync() (no Temporal)
raw - mcp's own stdio_client + ClientSession.initialize() + list_tools()
plugin - the plugin's registered "<server>-list-tools" Activity function, called directly
plugin-call - the plugin's registered "<server>-call-tool" Activity function, called directly
Exits 0 only when the outcome matches the defect report: with mcp 1.x all four succeed; with
mcp 2 "plugin" fails with the `nextCursor` AttributeError while the other three succeed
("plugin-call" must return a success result). With mcp 2, passing requires the defective outcome.
"""
import asyncio
import importlib.metadata as m
import sys
from mcp import ClientSession, StdioServerParameters, stdio_client
from strands.tools.mcp import MCPClient
from temporalio.strands_agents._temporal_mcp_client import (
_CallToolArgs,
_evict_connection,
build_call_tool_activity,
build_list_tools_activity,
)
PY, SCRIPT = sys.argv[1], sys.argv[2]
params = StdioServerParameters(command=PY, args=[SCRIPT])
results: dict[str, tuple[bool, str]] = {}
def factory() -> MCPClient:
return MCPClient(lambda: stdio_client(params))
def report(name, fn):
try:
out = fn()
results[name] = (True, str(out))
print(f"{name}: OK {out}", flush=True)
except BaseException as e: # noqa: BLE001
leaf = e
while isinstance(leaf, BaseExceptionGroup):
leaf = leaf.exceptions[0]
results[name] = (False, f"{type(leaf).__name__}: {leaf}")
print(f"{name}: FAILED {type(e).__name__}; innermost {type(leaf).__name__}: {leaf}", flush=True)
def native():
c = factory()
with c:
return [t.tool_name for t in c.list_tools_sync()]
async def _raw():
async with stdio_client(params) as (r, w):
async with ClientSession(r, w) as s:
await s.initialize()
return [t.name for t in (await s.list_tools()).tools]
async def _plugin():
list_tools = build_list_tools_activity("echo", factory)
try:
return [i.name for i in await asyncio.wait_for(list_tools(), 20)]
finally:
await _evict_connection("echo")
async def _plugin_call():
call_tool = build_call_tool_activity("echo", factory)
try:
r = await asyncio.wait_for(call_tool(_CallToolArgs("echo", {"message": "hi"}, "tu-1")), 20)
return {"status": r["status"], "content": r["content"]}
finally:
await _evict_connection("echo")
versions = {p: m.version(p) for p in ("temporalio", "strands-agents", "mcp")}
print("client:", versions, "server:", PY, SCRIPT, flush=True)
report("native", native)
report("raw", lambda: asyncio.run(_raw()))
report("plugin", lambda: asyncio.run(_plugin()))
report("plugin-call", lambda: asyncio.run(_plugin_call()))
mcp_major = int(versions["mcp"].split(".")[0])
expected_ok = {"native": True, "raw": True, "plugin": mcp_major < 2, "plugin-call": True}
wrong = [n for n, ok in expected_ok.items() if results[n][0] != ok]
if results["plugin-call"][0] and "'status': 'success'" not in results["plugin-call"][1]:
wrong.append("plugin-call (returned a tool error)")
if mcp_major >= 2 and not wrong and "'ListToolsResult' object has no attribute 'nextCursor'" not in results["plugin"][1]:
wrong.append("plugin (failed, but not with the nextCursor AttributeError)")
expectation = ("all four succeed" if mcp_major < 2
else "plugin listing fails with the nextCursor AttributeError; native, raw and plugin-call succeed")
if wrong:
print(f"check: FAIL mcp {versions['mcp']}: expected {expectation}; unexpected: {', '.join(wrong)}", flush=True)
sys.exit(1)
print(f"check: PASS mcp {versions['mcp']}: {expectation}", flush=True)"""Echo MCP server written for mcp 2.x (FastMCP was renamed MCPServer)."""
from mcp.server.mcpserver import MCPServer
mcp = MCPServer("echo-server")
@mcp.tool()
def echo(message: str) -> str:
"""Return the input message unchanged."""
return message
if __name__ == "__main__":
mcp.run()On main with strands-agents 1.62.0 and mcp 2.1.1 (python mcp_check.py <venv>/bin/python echo_v2_server.py):
client: {'temporalio': '1.34.0', 'strands-agents': '1.62.0', 'mcp': '2.1.1'} server: <venv>/bin/python ./echo_v2_server.py
native: OK ['echo']
raw: OK ['echo']
plugin: FAILED AttributeError; innermost AttributeError: 'ListToolsResult' object has no attribute 'nextCursor'
plugin-call: OK {'status': 'success', 'content': [{'text': 'hi'}]}
check: PASS mcp 2.1.1: plugin listing fails with the nextCursor AttributeError; native, raw and plugin-call succeed
exit=0
Expected
The plugin lists the tools with mcp 1.x and 2.x, as Strands' MCPClient does.
Proposed fix
Read the three fields under either name (snake_case first, then camelCase), and declare
mcp>=1.9.4,<2.2, the range current Strands releases accept. The tests' MCP servers import
MCPServer when FastMCP is gone. With the change, the same check on mcp 2.1.1:
client: {'temporalio': '1.34.0', 'strands-agents': '1.62.0', 'mcp': '2.1.1'} server: <venv>/bin/python ./echo_v2_server.py
native: OK ['echo']
raw: OK ['echo']
plugin: OK ['echo']
plugin-call: OK {'status': 'success', 'content': [{'text': 'hi'}]}
check: FAIL mcp 2.1.1: expected plugin listing fails with the nextCursor AttributeError; native, raw and plugin-call succeed; unexpected: plugin
exit=1
(check: FAIL there means the defect did not show.) The change runs only in Activities. A PR
follows with the change, a unit test in tests/test_mcp.py that feeds the listing code pages with
mcp 2's next_cursor (it fails on main and passes with the change, with the locked mcp 1.30.0),
and a README note. tests/test_mcp.py and tests/test_mcp_prefix.py also pass with mcp 2.1.1
installed.
Not covered: MCP 2 multi-round tool calls. The call Activity still negotiates with initialize()
(protocol 2025-11-25) and calls plain session.call_tool(), so an mcp 2 tool that returns
InputRequiredResult comes back as Tool execution failed: Handler returned an invalid result, on
main and with this change, while Strands' MCPClient negotiates with server/discover and resends
with request_state until the call finishes. Supporting that needs modern negotiation and a round
driver in the call Activity; this change does not claim it.
Activity