From 23de48ecbdcaf5388fa5e0431fd57ee2b85cf0c8 Mon Sep 17 00:00:00 2001 From: MyPrototypeWhat <43230886+MyPrototypeWhat@users.noreply.github.com> Date: Thu, 3 Apr 2025 18:51:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(mcp):=20add=20registryUrl=20to=20initialSt?= =?UTF-8?q?ate=20for=20improved=20package=20manag=E2=80=A6=20(#4279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(mcp): add registryUrl to initialState for improved package management * feat(mcp): initialize registryUrl in MCP server state for future enhancements * fix(inputbar):mcp server list * refactor(Inputbar): remove unused MCP server variable and console log for cleaner code * fix(Inputbar): 还原 * fix(Inputbar): Add activedMcpServers to Inputbar component props --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 11 ++++------- src/renderer/src/store/mcp.ts | 1 + src/renderer/src/utils/mcp-tools.ts | 1 + 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 5b0e0151..fa748e76 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -180,15 +180,11 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = if (mentionModels) { userMessage.mentions = mentionModels } - if (isFunctionCallingModel(model)) { if (!isEmpty(enabledMCPs) && !isEmpty(activedMcpServers)) { - userMessage.enabledMCPs = activedMcpServers.filter((server) => - enabledMCPs?.some((s) => s.id === server.id) - ) + userMessage.enabledMCPs = activedMcpServers.filter((server) => enabledMCPs?.some((s) => s.id === server.id)) } } - userMessage.usage = await estimateMessageUsage(userMessage) currentMessageId.current = userMessage.id @@ -208,7 +204,6 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = console.error('Failed to send message:', error) } }, [ - activedMcpServers, assistant, dispatch, files, @@ -219,7 +214,9 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = resizeTextArea, selectedKnowledgeBases, text, - topic + topic, + enabledMCPs, + activedMcpServers ]) const translate = async () => { diff --git a/src/renderer/src/store/mcp.ts b/src/renderer/src/store/mcp.ts index 9b8e69ce..d2fa82a5 100644 --- a/src/renderer/src/store/mcp.ts +++ b/src/renderer/src/store/mcp.ts @@ -11,6 +11,7 @@ const initialState: MCPConfig = { baseUrl: '', command: 'npx', args: ['-y', '@mcpmarket/mcp-auto-install', 'connect', '--json'], + registryUrl: 'https://registry.npmmirror.com', env: {}, isActive: false } diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index 079472cb..ea908a7d 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -245,6 +245,7 @@ export async function callMCPTool(tool: MCPTool): Promise { command: resp.data.command, args: resp.data.args, env: resp.data.env, + registryUrl: '', isActive: false } store.dispatch(addMCPServer(mcpServer))