mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-10 23:33:08 +00:00
Major Features:
- Pre-extracted 197 node configurations from 2,646 workflow templates
- Removed get_node_for_task tool (28% failure rate, 31 tasks)
- Enhanced search_nodes and get_node_essentials with includeExamples parameter
- 30-60x faster queries (<1ms vs 30-60ms)
Database Schema:
- New table: template_node_configs with optimized indexes
- New view: ranked_node_configs for top 5 configs per node
- Migration script: add-template-node-configs.sql
Template Processing:
- extractNodeConfigs: Extract configs from workflow templates
- detectExpressions: Identify n8n expressions ({{...}}, $json, $node)
- insertAndRankConfigs: Rank by popularity, keep top 10 per node
Tool Enhancements:
- search_nodes: Added includeExamples parameter (top 2 configs)
- get_node_essentials: Added includeExamples parameter (top 3 configs)
CLI Features:
- --extract-only: Extract configs without fetching new templates
- Automatic table creation if missing
Breaking Changes:
- Removed get_node_for_task tool
- Use search_nodes({includeExamples: true}) or get_node_essentials({includeExamples: true}) instead
Performance:
- Query time: <1ms for pre-extracted configs
- 85x more examples (2,646 vs 31)
- Database size increase: ~197 configs stored
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
109 lines
3.5 KiB
TypeScript
109 lines
3.5 KiB
TypeScript
/**
|
|
* MCPEngine - A simplified interface for benchmarking MCP tool execution
|
|
* This directly implements the MCP tool functionality without server dependencies
|
|
*/
|
|
import { NodeRepository } from './database/node-repository';
|
|
import { PropertyFilter } from './services/property-filter';
|
|
import { TaskTemplates } from './services/task-templates';
|
|
import { ConfigValidator } from './services/config-validator';
|
|
import { EnhancedConfigValidator } from './services/enhanced-config-validator';
|
|
import { WorkflowValidator, WorkflowValidationResult } from './services/workflow-validator';
|
|
|
|
export class MCPEngine {
|
|
private workflowValidator: WorkflowValidator;
|
|
|
|
constructor(private repository: NodeRepository) {
|
|
this.workflowValidator = new WorkflowValidator(repository, EnhancedConfigValidator);
|
|
}
|
|
|
|
async listNodes(args: any = {}) {
|
|
return this.repository.getAllNodes(args.limit);
|
|
}
|
|
|
|
async searchNodes(args: any) {
|
|
return this.repository.searchNodes(args.query, args.mode || 'OR', args.limit || 20);
|
|
}
|
|
|
|
async getNodeInfo(args: any) {
|
|
return this.repository.getNodeByType(args.nodeType);
|
|
}
|
|
|
|
async getNodeEssentials(args: any) {
|
|
const node = await this.repository.getNodeByType(args.nodeType);
|
|
if (!node) return null;
|
|
|
|
// Filter to essentials using static method
|
|
const essentials = PropertyFilter.getEssentials(node.properties || [], args.nodeType);
|
|
return {
|
|
nodeType: node.nodeType,
|
|
displayName: node.displayName,
|
|
description: node.description,
|
|
category: node.category,
|
|
required: essentials.required,
|
|
common: essentials.common
|
|
};
|
|
}
|
|
|
|
async getNodeDocumentation(args: any) {
|
|
const node = await this.repository.getNodeByType(args.nodeType);
|
|
return node?.documentation || null;
|
|
}
|
|
|
|
async validateNodeOperation(args: any) {
|
|
// Get node properties and validate
|
|
const node = await this.repository.getNodeByType(args.nodeType);
|
|
if (!node) {
|
|
return {
|
|
valid: false,
|
|
errors: [{ type: 'invalid_configuration', property: '', message: 'Node type not found' }],
|
|
warnings: [],
|
|
suggestions: [],
|
|
visibleProperties: [],
|
|
hiddenProperties: []
|
|
};
|
|
}
|
|
|
|
return ConfigValidator.validate(args.nodeType, args.config, node.properties || []);
|
|
}
|
|
|
|
async validateNodeMinimal(args: any) {
|
|
// Get node and check minimal requirements
|
|
const node = await this.repository.getNodeByType(args.nodeType);
|
|
if (!node) {
|
|
return { missingFields: [], error: 'Node type not found' };
|
|
}
|
|
|
|
const missingFields: string[] = [];
|
|
const requiredFields = PropertyFilter.getEssentials(node.properties || [], args.nodeType).required;
|
|
|
|
for (const field of requiredFields) {
|
|
if (!args.config[field.name]) {
|
|
missingFields.push(field.name);
|
|
}
|
|
}
|
|
|
|
return { missingFields };
|
|
}
|
|
|
|
async searchNodeProperties(args: any) {
|
|
return this.repository.searchNodeProperties(args.nodeType, args.query, args.maxResults || 20);
|
|
}
|
|
|
|
async listAITools(args: any) {
|
|
return this.repository.getAIToolNodes();
|
|
}
|
|
|
|
async getDatabaseStatistics(args: any) {
|
|
const count = await this.repository.getNodeCount();
|
|
const aiTools = await this.repository.getAIToolNodes();
|
|
return {
|
|
totalNodes: count,
|
|
aiToolsCount: aiTools.length,
|
|
categories: ['trigger', 'transform', 'output', 'input']
|
|
};
|
|
}
|
|
|
|
async validateWorkflow(args: any): Promise<WorkflowValidationResult> {
|
|
return this.workflowValidator.validateWorkflow(args.workflow, args.options);
|
|
}
|
|
} |