n8n MCP Server
Enables AI agents to create, retrieve, update, and manage n8n workflows through the n8n API. Supports full workflow lifecycle management including activation, deactivation, and deletion operations.
README
n8n-mcp
An MCP (Model Context Protocol) server for managing n8n workflows. This server allows AI agents to create, retrieve, update, and manage n8n workflows through the n8n API.
Features
Workflow Management
- List Workflows: Get all workflows from your n8n instance
- Get Workflow: Retrieve a specific workflow by ID
- Create Workflow: Create new workflows with nodes and connections
- Update Workflow: Modify existing workflows
- Delete Workflow: Remove workflows
- Activate/Deactivate: Control workflow execution state
- List Executions: Get workflow executions with pagination support
- Get Execution: Retrieve specific execution details by ID
- Delete Execution: Remove execution records
Variables Management
- List Variables: Get all variables with pagination support
- Create Variable: Create new key-value variables (enforces unique keys)
- Update Variable: Modify existing variable values
- Delete Variable: Remove variables
- CLI & MCP Support: Full access via both command line and MCP tools
Installation
From GitHub Packages
npm install @get2knowio/n8n-mcp
From Source
git clone https://github.com/get2knowio/n8n-mcp.git
cd n8n-mcp
npm install
npm run build
Configuration
Set the following environment variables:
Option 1: API Key Authentication
export N8N_BASE_URL=http://localhost:5678
export N8N_API_KEY=your_api_key_here
Option 2: Basic Authentication
export N8N_BASE_URL=http://localhost:5678
export N8N_USERNAME=your_username
export N8N_PASSWORD=your_password
Usage
As an MCP Server
npm start
The server runs on stdio and implements the MCP protocol for integration with AI agents.
As a CLI Tool
For testing and development, you can use the CLI interface:
# List all workflows
npm run cli list
# Get a specific workflow
npm run cli get 1
# Create a workflow from JSON file
npm run cli create examples/example-workflow.json
# Delete a workflow
npm run cli delete 1
# Activate/deactivate workflows
npm run cli activate 1
npm run cli deactivate 1
# Variables management
npm run cli variables list
npm run cli variables create --key mykey --value myvalue
npm run cli variables update var-123 --value newvalue
npm run cli variables delete var-123
# List executions
npm run cli executions list
# List executions with pagination and filtering
npm run cli executions list --limit 50 --workflow-id 1
# Get a specific execution
npm run cli executions get exec_123
# Delete an execution
npm run cli executions delete exec_123
# Get webhook URLs for a webhook node
npm run cli webhook-urls 1 webhook-node-id
# Execute a workflow manually once
npm run cli run-once 1
# Execute a workflow with input data
npm run cli run-once 1 input-data.json
Available Tools
Workflow Tools
- list_workflows - List all workflows
- get_workflow - Get workflow by ID
- create_workflow - Create a new workflow
- update_workflow - Update existing workflow
- delete_workflow - Delete a workflow
- activate_workflow - Activate a workflow
- deactivate_workflow - Deactivate a workflow
- list_executions - List workflow executions with pagination
- get_execution - Get execution by ID
- delete_execution - Delete an execution
- webhook_urls - Get webhook URLs for a webhook node
- run_once - Execute a workflow manually once
Variables Tools
- list_variables - List all variables with pagination support
- create_variable - Create a new variable (requires unique key)
- update_variable - Update an existing variable value
- delete_variable - Delete a variable
- list_executions - List workflow executions with pagination
- get_execution - Get execution by ID
- delete_execution - Delete an execution
- webhook_urls - Get webhook URLs for a webhook node
- run_once - Execute a workflow manually once
Example Workflow Creation
{
"name": "Example Workflow",
"nodes": [
{
"id": "webhook",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [250, 300],
"parameters": {
"httpMethod": "GET",
"path": "example"
}
}
],
"connections": {},
"active": false,
"tags": ["example"]
}
Example Variable Management
Variables in n8n are simple key-value pairs that can be used for configuration and state management:
{
"id": "var-123",
"key": "api_endpoint",
"value": "https://api.example.com/v1"
}
CLI Usage Examples
# Create a variable
npm run cli variables create --key environment --value production
# List all variables
npm run cli variables list
# Update a variable value
npm run cli variables update var-123 --value "https://api.newdomain.com/v2"
# Delete a variable
npm run cli variables delete var-123
MCP Tool Usage
Variables can be managed through MCP tools for integration with AI agents:
list_variables()- Returns paginated list of all variablescreate_variable({ key: "config_mode", value: "advanced" })- Creates new variableupdate_variable({ id: "var-123", value: "new_value" })- Updates existing variabledelete_variable({ id: "var-123" })- Removes variable
Execution Management
The server provides comprehensive execution management capabilities:
Listing Executions
# List recent executions
npm run cli executions list
# List with pagination
npm run cli executions list --limit 20 --cursor next_page_cursor
# Filter by workflow
npm run cli executions list --workflow-id 1
The list_executions tool supports:
- limit: Maximum number of executions to return (pagination)
- cursor: Pagination cursor for getting next/previous pages
- workflowId: Filter executions by specific workflow ID
Getting Execution Details
npm run cli executions get exec_12345
Returns complete execution data including:
- Execution status and timing
- Input/output data
- Error details (if failed)
- Node execution results
Deleting Executions
npm run cli executions delete exec_12345
Permanently removes execution records to help manage storage.
Pagination Notes
When listing executions:
- Use
limitparameter to control page size - Use
nextCursorfrom response to get the next page - Cursors are opaque strings - store and use them as-is
- Empty
nextCursorindicates no more pages available
Webhook URLs
The webhook_urls tool helps you get the correct webhook URLs for webhook nodes in your workflows. This is useful for:
- Getting URLs to configure external systems that need to call your webhooks
- Testing webhook endpoints during development
- Documentation and integration guides
Prerequisites for Webhook Nodes
For the webhook_urls tool to work correctly, your webhook node must:
- Be of type
n8n-nodes-base.webhook - Have a
pathparameter configured - Be part of an existing workflow
URL Format
The tool returns URLs in n8n's standard format:
- Test URL:
${baseUrl}/webhook-test/${path}- Used for testing during workflow development - Production URL:
${baseUrl}/webhook/${path}- Used when the workflow is active
Example Usage
// Get webhook URLs for a node
const urls = await client.getWebhookUrls(1, 'webhook-node-id');
console.log(urls);
// Output:
// {
// "testUrl": "http://localhost:5678/webhook-test/my-webhook",
// "productionUrl": "http://localhost:5678/webhook/my-webhook"
// }
Manual Workflow Execution
The run_once tool allows you to manually execute workflows, which is useful for:
- Testing workflows during development
- Triggering workflows programmatically
- Running workflows with specific input data
- Debugging workflow issues
Workflow Types
The tool handles different workflow types gracefully:
- Manual Workflows: Workflows that start with manual triggers (e.g., Start node)
- Trigger Workflows: Workflows with automatic triggers (e.g., Webhook, Cron, etc.)
Input Data
You can optionally provide input data when executing a workflow:
// Execute without input
const execution = await client.runOnce(1);
// Execute with input data
const execution = await client.runOnce(1, {
name: "John Doe",
email: "john@example.com"
});
Response Format
The tool returns execution details:
{
"executionId": "uuid-execution-id",
"status": "running" // or "completed", "failed", etc.
}
Development
Setup
npm install
npm run build
Testing
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Lint code (TypeScript type checking)
npm run lint
Scripts
npm run dev # Watch mode for development
npm run build # Build TypeScript
npm run test # Run tests
npm run lint # TypeScript type checking
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
All contributions are welcome! Please make sure to update tests as appropriate and follow the existing code style.
Releases
This project uses automated releases. When a new release is published on GitHub:
- The release workflow automatically triggers
- The package is built and tested
- If all tests pass, the package is published to GitHub Packages
- The package can then be installed using:
npm install @get2knowio/n8n-mcp
To create a new release:
- Update the version in
package.json - Create a new release on GitHub with a tag matching the version
- The automated workflow will handle the rest
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。