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
[MCP] configure static mcp header (#16179)
YutaSaito8e27b6c0b4ff
diff --git a/docs/my-website/docs/mcp.md b/docs/my-website/docs/mcp.mdindex 10405c1b493..c735b8ecdd9 100644--- a/docs/my-website/docs/mcp.md+++ b/docs/my-website/docs/mcp.md@@ -107,6 +107,26 @@ For stdio MCP servers, select "Standard Input/Output (stdio)" as the transport tstyle={{width: '80%', display: 'block', margin: '0'}}/>+<br/>+<br/>++### Static Headers++Sometimes your MCP server needs specific headers on every request. Maybe it's an API key, maybe it's a custom header the server expects. Instead of configuring auth, you can just set them directly.++<Image+ img={require('../img/static_headers.png')}+ style={{width: '80%', display: 'block', margin: '0'}}+/>++These headers get sent with every request to the server. That's it.+++**When to use this:**+- Your server needs custom headers that don't fit the standard auth patterns+- You want full control over exactly what headers are sent+- You're debugging and need to quickly add headers without changing auth configuration+</TabItem><TabItem value="config" label="config.yaml">@@ -175,6 +195,7 @@ mcp_servers:| `authorization` | `Authorization: <auth_value>` |- **Extra Headers**: Optional list of additional header names that should be forwarded from client to the MCP server+- **Static Headers**: Optional map of header key/value pairs to include every request to the MCP server.- **Spec Version**: Optional MCP specification version (defaults to `2025-06-18`)Examples for each auth type:@@ -217,28 +238,15 @@ mcp_servers:auth_type: "bearer_token"auth_value: "ghp_example_token"extra_headers: ["custom_key", "x-custom-header"] # These headers will be forwarded from client-```--### Static Headers--Sometimes your MCP server needs specific headers on every request. Maybe it's an API key, maybe it's a custom header the server expects. Instead of configuring auth, you can just set them directly.-```yaml title="config.yaml" showLineNumbers-mcp_servers:+ # Example with static headersmy_mcp_server:url: "https://my-mcp-server.com/mcp"- static_headers:+ static_headers: # These headers will be requested to the MCP serverX-API-Key: "abc123"X-Custom-Header: "some-value"```-These headers get sent with every request to the server. That's it.--**When to use this:**-- Your server needs custom headers that don't fit the standard auth patterns-- You want full control over exactly what headers are sent-- You're debugging and need to quickly add headers without changing auth configuration-### MCP AliasesYou can define aliases for your MCP servers in the `litellm_settings` section. This allows you to:diff --git a/docs/my-website/img/static_headers.png b/docs/my-website/img/static_headers.pngnew file mode 100644index 00000000000..02d67523e7fBinary files /dev/null and b/docs/my-website/img/static_headers.png differdiff --git a/litellm-proxy-extras/litellm_proxy_extras/migrations/20251103072422_add_static_headers/migration.sql b/litellm-proxy-extras/litellm_proxy_extras/migrations/20251103072422_add_static_headers/migration.sqlnew file mode 100644index 00000000000..0bedac76313--- /dev/null+++ b/litellm-proxy-extras/litellm_proxy_extras/migrations/20251103072422_add_static_headers/migration.sql@@ -0,0 +1,2 @@+-- AlterTable+ALTER TABLE "LiteLLM_MCPServerTable" ADD COLUMN "static_headers" JSONB DEFAULT '{}';diff --git a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma b/litellm-proxy-extras/litellm_proxy_extras/schema.prismaindex 605a312db4d..9702c390288 100644--- a/litellm-proxy-extras/litellm_proxy_extras/schema.prisma+++ b/litellm-proxy-extras/litellm_proxy_extras/schema.prisma@@ -182,6 +182,7 @@ model LiteLLM_MCPServerTable {mcp_access_groups String[]allowed_tools String[] @default([])extra_headers String[] @default([])+ static_headers Json? @default("{}")// Health check statusstatus String? @default("unknown")last_health_check DateTime?@@ -607,4 +608,4 @@ model LiteLLM_CacheConfig {cache_settings Jsoncreated_at DateTime @default(now())updated_at DateTime @updatedAt-}\ No newline at end of file+}diff --git a/litellm/proxy/_experimental/mcp_server/db.py b/litellm/proxy/_experimental/mcp_server/db.pyindex 22695485741..dca9af62c72 100644--- a/litellm/proxy/_experimental/mcp_server/db.py+++ b/litellm/proxy/_experimental/mcp_server/db.py@@ -35,6 +35,10 @@ def _prepare_mcp_server_data(if "alias" not in data_dict:data_dict["alias"] = getattr(data, "alias", None)+ # Handle static_headers serialization+ if data.static_headers is not None:+ data_dict["static_headers"] = safe_dumps(data.static_headers)+# Handle mcp_info serializationif data.mcp_info is not None:data_dict["mcp_info"] = safe_dumps(data.mcp_info)@@ -76,12 +80,12 @@ async def get_mcp_server("""Returns the matching mcp server from the db iff exists"""- mcp_server: Optional[LiteLLM_MCPServerTable] = (- await prisma_client.db.litellm_mcpservertable.find_unique(- where={- "server_id": server_id,- }- )+ mcp_server: Optional[+ LiteLLM_MCPServerTable+ ] = await prisma_client.db.litellm_mcpservertable.find_unique(+ where={+ "server_id": server_id,+ })return mcp_server@@ -92,12 +96,12 @@ async def get_mcp_servers("""Returns the matching mcp servers from the db with the server_ids"""- _mcp_servers: List[LiteLLM_MCPServerTable] = (- await prisma_client.db.litellm_mcpservertable.find_many(- where={- "server_id": {"in": server_ids},- }- )+ _mcp_servers: List[+ LiteLLM_MCPServerTable+ ] = await prisma_client.db.litellm_mcpservertable.find_many(+ where={+ "server_id": {"in": server_ids},+ })final_mcp_servers: List[LiteLLM_MCPServerTable] = []for _mcp_server in _mcp_servers:diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.pyindex 631aa2e897b..49ff1effd19 100644--- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py+++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py@@ -43,29 +43,25 @@ from litellm.types.mcp import MCPAuth, MCPStdioConfigfrom litellm.types.mcp_server.mcp_server_manager import MCPInfo, MCPServer-def _deserialize_env_dict(env_data: Any) -> Optional[Dict[str, str]]:+def _deserialize_json_dict(data: Any) -> Optional[Dict[str, str]]:"""- Helper function to deserialize environment dictionary from database storage.- Handles both JSON string and dictionary formats.+ Deserialize optional JSON mappings stored in the database.- Args:- env_data: The environment data from database (could be JSON string or dict)-- Returns:- Dict[str, str] or None: Deserialized environment dictionary+ Accepts values kept as JSON strings or materialized dictionaries and+ returns None when the input is empty or cannot be decoded."""- if not env_data:+ if not data:return None- if isinstance(env_data, str):+ if isinstance(data, str):try:- return json.loads(env_data)+ return json.loads(data)except (json.JSONDecodeError, TypeError):# If it's not valid JSON, return as-is (shouldn't happen but safety)return Noneelse:# Already a dictionary- return env_data+ return dataclass MCPServerManager:@@ -398,10 +394,12 @@ class MCPServerManager:try:if mcp_server.server_id not in self.get_registry():_mcp_info: MCPInfo = mcp_server.mcp_info or {}- # Use helper to deserialize environment dictionary+ # Use helper to deserialize dictionary# Safely access env field which may not exist on Prisma model objects- env_data = getattr(mcp_server, "env", None)- env_dict = _deserialize_env_dict(env_data)+ env_dict = _deserialize_json_dict(getattr(mcp_server, "env", None))+ static_headers_dict = _deserialize_json_dict(+ getattr(mcp_server, "static_headers", None)+ )# Use alias for name if present, else server_namename_for_prefix = (mcp_server.alias or mcp_server.server_name or mcp_server.server_id@@ -426,6 +424,7 @@ class MCPServerManager:auth_type=cast(MCPAuthType, mcp_server.auth_type),mcp_info=mcp_info,extra_headers=getattr(mcp_server, "extra_headers", None),+ static_headers=static_headers_dict,# oauth specific fieldsclient_id=getattr(mcp_server, "client_id", None),client_secret=getattr(mcp_server, "client_secret", None),diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.pyindex c6e00720e25..783728d5a9b 100644--- a/litellm/proxy/_types.py+++ b/litellm/proxy/_types.py@@ -964,6 +964,7 @@ class NewMCPServerRequest(LiteLLMPydanticObjectBase):mcp_access_groups: List[str] = Field(default_factory=list)allowed_tools: Optional[List[str]] = Noneextra_headers: Optional[List[str]] = None+ static_headers: Optional[Dict[str, str]] = None# Stdio-specific fieldscommand: Optional[str] = Noneargs: List[str] = Field(default_factory=list)@@ -995,6 +996,7 @@ class UpdateMCPServerRequest(LiteLLMPydanticObjectBase):url: Optional[str] = Nonemcp_info: Optional[MCPInfo] = Nonemcp_access_groups: List[str] = Field(default_factory=list)+ static_headers: Optional[Dict[str, str]] = None# Stdio-specific fieldscommand: Optional[str] = Noneargs: List[str] = Field(default_factory=list)@@ -1035,6 +1037,7 @@ class LiteLLM_MCPServerTable(LiteLLMPydanticObjectBase):allowed_tools: List[str] = Field(default_factory=list)extra_headers: List[str] = Field(default_factory=list)mcp_info: Optional[MCPInfo] = None+ static_headers: Optional[Dict[str, str]] = None# Health check statusstatus: Optional[Literal["healthy", "unhealthy", "unknown"]] = Field(default="unknown",diff --git a/litellm/proxy/schema.prisma b/litellm/proxy/schema.prismaindex 605a312db4d..760954a1d60 100644--- a/litellm/proxy/schema.prisma+++ b/litellm/proxy/schema.prisma@@ -182,6 +182,7 @@ model LiteLLM_MCPServerTable {mcp_access_groups String[]allowed_tools String[] @default([])extra_headers String[] @default([])+ static_headers Json? @default("{}")// Health check statusstatus String? @default("unknown")last_health_check DateTime?diff --git a/litellm/types/mcp_server/mcp_server_manager.py b/litellm/types/mcp_server/mcp_server_manager.pyindex 9bbec4e41d8..bba28b26aef 100644--- a/litellm/types/mcp_server/mcp_server_manager.py+++ b/litellm/types/mcp_server/mcp_server_manager.py@@ -27,6 +27,9 @@ class MCPServer(BaseModel):allowed_params: Optional[Dict[str, List[str]]] = None # map of tool names to allowed parameter lists+ static_headers: Optional[+ Dict[str, str]+ ] = None # static headers to forward to the MCP server# OAuth-specific fieldsclient_id: Optional[str] = Noneclient_secret: Optional[str] = None@@ -39,7 +42,4 @@ class MCPServer(BaseModel):args: Optional[List[str]] = Noneenv: Optional[Dict[str, str]] = Noneaccess_groups: Optional[List[str]] = None- static_headers: Optional[- Dict[str, str]- ] = None # static headers to forward to the MCP servermodel_config = ConfigDict(arbitrary_types_allowed=True)diff --git a/schema.prisma b/schema.prismaindex 605a312db4d..760954a1d60 100644--- a/schema.prisma+++ b/schema.prisma@@ -182,6 +182,7 @@ model LiteLLM_MCPServerTable {mcp_access_groups String[]allowed_tools String[] @default([])extra_headers String[] @default([])+ static_headers Json? @default("{}")// Health check statusstatus String? @default("unknown")last_health_check DateTime?diff --git a/tests/mcp_tests/test_mcp_server.py b/tests/mcp_tests/test_mcp_server.pyindex b124b81f766..6f6127ed26c 100644--- a/tests/mcp_tests/test_mcp_server.py+++ b/tests/mcp_tests/test_mcp_server.py@@ -1344,6 +1344,7 @@ def test_add_update_server_with_alias():mock_mcp_server.auth_type = Nonemock_mcp_server.description = "Test server description"mock_mcp_server.mcp_info = {}+ mock_mcp_server.static_headers = {}mock_mcp_server.command = Nonemock_mcp_server.args = []mock_mcp_server.env = None@@ -1381,6 +1382,7 @@ def test_add_update_server_without_alias():mock_mcp_server.auth_type = Nonemock_mcp_server.description = "Test server description"mock_mcp_server.mcp_info = {}+ mock_mcp_server.static_headers = {}mock_mcp_server.command = Nonemock_mcp_server.args = []mock_mcp_server.env = None@@ -1418,6 +1420,7 @@ def test_add_update_server_fallback_to_server_id():mock_mcp_server.auth_type = Nonemock_mcp_server.description = "Test server description"mock_mcp_server.mcp_info = {}+ mock_mcp_server.static_headers = {}mock_mcp_server.command = Nonemock_mcp_server.args = []mock_mcp_server.env = Nonediff --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.pyindex bfb2f4bf195..cce318654cc 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@@ -10,7 +10,7 @@ sys.path.insert(0, "../../../../../")from litellm.proxy._experimental.mcp_server.mcp_server_manager import (MCPServerManager,- _deserialize_env_dict,+ _deserialize_json_dict,)from litellm.proxy._types import LiteLLM_MCPServerTable, MCPTransportfrom litellm.types.mcp_server.mcp_server_manager import MCPServer@@ -19,21 +19,21 @@ from litellm.types.mcp_server.mcp_server_manager import MCPServerclass TestMCPServerManager:"""Test MCP Server Manager stdio functionality"""- def test_deserialize_env_dict(self):+ def test_deserialize_json_dict(self):"""Test environment dictionary deserialization"""# Test JSON stringenv_json = '{"PATH": "/usr/bin", "DEBUG": "1"}'- result = _deserialize_env_dict(env_json)+ result = _deserialize_json_dict(env_json)assert result == {"PATH": "/usr/bin", "DEBUG": "1"}# Test already dictenv_dict = {"PATH": "/usr/bin", "DEBUG": "1"}- result = _deserialize_env_dict(env_dict)+ result = _deserialize_json_dict(env_dict)assert result == {"PATH": "/usr/bin", "DEBUG": "1"}# Test invalid JSONinvalid_json = '{"PATH": "/usr/bin", "DEBUG": 1'- result = _deserialize_env_dict(invalid_json)+ result = _deserialize_json_dict(invalid_json)assert result is Nonedef test_add_update_server_stdio(self):diff --git a/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.tsx b/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.tsxindex e36ae16d43e..9286e4825cf 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/MCPPermissionManagement.tsx@@ -1,6 +1,6 @@import React, { useEffect } from "react";-import { Form, Select, Tooltip, Collapse } from "antd";-import { InfoCircleOutlined } from "@ant-design/icons";+import { Form, Select, Tooltip, Collapse, Input, Space, Button } from "antd";+import { InfoCircleOutlined, MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";import { MCPServer } from "./types";const { Panel } = Collapse;@@ -31,6 +31,13 @@ const MCPPermissionManagement: React.FC<MCPPermissionManagementProps> = ({if (mcpServer.extra_headers) {form.setFieldValue("extra_headers", mcpServer.extra_headers);}+ if (mcpServer.static_headers) {+ const staticHeaders = Object.entries(mcpServer.static_headers).map(([header, value]) => ({+ header,+ value: value != null ? String(value) : "",+ }));+ form.setFieldValue("static_headers", staticHeaders);+ }}}, [mcpServer, form]);@@ -105,6 +112,62 @@ const MCPPermissionManagement: React.FC<MCPPermissionManagementProps> = ({allowClear/></Form.Item>++ <Form.Item+ label={+ <span className="text-sm font-medium text-gray-700 flex items-center">+ Static Headers+ <Tooltip title="Send these key-value headers with every request to this MCP server.">+ <InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />+ </Tooltip>+ </span>+ }+ required={false}+ >+ <Form.List name="static_headers">+ {(fields, { add, remove }) => (+ <div className="space-y-3">+ {fields.map(({ key, name, ...restField }) => (+ <Space key={key} className="flex w-full" align="baseline" size="middle">+ <Form.Item+ {...restField}+ name={[name, "header"]}+ className="flex-1"+ rules={[{ required: true, message: "Header name is required" }]}+ >+ <Input+ size="large"+ allowClear+ className="rounded-lg"+ placeholder="Header name (e.g., X-API-Key)"+ />+ </Form.Item>+ <Form.Item+ {...restField}+ name={[name, "value"]}+ className="flex-1"+ rules={[{ required: true, message: "Header value is required" }]}+ >+ <Input+ size="large"+ allowClear+ className="rounded-lg"+ placeholder="Header value"+ />+ </Form.Item>+ <MinusCircleOutlined+ onClick={() => remove(name)}+ className="text-gray-500 hover:text-red-500 cursor-pointer"+ />+ </Space>+ ))}+ <Button type="dashed" onClick={() => add()} icon={<PlusOutlined />} block>+ Add Static Header+ </Button>+ </div>+ )}+ </Form.List>+ </Form.Item></div></Panel></Collapse>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 7c19b7589a9..e94324e6368 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@@ -60,18 +60,30 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({}};- const handleCreate = async (formValues: Record<string, any>) => {+ const handleCreate = async (values: Record<string, any>) => {setIsLoading(true);try {+ const { static_headers: staticHeadersList, stdio_config: rawStdioConfig, ...restValues } = values;+// Transform access groups into objects with name property+ const accessGroups = restValues.mcp_access_groups;- const accessGroups = formValues.mcp_access_groups;+ const staticHeaders = Array.isArray(staticHeadersList)+ ? staticHeadersList.reduce((acc: Record<string, string>, entry: Record<string, string>) => {+ const header = entry?.header?.trim();+ if (!header) {+ return acc;+ }+ acc[header] = entry?.value ?? "";+ return acc;+ }, {})+ : {} as Record<string, string>;// Process stdio configuration if presentlet stdioFields = {};- if (formValues.stdio_config && transportType === "stdio") {+ if (rawStdioConfig && transportType === "stdio") {try {- const stdioConfig = JSON.parse(formValues.stdio_config);+ const stdioConfig = JSON.parse(rawStdioConfig);// Handle both formats:// 1. Full mcpServers structure: {"mcpServers": {"server-name": {...}}}@@ -87,8 +99,8 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({actualConfig = stdioConfig.mcpServers[firstServerName];// If no alias is provided, use the server name from the JSON- if (!formValues.server_name) {- formValues.server_name = firstServerName.replace(/-/g, "_"); // Replace hyphens with underscores+ if (!restValues.server_name) {+ restValues.server_name = firstServerName.replace(/-/g, "_"); // Replace hyphens with underscores}}}@@ -108,20 +120,22 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({// Prepare the payload with cost configuration and allowed toolsconst payload = {- ...formValues,+ ...restValues,...stdioFields,// Remove the raw stdio_config field as we've extracted its componentsstdio_config: undefined,mcp_info: {- server_name: formValues.server_name || formValues.url,- description: formValues.description,+ server_name: restValues.server_name || restValues.url,+ description: restValues.description,mcp_server_cost_info: Object.keys(costConfig).length > 0 ? costConfig : null,},mcp_access_groups: accessGroups,- alias: formValues.alias,+ alias: restValues.alias,allowed_tools: allowedTools.length > 0 ? allowedTools : null,};+ payload.static_headers = staticHeaders;+console.log(`Payload: ${JSON.stringify(payload)}`);if (accessToken != null) {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 10bf7431f7d..54e1f9f9573 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@@ -32,6 +32,24 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({const [aliasManuallyEdited, setAliasManuallyEdited] = useState(false);const [allowedTools, setAllowedTools] = useState<string[]>([]);+ const initialStaticHeaders = React.useMemo(() => {+ if (!mcpServer.static_headers) {+ return [];+ }+ return Object.entries(mcpServer.static_headers).map(([header, value]) => ({+ header,+ value: value != null ? String(value) : "",+ }));+ }, [mcpServer.static_headers]);++ const initialValues = React.useMemo(+ () => ({+ ...mcpServer,+ static_headers: initialStaticHeaders,+ }),+ [mcpServer, initialStaticHeaders],+ );+// Initialize cost config from existing server datauseEffect(() => {if (mcpServer.mcp_info?.mcp_server_cost_info) {@@ -130,25 +148,39 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({if (!accessToken) return;try {// Ensure access groups is always a string array- const accessGroups = (values.mcp_access_groups || []).map((g: any) =>+ const { static_headers: staticHeadersList, ...restValues } = values;++ const accessGroups = (restValues.mcp_access_groups || []).map((g: any) =>typeof g === "string" ? g : g.name || String(g),);+ const staticHeaders = Array.isArray(staticHeadersList)+ ? staticHeadersList.reduce((acc: Record<string, string>, entry: Record<string, string>) => {+ const header = entry?.header?.trim();+ if (!header) {+ return acc;+ }+ acc[header] = entry?.value ?? "";+ return acc;+ }, {})+ : {} as Record<string, string>;+// Prepare the payload with cost configuration and permission fieldsconst payload = {- ...values,+ ...restValues,server_id: mcpServer.server_id,mcp_info: {- server_name: values.server_name || values.url,- description: values.description,+ server_name: restValues.server_name || restValues.url,+ description: restValues.description,mcp_server_cost_info: Object.keys(costConfig).length > 0 ? costConfig : null,},mcp_access_groups: accessGroups,- alias: values.alias,+ alias: restValues.alias,// Include permission management fields- extra_headers: values.extra_headers || [],+ extra_headers: restValues.extra_headers || [],allowed_tools: allowedTools.length > 0 ? allowedTools : null,- disallowed_tools: values.disallowed_tools || [],+ disallowed_tools: restValues.disallowed_tools || [],+ static_headers: staticHeaders,};const updated = await updateMCPServer(accessToken, payload);@@ -167,7 +199,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({</TabList><TabPanels className="mt-6"><TabPanel>- <Form form={form} onFinish={handleSave} initialValues={mcpServer} layout="vertical">+ <Form form={form} onFinish={handleSave} initialValues={initialValues} layout="vertical"><Form.Itemlabel="MCP Server Name"name="server_name"diff --git a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx b/ui/litellm-dashboard/src/components/mcp_tools/types.tsxindex 33990f12a94..29bb19d294f 100644--- a/ui/litellm-dashboard/src/components/mcp_tools/types.tsx+++ b/ui/litellm-dashboard/src/components/mcp_tools/types.tsx@@ -139,6 +139,7 @@ export interface MCPServer {updated_at: string;updated_by: string;extra_headers?: string[] | null;+ static_headers?: Record<string, string> | null;status?: "healthy" | "unhealthy" | "unknown";last_health_check?: string | null;health_check_error?: string | null;diff --git a/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx b/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsxindex 7f9c6f3a9ed..4c1f88ea2b5 100644--- a/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx+++ b/ui/litellm-dashboard/src/hooks/useTestMCPConnection.tsx@@ -8,6 +8,7 @@ interface MCPServerConfig {transport?: string;auth_type?: string;mcp_info?: any;+ static_headers?: Record<string, string>;}interface UseTestMCPConnectionProps {@@ -39,6 +40,8 @@ export const useTestMCPConnection = ({// Check if we have the minimum required fields to fetch toolsconst canFetchTools = !!(formValues.url && formValues.transport && formValues.auth_type && accessToken);+ const staticHeadersKey = JSON.stringify(formValues.static_headers ?? {});+const fetchTools = async () => {if (!accessToken || !formValues.url) {return;@@ -49,6 +52,28 @@ export const useTestMCPConnection = ({try {// Prepare the MCP server config from form values+ const staticHeaders = Array.isArray(formValues.static_headers)+ ? formValues.static_headers.reduce((acc: Record<string, string>, entry: Record<string, string>) => {+ const header = entry?.header?.trim();+ if (!header) {+ return acc;+ }+ acc[header] = entry?.value != null ? String(entry.value) : "";+ return acc;+ }, {})+ : !Array.isArray(formValues.static_headers) && formValues.static_headers && typeof formValues.static_headers === "object"+ ? Object.entries(formValues.static_headers).reduce(+ (acc: Record<string, string>, [header, value]) => {+ if (!header) {+ return acc;+ }+ acc[header] = value != null ? String(value) : "";+ return acc;+ },+ {},+ )+ : {} as Record<string, string>;+const mcpServerConfig: MCPServerConfig = {server_id: formValues.server_id || "",server_name: formValues.server_name || "",@@ -56,6 +81,7 @@ export const useTestMCPConnection = ({transport: formValues.transport,auth_type: formValues.auth_type,mcp_info: formValues.mcp_info,+ static_headers: staticHeaders,};const toolsResponse = await testMCPToolsListRequest(accessToken, mcpServerConfig);@@ -100,7 +126,7 @@ export const useTestMCPConnection = ({clearTools();}// eslint-disable-next-line react-hooks/exhaustive-deps- }, [formValues.url, formValues.transport, formValues.auth_type, accessToken, enabled, canFetchTools]);+ }, [formValues.url, formValues.transport, formValues.auth_type, accessToken, enabled, canFetchTools, staticHeadersKey]);return {tools,