n8n MCP Server
A Model Context Protocol (MCP) server that allows AI assistants to interact with n8n workflows through natural language.
Overview
This MCP server provides tools and resources for AI assistants to manage n8n workflows and executions. It allows assistants to:
- List, create, update, and delete workflows
- Activate and deactivate workflows
- Execute workflows and monitor their status
- Access workflow information and execution statistics
Installation
Prerequisites
- Node.js 18 or later
- n8n instance with API access enabled
Install from npm
1npm install -g n8n-mcp-server
Install from source
1# Clone the repository 2git clone https://github.com/leonardsellem/n8n-mcp-server.git 3cd n8n-mcp-server 4 5# Install dependencies 6npm install 7 8# Build the project 9npm run build 10 11# Optional: Install globally 12npm install -g .
Configuration
Create a .env
file in the directory where you'll run the server, using .env.example
as a template:
1cp .env.example .env
Configure the following environment variables:
| Variable | Description | Example |
|----------|-------------|---------|
| N8N_API_URL
| URL of the n8n API | http://localhost:5678/api/v1
|
| N8N_API_KEY
| API key for authenticating with n8n | n8n_api_...
|
| N8N_WEBHOOK_USERNAME
| Username for webhook authentication | username
|
| N8N_WEBHOOK_PASSWORD
| Password for webhook authentication | password
|
| DEBUG
| Enable debug logging (optional) | true
or false
|
Generating an n8n API Key
- Open your n8n instance in a browser
- Go to Settings > API > API Keys
- Create a new API key with appropriate permissions
- Copy the key to your
.env
file
Usage
Running the Server
From the installation directory:
1n8n-mcp-server
Or if installed globally:
1n8n-mcp-server
Integrating with AI Assistants
To use this MCP server with AI assistants, you need to register it with your AI assistant platform. The exact method depends on the platform you're using.
For example, with the MCP installer:
1npx @anaisbetts/mcp-installer
Then register the server:
install_local_mcp_server path/to/n8n-mcp-server
Available Tools
The server provides the following tools:
Using Webhooks
This MCP server supports executing workflows through n8n webhooks. To use this functionality:
- Create a webhook-triggered workflow in n8n.
- Set up Basic Authentication on your webhook node.
- Use the
run_webhook
tool to trigger the workflow, passing just the workflow name.
Example:
1const result = await useRunWebhook({ 2 workflowName: "hello-world", // Will call <n8n-url>/webhook/hello-world 3 data: { 4 prompt: "Hello from AI assistant!" 5 } 6});
The webhook authentication is handled automatically using the N8N_WEBHOOK_USERNAME
and N8N_WEBHOOK_PASSWORD
environment variables.
Workflow Management
workflow_list
: List all workflowsworkflow_get
: Get details of a specific workflowworkflow_create
: Create a new workflowworkflow_update
: Update an existing workflowworkflow_delete
: Delete a workflowworkflow_activate
: Activate a workflowworkflow_deactivate
: Deactivate a workflow
Execution Management
execution_run
: Execute a workflow via the APIrun_webhook
: Execute a workflow via a webhookexecution_get
: Get details of a specific executionexecution_list
: List executions for a workflowexecution_stop
: Stop a running execution
Resources
The server provides the following resources:
n8n://workflows/list
: List of all workflowsn8n://workflow/{id}
: Details of a specific workflown8n://executions/{workflowId}
: List of executions for a workflown8n://execution/{id}
: Details of a specific execution
Development
Building
1npm run build
Running in Development Mode
1npm run dev
Testing
1npm test
Linting
1npm run lint
License
MIT