Repository navigation
refactor(mcp): upgrade SDK2 while preserving legacy gateway behavior #41718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
eebc76c
fix(deps): correct minimum versions for supported Python releases
joshua-berri 3519d01
test(mcp): add isolated SDK2 dependency compatibility gate
joshua-berri 0a87dc6
ci(deps): run wheel installation gates in GitHub Actions
joshua-berri 1dbcf31
ci(mcp): run isolated dependency gates in GitHub Actions
joshua-berri c19b5c5
ci(deps): document pinned action versions
joshua-berri b42e282
ci(mcp): document pinned workflow action versions
joshua-berri 6aa921c
fix(ci): run dependency tests in an isolated Python environment
joshua-berri 21beb9b
fix(ci): verify coverage uploads and normalize dependency inventories
joshua-berri dfd0474
fix(ci): preserve repository paths in dependency coverage reports
joshua-berri 4bc3f1d
build(deps): migrate MCP integration to MCP SDK 2.2.0
joshua-berri 5dc0131
refactor(mcp): port MCP client and server helpers to MCP SDK 2
joshua-berri 545bbeb
test(mcp): update MCP suites for SDK 2 APIs
joshua-berri 7830380
refactor(mcp): register SDK2 request handlers and drop request_ctx Co…
joshua-berri 0d2963f
test(mcp): update MCP suites for SDK2 handler signatures and ctx var
joshua-berri 8d8a2c3
ci(mcp): add dependency-resolution workflow for the SDK 2 floor
joshua-berri 8d8efe7
style(mcp): satisfy lint and type budgets for the SDK 2 port
joshua-berri 7410d00
merge(main): resolve mcp server.py import conflict and relock
joshua-berri 4a7d8bb
fix(mcp): resolve SDK2 wire-shape regressions in guardrail, arize, an…
joshua-berri a873ead
test(mcp): read SDK2 snake_case fields on CallToolResult
joshua-berri 77cf6c2
ci(mcp): keep dependency-resolution matrix to resolve and import smoke
joshua-berri aea13ee
fix(mcp): preserve legacy behavior on SDK2 and streamline verification
joshua-berri f5ab563
fix(mcp): preserve session expiry signals and scope dependency CI
joshua-berri c91ca90
fix(mcp): retain wire aliases in guardrail inspection payloads
joshua-berri fb56a14
chore(mcp): merge main with unit test timeout safeguards
joshua-berri 8f3562e
ci(mcp): consolidate integration tests into shared workflow
joshua-berri 78e1103
fix(ci): preserve shared runner setup time allowance
joshua-berri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: LiteLLM MCP Dependency Resolution | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - litellm_internal_staging | ||
| - litellm_oss_staging | ||
| - "litellm_**" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| resolve: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Detect relevant changes | ||
| id: changes | ||
| uses: ./.github/actions/detect-changes | ||
| with: | ||
| category: mcp-dependencies | ||
|
|
||
| - name: Set up Python | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Set up uv | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| uses: ./.github/actions/setup-uv-with-retries | ||
| with: | ||
| version: "0.10.9" | ||
|
|
||
| - name: Cache the Rust build | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| uses: ./.github/actions/cache-cargo-build | ||
|
|
||
| - name: Verify lockfile | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| run: | | ||
| uv lock --check | ||
|
|
||
| - name: Check locked runtime installations | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| run: | | ||
| for extra in core mcp proxy; do | ||
| args=() | ||
| if [ "$extra" != core ]; then args=(--extra "$extra"); fi | ||
| UV_PROJECT_ENVIRONMENT=".venv-$extra" .github/scripts/uv_sync_with_retries.sh --frozen --no-dev --no-editable --python ${{ matrix.python-version }} "${args[@]}" | ||
| uv pip check --python ".venv-$extra" | ||
| if [ "$extra" = core ]; then | ||
| checker=("$GITHUB_WORKSPACE/tests/base_sdk_tests/check_base_sdk_install.py") | ||
| else | ||
| checker=("$GITHUB_WORKSPACE/scripts/check_mcp_sdk_install.py" --extra "$extra") | ||
| fi | ||
| (cd "$RUNNER_TEMP" && "$GITHUB_WORKSPACE/.venv-$extra/bin/python" "${checker[@]}") | ||
| done | ||
|
|
||
| - name: Build the public wheel | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| run: uv build --all-packages --wheel --out-dir dist/mcp-check | ||
|
|
||
| - name: Check lowest direct runtime installations | ||
| if: steps.changes.outputs.decision != 'skip' | ||
| run: | | ||
| wheel=$(realpath dist/mcp-check/litellm-[0-9]*.whl) | ||
| for extra in core mcp proxy; do | ||
| args=() | ||
| if [ "$extra" != core ]; then args=(--extra "$extra"); fi | ||
| uv pip compile pyproject.toml --no-sources --find-links dist/mcp-check "${args[@]}" --python-version ${{ matrix.python-version }} --resolution lowest-direct -o "lowest-$extra.txt" | ||
| uv venv --python ${{ matrix.python-version }} ".venv-lowest-$extra" | ||
| uv pip sync --find-links dist/mcp-check --python ".venv-lowest-$extra" "lowest-$extra.txt" | ||
| uv pip install --python ".venv-lowest-$extra" --no-deps "$wheel" | ||
| uv pip check --python ".venv-lowest-$extra" | ||
| if [ "$extra" = core ]; then | ||
| checker=("$GITHUB_WORKSPACE/tests/base_sdk_tests/check_base_sdk_install.py") | ||
| else | ||
| checker=("$GITHUB_WORKSPACE/scripts/check_mcp_sdk_install.py" --extra "$extra") | ||
| fi | ||
| (cd "$RUNNER_TEMP" && "$GITHUB_WORKSPACE/.venv-lowest-$extra/bin/python" "${checker[@]}") | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,15 @@ | ||
| # LiteLLM MCP Client | ||
|
|
||
| LiteLLM MCP Client is a client that allows you to use MCP tools with LiteLLM. | ||
| LiteLLM MCP Client allows you to use MCP tools with LiteLLM | ||
|
|
||
| ## MCP Python SDK compatibility | ||
|
|
||
| The `mcp` and `proxy` extras require MCP Python SDK 2.2 or newer within the 2.x release line. Installing core LiteLLM without these extras does not require MCP | ||
|
|
||
| Existing MCP SDK1 clients can continue connecting to the gateway over the supported legacy MCP protocols. The client and gateway can use different SDK versions in separate Python environments. Modern protocol advertisement remains disabled during the Phase 0 upgrade. An initialize body requesting `2026-07-28` falls back to the supported legacy version `2025-11-25`; an explicit `MCP-Protocol-Version: 2026-07-28` HTTP header is rejected with HTTP 400 | ||
|
|
||
| Code sharing the gateway's Python environment must support SDK2. Its Python API has breaking changes, including renamed imports and snake_case model attributes such as `input_schema`, `is_error`, and `structured_content`. This also applies to callers consuming SDK objects returned by LiteLLM's experimental MCP client. MCP JSON fields retain their protocol spelling, such as `inputSchema` and `isError` | ||
|
|
||
| Upgrade SDK1-dependent libraries before installing them alongside `litellm[mcp]` or `litellm[proxy]`, or keep those clients in a separate environment and connect over the network. For example, `langchain-mcp-adapters==0.2.1` uses SDK1 Python APIs and is tested as a separate legacy client, not as a shared SDK2 dependency | ||
|
|
||
| See the official [SDK migration guide](https://py.sdk.modelcontextprotocol.io/migration/) for Python API changes | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.