Skip to content

Commit f695886

Browse files
b88funruvnet
andauthored
fix: support mcp 2.x, which breaks the client on a fresh install (#50)
pyproject pins "mcp>=1.9.0" with no upper bound, so any new install resolves mcp 2.0.0 and every XpozClient() raises immediately: ExceptionGroup: unhandled errors in a TaskGroup ValueError: not enough values to unpack (expected 3, got 2) Two breaking changes in mcp 2.0: - streamable_http_client yields 2 values instead of 3, so the "read, write, _ = streams" unpack fails. - CallToolResult.isError was renamed to is_error. Both are now handled without pinning, so the SDK works on 1.x and 2.x. This is the same ValueError behind the errors seen across the live-API test suites; tests/test_instagram.py goes from erroring to 13/13 passing against the live API on mcp 2.0.0. Claude-Session: https://claude.ai/code/session_011ekeWsNRndQwdgUE1SHqfe Co-authored-by: claude-flow <ruv@ruv.net>
1 parent 8e17202 commit f695886

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

‎src/xpoz/_mcp/_transport.py‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,19 @@ def _resolve_user_agent(override: str | None) -> str:
2828
return override
2929

3030

31+
def _unpack_streams(streams: Any) -> tuple[Any, Any]:
32+
read_stream, write_stream = streams[0], streams[1]
33+
return read_stream, write_stream
34+
35+
36+
def _is_error_result(result: Any) -> bool:
37+
if hasattr(result, "is_error"):
38+
return bool(result.is_error)
39+
return bool(result.isError)
40+
41+
3142
def _parse_tool_result(tool_name: str, result: Any) -> dict[str, Any]:
32-
if result.isError:
43+
if _is_error_result(result):
3344
error_text = ""
3445
for block in result.content:
3546
if hasattr(block, "text"):
@@ -71,7 +82,7 @@ async def connect(self) -> None:
7182
streams = await ctx.__aenter__()
7283
self._context_stack.append(ctx)
7384

74-
read_stream, write_stream, _ = streams
85+
read_stream, write_stream = _unpack_streams(streams)
7586
session_ctx = ClientSession(read_stream, write_stream)
7687
self._session = await session_ctx.__aenter__()
7788
self._context_stack.append(session_ctx)
@@ -139,7 +150,7 @@ async def _lifecycle(
139150
timeout=httpx.Timeout(30, read=None),
140151
)
141152
async with streamable_http_client(self._server_url, http_client=http_client) as streams:
142-
read_stream, write_stream, _ = streams
153+
read_stream, write_stream = _unpack_streams(streams)
143154
async with ClientSession(read_stream, write_stream) as session:
144155
await session.initialize()
145156
self._session = session

0 commit comments

Comments
 (0)