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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(ui): extract isClientForwardedTokenMode helper for the pass-through modes
Tinee5a0651161b
diff --git a/ui/litellm-dashboard/eslint-metrics.json b/ui/litellm-dashboard/eslint-metrics.jsonindex 37bad071081..e4647b33d61 100644--- a/ui/litellm-dashboard/eslint-metrics.json+++ b/ui/litellm-dashboard/eslint-metrics.json@@ -1,7 +1,7 @@{"@typescript-eslint/no-explicit-any": 1982,"complexity": 128,- "local/no-large-inline-object-arg": 519,+ "local/no-large-inline-object-arg": 513,"local/no-long-condition-chain": 233,"max-depth": 59,"no-console": 15diff --git a/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx b/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsxindex 453e3024000..af81f2713ae 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/PassthroughAuthorizeSection.tsx@@ -1,6 +1,6 @@import React from "react";import { Button, Form, Input } from "antd";-import { AUTH_TYPE } from "./types";+import { isClientForwardedTokenMode } from "./types";interface PassthroughOAuthFlow {startOAuthFlow: () => void | Promise<void>;@@ -26,7 +26,12 @@ export default function PassthroughAuthorizeSection({authType?: string | null;oauthFlow: PassthroughOAuthFlow;}) {- if (authType !== AUTH_TYPE.TRUE_PASSTHROUGH && authType !== AUTH_TYPE.OAUTH_DELEGATE) return null;+ if (!isClientForwardedTokenMode(authType)) return null;+ const authorizeButtonLabels: Record<string, string> = {+ authorizing: "Waiting for authorization...",+ exchanging: "Exchanging authorization code...",+ };+ const authorizeButtonLabel = authorizeButtonLabels[oauthFlow.status] ?? "Authorize & Fetch Tools (browser-only)";return (<div className="rounded-lg border border-dashed border-gray-300 p-4 space-y-2 mb-4"><p className="text-sm text-gray-600">@@ -57,11 +62,7 @@ export default function PassthroughAuthorizeSection({onClick={oauthFlow.startOAuthFlow}disabled={oauthFlow.status === "authorizing" || oauthFlow.status === "exchanging"}>- {oauthFlow.status === "authorizing"- ? "Waiting for authorization..."- : oauthFlow.status === "exchanging"- ? "Exchanging authorization code..."- : "Authorize & Fetch Tools (browser-only)"}+ {authorizeButtonLabel}</Button>{oauthFlow.error && <p className="text-sm text-red-500">{oauthFlow.error}</p>}{oauthFlow.status === "success" && oauthFlow.tokenResponse?.access_token && (diff --git a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsxindex ad7d4530c92..7d160407d02 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/create_mcp_server.tsx@@ -14,6 +14,7 @@ import {getMcpOAuthMode,MCP_OAUTH2_FLOW_M2M,MCP_OAUTH2_FLOW_INTERACTIVE,+ isClientForwardedTokenMode,} from "./types";import OAuthFormFields from "./OAuthFormFields";import TruePassthroughWarning from "./TruePassthroughWarning";@@ -184,10 +185,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({description: values.description,url,transport: transport === TRANSPORT.OPENAPI ? "http" : transport,- auth_type:- values.auth_type === AUTH_TYPE.TRUE_PASSTHROUGH || values.auth_type === AUTH_TYPE.OAUTH_DELEGATE- ? values.auth_type- : AUTH_TYPE.OAUTH2,+ auth_type: isClientForwardedTokenMode(values.auth_type) ? values.auth_type : AUTH_TYPE.OAUTH2,credentials: values.credentials,authorization_url: values.authorization_url,token_url: values.token_url,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.tsxindex 0a00f05ab53..2c43b9cb056 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@@ -4,6 +4,7 @@ import { InfoCircleOutlined } from "@ant-design/icons";import { Button, TabGroup, TabList, Tab, TabPanels, TabPanel } from "@tremor/react";import {AUTH_TYPE,+ isClientForwardedTokenMode,OAUTH_FLOW,MCP_OAUTH2_FLOW_M2M,MCP_OAUTH2_FLOW_INTERACTIVE,@@ -163,10 +164,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({description: values.description || mcpServer.description,url,transport,- auth_type:- values.auth_type === AUTH_TYPE.TRUE_PASSTHROUGH || values.auth_type === AUTH_TYPE.OAUTH_DELEGATE- ? values.auth_type- : AUTH_TYPE.OAUTH2,+ auth_type: isClientForwardedTokenMode(values.auth_type) ? values.auth_type : AUTH_TYPE.OAUTH2,credentials: values.credentials,mcp_access_groups: values.mcp_access_groups || mcpServer.mcp_access_groups,static_headers: staticHeaders,@@ -181,7 +179,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({}const effectiveAuthType = form.getFieldValue("auth_type") ?? mcpServer.auth_type;- if (effectiveAuthType === AUTH_TYPE.TRUE_PASSTHROUGH || effectiveAuthType === AUTH_TYPE.OAUTH_DELEGATE) {+ if (isClientForwardedTokenMode(effectiveAuthType)) {setToken(mcpServer.server_id,{@@ -393,8 +391,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({oauth2_flow: mcpServer.oauth2_flow,delegate_auth_to_upstream: mcpServer.delegate_auth_to_upstream,}) === "passthrough";- const isBrowserHeldTokenMode =- mcpServer.auth_type === AUTH_TYPE.TRUE_PASSTHROUGH || mcpServer.auth_type === AUTH_TYPE.OAUTH_DELEGATE;+ const isBrowserHeldTokenMode = isClientForwardedTokenMode(mcpServer.auth_type);if (isPassthrough || isBrowserHeldTokenMode) {const token =oauthTokenResponse?.access_token ??diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsxindex 6c99a53afaa..928a2e3c6bb 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_tools.tsx@@ -2,7 +2,14 @@ import React, { useCallback, useEffect, useState } from "react";import { useQuery, useMutation } from "@tanstack/react-query";import { ToolTestPanel } from "./ToolTestPanel";import { resolveLogoSrc } from "@/lib/assetPaths";-import { AUTH_TYPE, MCPTool, MCPToolsViewerProps, MCPContent, CallMCPToolResponse, getMcpOAuthMode } from "./types";+import {+ isClientForwardedTokenMode,+ MCPTool,+ MCPToolsViewerProps,+ MCPContent,+ CallMCPToolResponse,+ getMcpOAuthMode,+} from "./types";import { listMCPTools, callMCPTool, getMCPOAuthUserCredentialStatus } from "../networking";import { isTokenValid, getToken, removeToken } from "@/utils/mcpTokenStore";import { sanitizeMcpAliasForHeader, buildMcpPassthroughAuthHeader } from "@/utils/mcpHeaderUtils";@@ -45,8 +52,7 @@ const MCPToolsViewer = ({// The client-forwarded token modes gate the same way as PKCE passthrough: the// browser session token (established via the browser-only Authorize in the// create/edit forms, or right here) is the upstream credential.- const usesBrowserHeldToken =- isPassthrough || auth_type === AUTH_TYPE.TRUE_PASSTHROUGH || auth_type === AUTH_TYPE.OAUTH_DELEGATE;+ const usesBrowserHeldToken = isPassthrough || isClientForwardedTokenMode(auth_type);const isAuthorizationCode = oauthMode === "authorization_code";const [oauthToken, setOauthToken] = useState<string | null>(() =>usesBrowserHeldToken && isTokenValid(serverId, userID) ? getToken(serverId, userID)?.access_token ?? null : null,diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsxindex 70cc8129bf1..dca9e574e22 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx@@ -45,6 +45,13 @@ export const AUTH_TYPE = {OAUTH_DELEGATE: "oauth_delegate",};+// The two client-forwarded token modes: the caller supplies the upstream Authorization (forwarded+// verbatim for true_passthrough, alongside LiteLLM admission for oauth_delegate). The dashboard holds+// their token in sessionStorage instead of persisting it, and the browser-authorize temp payload keeps+// their real auth_type so the backend does not treat them as needing a stored per-user token.+export const isClientForwardedTokenMode = (authType?: string | null): boolean =>+ authType === AUTH_TYPE.TRUE_PASSTHROUGH || authType === AUTH_TYPE.OAUTH_DELEGATE;+export const OAUTH_FLOW = {INTERACTIVE: "interactive",M2M: "m2m",