Skip to content

test(mcp): migrate the mcp test helpers to the mcp 2.x MCPServer API - #42075

Merged
yuneng-berri merged 1 commit into
rc/1.103.0from
litellm_rc_1_103_0_mcp2_test_helpers
Sep 20, 2026
Merged

yuneng-berri merged 1 commit into
rc/1.103.0from
litellm_rc_1_103_0_mcp2_test_helpers

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • integration-extensions is red on rc/1.103.0
  • Two test helpers still import mcp.server.fastmcp
  • pyproject pins mcp>=2.2.0,<3, where that module is gone

How it solves it:

  • Ports the helpers verbatim from main
  • No product code changes; two test files only

User Flow

Not user-facing. This changes test helpers only; no runtime behavior on any route.

Relevant issues

Affected release

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests — not applicable: this repairs existing tests that could not be collected
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5

Screenshots / Proof of Fix

Root cause: mcp 2.x renamed FastMCP to MCPServer and moved stateless_http, json_response, transport_security, host and port off the constructor onto streamable_http_app() and run(). pyproject.toml pins mcp>=2.2.0,<3, so the v1 import raises at collection. No product code under litellm/ or enterprise/ uses FastMCP — this is test-support only.

Why main is green and the rc is not: the same migration landed on main in 479360ae87, after rc/1.103.0 was cut at fba00f5084. The rc caught the window where an earlier revert (57c757e9d7) was in effect. Only the two helper files are taken from that commit; the rest of it restores unrelated test surface that does not belong on a release candidate.

Setup, both sides:

PYTHONPATH=$PWD/tests:$PWD .venv/bin/python -m pytest \
  tests/integration/mcp/test_mcp_lifecycle.py \
  tests/integration/mcp/test_mcp_protocol_errors.py \
  tests/integration/mcp/test_oauth_configuration.py \
  tests/integration/compatibility/test_persisted_toolsets.py --collect-only -q

Before (fba00f5)

  1. Run the command above
  2. ModuleNotFoundError: No module named 'mcp.server.fastmcp' on all 4 modules
  3. no tests collected, 4 errors in 0.31s

After (9f79a59)

  1. Run the same command
  2. Zero mcp.server.fastmcp errors
  3. 6 tests collected in 0.23s

Type

✅ Test

Caveats (if any)

Low

  • tests/mcp_tests/mcp_server.py still imports FastMCP on main and here
  • It is launched as a subprocess, not imported, so it does not break collection
  • Left alone to keep this port minimal; worth a separate follow-up

pyproject pins mcp>=2.2.0,<3, where FastMCP was renamed to MCPServer and
stateless_http, json_response, transport_security, host and port moved off
the constructor onto streamable_http_app() and run(). The two helpers still
imported mcp.server.fastmcp, so every module reaching them died at collection
and integration-extensions went red on the release candidate.

This ports the helpers verbatim from main, where the same migration already
landed in 479360a after rc/1.103.0 was cut. Only the two helper files are
taken; the rest of that commit restores unrelated test surface.

Collection on the four affected modules: 4 errors and 0 tests before, 0
errors and 6 tests after.
@greptile-apps

greptile-apps Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge because it preserves the existing test-helper contracts while adopting the pinned MCP 2.x API

Summary

Migrates two MCP test helpers from the removed FastMCP module to the MCP 2.x MCPServer API while retaining their existing behavior

  • Moves stateless HTTP, JSON response, and transport-security options to streamable_http_app
  • Moves host, port, and transport-security options to MCPServer.run
  • Preserves tool registration, request capture, and synthetic failure coverage

Reviews (1) · Last reviewed commit: "test(mcp): migrate the mcp test helpers ..."

@yuneng-berri
yuneng-berri merged commit 840f033 into rc/1.103.0 Sep 20, 2026
7 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_rc_1_103_0_mcp2_test_helpers branch September 20, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant