Skip to content

build: v1.89.0-rc.3 MCP cherry-picks + OAuth persist fix (deploy vehicle) - #30335

Open
tin-berri wants to merge 7 commits into
litellm_v1.89.0-rc.3_mcp_patches_basefrom
litellm_v1.89.0-rc.3_mcp_patches
Open

build: v1.89.0-rc.3 MCP cherry-picks + OAuth persist fix (deploy vehicle)#30335
tin-berri wants to merge 7 commits into
litellm_v1.89.0-rc.3_mcp_patches_basefrom
litellm_v1.89.0-rc.3_mcp_patches

Conversation

@tin-berri

Copy link
Copy Markdown
Contributor

Relevant issues

Build/deploy vehicle for the v1.89.0-rc.3 MCP cherry-picks plus the Greptile follow-up fix. These same commits already live directly on patch/v1.89.0-rc.2; this PR exists so the litellm-ops componentized image build (which clones refs/pull/<N>/head) can build the full latest state including the onSuccess fix.

Changes

Seven commits: the six MCP cherry-picks (#29867, #29951, #29960, #30000, #30041, #30141) plus fix(ui/mcp): refresh parent on OAuth token persist failure during server edit addressing the Greptile P2 on mcp_server_edit.tsx.

Type

🐛 Bug Fix

tin-berri and others added 7 commits June 12, 2026 17:23
…the Tools page (#29867)

* fix(ui): let non-creator users OAuth into OBO-mode MCP servers from the Tools page

* fix(ui): clear OBO Tools-tab one-shot on navigate-back and gate on credential-status errors
…ware GET path (#29960)

* fix(ui): load MCP tool configuration tools via the OBO/passthrough-aware GET path

* fix(mcp): admin-only include_disabled_tools so the settings UI shows toggled-off tools

* fix(ui): repopulate MCP server edit form when server data loads after mount (OAuth return)

* fix(ui): persist MCP OAuth token on save and return to the Settings tab after authorize

* fix(ui): scope MCP OAuth callback to the initiating form so create and edit flows don't cross-talk

* fix(ui): derive OAuth-return Settings tab via lazy state init instead of setState-in-effect

* Fix MCP OAuth edit token handling

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…r server's token no longer leaks into the next add-server session (#30000)

* fix(ui/mcp): reset OAuth hook state on modal close so a prior server's token no longer leaks into the next add-server session

* fix(ui/mcp): clear in-flight OAuth guard on reset and reset form/tools on modal close so nothing leaks on a parent-driven dismiss
…ess check (#30041)

* fix(mcp): honor team access-group grants in OAuth authorize/token access check

* test(mcp): mock build_effective_auth_contexts in non-admin authorize tests for isolation
…ver edit

The server config is already saved by updateMCPServer when the subsequent
per-user token persist throws, so returning early without onSuccess(updated)
left the edit form open and the parent list stale despite a committed change.
Call onSuccess(updated) before returning so the UI matches DB state; the
warning toast still replaces the success toast.
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Seven commits landing six MCP cherry-picks plus the follow-up OAuth persist fix. The changes span the full stack: Python backend (server delete cleans up credential rows, token-exchange stops fabricating a default expires_in, admin-only include_disabled_tools flag, team-grant access check via build_effective_auth_contexts) and the TypeScript UI (OBO credential gate in the Tools viewer, flowSource discrimination to prevent cross-form OAuth token theft, OAuth token persistence on edit save, form-resync on post-redirect mount).

  • Backend: delete_mcp_server now independently cleans litellm_mcpusercredentials and litellm_mcpuserenvvars; exchange_token_with_server faithfully mirrors the upstream expires_in instead of defaulting to 3600; include_disabled_tools is admin-only and properly gate-checked; the OAuth authorize endpoint expands UI session tokens through build_effective_auth_contexts so team-scoped grants are honoured.
  • UI: OBO-mode servers show an Authorize gate instead of silently listing zero tools; useMcpOAuthFlow gains flowSource matching and a reset() method; MCPToolConfiguration removes its internal fetch fallback, with the parent always owning the tool list; EDIT_OAUTH_UI_STATE_KEY is exported for import reuse but one consumer still holds a local copy.

Confidence Score: 4/5

Safe to merge; all changes are targeted MCP cherry-picks and a narrowly-scoped follow-up fix, each backed by new unit tests.

All backend changes are well-tested and the logic is straightforward. The UI changes correctly handle the cross-form OAuth token routing, the OBO credential gate, and the post-redirect form-resync. The only notable gap is the duplicate EDIT_OAUTH_UI_STATE_KEY string in mcp_servers.tsx — the constant is now exported from mcp_server_edit.tsx and imported in mcp_server_view.tsx, but mcp_servers.tsx keeps its own local copy, creating a silent mismatch risk if the key is renamed.

mcp_servers.tsx (duplicate key constant) and mcp_server_edit.tsx (eslint suppression on the fetchTools dependency array — intentional but worth a second glance).

Important Files Changed

Filename Overview
litellm/proxy/_experimental/mcp_server/db.py Extends delete_mcp_server to also purge litellm_mcpusercredentials rows alongside the existing litellm_mcpuserenvvars cleanup, using an independent try/except per table so a failure in one leg doesn't skip the other.
litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py Stops fabricating a default expires_in: 3600 when the upstream token provider omits it; now only forwards fields actually present in the provider's token response.
litellm/proxy/_experimental/mcp_server/rest_endpoints.py Adds include_disabled_tools (admin-only) query param and apply_tool_filters flag threaded through to _get_tools_for_single_server, allowing the settings UI to fetch the full server catalog before allowlist filtering is applied.
litellm/proxy/management_endpoints/mcp_management_endpoints.py Replaces a single get_allowed_mcp_servers call with iteration over build_effective_auth_contexts, so team-granted access that flows through a UI session token is correctly recognized in the authorize/token access check.
ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx Adds flowSource discrimination to prevent the create form from consuming the edit form's OAuth result; persists OBO tokens to DB and passthrough tokens to sessionStorage on save; passes include_disabled_tools=true for the tool-config fetch; adds a form-resync guard for the post-OAuth-redirect blank-form bug.
ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx Adds OBO credential-status check so users without a DB credential see an Authorize gate instead of a silent empty tool list; refactors passthrough header building into shared buildMcpPassthroughAuthHeader.
ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.tsx Adds flowSource field to stored flow state and a source-match guard in resumeOAuthFlow; adds a public reset() method to clear token/status/in-flight guard for reuse across sessions.
ui/litellm-dashboard/src/components/mcp_tools/mcp_servers.tsx Reads a one-shot TOOLS_OAUTH_UI_STATE_KEY from sessionStorage on mount to restore the correct server's Tools tab after an OBO OAuth redirect; clears the key immediately and on handleBack.
ui/litellm-dashboard/src/components/mcp_tools/mcp_server_view.tsx Adds isReturningFromEditOAuth helper to auto-select the Settings tab (index 2) on return from an edit-flow OAuth redirect; threads userID and initialTabIndex props.
ui/litellm-dashboard/src/components/mcp_tools/mcp_tool_configuration.tsx Removes the internal useTestMCPConnection fallback; component now always renders parent-provided tool state, eliminating the dual-source-of-truth risk.
ui/litellm-dashboard/src/components/networking.tsx Adds includeDisabledTools parameter to listMCPTools, appending include_disabled_tools=true to the query string when requested.
ui/litellm-dashboard/src/hooks/mcpOAuthUtils.ts Exports TOOLS_OAUTH_UI_STATE_KEY constant for the OBO redirect-resume flow, mirroring the existing EDIT_OAUTH_UI_STATE_KEY pattern.
ui/litellm-dashboard/src/utils/mcpHeaderUtils.ts Extracts buildMcpPassthroughAuthHeader helper that consolidates the alias-to-header-name logic used in multiple components.
ui/litellm-dashboard/src/hooks/useMcpOAuthFlow.test.tsx New test file for the reset() method: verifies it clears token state and unblocks the in-flight guard for a subsequent exchange.
ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx Extensive new test suites covering tool-list fetch (OBO vs passthrough, staged token), form-resync on post-redirect mount, and OAuth token persistence (OBO, passthrough, failure path).
tests/test_litellm/proxy/_experimental/mcp_server/test_rest_endpoints.py Adds tests for include_disabled_tools admin-only enforcement and apply_tool_filters=False full-catalog behavior; updates existing stubs to include the new apply_tool_filters parameter.
tests/test_litellm/proxy/management_endpoints/test_mcp_management_endpoints.py Adds a new test verifying that a team-access-group grant is recognized via build_effective_auth_contexts; patches the new mock into existing tests that previously lacked it.
tests/test_litellm/proxy/_experimental/mcp_server/test_discoverable_endpoints.py Adds tests verifying that expires_in is omitted when the upstream provider omits it and forwarded unchanged when present.
tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_env_vars.py New tests covering credential-row cleanup on server delete: success path, no-op for missing server, and independent-failure isolation between tables.

Reviews (1): Last reviewed commit: "fix(ui/mcp): refresh parent on OAuth tok..." | Re-trigger Greptile

Comment on lines +24 to 26
import { TOOLS_OAUTH_UI_STATE_KEY } from "@/hooks/mcpOAuthUtils";
import UserEnvVarsModal from "./UserEnvVarsModal";
import { listMCPUserEnvVarStatus } from "../networking";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 This PR exports EDIT_OAUTH_UI_STATE_KEY from mcp_server_edit.tsx so mcp_server_view.tsx can import it, but mcp_servers.tsx still defines its own local copy of the same string. If the key is ever renamed in mcp_server_edit.tsx, the local copy here won't be updated, silently breaking the edit-OAuth redirect-restore logic in this file.

Suggested change
import { TOOLS_OAUTH_UI_STATE_KEY } from "@/hooks/mcpOAuthUtils";
import UserEnvVarsModal from "./UserEnvVarsModal";
import { listMCPUserEnvVarStatus } from "../networking";
import { TOOLS_OAUTH_UI_STATE_KEY } from "@/hooks/mcpOAuthUtils";
import { EDIT_OAUTH_UI_STATE_KEY } from "./mcp_server_edit";
import UserEnvVarsModal from "./UserEnvVarsModal";
import { listMCPUserEnvVarStatus } from "../networking";

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