agentscope-ai / agentscope-ai/agentscope
Support mcp 2.x (Python SDK): pin mcp<2.0.0 blocks 2.0.0
- 主要语言
- Python
- 星标
- 31.5k
- 派生
- 3.5k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 95
描述
## Summary
`agentscope` currently pins the MCP Python SDK below 2.0 (`mcp<2.0.0`, added in #2091) and cannot be installed alongside `mcp` 2.0.0 (released 2026-07-28). This issue tracks the breaking changes in `mcp` 2.0 that affect agentscope. The surface is small and well-localized.
### Current pin
`mcp<2.0.0` — `pyproject.toml:29`.
### Breaking changes in `mcp` 2.0 that affect agentscope
Verified against the installed `mcp==2.0.0` SDK and agentscope `main`. agentscope is a client-only consumer of raw `mcp`:
1. **camelCase attribute reads on `mcp.types` → snake_case** (the most widespread):
- `src/agentscope/tool/_adapters.py:326` — `result.isError` → `is_error`
- `src/agentscope/tool/_adapters.py:233` — `tool.inputSchema` → `input_schema`
- `src/agentscope/workspace/_gateway_client.py:96` — `tool.inputSchema` → `input_schema`
- `src/agentscope/tool/_adapters.py:356, 383` — `content.mimeType` → `mime_type`
2. **`McpError` renamed → `MCPError`.**
- `src/agentscope/tool/_toolkit.py:339` — `except mcp.shared.exceptions.McpError as e:` → `MCPError` (constructor `MCPError(code, message, data=None)`).
3. **`ClientSession.call_tool(read_timeout_seconds=timedelta(...))` now takes a float.**
- `src/agentscope/tool/_adapters.py:312, 319` — passes `read_timeout_seconds=self._timeout`, where `self._timeout` is built as `timedelta(seconds=timeout)` at `_adapters.py:254`. In 2.0 the param is a float of seconds, so both the construction (`:254`) and the two call sites need updating.
### Notes
- The HTTP transport layer is already 2.0-ready: `src/agentscope/mcp/_mcp_client.py:11` imports the new `streamable_http_client` name and `:212-215` calls it with `http_client=httpx.AsyncClient(headers=..., timeout=...)`; the 2-tuple unpack (`_mcp_client.py:241`, `_adapters.py:305`) is 2.0-safe. No lowlevel `@server.list_tools()`/`@server.call_tool()` decorators are used (client-only), and there is no `fastmcp` dependency.
- The work is concentrated in `src/agentscope/tool/_adapters.py` and `src/agentscope/workspace/_gateway_client.py`, plus the one exception catch in `_toolkit.py`.
- **Dependency-floor updates.** `mcp` 2.0 requires `pydantic>=2.12`, `anyio>=4.9`, `typing-extensions>=4.13`, and adds required deps `opentelemetry-api` and `mcp-types` (exact-pinned to the SDK version); the SDK's HTTP layer moved from `httpx`/`httpx-sse` to `httpx2>=2.5.0`.
Happy to help with a PR if the maintainers are open to it.
贡献指南
评估
这个 Issue 还没有评估数据。