Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Merge branch 'litellm_internal_staging' into litellm_lit4337_dcr_bridge_ui

Tin Chi Lof3bfafedc098
diff --cc ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx
index 727bc8804bd,4cd551e4d10..0ed4ee555d1
--- a/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx
@@@ -1,7 -1,6 +1,7 @@@
import React from "react";
- import { Button, Form, Input } from "antd";
+ import { Button, Checkbox, Form, Input } from "antd";
+import DcrBridgeToggle from "./DcrBridgeToggle";
- import { isClientForwardedTokenMode } from "./types";
+ import { credentialAuthClass, isClientForwardedTokenMode } from "./types";
interface PassthroughOAuthFlow {
startOAuthFlow: () => void | Promise<void>;
@@@ -24,11 -32,19 +33,21 @@@
export default function PassthroughAuthorizeSection({
authType,
oauthFlow,
+ dcrBridgeInitialChecked,
+ isEditing = false,
+ savedAuthType,
+ removeStoredApp = false,
+ onRemoveStoredAppChange,
+ appMayNotMatchUpstream = false,
}: {
authType?: string | null;
oauthFlow: PassthroughOAuthFlow;
+ dcrBridgeInitialChecked?: boolean;
+ isEditing?: boolean;
+ savedAuthType?: string | null;
+ removeStoredApp?: boolean;
+ onRemoveStoredAppChange?: (remove: boolean) => void;
+ appMayNotMatchUpstream?: boolean;
}) {
if (!isClientForwardedTokenMode(authType)) return null;
const authorizeButtonLabels: Record<string, string> = {
@@@ -44,13 -72,20 +75,20 @@@
and is never saved to LiteLLM. An OAuth app configured below IS saved with the server, so internal users who
authorize from the Tools page go through it.
</p>
+ {appMayNotMatchUpstream && (
+ <p className="text-sm text-amber-600">
+ You changed the upstream URL or endpoints; the OAuth app entered here was registered for the previous upstream
+ and may not be valid. Update the client ID, or clear it to use dynamic client registration.
+ </p>
+ )}
<Form.Item
- label={<span className="text-sm font-medium text-gray-700">OAuth Client ID (optional, saved)</span>}
+ label={<span className="text-sm font-medium text-gray-700">OAuth Client ID (optional)</span>}
name={["credentials", "client_id"]}
- extra="Only needed when the upstream does not support dynamic client registration (e.g. a pre-registered Slack app)."
+ extra={clientIdExtra}
>
<Input.Password
- placeholder="Leave blank to use dynamic client registration"
+ placeholder={clientIdPlaceholder}
+ disabled={removeStoredApp}
className="rounded-lg border-gray-300 focus:border-blue-500 focus:ring-blue-500"
/>
</Form.Item>
@@@ -63,7 -99,13 +102,14 @@@
className="rounded-lg border-gray-300 focus:border-blue-500 focus:ring-blue-500"
/>
</Form.Item>
+ <DcrBridgeToggle authType={authType} initialChecked={dcrBridgeInitialChecked} />
+ {isEditing && onRemoveStoredAppChange && (
+ <Checkbox checked={removeStoredApp} onChange={(e) => onRemoveStoredAppChange(e.target.checked)}>
+ <span className="text-sm text-gray-700">
+ Remove the saved OAuth app on save (the server goes back to dynamic client registration)
+ </span>
+ </Checkbox>
+ )}
<Button
onClick={oauthFlow.startOAuthFlow}
disabled={oauthFlow.status === "authorizing" || oauthFlow.status === "exchanging"}
diff --cc ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx
index 119b39329ed,cbd18d145ce..5b8d0aac8c0
--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx
@@@ -1737,168 -1991,3 +1991,168 @@@ describe("MCPServerEdit (max concurren
expect(payload.max_concurrent_requests).toBeNull();
});
});
+
+describe("MCPServerEdit (dcr_bridge toggle)", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mockOauth.tokenResponse = null;
+ });
+
+ const getDcrToggle = () => document.getElementById("dcr_bridge");
+
+ function renderEdit(server: Record<string, unknown>) {
+ render(
+ <MCPServerEdit
+ mcpServer={{ ...interactiveOAuthServer, ...server }}
+ accessToken="access-token"
+ onCancel={vi.fn()}
+ onSuccess={vi.fn()}
+ availableAccessGroups={[]}
+ />,
+ );
+ }
+
+ async function saveAndGetPayload() {
+ const saveButtons = screen.getAllByRole("button", { name: "Save Changes" });
+ await act(async () => {
+ fireEvent.click(saveButtons[0]);
+ });
+ await waitFor(() => {
+ expect(networking.updateMCPServer).toHaveBeenCalledTimes(1);
+ });
+ const [, payload] = vi.mocked(networking.updateMCPServer).mock.calls[0];
+ return payload;
+ }
+
+ it.each([["true_passthrough"], ["oauth_delegate"]])("renders the toggle for a %s server", async (authType) => {
+ renderEdit({ auth_type: authType });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ expect(screen.getByText("Gateway-hosted sign-in (DCR bridge)")).toBeInTheDocument();
+ });
+
+ it.each([["oauth2"], ["api_key"], ["none"]])("does not render the toggle for an %s server", async (authType) => {
+ renderEdit({ auth_type: authType });
+
+ await waitFor(() => {
+ expect(screen.getAllByRole("button", { name: "Save Changes" }).length).toBeGreaterThan(0);
+ });
+ expect(screen.queryByText("Gateway-hosted sign-in (DCR bridge)")).not.toBeInTheDocument();
+ expect(getDcrToggle()).not.toBeInTheDocument();
+ });
+
+ it("renders the toggle between the OAuth client fields and the Authorize button", async () => {
+ renderEdit({ auth_type: "true_passthrough" });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ const toggle = getDcrToggle() as HTMLElement;
- const secretInput = screen.getByPlaceholderText("Leave blank for public clients / PKCE");
++ const secretInput = screen.getByPlaceholderText("Leave blank to keep the currently saved secret (if any)");
+ const authorizeButton = screen.getByRole("button", { name: "Authorize & Fetch Tools (browser-only)" });
+ expect(secretInput.compareDocumentPosition(toggle) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(toggle.compareDocumentPosition(authorizeButton) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ });
+
+ it("initializes unchecked from a null stored value and saves an explicit false", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({
+ ...interactiveOAuthServer,
+ auth_type: "true_passthrough",
+ });
+ renderEdit({ auth_type: "true_passthrough", dcr_bridge: null });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ expect(getDcrToggle()).toHaveAttribute("aria-checked", "false");
+
+ const payload = await saveAndGetPayload();
+ expect(payload.dcr_bridge).toBe(false);
+ });
+
+ it("initializes checked from a stored true and saves an explicit true", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({
+ ...interactiveOAuthServer,
+ auth_type: "oauth_delegate",
+ dcr_bridge: true,
+ });
+ renderEdit({ auth_type: "oauth_delegate", dcr_bridge: true });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ expect(getDcrToggle()).toHaveAttribute("aria-checked", "true");
+
+ const payload = await saveAndGetPayload();
+ expect(payload.dcr_bridge).toBe(true);
+ });
+
+ it("saves an explicit false after the admin unchecks a stored true", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({
+ ...interactiveOAuthServer,
+ auth_type: "true_passthrough",
+ dcr_bridge: false,
+ });
+ renderEdit({ auth_type: "true_passthrough", dcr_bridge: true });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ await act(async () => {
+ fireEvent.click(getDcrToggle()!);
+ });
+ expect(getDcrToggle()).toHaveAttribute("aria-checked", "false");
+
+ const payload = await saveAndGetPayload();
+ expect(payload.dcr_bridge).toBe(false);
+ });
+
+ it("forces dcr_bridge: false when the auth type is switched away", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({
+ ...interactiveOAuthServer,
+ auth_type: "api_key",
+ });
+ renderEdit({ auth_type: "true_passthrough", dcr_bridge: true });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+
+ await selectAntOption("Authentication", "API Key");
+ await waitFor(() => {
+ expect(getDcrToggle()).not.toBeInTheDocument();
+ });
+
+ // Mirrors the sibling delegate_auth_to_upstream / oauth_passthrough force-false: a stale true is
+ // never left behind to silently re-activate if the mode is switched back.
+ const payload = await saveAndGetPayload();
+ expect(payload.dcr_bridge).toBe(false);
+ });
+
+ it("preserves the toggle value when switching between the two client-forwarded modes", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({
+ ...interactiveOAuthServer,
+ auth_type: "oauth_delegate",
+ dcr_bridge: true,
+ });
+ renderEdit({ auth_type: "true_passthrough", dcr_bridge: true });
+
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ expect(getDcrToggle()).toHaveAttribute("aria-checked", "true");
+
+ // The Form.Item stays mounted across the two client-forwarded modes, so the live toggle value is
+ // preserved rather than forced false by the switch.
+ await selectAntOption("Authentication", "OAuth Delegate (client-supplied upstream token)");
+ await waitFor(() => {
+ expect(getDcrToggle()).toBeInTheDocument();
+ });
+ expect(getDcrToggle()).toHaveAttribute("aria-checked", "true");
+
+ const payload = await saveAndGetPayload();
+ expect(payload.dcr_bridge).toBe(true);
+ });
+});
diff --cc ui/litellm-dashboard/src/components/mcp_tools/types.tsx
index aaddf2307ca,0aceff87143..04766aad7b4
--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
@@@ -319,8 -367,9 +367,10 @@@ export interface MCPServer
available_on_public_internet?: boolean;
delegate_auth_to_upstream?: boolean;
oauth_passthrough?: boolean;
+ dcr_bridge?: boolean | null;
max_concurrent_requests?: number | null;
+ /** Redacted to null in server responses; present when constructing a server locally. */
+ credentials?: Record<string, unknown> | null;
/** Stdio-only fields (present when transport === 'stdio') */
command?: string | null;