feat: add workflowNodeType field to MCP tool responses for proper n8n workflow creation
- Added workflowNodeType field to all node-returning MCP tools - AI agents now receive both internal format (nodes-base.webhook) and workflow format (n8n-nodes-base.webhook) - Created getWorkflowNodeType() utility to construct proper n8n format from package name - Solves issue where AI agents would search nodes and use wrong format in workflows - No database changes required - uses existing package_name field - Updated: search_nodes, get_node_info, get_node_essentials, get_node_as_tool_info, validate_node_operation - Updated CHANGELOG.md with comprehensive documentation of the changes This completes the fix for issue #71, ensuring AI agents can seamlessly create workflows with the correct node type format without manual intervention.
This commit is contained in:
@@ -43,4 +43,31 @@ export function getNodeTypeAlternatives(nodeType: string): string[] {
|
||||
}
|
||||
|
||||
return alternatives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the workflow node type from package name and normalized node type
|
||||
* This creates the format that n8n expects in workflow definitions
|
||||
*
|
||||
* Examples:
|
||||
* - ('n8n-nodes-base', 'nodes-base.webhook') → 'n8n-nodes-base.webhook'
|
||||
* - ('@n8n/n8n-nodes-langchain', 'nodes-langchain.agent') → '@n8n/n8n-nodes-langchain.agent'
|
||||
*
|
||||
* @param packageName The package name from the database
|
||||
* @param nodeType The normalized node type from the database
|
||||
* @returns The workflow node type for use in n8n workflows
|
||||
*/
|
||||
export function getWorkflowNodeType(packageName: string, nodeType: string): string {
|
||||
// Extract just the node name from the normalized type
|
||||
const nodeName = nodeType.split('.').pop() || nodeType;
|
||||
|
||||
// Construct the full workflow type based on package
|
||||
if (packageName === 'n8n-nodes-base') {
|
||||
return `n8n-nodes-base.${nodeName}`;
|
||||
} else if (packageName === '@n8n/n8n-nodes-langchain') {
|
||||
return `@n8n/n8n-nodes-langchain.${nodeName}`;
|
||||
}
|
||||
|
||||
// Fallback for unknown packages - return as is
|
||||
return nodeType;
|
||||
}
|
||||
Reference in New Issue
Block a user