summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/mcpCommand.test.ts
diff options
context:
space:
mode:
authorBilly Biggs <[email protected]>2025-07-18 20:45:00 +0200
committerGitHub <[email protected]>2025-07-18 18:45:00 +0000
commit18c3bf3a4206d5d3be41b2510ec3940760a15e9f (patch)
tree960112fd2f233b53f6ea35aa777da51769617197 /packages/cli/src/ui/commands/mcpCommand.test.ts
parent9dadf2295804867d44628eda32fc1e46d80f9db3 (diff)
Summarize extensions and MCP servers on startup (#3977)
Diffstat (limited to 'packages/cli/src/ui/commands/mcpCommand.test.ts')
-rw-r--r--packages/cli/src/ui/commands/mcpCommand.test.ts57
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/cli/src/ui/commands/mcpCommand.test.ts b/packages/cli/src/ui/commands/mcpCommand.test.ts
index 0a8d8306..f23cf3ab 100644
--- a/packages/cli/src/ui/commands/mcpCommand.test.ts
+++ b/packages/cli/src/ui/commands/mcpCommand.test.ts
@@ -63,6 +63,7 @@ describe('mcpCommand', () => {
let mockConfig: {
getToolRegistry: ReturnType<typeof vi.fn>;
getMcpServers: ReturnType<typeof vi.fn>;
+ getBlockedMcpServers: ReturnType<typeof vi.fn>;
};
beforeEach(() => {
@@ -83,6 +84,7 @@ describe('mcpCommand', () => {
getAllTools: vi.fn().mockReturnValue([]),
}),
getMcpServers: vi.fn().mockReturnValue({}),
+ getBlockedMcpServers: vi.fn().mockReturnValue([]),
};
mockContext = createMockCommandContext({
@@ -419,6 +421,61 @@ describe('mcpCommand', () => {
);
}
});
+
+ it('should display the extension name for servers from extensions', async () => {
+ const mockMcpServers = {
+ server1: { command: 'cmd1', extensionName: 'my-extension' },
+ };
+ mockConfig.getMcpServers = vi.fn().mockReturnValue(mockMcpServers);
+
+ const result = await mcpCommand.action!(mockContext, '');
+
+ expect(isMessageAction(result)).toBe(true);
+ if (isMessageAction(result)) {
+ const message = result.content;
+ expect(message).toContain('server1 (from my-extension)');
+ }
+ });
+
+ it('should display blocked MCP servers', async () => {
+ mockConfig.getMcpServers = vi.fn().mockReturnValue({});
+ const blockedServers = [
+ { name: 'blocked-server', extensionName: 'my-extension' },
+ ];
+ mockConfig.getBlockedMcpServers = vi.fn().mockReturnValue(blockedServers);
+
+ const result = await mcpCommand.action!(mockContext, '');
+
+ expect(isMessageAction(result)).toBe(true);
+ if (isMessageAction(result)) {
+ const message = result.content;
+ expect(message).toContain(
+ '🔴 \u001b[1mblocked-server (from my-extension)\u001b[0m - Blocked',
+ );
+ }
+ });
+
+ it('should display both active and blocked servers correctly', async () => {
+ const mockMcpServers = {
+ server1: { command: 'cmd1', extensionName: 'my-extension' },
+ };
+ mockConfig.getMcpServers = vi.fn().mockReturnValue(mockMcpServers);
+ const blockedServers = [
+ { name: 'blocked-server', extensionName: 'another-extension' },
+ ];
+ mockConfig.getBlockedMcpServers = vi.fn().mockReturnValue(blockedServers);
+
+ const result = await mcpCommand.action!(mockContext, '');
+
+ expect(isMessageAction(result)).toBe(true);
+ if (isMessageAction(result)) {
+ const message = result.content;
+ expect(message).toContain('server1 (from my-extension)');
+ expect(message).toContain(
+ '🔴 \u001b[1mblocked-server (from another-extension)\u001b[0m - Blocked',
+ );
+ }
+ });
});
describe('schema functionality', () => {