diff options
Diffstat (limited to 'packages/cli/src/ui/commands')
| -rw-r--r-- | packages/cli/src/ui/commands/mcpCommand.test.ts | 32 | ||||
| -rw-r--r-- | packages/cli/src/ui/commands/mcpCommand.ts | 6 | ||||
| -rw-r--r-- | packages/cli/src/ui/commands/toolsCommand.test.ts | 11 | ||||
| -rw-r--r-- | packages/cli/src/ui/commands/toolsCommand.ts | 2 |
4 files changed, 24 insertions, 27 deletions
diff --git a/packages/cli/src/ui/commands/mcpCommand.test.ts b/packages/cli/src/ui/commands/mcpCommand.test.ts index 09b97bb0..8bf27291 100644 --- a/packages/cli/src/ui/commands/mcpCommand.test.ts +++ b/packages/cli/src/ui/commands/mcpCommand.test.ts @@ -83,7 +83,7 @@ describe('mcpCommand', () => { // Create mock config with all necessary methods mockConfig = { - getToolRegistry: vi.fn().mockResolvedValue({ + getToolRegistry: vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue([]), }), getMcpServers: vi.fn().mockReturnValue({}), @@ -119,7 +119,7 @@ describe('mcpCommand', () => { }); it('should show an error if tool registry is not available', async () => { - mockConfig.getToolRegistry = vi.fn().mockResolvedValue(undefined); + mockConfig.getToolRegistry = vi.fn().mockReturnValue(undefined); const result = await mcpCommand.action!(mockContext, ''); @@ -133,7 +133,7 @@ describe('mcpCommand', () => { describe('no MCP servers configured', () => { beforeEach(() => { - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue([]), }); mockConfig.getMcpServers = vi.fn().mockReturnValue({}); @@ -184,7 +184,7 @@ describe('mcpCommand', () => { ...mockServer3Tools, ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(allTools), }); @@ -243,7 +243,7 @@ describe('mcpCommand', () => { createMockMCPTool('tool2', 'server1', 'This is tool 2 description'), ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -296,7 +296,7 @@ describe('mcpCommand', () => { createMockMCPTool('tool1', 'server1', 'This is tool 1 description'), ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -340,7 +340,7 @@ describe('mcpCommand', () => { // Mock tools - only server1 has tools const mockServerTools = [createMockMCPTool('server1_tool1', 'server1')]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -386,7 +386,7 @@ describe('mcpCommand', () => { createMockMCPTool('server2_tool1', 'server2'), ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -523,7 +523,7 @@ describe('mcpCommand', () => { const mockServerTools = [tool1, tool2]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -566,7 +566,7 @@ describe('mcpCommand', () => { createMockMCPTool('tool1', 'server1', 'Tool without schema'), ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); @@ -603,7 +603,7 @@ describe('mcpCommand', () => { createMockMCPTool('tool1', 'server1', 'Test tool'), ]; - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue(mockServerTools), }); }); @@ -766,7 +766,7 @@ describe('mcpCommand', () => { }; mockConfig.getMcpServers = vi.fn().mockReturnValue(mockMcpServers); - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue([]), }); @@ -787,7 +787,7 @@ describe('mcpCommand', () => { }; mockConfig.getMcpServers = vi.fn().mockReturnValue(mockMcpServers); - mockConfig.getToolRegistry = vi.fn().mockResolvedValue({ + mockConfig.getToolRegistry = vi.fn().mockReturnValue({ getAllTools: vi.fn().mockReturnValue([]), }); @@ -879,7 +879,7 @@ describe('mcpCommand', () => { oauth: { enabled: true }, }, }), - getToolRegistry: vi.fn().mockResolvedValue(mockToolRegistry), + getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry), getGeminiClient: vi.fn().mockReturnValue(mockGeminiClient), getPromptRegistry: vi.fn().mockResolvedValue({ removePromptsByServer: vi.fn(), @@ -984,7 +984,7 @@ describe('mcpCommand', () => { config: { getMcpServers: vi.fn().mockReturnValue({ server1: {} }), getBlockedMcpServers: vi.fn().mockReturnValue([]), - getToolRegistry: vi.fn().mockResolvedValue(mockToolRegistry), + getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry), getGeminiClient: vi.fn().mockReturnValue(mockGeminiClient), getPromptRegistry: vi.fn().mockResolvedValue({ getPromptsByServer: vi.fn().mockReturnValue([]), @@ -1040,7 +1040,7 @@ describe('mcpCommand', () => { }); it('should show an error if tool registry is not available', async () => { - mockConfig.getToolRegistry = vi.fn().mockResolvedValue(undefined); + mockConfig.getToolRegistry = vi.fn().mockReturnValue(undefined); const refreshCommand = mcpCommand.subCommands?.find( (cmd) => cmd.name === 'refresh', diff --git a/packages/cli/src/ui/commands/mcpCommand.ts b/packages/cli/src/ui/commands/mcpCommand.ts index 9e321937..67d66604 100644 --- a/packages/cli/src/ui/commands/mcpCommand.ts +++ b/packages/cli/src/ui/commands/mcpCommand.ts @@ -44,7 +44,7 @@ const getMcpStatus = async ( }; } - const toolRegistry = await config.getToolRegistry(); + const toolRegistry = config.getToolRegistry(); if (!toolRegistry) { return { type: 'message', @@ -400,7 +400,7 @@ const authCommand: SlashCommand = { ); // Trigger tool re-discovery to pick up authenticated server - const toolRegistry = await config.getToolRegistry(); + const toolRegistry = config.getToolRegistry(); if (toolRegistry) { context.ui.addItem( { @@ -485,7 +485,7 @@ const refreshCommand: SlashCommand = { }; } - const toolRegistry = await config.getToolRegistry(); + const toolRegistry = config.getToolRegistry(); if (!toolRegistry) { return { type: 'message', diff --git a/packages/cli/src/ui/commands/toolsCommand.test.ts b/packages/cli/src/ui/commands/toolsCommand.test.ts index 41c5196b..01399512 100644 --- a/packages/cli/src/ui/commands/toolsCommand.test.ts +++ b/packages/cli/src/ui/commands/toolsCommand.test.ts @@ -31,7 +31,7 @@ describe('toolsCommand', () => { const mockContext = createMockCommandContext({ services: { config: { - getToolRegistry: () => Promise.resolve(undefined), + getToolRegistry: () => undefined, }, }, }); @@ -52,8 +52,7 @@ describe('toolsCommand', () => { const mockContext = createMockCommandContext({ services: { config: { - getToolRegistry: () => - Promise.resolve({ getAllTools: () => [] as Tool[] }), + getToolRegistry: () => ({ getAllTools: () => [] as Tool[] }), }, }, }); @@ -73,8 +72,7 @@ describe('toolsCommand', () => { const mockContext = createMockCommandContext({ services: { config: { - getToolRegistry: () => - Promise.resolve({ getAllTools: () => mockTools }), + getToolRegistry: () => ({ getAllTools: () => mockTools }), }, }, }); @@ -92,8 +90,7 @@ describe('toolsCommand', () => { const mockContext = createMockCommandContext({ services: { config: { - getToolRegistry: () => - Promise.resolve({ getAllTools: () => mockTools }), + getToolRegistry: () => ({ getAllTools: () => mockTools }), }, }, }); diff --git a/packages/cli/src/ui/commands/toolsCommand.ts b/packages/cli/src/ui/commands/toolsCommand.ts index e993bab3..31ff8c27 100644 --- a/packages/cli/src/ui/commands/toolsCommand.ts +++ b/packages/cli/src/ui/commands/toolsCommand.ts @@ -24,7 +24,7 @@ export const toolsCommand: SlashCommand = { useShowDescriptions = true; } - const toolRegistry = await context.services.config?.getToolRegistry(); + const toolRegistry = context.services.config?.getToolRegistry(); if (!toolRegistry) { context.ui.addItem( { |
