Skip to main content
Glama

create_workflow

Build automated workflows by defining nodes and connections to streamline business processes and integrate applications.

Instructions

Create a new n8n workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
nodesYes
connectionsYes
activeNo
tagsNo

Implementation Reference

  • src/index.ts:71-71 (registration)
    Registration of the 'create_workflow' MCP tool, including input schema definition
    { name: 'create_workflow', description: 'Create a new n8n workflow', inputSchema: { type: 'object', properties: { name: { type: 'string' }, nodes: { type: 'array', items: { type: 'object' } }, connections: { type: 'object' }, active: { type: 'boolean', default: false }, tags: { type: 'array', items: { type: 'string' } } }, required: ['name', 'nodes', 'connections'] } },
  • MCP server handler for 'create_workflow': calls N8nClient.createWorkflow, adds numeric ID alias, returns JSON response
    private async handleCreateWorkflow(args: Omit<N8nWorkflow, 'id'>) { const workflow = await this.n8nClient.createWorkflow(args); this.withAlias(workflow); return { content: [{ type: 'text', text: JSON.stringify(jsonSuccess(workflow), null, 2) }] }; }
  • Switch case in CallToolRequestHandler dispatching 'create_workflow' calls to the handler method
    case 'create_workflow': return await this.handleCreateWorkflow(request.params.arguments as Omit<N8nWorkflow, 'id'>);
  • Core N8nClient implementation: resolves credential aliases, sanitizes workflow (settings/tags/active), POSTs to n8n /workflows endpoint
    async createWorkflow(workflow: Omit<N8nWorkflow, 'id'>): Promise<N8nWorkflow> { // Resolve credential aliases before creating the workflow await this.resolveCredentialsInWorkflow(workflow); // Ensure required fields expected by n8n API if ((workflow as any).settings == null) { (workflow as any).settings = {}; } // Some n8n deployments may not accept non-numeric tag values on create. // If tags are provided as strings (names), omit them here; users can set numeric tag IDs via setWorkflowTags. if (Array.isArray((workflow as any).tags) && (workflow as any).tags.some((t: any) => typeof t !== 'number')) { delete (workflow as any).tags; } // 'active' is managed via dedicated activate/deactivate endpoints; omit on create if ('active' in (workflow as any)) { delete (workflow as any).active; } const response = await this.api.post<N8nApiResponse<N8nWorkflow> | N8nWorkflow>('/workflows', workflow); const payload: any = response.data as any; return (payload && typeof payload === 'object' && 'data' in payload) ? payload.data : payload; }
  • TypeScript interface N8nWorkflow defining the structure expected for create_workflow input (Omit<..., 'id'>)
    export interface N8nWorkflow { id?: string | number; name: string; nodes: N8nNode[]; connections: N8nConnections; active?: boolean; settings?: Record<string, any>; staticData?: Record<string, any>; tags?: string[]; pinData?: Record<string, any>; versionId?: string; meta?: Record<string, any>; }

Latest Blog Posts

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/get2knowio/n8n-mcp'

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