Files
n8n-mcp/src/mcp/resources.ts
czlonkowski 04627616d4 Add AI Agent node source code extraction capability
This commit implements the ability to extract n8n node source code through MCP:

Features:
- New MCP tools: get_node_source_code and list_available_nodes
- NodeSourceExtractor utility for file system access to n8n nodes
- Support for extracting any n8n node including AI Agent from @n8n/n8n-nodes-langchain
- Resource endpoint for accessing node source: nodes://source/{nodeType}

Testing:
- Docker test environment with mounted n8n node_modules
- Multiple test scripts for different scenarios
- Comprehensive test documentation
- Standalone MCP client test demonstrating full extraction flow

The implementation successfully demonstrates:
1. MCP server can access n8n's installed nodes
2. Source code can be extracted and returned to MCP clients
3. Full metadata including package info and file locations
4. Support for credential code extraction when available

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-07 15:57:49 +00:00

40 lines
1023 B
TypeScript

import { ResourceDefinition } from '../types';
export const n8nResources: ResourceDefinition[] = [
{
uri: 'workflow://active',
name: 'Active Workflows',
description: 'List of all active workflows in n8n',
mimeType: 'application/json',
},
{
uri: 'workflow://all',
name: 'All Workflows',
description: 'List of all workflows in n8n',
mimeType: 'application/json',
},
{
uri: 'execution://recent',
name: 'Recent Executions',
description: 'Recent workflow execution history',
mimeType: 'application/json',
},
{
uri: 'credentials://types',
name: 'Credential Types',
description: 'Available credential types in n8n',
mimeType: 'application/json',
},
{
uri: 'nodes://available',
name: 'Available Nodes',
description: 'List of all available n8n nodes',
mimeType: 'application/json',
},
{
uri: 'nodes://source',
name: 'Node Source Code',
description: 'Source code of n8n nodes',
mimeType: 'text/javascript',
},
];