mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 21:43:07 +00:00
* feat: Remove 9 low-value tools and consolidate n8n_health_check (v2.25.0) Telemetry-driven tool cleanup to improve API clarity: **Removed Tools (9):** - list_nodes - Use search_nodes instead - list_ai_tools - Use search_nodes with isAITool filter - list_tasks - Low usage (0.02%) - get_database_statistics - Use n8n_health_check - list_templates - Use search_templates or get_templates_for_task - get_node_as_tool_info - Documented in get_node - validate_workflow_connections - Use validate_workflow - validate_workflow_expressions - Use validate_workflow - n8n_list_available_tools - Use n8n_health_check - n8n_diagnostic - Merged into n8n_health_check **Consolidated Tool:** - n8n_health_check now supports mode='diagnostic' for detailed troubleshooting **Tool Count:** - Before: 38 tools - After: 31 tools (18% reduction) Concieved by Romuald Członkowski - www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * 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> * fix: update integration tests to use valid tools after v2.25.0 removal Replaced all references to removed tools in integration tests: - list_nodes -> search_nodes - get_database_statistics -> tools_documentation - list_ai_tools -> search_nodes/tools_documentation - list_tasks -> tools_documentation - get_node_as_tool_info -> removed test section Updated test files: - tests/integration/mcp-protocol/basic-connection.test.ts - tests/integration/mcp-protocol/performance.test.ts - tests/integration/mcp-protocol/session-management.test.ts - tests/integration/mcp-protocol/test-helpers.ts - tests/integration/mcp-protocol/tool-invocation.test.ts - tests/integration/telemetry/mcp-telemetry.test.ts - tests/unit/mcp/disabled-tools.test.ts - tests/unit/mcp/tools-documentation.test.ts Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Tool consolidation v2.26.0 - reduce tools by 38% (31 → 19) Major consolidation of MCP tools using mode-based parameters for better AI agent ergonomics: Node Tools: - get_node_documentation → get_node with mode='documentation' - search_node_properties → get_node with mode='search_properties' - get_property_dependencies → removed Validation Tools: - validate_node_operation + validate_node_minimal → validate_node with mode param Template Tools: - list_node_templates → search_templates with searchMode='nodes' - search_templates_by_metadata → search_templates with searchMode='metadata' - get_templates_for_task → search_templates with searchMode='task' Workflow Getters: - n8n_get_workflow_details/structure/minimal → n8n_get_workflow with mode param Execution Tools: - n8n_list/get/delete_execution → n8n_executions with action param Test updates for all consolidated tools. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en * docs: comprehensive README update for v2.26.0 tool consolidation - Quick Start: Added hosted service (dashboard.n8n-mcp.com) as primary option - Self-hosting: Renamed options to A (npx), B (Docker), C (Local), D (Railway) - Removed: "Memory Leak Fix (v2.20.2)" section (outdated) - Removed: "Known Issues" section (outdated container management) - Claude Project Setup: Updated all tool references to v2.26.0 consolidated tools - validate_node({mode: 'minimal'|'full'}) instead of separate tools - search_templates({searchMode: ...}) unified template search - get_node({mode: 'docs'|'search_properties'}) for documentation - n8n_executions({action: ...}) unified execution management - Available MCP Tools: Updated to show 19 consolidated tools (7 core + 12 mgmt) - Recent Updates: Simplified to just link to CHANGELOG.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en * fix: update tool count from 31 to 19 in diagnostic message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(tests): update tool count expectations for v2.26.0 Update handlers-n8n-manager.test.ts to expect new consolidated tool counts (7/12/19) after v2.26.0 tool consolidation. 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> --------- Co-authored-by: Claude <noreply@anthropic.com>
380 lines
14 KiB
TypeScript
380 lines
14 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { n8nDocumentationToolsFinal } from '@/mcp/tools';
|
|
import { z } from 'zod';
|
|
|
|
describe('n8nDocumentationToolsFinal', () => {
|
|
describe('Tool Structure Validation', () => {
|
|
it('should have all required properties for each tool', () => {
|
|
n8nDocumentationToolsFinal.forEach(tool => {
|
|
// Check required properties exist
|
|
expect(tool).toHaveProperty('name');
|
|
expect(tool).toHaveProperty('description');
|
|
expect(tool).toHaveProperty('inputSchema');
|
|
|
|
// Check property types
|
|
expect(typeof tool.name).toBe('string');
|
|
expect(typeof tool.description).toBe('string');
|
|
expect(tool.inputSchema).toBeTypeOf('object');
|
|
|
|
// Name should be non-empty
|
|
expect(tool.name.length).toBeGreaterThan(0);
|
|
|
|
// Description should be meaningful
|
|
expect(tool.description.length).toBeGreaterThan(10);
|
|
});
|
|
});
|
|
|
|
it('should have unique tool names', () => {
|
|
const names = n8nDocumentationToolsFinal.map(tool => tool.name);
|
|
const uniqueNames = new Set(names);
|
|
expect(names.length).toBe(uniqueNames.size);
|
|
});
|
|
|
|
it('should have valid JSON Schema for all inputSchemas', () => {
|
|
// Define a minimal JSON Schema validator using Zod
|
|
const jsonSchemaValidator = z.object({
|
|
type: z.literal('object'),
|
|
properties: z.record(z.any()).optional(),
|
|
required: z.array(z.string()).optional(),
|
|
});
|
|
|
|
n8nDocumentationToolsFinal.forEach(tool => {
|
|
expect(() => {
|
|
jsonSchemaValidator.parse(tool.inputSchema);
|
|
}).not.toThrow();
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Individual Tool Validation', () => {
|
|
describe('tools_documentation', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'tools_documentation');
|
|
|
|
it('should exist', () => {
|
|
expect(tool).toBeDefined();
|
|
});
|
|
|
|
it('should have correct schema', () => {
|
|
expect(tool?.inputSchema).toMatchObject({
|
|
type: 'object',
|
|
properties: {
|
|
topic: {
|
|
type: 'string',
|
|
description: expect.any(String)
|
|
},
|
|
depth: {
|
|
type: 'string',
|
|
enum: ['essentials', 'full'],
|
|
description: expect.any(String),
|
|
default: 'essentials'
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it('should have helpful description', () => {
|
|
expect(tool?.description).toContain('documentation');
|
|
expect(tool?.description).toContain('MCP tools');
|
|
});
|
|
});
|
|
|
|
describe('get_node', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'get_node');
|
|
|
|
it('should exist', () => {
|
|
expect(tool).toBeDefined();
|
|
});
|
|
|
|
it('should have nodeType as required parameter', () => {
|
|
expect(tool?.inputSchema.required).toContain('nodeType');
|
|
});
|
|
|
|
it('should mention detail levels in description', () => {
|
|
expect(tool?.description).toMatch(/minimal|standard|full/i);
|
|
});
|
|
});
|
|
|
|
describe('search_nodes', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'search_nodes');
|
|
|
|
it('should exist', () => {
|
|
expect(tool).toBeDefined();
|
|
});
|
|
|
|
it('should have query as required parameter', () => {
|
|
expect(tool?.inputSchema.required).toContain('query');
|
|
});
|
|
|
|
it('should have mode enum with correct values', () => {
|
|
expect(tool?.inputSchema.properties.mode.enum).toEqual(['OR', 'AND', 'FUZZY']);
|
|
expect(tool?.inputSchema.properties.mode.default).toBe('OR');
|
|
});
|
|
|
|
it('should have limit with default value', () => {
|
|
expect(tool?.inputSchema.properties.limit.default).toBe(20);
|
|
});
|
|
});
|
|
|
|
describe('validate_workflow', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'validate_workflow');
|
|
|
|
it('should exist', () => {
|
|
expect(tool).toBeDefined();
|
|
});
|
|
|
|
it('should have workflow as required parameter', () => {
|
|
expect(tool?.inputSchema.required).toContain('workflow');
|
|
});
|
|
|
|
it('should have options with correct validation settings', () => {
|
|
const options = tool?.inputSchema.properties.options.properties;
|
|
expect(options).toHaveProperty('validateNodes');
|
|
expect(options).toHaveProperty('validateConnections');
|
|
expect(options).toHaveProperty('validateExpressions');
|
|
expect(options).toHaveProperty('profile');
|
|
});
|
|
|
|
it('should have correct profile enum values', () => {
|
|
const profile = tool?.inputSchema.properties.options.properties.profile;
|
|
expect(profile.enum).toEqual(['minimal', 'runtime', 'ai-friendly', 'strict']);
|
|
expect(profile.default).toBe('runtime');
|
|
});
|
|
});
|
|
|
|
describe('search_templates (consolidated)', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'search_templates');
|
|
|
|
it('should exist', () => {
|
|
expect(tool).toBeDefined();
|
|
});
|
|
|
|
it('should have searchMode parameter with correct enum values', () => {
|
|
const searchModeParam = tool?.inputSchema.properties?.searchMode;
|
|
expect(searchModeParam).toBeDefined();
|
|
expect(searchModeParam.enum).toEqual(['keyword', 'by_nodes', 'by_task', 'by_metadata']);
|
|
expect(searchModeParam.default).toBe('keyword');
|
|
});
|
|
|
|
it('should have task parameter for by_task searchMode', () => {
|
|
const taskParam = tool?.inputSchema.properties?.task;
|
|
expect(taskParam).toBeDefined();
|
|
const expectedTasks = [
|
|
'ai_automation',
|
|
'data_sync',
|
|
'webhook_processing',
|
|
'email_automation',
|
|
'slack_integration',
|
|
'data_transformation',
|
|
'file_processing',
|
|
'scheduling',
|
|
'api_integration',
|
|
'database_operations'
|
|
];
|
|
expect(taskParam.enum).toEqual(expectedTasks);
|
|
});
|
|
|
|
it('should have nodeTypes parameter for by_nodes searchMode', () => {
|
|
const nodeTypesParam = tool?.inputSchema.properties?.nodeTypes;
|
|
expect(nodeTypesParam).toBeDefined();
|
|
expect(nodeTypesParam.type).toBe('array');
|
|
expect(nodeTypesParam.items.type).toBe('string');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Tool Description Quality', () => {
|
|
it('should have concise descriptions that fit within reasonable limits', () => {
|
|
n8nDocumentationToolsFinal.forEach(tool => {
|
|
// Consolidated tools (v2.26.0) may have longer descriptions due to multiple modes
|
|
// Allow up to 500 chars for tools with mode-based functionality
|
|
expect(tool.description.length).toBeLessThan(500);
|
|
});
|
|
});
|
|
|
|
it('should include examples or key information in descriptions', () => {
|
|
const toolsWithExamples = [
|
|
'get_node',
|
|
'search_nodes'
|
|
];
|
|
|
|
toolsWithExamples.forEach(toolName => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === toolName);
|
|
// Should include either example usage, format information, or "nodes-base"
|
|
expect(tool?.description).toMatch(/example|Example|format|Format|nodes-base|Common:|mode/i);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Schema Consistency', () => {
|
|
it('should use consistent parameter naming', () => {
|
|
const toolsWithNodeType = n8nDocumentationToolsFinal.filter(tool =>
|
|
tool.inputSchema.properties?.nodeType
|
|
);
|
|
|
|
toolsWithNodeType.forEach(tool => {
|
|
const nodeTypeParam = tool.inputSchema.properties.nodeType;
|
|
expect(nodeTypeParam.type).toBe('string');
|
|
// Should mention the prefix requirement
|
|
expect(nodeTypeParam.description).toMatch(/nodes-base|prefix/i);
|
|
});
|
|
});
|
|
|
|
it('should have consistent limit parameter defaults', () => {
|
|
const toolsWithLimit = n8nDocumentationToolsFinal.filter(tool =>
|
|
tool.inputSchema.properties?.limit
|
|
);
|
|
|
|
toolsWithLimit.forEach(tool => {
|
|
const limitParam = tool.inputSchema.properties.limit;
|
|
expect(limitParam.type).toBe('number');
|
|
expect(limitParam.default).toBeDefined();
|
|
expect(limitParam.default).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Tool Categories Coverage', () => {
|
|
it('should have tools for all major categories', () => {
|
|
// Updated for v2.26.0 consolidated tools
|
|
const categories = {
|
|
discovery: ['search_nodes'],
|
|
configuration: ['get_node'], // get_node now includes docs mode
|
|
validation: ['validate_node', 'validate_workflow'], // consolidated validate_node
|
|
templates: ['search_templates', 'get_template'], // search_templates now handles all search modes
|
|
documentation: ['tools_documentation']
|
|
};
|
|
|
|
Object.entries(categories).forEach(([_category, expectedTools]) => {
|
|
expectedTools.forEach(toolName => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === toolName);
|
|
expect(tool).toBeDefined();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Parameter Validation', () => {
|
|
it('should have proper type definitions for all parameters', () => {
|
|
const validTypes = ['string', 'number', 'boolean', 'object', 'array'];
|
|
|
|
n8nDocumentationToolsFinal.forEach(tool => {
|
|
if (tool.inputSchema.properties) {
|
|
Object.entries(tool.inputSchema.properties).forEach(([paramName, param]) => {
|
|
expect(validTypes).toContain(param.type);
|
|
expect(param.description).toBeDefined();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
it('should mark required parameters correctly', () => {
|
|
const toolsWithRequired = n8nDocumentationToolsFinal.filter(tool =>
|
|
tool.inputSchema.required && tool.inputSchema.required.length > 0
|
|
);
|
|
|
|
toolsWithRequired.forEach(tool => {
|
|
tool.inputSchema.required!.forEach(requiredParam => {
|
|
expect(tool.inputSchema.properties).toHaveProperty(requiredParam);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Edge Cases', () => {
|
|
it('should handle tools with optional parameters only', () => {
|
|
// Tools where all parameters are optional
|
|
const toolsWithOptionalParams = ['tools_documentation'];
|
|
|
|
toolsWithOptionalParams.forEach(toolName => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === toolName);
|
|
expect(tool).toBeDefined();
|
|
// These tools have properties but no required array or empty required array
|
|
expect(tool?.inputSchema.required === undefined || tool?.inputSchema.required?.length === 0).toBe(true);
|
|
});
|
|
});
|
|
|
|
it('should have array parameters defined correctly', () => {
|
|
// search_templates now handles nodeTypes for by_nodes mode
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'search_templates');
|
|
const arrayParam = tool?.inputSchema.properties?.nodeTypes;
|
|
expect(arrayParam?.type).toBe('array');
|
|
expect(arrayParam?.items).toBeDefined();
|
|
expect(arrayParam?.items.type).toBe('string');
|
|
});
|
|
});
|
|
|
|
describe('Consolidated Template Tools (v2.26.0)', () => {
|
|
describe('get_template', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'get_template');
|
|
|
|
it('should exist and support mode parameter', () => {
|
|
expect(tool).toBeDefined();
|
|
expect(tool?.description).toContain('mode');
|
|
});
|
|
|
|
it('should have mode parameter with correct values', () => {
|
|
expect(tool?.inputSchema.properties).toHaveProperty('mode');
|
|
|
|
const modeParam = tool?.inputSchema.properties.mode;
|
|
expect(modeParam.enum).toEqual(['nodes_only', 'structure', 'full']);
|
|
expect(modeParam.default).toBe('full');
|
|
});
|
|
|
|
it('should require templateId parameter', () => {
|
|
expect(tool?.inputSchema.required).toContain('templateId');
|
|
});
|
|
});
|
|
|
|
describe('search_templates (consolidated with searchMode)', () => {
|
|
const tool = n8nDocumentationToolsFinal.find(t => t.name === 'search_templates');
|
|
|
|
it('should exist with searchMode parameter', () => {
|
|
expect(tool).toBeDefined();
|
|
expect(tool?.inputSchema.properties).toHaveProperty('searchMode');
|
|
});
|
|
|
|
it('should support metadata filtering via by_metadata searchMode', () => {
|
|
// These properties are for by_metadata searchMode
|
|
const props = tool?.inputSchema.properties;
|
|
expect(props).toHaveProperty('category');
|
|
expect(props).toHaveProperty('complexity');
|
|
expect(props?.complexity?.enum).toEqual(['simple', 'medium', 'complex']);
|
|
});
|
|
|
|
it('should have pagination parameters', () => {
|
|
const limitProp = tool?.inputSchema.properties?.limit;
|
|
const offsetProp = tool?.inputSchema.properties?.offset;
|
|
|
|
expect(limitProp).toBeDefined();
|
|
expect(limitProp.type).toBe('number');
|
|
expect(limitProp.default).toBe(20);
|
|
expect(limitProp.maximum).toBe(100);
|
|
expect(limitProp.minimum).toBe(1);
|
|
|
|
expect(offsetProp).toBeDefined();
|
|
expect(offsetProp.type).toBe('number');
|
|
expect(offsetProp.default).toBe(0);
|
|
expect(offsetProp.minimum).toBe(0);
|
|
});
|
|
|
|
it('should include all search mode-specific properties', () => {
|
|
const properties = Object.keys(tool?.inputSchema.properties || {});
|
|
// Consolidated tool includes properties from all former tools
|
|
const expectedProperties = [
|
|
'searchMode', // New mode selector
|
|
'query', // For keyword search
|
|
'nodeTypes', // For by_nodes search (formerly list_node_templates)
|
|
'task', // For by_task search (formerly get_templates_for_task)
|
|
'category', // For by_metadata search
|
|
'complexity',
|
|
'limit',
|
|
'offset'
|
|
];
|
|
|
|
expectedProperties.forEach(prop => {
|
|
expect(properties).toContain(prop);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}); |