n8n MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A Model Context Protocol (MCP) server that allows AI assistants to interact with n8n workflows through natural language.
Overview
This project provides a Model Context Protocol (MCP) server that empowers AI assistants to seamlessly interact with n8n, a popular workflow automation tool. It acts as a bridge, enabling AI assistants to programmatically manage and control n8n workflows and executions using natural language commands.
Installation
Prerequisites
- Node.js 20 or later
- n8n instance with API access enabled
Install from npm
Install from source
Docker Installation
You can also run the server using Docker:
Updating the Server
How you update the server depends on how you initially installed it.
1. Installed globally via npm
If you installed the server using npm install -g @leonardsellem/n8n-mcp-server:
1. Open your terminal or command prompt.
2. Run the following command to get the latest version:
3. If the server is currently running (e.g., as a background process or service), you'll need to restart it for the changes to take effect.
2. Installed from source
If you cloned the repository and installed from source:
1. Open your terminal or command prompt.
2. Navigate to the directory where you cloned the project:
3. If you've made any local changes to the code that you want to keep, consider stashing them (optional):
You can apply them later with git stash pop.
4. Pull the latest changes from the repository (assuming you are on the main branch):
If you are on a different branch, replace main with your branch name.
5. Install or update any changed dependencies:
6. Rebuild the project to include the latest updates:
7. If you previously installed it globally from this source folder using npm install -g ., you might want to run this command again to update the global link:
8. Restart the server.
* If you run the server directly using a command like node build/index.js in your AI assistant's MCP configuration, ensure the path is still correct. Using npm install -g . and then n8n-mcp-server as the command should keep this consistent.
3. Using Docker
If you are running the server using Docker:
1. Pull the latest image from Docker Hub:
2. Stop and remove your old container. You'll need your container's name or ID (you can find it using docker ps):
3. Start a new container with the updated image. Use the same docker run command you used previously, including all your necessary environment variables (refer to the "Docker Installation" section for an example command). For instance:
Ensure you use :latest or the specific version tag you intend to run.
Configuration
Create a .env file in the directory where you'll run the server, using .env.example as a template:
Configure the following environment variables:
| Variable | Description | Example |
|----------|-------------|---------|
| N8N_API_URL | Full URL of the n8n API, including /api/v1 | http://localhost:5678/api/v1 |
| N8N_API_KEY | API key for authenticating with n8n | n8n_api_... |
| N8N_WEBHOOK_USERNAME | Username for webhook authentication (if using webhooks) | username |
| N8N_WEBHOOK_PASSWORD | Password for webhook authentication | password |
| DEBUG | Enable debug logging (optional) | true or false |
Generating an n8n API Key
1. Open your n8n instance in a browser
2. Go to Settings > API > API Keys
3. Create a new API key with appropriate permissions
4. Copy the key to your .env file
Usage
Running the Server
From the installation directory:
Or if installed globally:
Integrating with AI Assistants
After building the server (npm run build), you need to configure your AI assistant (like VS Code with the Claude extension or the Claude Desktop app) to run it. This typically involves editing a JSON configuration file.
**Example Configuration (e.g., in VS Code settings.json or Claude Desktop claude_desktop_config.json):**