diff --git a/src/renderer/src/pages/settings/MCPSettings/index.tsx b/src/renderer/src/pages/settings/MCPSettings/index.tsx index ae84646d..e982dc1b 100644 --- a/src/renderer/src/pages/settings/MCPSettings/index.tsx +++ b/src/renderer/src/pages/settings/MCPSettings/index.tsx @@ -169,13 +169,6 @@ const McpListContainer = styled(VStack)` height: calc(100vh - var(--navbar-height)); ` -const McpListHeader = styled(HStack)` - width: 100%; - padding: 10px 12px; - padding-bottom: 0; - justify-content: center; -` - const McpList = styled(Scrollbar)` display: flex; flex: 1; diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index e45f4010..a7573c3a 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -15,7 +15,9 @@ import { SimpleStringSchema, Tool as geminiTool } from '@google/generative-ai' +import { nanoid } from '@reduxjs/toolkit' import store from '@renderer/store' +import { addMCPServer } from '@renderer/store/mcp' import { MCPServer, MCPTool, MCPToolResponse } from '@renderer/types' import { ChatCompletionMessageToolCall, ChatCompletionTool } from 'openai/resources' @@ -232,6 +234,24 @@ export async function callMCPTool(tool: MCPTool): Promise { }) console.log(`[MCP] Tool called: ${tool.serverName} ${tool.name}`, resp) + + if (tool.serverName === '@cherry/mcp-auto-install') { + if (resp.data) { + const mcpServer: MCPServer = { + id: `f${nanoid()}`, + name: resp.data.name, + description: resp.data.description, + baseUrl: resp.data.baseUrl, + command: resp.data.command, + args: resp.data.args, + env: resp.data.env, + registryUrl: '', + isActive: false + } + store.dispatch(addMCPServer(mcpServer)) + } + } + return resp } catch (e) { console.error(`[MCP] Error calling Tool: ${tool.serverName} ${tool.name}`, e)