fix: cleanup stale references and update tests after tool removal

- Remove handleListAvailableTools dead code from handlers-n8n-manager.ts
- Update error messages to reference n8n_health_check(mode="diagnostic") instead of n8n_diagnostic
- Update tool counts in diagnostic messages (14 doc tools, 31 total)
- Fix error-handling.test.ts to use valid tools (search_nodes, tools_documentation)
- Remove obsolete list-tools.test.ts integration tests
- Remove unused ListToolsResponse type from response-types.ts
- Update tools.ts QUICK REFERENCE to remove list_nodes references
- Update tools-documentation.ts to remove references to removed tools
- Update tool-docs files to remove stale relatedTools references
- Fix tools.test.ts to not test removed tools (list_nodes, list_ai_tools, etc.)
- Fix parameter-validation.test.ts to not test removed tools
- Update handlers-n8n-manager.test.ts error message expectations

All 399 MCP unit tests now pass.

Conceived by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-11-25 00:51:33 +01:00
parent 2e40374da3
commit 13b8abaafb
14 changed files with 67 additions and 421 deletions

View File

@@ -84,16 +84,16 @@ describe('MCP Error Handling', () => {
describe('Tool-Specific Errors', () => {
describe('Node Discovery Errors', () => {
it('should handle invalid category filter', async () => {
const response = await client.callTool({ name: 'list_nodes', arguments: {
category: 'invalid_category'
it('should handle search with no matching results', async () => {
const response = await client.callTool({ name: 'search_nodes', arguments: {
query: 'xyznonexistentnode123'
} });
// Should return empty array, not error
const result = JSON.parse((response as any).content[0].text);
expect(result).toHaveProperty('nodes');
expect(Array.isArray(result.nodes)).toBe(true);
expect(result.nodes).toHaveLength(0);
expect(result).toHaveProperty('results');
expect(Array.isArray(result.results)).toBe(true);
expect(result.results).toHaveLength(0);
});
it('should handle invalid search mode', async () => {
@@ -279,9 +279,9 @@ describe('MCP Error Handling', () => {
for (let i = 0; i < requestCount; i++) {
promises.push(
client.callTool({ name: 'list_nodes', arguments: {
limit: 1,
category: i % 2 === 0 ? 'trigger' : 'transform'
client.callTool({ name: 'search_nodes', arguments: {
query: i % 2 === 0 ? 'webhook' : 'http',
limit: 1
} })
);
}
@@ -320,13 +320,13 @@ describe('MCP Error Handling', () => {
describe('Timeout Scenarios', () => {
it('should handle rapid sequential requests', async () => {
const start = Date.now();
for (let i = 0; i < 20; i++) {
await client.callTool({ name: 'get_database_statistics', arguments: {} });
await client.callTool({ name: 'tools_documentation', arguments: {} });
}
const duration = Date.now() - start;
// Should complete reasonably quickly (under 5 seconds)
expect(duration).toBeLessThan(5000);
});
@@ -410,25 +410,25 @@ describe('MCP Error Handling', () => {
}
// Should still work
const response = await client.callTool({ name: 'list_nodes', arguments: { limit: 1 } });
const response = await client.callTool({ name: 'search_nodes', arguments: { query: 'webhook', limit: 1 } });
expect(response).toBeDefined();
});
it('should handle mixed success and failure', async () => {
const promises = [
client.callTool({ name: 'list_nodes', arguments: { limit: 5 } }),
client.callTool({ name: 'search_nodes', arguments: { query: 'webhook', limit: 5 } }),
client.callTool({ name: 'get_node', arguments: { nodeType: 'invalid' } }).catch(e => ({ error: e })),
client.callTool({ name: 'get_database_statistics', arguments: {} }),
client.callTool({ name: 'tools_documentation', arguments: {} }),
client.callTool({ name: 'search_nodes', arguments: { query: '' } }).catch(e => ({ error: e })),
client.callTool({ name: 'list_ai_tools', arguments: {} })
client.callTool({ name: 'get_node', arguments: { nodeType: 'nodes-base.httpRequest' } })
];
const results = await Promise.all(promises);
// Some should succeed, some should fail
const successes = results.filter(r => !('error' in r));
const failures = results.filter(r => 'error' in r);
expect(successes.length).toBeGreaterThan(0);
expect(failures.length).toBeGreaterThan(0);
});
@@ -436,14 +436,14 @@ describe('MCP Error Handling', () => {
describe('Edge Cases', () => {
it('should handle empty responses gracefully', async () => {
const response = await client.callTool({ name: 'list_nodes', arguments: {
category: 'nonexistent_category'
const response = await client.callTool({ name: 'search_nodes', arguments: {
query: 'xyznonexistentnode12345'
} });
const result = JSON.parse((response as any).content[0].text);
expect(result).toHaveProperty('nodes');
expect(Array.isArray(result.nodes)).toBe(true);
expect(result.nodes).toHaveLength(0);
expect(result).toHaveProperty('results');
expect(Array.isArray(result.results)).toBe(true);
expect(result.results).toHaveLength(0);
});
it('should handle special characters in parameters', async () => {
@@ -469,14 +469,15 @@ describe('MCP Error Handling', () => {
it('should handle null and undefined gracefully', async () => {
// Most tools should handle missing optional params
const response = await client.callTool({ name: 'list_nodes', arguments: {
const response = await client.callTool({ name: 'search_nodes', arguments: {
query: 'webhook',
limit: undefined as any,
category: null as any
mode: null as any
} });
const result = JSON.parse((response as any).content[0].text);
expect(result).toHaveProperty('nodes');
expect(Array.isArray(result.nodes)).toBe(true);
expect(result).toHaveProperty('results');
expect(Array.isArray(result.results)).toBe(true);
});
});