mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
feat: feat: allow_all_keys to mcp server on the UI
This commit is contained in:
parent
f1d77ae14d
commit
38a20b8036
5 changed files with 55 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import React, { useEffect } from "react";
|
||||
import { Form, Select, Tooltip, Collapse, Input, Space, Button } from "antd";
|
||||
import { Form, Select, Tooltip, Collapse, Input, Space, Button, Switch } from "antd";
|
||||
import { InfoCircleOutlined, MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
import { MCPServer } from "./types";
|
||||
const { Panel } = Collapse;
|
||||
|
|
@ -38,6 +38,11 @@ const MCPPermissionManagement: React.FC<MCPPermissionManagementProps> = ({
|
|||
}));
|
||||
form.setFieldValue("static_headers", staticHeaders);
|
||||
}
|
||||
if (typeof mcpServer.allow_all_keys === "boolean") {
|
||||
form.setFieldValue("allow_all_keys", mcpServer.allow_all_keys);
|
||||
}
|
||||
} else {
|
||||
form.setFieldValue("allow_all_keys", false);
|
||||
}
|
||||
}, [mcpServer, form]);
|
||||
|
||||
|
|
@ -57,6 +62,26 @@ const MCPPermissionManagement: React.FC<MCPPermissionManagementProps> = ({
|
|||
className="border-0"
|
||||
>
|
||||
<div className="space-y-6 pt-4">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<span className="text-sm font-medium text-gray-700 flex items-center">
|
||||
Allow All LiteLLM Keys
|
||||
<Tooltip title="When enabled, every API key can access this MCP server.">
|
||||
<InfoCircleOutlined className="ml-2 text-blue-400 hover:text-blue-600 cursor-help" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
<p className="text-sm text-gray-600 mt-1">Enable if this server should be "public" to all keys.</p>
|
||||
</div>
|
||||
<Form.Item
|
||||
name="allow_all_keys"
|
||||
valuePropName="checked"
|
||||
initialValue={mcpServer?.allow_all_keys ?? false}
|
||||
className="mb-0"
|
||||
>
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item
|
||||
label={
|
||||
<span className="text-sm font-medium text-gray-700 flex items-center">
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
|
|||
static_headers: staticHeadersList,
|
||||
stdio_config: rawStdioConfig,
|
||||
credentials: credentialValues,
|
||||
allow_all_keys: allowAllKeysRaw,
|
||||
...restValues
|
||||
} = values;
|
||||
|
||||
|
|
@ -278,6 +279,7 @@ const CreateMCPServer: React.FC<CreateMCPServerProps> = ({
|
|||
mcp_access_groups: accessGroups,
|
||||
alias: restValues.alias,
|
||||
allowed_tools: allowedTools.length > 0 ? allowedTools : null,
|
||||
allow_all_keys: Boolean(allowAllKeysRaw),
|
||||
static_headers: staticHeaders,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -286,7 +286,12 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
|
|||
if (!accessToken) return;
|
||||
try {
|
||||
// Ensure access groups is always a string array
|
||||
const { static_headers: staticHeadersList, credentials: credentialValues, ...restValues } = values;
|
||||
const {
|
||||
static_headers: staticHeadersList,
|
||||
credentials: credentialValues,
|
||||
allow_all_keys: allowAllKeysRaw,
|
||||
...restValues
|
||||
} = values;
|
||||
|
||||
const accessGroups = (restValues.mcp_access_groups || []).map((g: any) =>
|
||||
typeof g === "string" ? g : g.name || String(g),
|
||||
|
|
@ -339,6 +344,7 @@ const MCPServerEdit: React.FC<MCPServerEditProps> = ({
|
|||
allowed_tools: allowedTools.length > 0 ? allowedTools : null,
|
||||
disallowed_tools: restValues.disallowed_tools || [],
|
||||
static_headers: staticHeaders,
|
||||
allow_all_keys: Boolean(allowAllKeysRaw ?? mcpServer.allow_all_keys),
|
||||
};
|
||||
|
||||
const includeCredentials = restValues.auth_type && AUTH_TYPES_REQUIRING_CREDENTIALS.includes(restValues.auth_type);
|
||||
|
|
|
|||
|
|
@ -229,6 +229,25 @@ export const MCPServerView: React.FC<MCPServerViewProps> = ({
|
|||
<Text className="font-medium">Auth Type</Text>
|
||||
<div>{handleAuth(mcpServer.auth_type)}</div>
|
||||
</div>
|
||||
<div>
|
||||
<Text className="font-medium">Allow All LiteLLM Keys</Text>
|
||||
<div className="flex items-center gap-2">
|
||||
{mcpServer.allow_all_keys ? (
|
||||
<span className="px-2 py-1 bg-green-50 text-green-700 rounded-md text-sm">
|
||||
Enabled
|
||||
</span>
|
||||
) : (
|
||||
<span className="px-2 py-1 bg-gray-100 text-gray-600 rounded-md text-sm">
|
||||
Disabled
|
||||
</span>
|
||||
)}
|
||||
{mcpServer.allow_all_keys && (
|
||||
<Text className="text-xs text-gray-500">
|
||||
All keys can access this MCP server
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Text className="font-medium">Access Groups</Text>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ export interface MCPServer {
|
|||
teams?: Team[];
|
||||
mcp_access_groups?: string[];
|
||||
allowed_tools?: string[];
|
||||
allow_all_keys?: boolean;
|
||||
}
|
||||
|
||||
export interface MCPServerProps {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue