mcp server tool alias (#4621)

This commit is contained in:
heheer
2025-04-22 15:25:11 +08:00
committed by GitHub
parent 6c61812e7a
commit 2dd5cf6d1f
8 changed files with 31 additions and 4 deletions

View File

@@ -10,5 +10,6 @@ export type McpKeyType = {
export type McpAppType = { export type McpAppType = {
appId: string; appId: string;
toolName: string; toolName: string;
toolAlias?: string;
description: string; description: string;
}; };

View File

@@ -41,6 +41,9 @@ const McpKeySchema = new Schema({
toolName: { toolName: {
type: String type: String
}, },
toolAlias: {
type: String
},
description: { description: {
type: String type: String
} }

View File

@@ -2,9 +2,12 @@
"app_alias_name": "Tool name", "app_alias_name": "Tool name",
"app_description": "Application Description", "app_description": "Application Description",
"app_name": "Application name", "app_name": "Application name",
"app_tool_name": "Tool alias",
"apps": "Exposed applications", "apps": "Exposed applications",
"create_mcp": "Create an MCP service",
"create_mcp_server": "Create a new service", "create_mcp_server": "Create a new service",
"delete_mcp_server_confirm_tip": "Confirm to delete the service?", "delete_mcp_server_confirm_tip": "Confirm to delete the service?",
"edit_mcp": "Edit MCP Services",
"has_chosen": "Selected", "has_chosen": "Selected",
"manage_app": "manage", "manage_app": "manage",
"mcp_apps": "Number of associated applications", "mcp_apps": "Number of associated applications",

View File

@@ -2,9 +2,12 @@
"app_alias_name": "工具名", "app_alias_name": "工具名",
"app_description": "应用描述", "app_description": "应用描述",
"app_name": "应用名", "app_name": "应用名",
"app_tool_name": "工具别名",
"apps": "暴露的应用", "apps": "暴露的应用",
"create_mcp": "创建 MCP 服务",
"create_mcp_server": "新建服务", "create_mcp_server": "新建服务",
"delete_mcp_server_confirm_tip": "确认删除该服务?", "delete_mcp_server_confirm_tip": "确认删除该服务?",
"edit_mcp": "编辑 MCP 服务",
"has_chosen": "已选择", "has_chosen": "已选择",
"manage_app": "管理", "manage_app": "管理",
"mcp_apps": "关联应用数量", "mcp_apps": "关联应用数量",

View File

@@ -2,9 +2,12 @@
"app_alias_name": "工具名", "app_alias_name": "工具名",
"app_description": "應用描述", "app_description": "應用描述",
"app_name": "應用名", "app_name": "應用名",
"app_tool_name": "工具別名",
"apps": "暴露的應用", "apps": "暴露的應用",
"create_mcp": "創建 MCP 服務",
"create_mcp_server": "新建服務", "create_mcp_server": "新建服務",
"delete_mcp_server_confirm_tip": "確認刪除該服務?", "delete_mcp_server_confirm_tip": "確認刪除該服務?",
"edit_mcp": "編輯 MCP 服務",
"has_chosen": "已選擇", "has_chosen": "已選擇",
"manage_app": "管理", "manage_app": "管理",
"mcp_apps": "關聯應用數量", "mcp_apps": "關聯應用數量",

View File

@@ -62,6 +62,7 @@ const SelectAppModal = ({
{ {
appId: string; appId: string;
toolName: string; toolName: string;
toolAlias: string;
avatar: string; avatar: string;
description: string; description: string;
}[] }[]
@@ -75,6 +76,7 @@ const SelectAppModal = ({
data.map((item) => ({ data.map((item) => ({
appId: item.id, appId: item.id,
toolName: item.name, toolName: item.name,
toolAlias: item.name,
avatar: item.avatar, avatar: item.avatar,
description: selectedApps.find((app) => app.appId === item.id)?.description || '' description: selectedApps.find((app) => app.appId === item.id)?.description || ''
})) }))
@@ -174,6 +176,7 @@ const SelectAppModal = ({
{ {
appId: item._id, appId: item._id,
toolName: item.name, toolName: item.name,
toolAlias: item.name,
avatar: item.avatar, avatar: item.avatar,
description: item.intro description: item.intro
} }
@@ -252,7 +255,6 @@ const EditMcpModal = ({
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const isEdit = !!editMcp.id; const isEdit = !!editMcp.id;
console.log(editMcp);
const { const {
isOpen: isOpenSelectApp, isOpen: isOpenSelectApp,
onOpen: onOpenSelectApp, onOpen: onOpenSelectApp,
@@ -279,6 +281,7 @@ const EditMcpModal = ({
apps: data.apps.map((item) => ({ apps: data.apps.map((item) => ({
appId: item.appId, appId: item.appId,
toolName: item.toolName, toolName: item.toolName,
toolAlias: item.toolAlias,
description: item.description description: item.description
})) }))
}), }),
@@ -296,6 +299,7 @@ const EditMcpModal = ({
apps: data.apps.map((item) => ({ apps: data.apps.map((item) => ({
appId: item.appId, appId: item.appId,
toolName: item.toolName, toolName: item.toolName,
toolAlias: item.toolAlias,
description: item.description description: item.description
})) }))
}), }),
@@ -311,7 +315,7 @@ const EditMcpModal = ({
<> <>
<MyModal <MyModal
iconSrc="key" iconSrc="key"
title={isEdit ? '编辑MCP' : '创建MCP'} title={isEdit ? t('dashboard_mcp:edit_mcp') : t('dashboard_mcp:create_mcp')}
w={'100%'} w={'100%'}
maxW={['90vw', '600px']} maxW={['90vw', '600px']}
isOpen isOpen
@@ -336,6 +340,7 @@ const EditMcpModal = ({
<Thead> <Thead>
<Tr> <Tr>
<Th>{t('dashboard_mcp:app_name')}</Th> <Th>{t('dashboard_mcp:app_name')}</Th>
<Th>{t('dashboard_mcp:app_tool_name')}</Th>
<Th>{t('dashboard_mcp:app_description')}</Th> <Th>{t('dashboard_mcp:app_description')}</Th>
<Th></Th> <Th></Th>
</Tr> </Tr>
@@ -345,6 +350,14 @@ const EditMcpModal = ({
return ( return (
<Tr key={app.id} fontWeight={500} fontSize={'mini'} color={'myGray.900'}> <Tr key={app.id} fontWeight={500} fontSize={'mini'} color={'myGray.900'}>
<Td>{app.toolName}</Td> <Td>{app.toolName}</Td>
<Td>
<Input
{...register(`apps.${index}.toolAlias`)}
placeholder={app.toolName}
bg={'myGray.50'}
w={'100%'}
/>
</Td>
<Td> <Td>
<Input <Input
{...register(`apps.${index}.description`, { required: true })} {...register(`apps.${index}.description`, { required: true })}
@@ -400,6 +413,7 @@ const EditMcpModal = ({
e.map((item) => ({ e.map((item) => ({
appId: item.appId, appId: item.appId,
toolName: item.toolName, toolName: item.toolName,
toolAlias: item.toolAlias,
description: item.description description: item.description
})) }))
); );

View File

@@ -184,7 +184,7 @@ async function handler(
const app = appList.find((app) => { const app = appList.find((app) => {
const mcpApp = mcp.apps.find((mcpApp) => String(mcpApp.appId) === String(app._id))!; const mcpApp = mcp.apps.find((mcpApp) => String(mcpApp.appId) === String(app._id))!;
return toolName === mcpApp.toolName; return toolName === mcpApp.toolAlias || toolName === mcpApp.toolName;
}); });
if (!app) { if (!app) {

View File

@@ -138,7 +138,7 @@ async function handler(
); );
return { return {
name: mcpApp.toolName, name: mcpApp.toolAlias || mcpApp.toolName,
description: mcpApp.description, description: mcpApp.description,
inputSchema: isPlugin inputSchema: isPlugin
? pluginNodes2InputSchema(version.nodes) ? pluginNodes2InputSchema(version.nodes)