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 = {
appId: string;
toolName: string;
toolAlias?: string;
description: string;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -184,7 +184,7 @@ async function handler(
const app = appList.find((app) => {
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) {

View File

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