fix: MCP cleanup part 1
This commit is contained in:
parent
b3348fd3ff
commit
2b56851cda
5 changed files with 11 additions and 10 deletions
|
|
@ -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 () => {
|
||||
|
|
|
|||
|
|
@ -135,16 +135,19 @@ export function getAllTools() {
|
|||
const allToolNames = [...builtinToolNames, ...mcpToolNames];
|
||||
|
||||
// Check if the ToolPermissionService is ready
|
||||
const serviceResult = getServiceSync<ToolPermissionServiceState>(
|
||||
const permissionsServiceResult = getServiceSync<ToolPermissionServiceState>(
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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 ?? "",
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
|
|||
</>
|
||||
)}
|
||||
|
||||
{/* Decided this is noisy for now */}
|
||||
{/* // MCP Servers
|
||||
{/* MCP Servers */}
|
||||
{config.mcpServers?.length && (
|
||||
<>
|
||||
<Text color="blue">MCP Servers:</Text>
|
||||
|
|
@ -106,7 +105,7 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
|
|||
))}
|
||||
<Text> </Text>
|
||||
</>
|
||||
)} */}
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,5 +59,4 @@ export interface SlashCommandResult {
|
|||
openModelSelector?: boolean;
|
||||
openMcpSelector?: boolean;
|
||||
compact?: boolean;
|
||||
model?: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue