Skip to content

Commit f1e4dfc

Browse files
committed
fix: correct internal MCP name from 'ncp' to 'mcp' in tests and cleanup setTimeout handles
- Fixed test failures in internal-mcps-e2e.test.ts and internal-mcp-manager-indexing.test.ts - NCPManagementMCP is registered with name 'mcp', not 'ncp' - Added proper setTimeout cleanup in mcp-timeout-scenarios.test.ts to prevent open handles - Store timeout IDs and clear them in afterEach to avoid Jest teardown warnings - All affected tests now passing
1 parent 1bbdd69 commit f1e4dfc

3 files changed

Lines changed: 28 additions & 20 deletions

File tree

tests/e2e/internal-mcps-e2e.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('Internal MCPs - E2E Tests', () => {
9191

9292
describe('MCP Management MCP', () => {
9393
test('should list available mcp management tools', () => {
94-
const mcpMCP = manager.getAllEnabledInternalMCPs().find(m => m.name === 'ncp');
94+
const mcpMCP = manager.getAllEnabledInternalMCPs().find(m => m.name === 'mcp');
9595

9696
expect(mcpMCP).toBeDefined();
9797
expect(mcpMCP?.tools.length).toBeGreaterThan(0);
@@ -103,7 +103,7 @@ describe('Internal MCPs - E2E Tests', () => {
103103
});
104104

105105
test('should list MCPs in profile', async () => {
106-
const result = await manager.executeInternalTool('ncp', 'list', {
106+
const result = await manager.executeInternalTool('mcp', 'list', {
107107
profile: 'default'
108108
});
109109

@@ -112,7 +112,7 @@ describe('Internal MCPs - E2E Tests', () => {
112112
});
113113

114114
test('should list MCPs from specific profile', async () => {
115-
const result = await manager.executeInternalTool('ncp', 'list', {
115+
const result = await manager.executeInternalTool('mcp', 'list', {
116116
profile: 'default'
117117
});
118118

tests/internal-mcps/internal-mcp-manager-indexing.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ describe('InternalMCPManager - Index Management', () => {
6161

6262
test('should handle multiple MCPs being disabled', async () => {
6363
await manager.disableInternalMCP('schedule');
64-
await manager.disableInternalMCP('ncp');
64+
await manager.disableInternalMCP('mcp');
6565

6666
expect(manager.isInternalMCPDisabled('schedule')).toBe(true);
67-
expect(manager.isInternalMCPDisabled('ncp')).toBe(true);
67+
expect(manager.isInternalMCPDisabled('mcp')).toBe(true);
6868

6969
const disabledList = manager.getDisabledInternalMCPs();
7070
expect(disabledList).toContain('schedule');
71-
expect(disabledList).toContain('ncp');
71+
expect(disabledList).toContain('mcp');
7272
});
7373
});
7474

@@ -124,23 +124,23 @@ describe('InternalMCPManager - Index Management', () => {
124124

125125
test('should return list of disabled MCPs', async () => {
126126
await manager.disableInternalMCP('schedule');
127-
await manager.disableInternalMCP('ncp');
127+
await manager.disableInternalMCP('mcp');
128128

129129
const disabled = manager.getDisabledInternalMCPs();
130130
expect(disabled).toHaveLength(2);
131131
expect(disabled).toContain('schedule');
132-
expect(disabled).toContain('ncp');
132+
expect(disabled).toContain('mcp');
133133
});
134134

135135
test('should update after enabling MCP', async () => {
136136
await manager.disableInternalMCP('schedule');
137-
await manager.disableInternalMCP('ncp');
137+
await manager.disableInternalMCP('mcp');
138138

139139
await manager.enableInternalMCP('schedule');
140140

141141
const disabled = manager.getDisabledInternalMCPs();
142142
expect(disabled).toHaveLength(1);
143-
expect(disabled).toContain('ncp');
143+
expect(disabled).toContain('mcp');
144144
expect(disabled).not.toContain('schedule');
145145
});
146146
});
@@ -153,7 +153,7 @@ describe('InternalMCPManager - Index Management', () => {
153153
expect(enabled.length).toBeGreaterThanOrEqual(2);
154154

155155
const names = enabled.map(m => m.name);
156-
expect(names).toContain('ncp');
156+
expect(names).toContain('mcp');
157157
expect(names).toContain('schedule');
158158
});
159159

@@ -163,7 +163,7 @@ describe('InternalMCPManager - Index Management', () => {
163163
const enabled = manager.getAllEnabledInternalMCPs();
164164
const names = enabled.map(m => m.name);
165165

166-
expect(names).toContain('ncp');
166+
expect(names).toContain('mcp');
167167
expect(names).not.toContain('schedule');
168168
});
169169

@@ -240,14 +240,14 @@ describe('InternalMCPManager - Index Management', () => {
240240

241241
test('should maintain state across multiple operations', async () => {
242242
await manager.disableInternalMCP('schedule');
243-
await manager.disableInternalMCP('ncp');
243+
await manager.disableInternalMCP('mcp');
244244

245245
expect(manager.getDisabledInternalMCPs()).toHaveLength(2);
246246

247247
await manager.enableInternalMCP('schedule');
248248

249249
expect(manager.getDisabledInternalMCPs()).toHaveLength(1);
250-
expect(manager.getDisabledInternalMCPs()).toContain('ncp');
250+
expect(manager.getDisabledInternalMCPs()).toContain('mcp');
251251
});
252252
});
253253
});

tests/mcp-timeout-scenarios.test.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ import { MCPServer } from '../src/server/mcp-server.js';
88

99
describe('MCP Timeout Prevention Tests', () => {
1010
let server: MCPServer;
11+
let timeoutIds: NodeJS.Timeout[] = [];
1112

1213
beforeEach(() => {
1314
server = new MCPServer('test', false);
15+
timeoutIds = [];
1416
});
1517

1618
afterEach(async () => {
19+
// Clear all pending timeouts
20+
timeoutIds.forEach(id => clearTimeout(id));
21+
timeoutIds = [];
22+
1723
if (server) {
1824
await server.cleanup?.();
1925
}
@@ -36,9 +42,10 @@ describe('MCP Timeout Prevention Tests', () => {
3642
method: 'tools/list'
3743
}),
3844
// Fail if any request takes more than 1 second
39-
new Promise((_, reject) =>
40-
setTimeout(() => reject(new Error(`Request ${i} timed out`)), 1000)
41-
)
45+
new Promise((_, reject) => {
46+
const timeoutId = setTimeout(() => reject(new Error(`Request ${i} timed out`)), 1000);
47+
timeoutIds.push(timeoutId);
48+
})
4249
])
4350
);
4451

@@ -57,9 +64,10 @@ describe('MCP Timeout Prevention Tests', () => {
5764
});
5865

5966
it('should respond to initialize within 100ms even with slow indexing', async () => {
60-
const timeout = new Promise((_, reject) =>
61-
setTimeout(() => reject(new Error('Initialize timed out')), 100)
62-
);
67+
const timeout = new Promise((_, reject) => {
68+
const timeoutId = setTimeout(() => reject(new Error('Initialize timed out')), 100);
69+
timeoutIds.push(timeoutId);
70+
});
6371

6472
const response = Promise.resolve(server.handleRequest({
6573
jsonrpc: '2.0',

0 commit comments

Comments
 (0)