Skip to main content
Glama

n8n MCP Server

MIT License
133
1,377
  • Apple
  • Linux
simple-tool.test.ts2.83 kB
/** * Simple workflow tool tests without complex dependencies */ import { describe, it, expect } from '@jest/globals'; interface MockWorkflow { id: string; name: string; active: boolean; createdAt: string; updatedAt: string; nodes: any[]; } interface WorkflowFilter { active?: boolean; } // Mock workflow data const mockWorkflows: MockWorkflow[] = [ { id: '1234abc', name: 'Test Workflow 1', active: true, createdAt: '2025-03-01T12:00:00.000Z', updatedAt: '2025-03-02T14:30:00.000Z', nodes: [] }, { id: '5678def', name: 'Test Workflow 2', active: false, createdAt: '2025-03-01T12:00:00.000Z', updatedAt: '2025-03-12T10:15:00.000Z', nodes: [] } ]; // Simple function to test tool definition function getListWorkflowsToolDefinition() { return { name: 'list_workflows', description: 'List all workflows with optional filtering by status', inputSchema: { type: 'object', properties: { active: { type: 'boolean', description: 'Filter workflows by active status' } }, required: [] } }; } // Simple function to test workflow filtering function filterWorkflows(workflows: MockWorkflow[], filter: WorkflowFilter): MockWorkflow[] { if (filter && typeof filter.active === 'boolean') { return workflows.filter(workflow => workflow.active === filter.active); } return workflows; } describe('Workflow Tools', () => { describe('getListWorkflowsToolDefinition', () => { it('should return the correct tool definition', () => { const definition = getListWorkflowsToolDefinition(); expect(definition.name).toBe('list_workflows'); expect(definition.description).toBeTruthy(); expect(definition.inputSchema).toBeDefined(); expect(definition.inputSchema.properties).toHaveProperty('active'); expect(definition.inputSchema.required).toEqual([]); }); }); describe('filterWorkflows', () => { it('should return all workflows when no filter is provided', () => { const result = filterWorkflows(mockWorkflows, {}); expect(result).toHaveLength(2); expect(result).toEqual(mockWorkflows); }); it('should filter workflows by active status when active is true', () => { const result = filterWorkflows(mockWorkflows, { active: true }); expect(result).toHaveLength(1); expect(result[0].id).toBe('1234abc'); expect(result[0].active).toBe(true); }); it('should filter workflows by active status when active is false', () => { const result = filterWorkflows(mockWorkflows, { active: false }); expect(result).toHaveLength(1); expect(result[0].id).toBe('5678def'); expect(result[0].active).toBe(false); }); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leonardsellem/n8n-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server