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]

feat(MCP/UI): add OAuth flow selector on the MCP edit page (#32298)

tin-berri12801260ce12
diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
index 61ba49729cd..d347c694366 100644
--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py
@@ -608,12 +608,15 @@ class MCPServerManager:
) -> Optional[Literal["client_credentials", "authorization_code"]]:
"""Infer oauth2_flow from field shape when the value is omitted.
- Not called directly by security sites; they go through ``effective_oauth2_flow``
- (boolean/enum decisions) or ``resolve_oauth2_flow_for_request`` (the egress object
- backstop), which are the single choke points for request-time resolution. DB rows
+ SECURITY-SENSITIVE: this is the shape-inference engine both request-time security
+ helpers delegate to, so it is what decides M2M-vs-interactive for an unstamped row.
+ Always access it through ``effective_oauth2_flow`` (boolean/enum decisions) or
+ ``resolve_oauth2_flow_for_request`` (the egress object backstop), which are the single
+ choke points for request-time resolution; do not call it directly from security sites
+ and do not weaken its M2M-shape branch without accounting for those callers. DB rows
are stamped at write time and by the startup backfill, config servers must declare
oauth2_flow (validated at load), and both builds read the value verbatim via
- ``_explicit_oauth2_flow``. Delete this whole request-time layer once the backstop
+ ``_explicit_oauth2_flow``. Delete this whole request-time layer only once the backstop
warning stays silent in production.
"""
if oauth2_flow in ("client_credentials", "authorization_code"):
@@ -4626,6 +4629,7 @@ class MCPServerManager:
authorization_url=server.authorization_url,
token_url=server.token_url,
registration_url=server.registration_url,
+ oauth2_flow=server.oauth2_flow,
allow_all_keys=server.allow_all_keys,
instructions=server.instructions,
timeout=server.timeout,
@@ -4729,6 +4733,7 @@ class MCPServerManager:
authorization_url=server.authorization_url,
token_url=server.token_url,
registration_url=server.registration_url,
+ oauth2_flow=server.oauth2_flow,
allow_all_keys=server.allow_all_keys,
available_on_public_internet=server.available_on_public_internet,
delegate_auth_to_upstream=server.delegate_auth_to_upstream,
diff --git a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
index 306c74c0d83..e0e890558af 100644
--- a/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
+++ b/tests/test_litellm/proxy/_experimental/mcp_server/test_mcp_server_manager.py
@@ -6282,3 +6282,45 @@ class TestRequestTimeOauth2FlowBackstop:
assert "no persisted oauth2_flow" in joined
assert "next proxy boot" not in joined
assert "will NOT self-heal" in joined
+
+
+def test_build_mcp_server_table_carries_oauth2_flow():
+ """GET /v1/mcp/server (list and by-id) serves registry servers through this
+ conversion; dropping oauth2_flow here blinds the dashboard to the persisted
+ flow, so the edit page cannot prefill and M2M gating never activates."""
+ manager = MCPServerManager()
+ server = MCPServer(
+ server_id="flow-table-server",
+ name="flow_table_server",
+ server_name="flow_table_server",
+ alias="flow_table_server",
+ url="https://up.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2,
+ oauth2_flow="client_credentials",
+ )
+
+ table = manager._build_mcp_server_table(server)
+
+ assert table.oauth2_flow == "client_credentials"
+
+
+def test_build_mcp_server_table_carries_null_oauth2_flow():
+ """A legacy row the backfill left unstamped must surface as oauth2_flow=None in
+ the GET response, so the dashboard maps it to undefined and prompts the admin to
+ choose a flow rather than showing a guessed default."""
+ manager = MCPServerManager()
+ server = MCPServer(
+ server_id="null-flow-server",
+ name="null_flow_server",
+ server_name="null_flow_server",
+ alias="null_flow_server",
+ url="https://up.example.com/mcp",
+ transport=MCPTransport.http,
+ auth_type=MCPAuth.oauth2,
+ oauth2_flow=None,
+ )
+
+ table = manager._build_mcp_server_table(server)
+
+ assert table.oauth2_flow is None
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.test.tsx
new file mode 100644
index 00000000000..8463a23cc16
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.test.tsx
@@ -0,0 +1,45 @@
+import React from "react";
+import { render, screen } from "@testing-library/react";
+import { describe, it, expect, vi } from "vitest";
+import MCPServerCard from "./MCPServerCard";
+import type { MCPServer } from "./types";
+
+const baseServer: MCPServer = {
+ server_id: "srv-1",
+ server_name: "demo_server",
+ alias: "demo_server",
+ transport: "http",
+ url: "https://example.com/mcp",
+ auth_type: "oauth2",
+} as MCPServer;
+
+function renderCard(overrides: Partial<MCPServer>) {
+ render(<MCPServerCard server={{ ...baseServer, ...overrides } as MCPServer} onClick={vi.fn()} />);
+}
+
+describe("MCPServerCard OAuth flow indicator", () => {
+ it("shows the 'OAuth flow not set' badge for an oauth2 server with no oauth2_flow", () => {
+ renderCard({ auth_type: "oauth2", oauth2_flow: null });
+ expect(screen.getByText("OAuth flow not set")).toBeInTheDocument();
+ });
+
+ it("does not show the badge once oauth2_flow is set (client_credentials)", () => {
+ renderCard({ auth_type: "oauth2", oauth2_flow: "client_credentials" });
+ expect(screen.queryByText("OAuth flow not set")).not.toBeInTheDocument();
+ });
+
+ it("does not show the badge once oauth2_flow is set (authorization_code)", () => {
+ renderCard({ auth_type: "oauth2", oauth2_flow: "authorization_code" });
+ expect(screen.queryByText("OAuth flow not set")).not.toBeInTheDocument();
+ });
+
+ it("does not show the badge for a non-oauth2 server", () => {
+ renderCard({ auth_type: "api_key", oauth2_flow: null });
+ expect(screen.queryByText("OAuth flow not set")).not.toBeInTheDocument();
+ });
+
+ it("does not show the badge for a delegate (PKCE passthrough) server", () => {
+ renderCard({ auth_type: "oauth2", oauth2_flow: null, delegate_auth_to_upstream: true });
+ expect(screen.queryByText("OAuth flow not set")).not.toBeInTheDocument();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.tsx b/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.tsx
index 082024fc853..c16ad87980e 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/MCPServerCard.tsx
@@ -8,7 +8,7 @@ import {
MoreOutlined,
ThunderboltOutlined,
} from "@ant-design/icons";
-import type { MCPServer } from "./types";
+import { AUTH_TYPE, type MCPServer } from "./types";
import { getMaskedAndFullUrl } from "./utils";
const { Text } = Typography;
@@ -57,6 +57,14 @@ const MCPServerCard: FC<MCPServerCardProps> = ({
const transport = server.transport || "http";
const displayTransport = server.spec_path && transport !== "stdio" ? "openapi" : transport;
const authType = server.auth_type || "none";
+ // An oauth2 server with no persisted oauth2_flow was never classified as M2M vs
+ // interactive; flag it so an admin can set it from the edit page (see the OAuth
+ // Flow Type selector) instead of leaving LiteLLM to fall back to a default.
+ // Delegate (PKCE passthrough) servers authenticate upstream and route to
+ // passthrough regardless of oauth2_flow, so the classification does not apply to
+ // them and they are not flagged.
+ const oauthFlowUnset =
+ server.auth_type === AUTH_TYPE.OAUTH2 && !server.oauth2_flow && !server.delegate_auth_to_upstream;
const status = server.status || "unknown";
const healthTone = HEALTH_TONE[status] ?? HEALTH_TONE.unknown;
const isPublic = server.available_on_public_internet;
@@ -203,6 +211,16 @@ const MCPServerCard: FC<MCPServerCardProps> = ({
/>
<Tag className="m-0">{displayTransport.toUpperCase()}</Tag>
<Tag className="m-0">{authType}</Tag>
+ {oauthFlowUnset && (
+ <Tooltip title="This OAuth server has no flow set (Machine-to-Machine vs Interactive). Open it and choose an OAuth Flow Type so LiteLLM authenticates it as you intend.">
+ <Tag color="warning" className="m-0">
+ <span className="inline-flex items-center gap-1">
+ <ExclamationCircleFilled />
+ OAuth flow not set
+ </span>
+ </Tag>
+ </Tooltip>
+ )}
<Tag color={isPublic ? "green" : "orange"} className="m-0">
<span className="inline-flex items-center gap-1">
<span className={`h-1.5 w-1.5 rounded-full ${isPublic ? "bg-green-500" : "bg-orange-500"}`} />
diff --git 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
index 7671f29b5e6..7bf197f7784 100644
--- 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
@@ -1039,7 +1039,7 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => {
});
});
-describe("MCPServerEdit oauth2_flow preservation", () => {
+describe("MCPServerEdit oauth2_flow selector", () => {
beforeEach(() => {
vi.clearAllMocks();
});
@@ -1078,19 +1078,155 @@ describe("MCPServerEdit oauth2_flow preservation", () => {
expect(payload).not.toHaveProperty("oauth2_flow");
});
- it("never writes oauth2_flow over an explicit client_credentials row", async () => {
+ it("re-writes an explicit client_credentials row with its own prefilled value", async () => {
const payload = await saveAndGetPayload({
oauth2_flow: "client_credentials",
token_url: "https://idp.example.com/oauth/token",
});
- expect(payload).not.toHaveProperty("oauth2_flow");
+ expect(payload.oauth2_flow).toBe("client_credentials");
});
- it("never writes oauth2_flow over the DCR authorization_code stamp", async () => {
+ it("re-writes the DCR authorization_code stamp with its own prefilled value", async () => {
const payload = await saveAndGetPayload({
oauth2_flow: "authorization_code",
token_url: "https://idp.example.com/oauth/token",
});
- expect(payload).not.toHaveProperty("oauth2_flow");
+ expect(payload.oauth2_flow).toBe("authorization_code");
+ });
+
+ it("persists client_credentials when the admin selects M2M on a legacy null-flow row", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({ ...interactiveOAuthServer });
+
+ render(
+ <MCPServerEdit
+ mcpServer={{
+ ...interactiveOAuthServer,
+ token_url: "https://idp.example.com/oauth/token",
+ oauth2_flow: null,
+ }}
+ accessToken="access-token"
+ onCancel={vi.fn()}
+ onSuccess={vi.fn()}
+ availableAccessGroups={[]}
+ />,
+ );
+
+ await selectAntOption("OAuth Flow Type", "Machine-to-Machine (M2M)");
+
+ 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];
+ expect(payload.oauth2_flow).toBe("client_credentials");
+ });
+
+ it("persists authorization_code when the admin selects Interactive on a legacy null-flow row", async () => {
+ vi.mocked(networking.updateMCPServer).mockResolvedValue({ ...interactiveOAuthServer });
+
+ render(
+ <MCPServerEdit
+ mcpServer={{
+ ...interactiveOAuthServer,
+ token_url: "https://idp.example.com/oauth/token",
+ oauth2_flow: null,
+ }}
+ accessToken="access-token"
+ onCancel={vi.fn()}
+ onSuccess={vi.fn()}
+ availableAccessGroups={[]}
+ />,
+ );
+
+ await selectAntOption("OAuth Flow Type", "Interactive (PKCE)");
+
+ 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];
+ expect(payload.oauth2_flow).toBe("authorization_code");
+ });
+});
+
+describe("MCPServerEdit OAuth flow prefill display", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ function renderEdit(server: Record<string, unknown>) {
+ render(
+ <MCPServerEdit
+ mcpServer={{ ...interactiveOAuthServer, ...server }}
+ accessToken="access-token"
+ onCancel={vi.fn()}
+ onSuccess={vi.fn()}
+ availableAccessGroups={[]}
+ />,
+ );
+ }
+
+ it("shows the placeholder and preselects nothing for a null-flow server (prompts the user to define it)", () => {
+ renderEdit({ oauth2_flow: null, token_url: "https://idp.example.com/oauth/token" });
+
+ // The select renders its placeholder (undefined value), not a guessed option.
+ expect(screen.getByText("Select OAuth flow")).toBeInTheDocument();
+ // Neither flow is preselected as the current value.
+ expect(screen.queryByText("Machine-to-Machine (M2M)")).not.toBeInTheDocument();
+ expect(screen.queryByText("Interactive (PKCE)")).not.toBeInTheDocument();
+ });
+
+ it("prefills Machine-to-Machine (M2M) for a stored client_credentials server", () => {
+ renderEdit({ oauth2_flow: "client_credentials" });
+
+ expect(screen.getByText("Machine-to-Machine (M2M)")).toBeInTheDocument();
+ expect(screen.queryByText("Select OAuth flow")).not.toBeInTheDocument();
+ });
+
+ it("prefills Interactive (PKCE) for a stored authorization_code server", () => {
+ renderEdit({ oauth2_flow: "authorization_code" });
+
+ expect(screen.getByText("Interactive (PKCE)")).toBeInTheDocument();
+ expect(screen.queryByText("Select OAuth flow")).not.toBeInTheDocument();
+ });
+
+ it("warns when a server has no OAuth flow set", () => {
+ renderEdit({ oauth2_flow: null, token_url: "https://idp.example.com/oauth/token" });
+
+ expect(screen.getByText("This server has no OAuth flow set")).toBeInTheDocument();
+ });
+
+ it("does not warn when the flow is already set", () => {
+ renderEdit({ oauth2_flow: "client_credentials" });
+
+ expect(screen.queryByText("This server has no OAuth flow set")).not.toBeInTheDocument();
+ });
+
+ it("does not warn for a delegate (PKCE passthrough) server even with no flow set", () => {
+ renderEdit({ oauth2_flow: null, delegate_auth_to_upstream: true });
+
+ expect(screen.queryByText("This server has no OAuth flow set")).not.toBeInTheDocument();
+ });
+
+ it("clears the warning once the admin selects a flow", async () => {
+ renderEdit({ oauth2_flow: null, token_url: "https://idp.example.com/oauth/token" });
+
+ expect(screen.getByText("This server has no OAuth flow set")).toBeInTheDocument();
+
+ await selectAntOption("OAuth Flow Type", "Machine-to-Machine (M2M)");
+
+ await waitFor(() => {
+ expect(screen.queryByText("This server has no OAuth flow set")).not.toBeInTheDocument();
+ });
});
});
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
index 413c7f1e11b..4bdec95fbb6 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx
@@ -1,15 +1,17 @@
import React, { useState, useEffect } from "react";
-import { Form, Select, Button as AntdButton, Tooltip, Input, InputNumber } from "antd";
+import { Form, Select, Button as AntdButton, Tooltip, Input, InputNumber, Alert } from "antd";
import { InfoCircleOutlined } from "@ant-design/icons";
import { Button, TabGroup, TabList, Tab, TabPanels, TabPanel } from "@tremor/react";
import {
AUTH_TYPE,
OAUTH_FLOW,
MCP_OAUTH2_FLOW_M2M,
+ MCP_OAUTH2_FLOW_INTERACTIVE,
MCPServer,
MCPServerCostInfo,
TRANSPORT,
getMcpOAuthMode,
+ oauth2FlowToFormValue,
} from "./types";
import { updateMCPServer, listMCPTools, storeMCPOAuthUserCredential } from "../networking";
import { getToken, isTokenValid, setToken } from "@/utils/mcpTokenStore";
@@ -76,6 +78,11 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
const isAwsSigV4AuthType = authType === AUTH_TYPE.AWS_SIGV4;
const oauthFlowTypeValue = Form.useWatch("oauth_flow_type", form) as string | undefined;
const isM2MFlow = isOAuthAuthType && oauthFlowTypeValue === OAUTH_FLOW.M2M;
+ // Watch reflects a live toggle when the delegate switch is mounted; fall back to
+ // the stored value otherwise (useWatch returns undefined for an unmounted field,
+ // the same trap the oauth_flow_type field originally hit).
+ const delegateAuthWatched = Form.useWatch("delegate_auth_to_upstream", form) as boolean | undefined;
+ const isDelegateAuth = delegateAuthWatched ?? Boolean(mcpServer.delegate_auth_to_upstream);
// Watch form fields that affect tool fetching
const currentUrl = Form.useWatch("url", form);
@@ -225,7 +232,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
static_headers: initialStaticHeaders,
env_vars: initialEnvVars,
extra_headers: mcpServer.extra_headers || [],
- oauth_flow_type: mcpServer.oauth2_flow === MCP_OAUTH2_FLOW_M2M ? OAUTH_FLOW.M2M : OAUTH_FLOW.INTERACTIVE,
+ oauth_flow_type: oauth2FlowToFormValue(mcpServer.oauth2_flow),
token_validation_json: mcpServer.token_validation
? JSON.stringify(mcpServer.token_validation, null, 2)
: undefined,
@@ -681,6 +688,12 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
? Boolean(oauthPassthroughRaw ?? mcpServer.oauth_passthrough)
: false;
})(),
+ ...(restValues.auth_type === AUTH_TYPE.OAUTH2 && restValues.oauth_flow_type
+ ? {
+ oauth2_flow:
+ restValues.oauth_flow_type === OAUTH_FLOW.M2M ? MCP_OAUTH2_FLOW_M2M : MCP_OAUTH2_FLOW_INTERACTIVE,
+ }
+ : {}),
// Include token_validation when it is set (non-null) or when clearing an existing value
...(tokenValidation !== null || mcpServer.token_validation ? { token_validation: tokenValidation } : {}),
};
@@ -929,6 +942,31 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
{!isStdioTransport && isOAuthAuthType && (
<>
+ <Form.Item
+ label={
+ <span className="text-sm font-medium text-gray-700 flex items-center">
+ OAuth Flow Type
+ <Tooltip title="Machine-to-Machine (M2M) authenticates with client credentials and no user interaction. Interactive (PKCE) authorizes each user in the browser and stores per-user tokens. Servers created before this field existed have no stored value; choose one to persist it.">
+ <InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
+ </Tooltip>
+ </span>
+ }
+ name="oauth_flow_type"
+ >
+ <Select placeholder="Select OAuth flow">
+ <Select.Option value={OAUTH_FLOW.M2M}>Machine-to-Machine (M2M)</Select.Option>
+ <Select.Option value={OAUTH_FLOW.INTERACTIVE}>Interactive (PKCE)</Select.Option>
+ </Select>
+ </Form.Item>
+ {!oauthFlowTypeValue && !isDelegateAuth && (
+ <Alert
+ type="warning"
+ showIcon
+ className="mb-4 rounded-lg"
+ message="This server has no OAuth flow set"
+ description="Choose Machine-to-Machine (M2M) or Interactive (PKCE) so LiteLLM authenticates it the way you intend, then save. Until it is set, LiteLLM falls back to interactive per-user auth and treats a machine-to-machine credential shape conservatively."
+ />
+ )}
<Form.Item
label={
<span className="text-sm font-medium text-gray-700 flex items-center">
@@ -1262,8 +1300,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
auth_type: currentAuthType ?? mcpServer.auth_type,
mcp_info: mcpServer.mcp_info,
oauth_flow_type:
- oauthFlowTypeValue ??
- (mcpServer.oauth2_flow === MCP_OAUTH2_FLOW_M2M ? OAUTH_FLOW.M2M : OAUTH_FLOW.INTERACTIVE),
+ oauthFlowTypeValue ?? oauth2FlowToFormValue(mcpServer.oauth2_flow) ?? OAUTH_FLOW.INTERACTIVE,
static_headers: currentStaticHeaders ?? mcpServer.static_headers,
credentials: currentCredentials,
authorization_url: currentAuthorizationUrl ?? mcpServer.authorization_url,
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.test.tsx
index 6f050d22fb4..1fbb1388cbe 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/types.test.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.test.tsx
@@ -7,6 +7,7 @@ import {
handleTransport,
handleAuth,
getMcpOAuthMode,
+ oauth2FlowToFormValue,
} from "./types";
describe("handleTransport", () => {
@@ -126,3 +127,18 @@ describe("getMcpOAuthMode", () => {
);
});
});
+
+describe("oauth2FlowToFormValue", () => {
+ it("maps client_credentials to the M2M select value", () => {
+ expect(oauth2FlowToFormValue(MCP_OAUTH2_FLOW_M2M)).toBe(OAUTH_FLOW.M2M);
+ });
+
+ it("maps authorization_code to the Interactive select value", () => {
+ expect(oauth2FlowToFormValue("authorization_code")).toBe(OAUTH_FLOW.INTERACTIVE);
+ });
+
+ it("returns undefined for a null/unset flow so the select shows its placeholder", () => {
+ expect(oauth2FlowToFormValue(null)).toBeUndefined();
+ expect(oauth2FlowToFormValue(undefined)).toBeUndefined();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
index ebf7c919b48..583191791a9 100644
--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx
@@ -71,6 +71,16 @@ export function getMcpOAuthMode(s: {
return s.delegate_auth_to_upstream ? "passthrough" : "obo";
}
+// Map a server's stored `oauth2_flow` (the API value: client_credentials /
+// authorization_code / null) to the edit form's OAuth Flow Type select value.
+// A null/unset flow returns undefined so the select shows its placeholder rather
+// than a guessed default — an unstamped legacy row must be assigned explicitly.
+export function oauth2FlowToFormValue(oauth2Flow?: string | null): string | undefined {
+ if (oauth2Flow === MCP_OAUTH2_FLOW_M2M) return OAUTH_FLOW.M2M;
+ if (oauth2Flow) return OAUTH_FLOW.INTERACTIVE;
+ return undefined;
+}
+
export const TRANSPORT = {
SSE: "sse",
HTTP: "http",