Skip to content

Migrate the MCP integration to the mcp 2.x SDK #1653

Open

Description

@psschwei

pyproject.toml declares mcp>=1.27.0 in the tools extra, so any unlocked
pip install "mellea[tools]" resolves mcp to 2.x, where the server API was renamed and
the model fields moved to snake_case. uv.lock pins 1.27.0, so every CI path except the
new Colab job installs 1.x and stays green. The Colab job caught this on its first run.

Worked out by hand against mcp 2.2.0; docs/examples/notebooks/mcp_example.ipynb is
currently pinned to mcp<2 as a stopgap, which this issue should remove.

Mechanical parts

  • Server class: mcp.server.fastmcp.FastMCP -> mcp.server.mcpserver.MCPServer. The
    decorator surface (tool, resource, run) is unchanged and uv run mcp dev still
    works, so call sites need only the import and the constructor renamed. Note that
    mcp.server.fastmcp still exists in 2.x as a tombstone that raises ModuleNotFoundError
    with a migration hint.
  • Field renames, camelCase -> snake_case (isError, inputSchema, mimeType):
    mellea/stdlib/tools/mcp.py lines 140, 305, 321, 329, 338; test/stdlib/tools/test_mcp.py
    lines 41, 64, 206, 223, 241, 362. With just these 11 edits all 33 tests in
    test/stdlib/tools/test_mcp.py pass under 2.2.0.

The part that needs a decision

_open_session's streamable-http branch in mellea/stdlib/tools/mcp.py:

  • :265 unpacks a 3-tuple, but 2.x's streamable_http_client yields (read_stream, write_stream)
  • :266 passes an httpx.AsyncClient, but the signature is http_client: httpx2.AsyncClient | None

mcp 2.x depends on httpx2>=2.5.0, a distribution separate from httpx (in a clean mcp-2
environment httpx is not installed at all). So the mcp module would run on httpx2 while
mellea/backends/ollama.py stays on httpx, leaving mellea with two HTTP stacks, and the
tools extra's httpx>=0.27 needs revisiting.

Test gap

The 33 unit tests mock the ClientSession, so the streamable-http transport never executes.
Only mypy caught both breakages above. Worth adding coverage that exercises the real
transport construction.

Also needs updating

  • docs/docs/integrations/mcp.md — 5 code spots, plus the pip install "mcp[cli]"
    prerequisite on line 14
  • docs/examples/mcp/mcp_example.py — lines 14 and 29, plus the install hint in its docstring
  • docs/examples/notebooks/mcp_example.ipynb — drop the mcp<2 stopgap
  • Leave docs/versioned_docs/version-0.7.0/integrations/mcp.md alone; it is a frozen
    snapshot that correctly documents 1.x

Unrelated bug found nearby

docs/docs/integrations/mcp.md:9 credits jlowin/fastmcp,
but the code imports the official SDK's server, not that third-party project. Wrong
attribution today, independent of the version question.

Activity

  1. added
    enhancement
    area/tools
    on Oct 20, 2026
  2. pavani42 commented on Nov 10, 2026

    @pavani42
    Contributor

    Hi, is this issue ready to be picked up? If yes, I'd be happy to take it. Could you please assign it to me? Thanks!

  3. Ankur1911 commented on Nov 20, 2026

    @Ankur1911

    @pavani42 are you still working on this? I have a branch that runs the MCP integration on both mcp 1.27 and 2.3 (stdio, HTTP and SSE; 42 MCP tests pass on each). Happy to open it as a PR, or to leave this to you and share the test cases instead — whichever you and the maintainers prefer.

  4. pavani42 commented on Nov 20, 2026

    @pavani42
    Contributor

    @Ankur1911 I didn't started on this, pls go ahead and open PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/toolsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions