From 2b56851cda96c62fe75b095e2ca2fc60382aa57e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 13 Aug 2025 14:42:51 -0700 Subject: [PATCH] fix: MCP cleanup part 1 --- src/streamChatResponse.getAllTools.test.ts | 4 ++-- src/streamChatResponse.ts | 9 ++++++--- src/tools/index.ts | 2 +- src/ui/IntroMessage.tsx | 5 ++--- src/ui/hooks/useChat.types.ts | 1 - 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/streamChatResponse.getAllTools.test.ts b/src/streamChatResponse.getAllTools.test.ts index e5b35eef2..5af7af0dc 100644 --- a/src/streamChatResponse.getAllTools.test.ts +++ b/src/streamChatResponse.getAllTools.test.ts @@ -108,11 +108,11 @@ describe('getAllTools - Tool Filtering', () => { expect(toolNames).toContain('Edit'); }); - test('should throw error when ToolPermissionService is not initialized', () => { + test('should throw error when MCP service is not initialized', () => { // Don't initialize services - this should cause getAllTools to throw expect(() => { getAllTools(); - }).toThrow('ToolPermissionService not initialized. Services must be initialized before requesting tools.'); + }).toThrow('MCP Service not initialized'); }); test('should respect explicit exclude in normal mode', async () => { diff --git a/src/streamChatResponse.ts b/src/streamChatResponse.ts index 5d9d40914..ef386b4b5 100644 --- a/src/streamChatResponse.ts +++ b/src/streamChatResponse.ts @@ -135,16 +135,19 @@ export function getAllTools() { const allToolNames = [...builtinToolNames, ...mcpToolNames]; // Check if the ToolPermissionService is ready - const serviceResult = getServiceSync( + const permissionsServiceResult = getServiceSync( SERVICE_NAMES.TOOL_PERMISSIONS, ); let allowedToolNames: string[]; - if (serviceResult.state === "ready" && serviceResult.value) { + if ( + permissionsServiceResult.state === "ready" && + permissionsServiceResult.value + ) { // Filter out excluded tools based on permissions allowedToolNames = filterExcludedTools( allToolNames, - serviceResult.value.permissions, + permissionsServiceResult.value.permissions, ); } else { // Service not ready - this is a critical error since tools should only be diff --git a/src/tools/index.ts b/src/tools/index.ts index 66ac320b3..2bc20cc48 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -125,7 +125,7 @@ export async function getAvailableTools() { ); const tools = mcpState.mcpService?.getTools() ?? []; const mcpTools: Tool[] = - tools.map((t: any) => ({ + tools.map((t) => ({ name: t.name, displayName: t.name.replace("mcp__", "").replace("ide__", ""), description: t.description ?? "", diff --git a/src/ui/IntroMessage.tsx b/src/ui/IntroMessage.tsx index 91fae3908..5e7a10e49 100644 --- a/src/ui/IntroMessage.tsx +++ b/src/ui/IntroMessage.tsx @@ -94,8 +94,7 @@ const IntroMessage: React.FC = ({ )} - {/* Decided this is noisy for now */} - {/* // MCP Servers + {/* MCP Servers */} {config.mcpServers?.length && ( <> MCP Servers: @@ -106,7 +105,7 @@ const IntroMessage: React.FC = ({ ))} - )} */} + )} ); }; diff --git a/src/ui/hooks/useChat.types.ts b/src/ui/hooks/useChat.types.ts index b5e0ba6d0..8660cd717 100644 --- a/src/ui/hooks/useChat.types.ts +++ b/src/ui/hooks/useChat.types.ts @@ -59,5 +59,4 @@ export interface SlashCommandResult { openModelSelector?: boolean; openMcpSelector?: boolean; compact?: boolean; - model?: string; }