crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Support mcp 2.x (Python SDK): pin blocks mcp 2.0.0

Open SiAgentBuild opened this issue 4 months ago • 4 comments

Summary

crewAI currently pins the MCP Python SDK to the 1.x line and therefore cannot be installed alongside mcp 2.0.0 (released 2026-07-28). This issue tracks the breaking changes in mcp 2.0 that affect crewAI and what it would take to support it.

Current pins

Package Constraint Location
crewai (core) mcp~=1.28.1 (i.e. >=1.28.1,<1.29) lib/crewai/pyproject.toml:43
crewai-tools[mcp] extra mcp>=1.28.1,<2 + mcpadapt>=0.1.9 lib/crewai-tools/pyproject.toml:102-105

Both hard-cap the SDK below 2.0.

Breaking changes in mcp 2.0 that affect crewAI

Verified against the installed mcp==2.0.0 SDK and crewAI main:

  1. streamablehttp_client renamed → streamable_http_client, and now yields a 2-tuple instead of a 3-tuple. It yields (read_stream, write_stream); the third get_session_id element is gone. Used in 3 places with the old name + 3-tuple unpack:

    • lib/crewai/src/crewai/mcp/transports/http.py:75,77,84 — read, write, _ = await self._transport_context.__aenter__()
    • lib/crewai/src/crewai/mcp/tool_resolver.py:601,605 — async with streamablehttp_client(server_url) as (read, write, _)
    • lib/crewai/src/crewai/tools/mcp_tool_wrapper.py:165,173,175 — as (read, write, _)
  2. streamable_http_client dropped the headers kwarg. Its 2.0 signature is (url, *, http_client=None, terminate_on_close=True). Custom headers must now be set on an httpx2.AsyncClient passed as http_client= (e.g. via mcp.shared._httpx_utils.create_mcp_http_client(headers=...)). This affects transports/http.py:78-80, which passes headers=self.headers.

  3. camelCase attribute reads on mcp.types → snake_case. Constructing with camelCase aliases still parses, but attribute access must now be snake_case:

    • client.py:418 — getattr(tool, "inputSchema", {}) → input_schema
    • client.py:598 — getattr(result, "isError", False) → is_error
    • tool_resolver.py:619,621 — tool.inputSchema → input_schema
    • lib/crewai-tools/src/crewai_tools/adapters/mcp_adapter.py:54 — mcp_tool.inputSchema → input_schema
  4. 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); httpx/httpx-sse are replaced by httpx2>=2.5.0. The crewai-tools[mcp] path additionally depends on the third-party mcpadapt bridge, so that path's 2.0 support is gated on mcpadapt adding 2.0 compatibility too.

Notes

  • crewAI uses only the raw mcp SDK — no fastmcp dependency — so it is not transitively blocked the way some frameworks are. The native client code is also nicely centralized under lib/crewai/src/crewai/mcp/, which keeps the migration surface small (~5 modules).
  • Already compatible, no change needed: SessionMessage still exists in 2.0 (mcp/shared/message.py:59), so transports/base.py:8 is fine. crewAI does not use McpError, read_timeout_seconds=timedelta(...), the removed mcp.types.Content/Cursor/ResourceReference, or the removed lowlevel @server.list_tools()/@server.call_tool() decorators (crewAI is a pure MCP client).

Happy to help with a PR if the maintainers are open to it.

SiAgentBuild avatar Jul 31 '26 01:07 SiAgentBuild

hey looks like we need to update the mcp version constraints, I'll take care of it

Mahnoor-Zaffar avatar Jul 31 '26 14:07 Mahnoor-Zaffar

For the 1.x→2.x migration, I would add a small semantic conformance matrix in addition to import/API compatibility tests. The risk is not only that the client starts; it is that transport/API changes silently alter what CrewAI can observe.

Useful invariants across both supported SDK lines:

  • tool name + normalized input schema presented to the agent is equivalent;
  • is_error/error outcomes cannot be lost by the camelCase→snake_case transition;
  • auth/header behavior is actually effective on the wire, not merely configured;
  • session/transport identity changes are recorded explicitly rather than inferred from the old third tuple element;
  • a failing MCP server and a successful tool result remain distinguishable in the same way.

That lets the SDK version be provenance, not a security/correctness verdict by itself.

This configured-vs-effective/transport-provenance distinction is also used in AgentCI: https://github.com/jinngimk-lang/agentci . Reference only; no CrewAI/MCP compatibility or certification claim.

jinngimk-lang avatar Aug 17 '26 01:08 jinngimk-lang

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 02 '26 12:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Oct 07 '26 12:10 github-actions[bot]