Skip to content

feat: migrate llama-index-tools-mcp to mcp 2.x - #22557

Merged
logan-markewich merged 2 commits into
run-llama:mainfrom
ProgrammerPlus1998:feat/mcp-2x-migration
Aug 11, 2026
Merged

logan-markewich merged 2 commits into
run-llama:mainfrom
ProgrammerPlus1998:feat/mcp-2x-migration

Conversation

@ProgrammerPlus1998

Copy link
Copy Markdown
Contributor

Description

Migrates the llama-index-tools-mcp integration to the MCP Python SDK 2.x line. The previous pin (mcp>=1.24.0,<2) blocks mcp 2.0.0, which removed the server-side FastMCP module, changed several model fields from camelCase to snake_case, moved a couple of public symbols, and switched the HTTP/SSE client layer to httpx2. This updates the integration, its test server, and the example to the 2.0 API and loosens the pin to mcp>=2.0.0,<3.

This takes the "upgrade to 2.x" approach (require the 2.x SDK) rather than supporting both 1.x and 2.x side by side.

Fixes #22515

New Package?

Did I fill in the tool.llamahub section in the pyproject.toml and provide a detailed README.md for my new integration or package?

  • Yes
  • No

Version Bump?

Did I bump the version in the pyproject.toml file of the package I am updating? (Except for the llama-index-core package)

  • Yes (0.4.8 → 0.5.0)
  • No

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

(Breaking only in that it now requires mcp 2.x; the public llama-index API is unchanged.)

What changed

  • Dependency: mcp>=1.24.0,<2 → mcp>=2.0.0,<3.
  • client.py
    • ProgressFnT moved from the removed mcp.shared.session to mcp.shared.dispatcher.
    • ClientSession(read_timeout_seconds=...) now takes float seconds instead of a timedelta.
    • http_client typing switched from httpx to httpx2 (2.0 builds its HTTP/SSE clients and OAuth provider on httpx2); docstrings updated.
    • message.content.mimeType → mime_type.
  • base.py
    • ListResourceTemplatesResult.resourceTemplates → resource_templates (this was a silent failure before — the hasattr guard always fell through to []).
    • tool.inputSchema → tool.input_schema.
  • utils.py
    • mcp.server.fastmcp.FastMCP was removed in 2.0 → mcp.server.mcpserver.MCPServer.
    • Context.log(..., message=...) → data=... (the 2.0 signature).
  • tests/server.py, examples/mcp_server.py: FastMCP → MCPServer, prompts base import moved to mcp.server.mcpserver.prompts.
  • tests/test_client.py: mimeType → mime_type; provided HTTP client uses httpx2.AsyncClient.

How Has This Been Tested?

  • I added new unit tests to cover this change
  • I believe this change is already covered by existing unit tests

Ran the package test suites against mcp 2.0.0:

  • llama-index-tools-mcp tests: 51 passed (spins up the in-repo MCP stdio server).
  • llama-index-tools-mcp-discovery tests: 3 passed.
  • ruff check clean on the integration and tests (the example file has pre-existing docstring-style warnings unrelated to this change).

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Bump the mcp dependency to >=2.0.0,<3 and update the integration for the
2.0 breaking changes:

- Server-side FastMCP was removed; use mcp.server.mcpserver.MCPServer
  (utils.workflow_as_mcp, test server, example server).
- ClientSession.read_timeout_seconds now takes float seconds instead of a
  timedelta.
- Model fields are snake_case: tool.input_schema,
  ListResourceTemplatesResult.resource_templates, content.mime_type.
- ProgressFnT moved from mcp.shared.session to mcp.shared.dispatcher.
- Context.log now takes the payload as data= rather than message=.
- HTTP client / OAuth are built on httpx2 in 2.0, so the client's
  http_client typing and tests use httpx2.

Tests: 51 passed (tests/), 3 passed (mcp-discovery).
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 3, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 11, 2026
@logan-markewich
logan-markewich merged commit 2af7934 into run-llama:main Aug 11, 2026
11 of 12 checks passed
@ProgrammerPlus1998
ProgrammerPlus1998 deleted the feat/mcp-2x-migration branch August 12, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llama-index-tools-mcp: support mcp 2.x (Python SDK): pin blocks mcp 2.0.0

2 participants