Skip to main content
Glama
JBrightmanAI

n8n MCP Server

by JBrightmanAI
README.md
# n8n MCP Server

A Model Context Protocol (MCP) server for managing n8n workflows. This server enables AI assistants to interact with your n8n instance to create, update, delete, monitor, and control workflows and executions.

## Features

### Workflow Management
- **List workflows** - Get all workflows with optional filtering by active status
- **Get workflow** - Retrieve detailed information about a specific workflow
- **Create workflow** - Create new workflows programmatically
- **Update workflow** - Modify existing workflow configurations
- **Delete workflow** - Remove workflows from your n8n instance

### Workflow Control
- **Activate workflow** - Enable a workflow to run on triggers
- **Deactivate workflow** - Disable a workflow

### Workflow Execution
- **Execute workflow** - Manually trigger a workflow execution
- **List executions** - View execution history with optional workflow filtering
- **Get execution** - Retrieve detailed execution information including results
- **Delete execution** - Remove execution records

## Prerequisites

- Node.js 18 or higher
- n8n instance (self-hosted or cloud)
- n8n API key

## Installation

1. Clone this repository:
```bash
git clone <repository-url>
cd n8n-mcp
```

2. Install dependencies:
```bash
npm install
```

3. Build the server:
```bash
npm run build
```

## Configuration

### Generate n8n API Key

1. Log in to your n8n instance
2. Go to **Settings** > **n8n API**
3. Click **Create an API Key**
4. Copy the generated API key

### Environment Variables

Set the following environment variables:

```bash
export N8N_BASE_URL="https://your-n8n-instance.com"
export N8N_API_KEY="your-api-key-here"
```

For n8n cloud:
```bash
export N8N_BASE_URL="https://your-instance.app.n8n.cloud"
```

For self-hosted:
```bash
export N8N_BASE_URL="http://localhost:5678"
```

## Usage with Claude Desktop

Add this server to your Claude Desktop configuration file:

**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "n8n": {
      "command": "node",
      "args": ["/absolute/path/to/n8n-mcp/build/index.js"],
      "env": {
        "N8N_BASE_URL": "https://your-n8n-instance.com",
        "N8N_API_KEY": "your-api-key-here"
      }
    }
  }
}
```

## Available Tools

### Workflow Management

#### `list_workflows`
List all workflows with optional active status filter.

**Parameters:**
- `active` (boolean, optional): Filter by active status

**Example:**
```
List all active workflows
```

#### `get_workflow`
Get detailed information about a specific workflow.

**Parameters:**
- `id` (string, required): Workflow ID

**Example:**
```
Get workflow with ID "123"
```

#### `create_workflow`
Create a new workflow.

**Parameters:**
- `name` (string, required): Workflow name
- `nodes` (array, required): Workflow nodes configuration
- `connections` (object, optional): Node connections
- `settings` (object, optional): Workflow settings

**Example:**
```
Create a simple workflow named "Test Workflow"
```

#### `update_workflow`
Update an existing workflow.

**Parameters:**
- `id` (string, required): Workflow ID
- `name` (string, optional): New workflow name
- `nodes` (array, optional): Updated nodes
- `connections` (object, optional): Updated connections
- `settings` (object, optional): Updated settings

#### `delete_workflow`
Delete a workflow.

**Parameters:**
- `id` (string, required): Workflow ID

### Workflow Control

#### `activate_workflow`
Activate a workflow to enable trigger-based execution.

**Parameters:**
- `id` (string, required): Workflow ID

#### `deactivate_workflow`
Deactivate a workflow.

**Parameters:**
- `id` (string, required): Workflow ID

### Execution Management

#### `execute_workflow`
Manually execute a workflow.

**Parameters:**
- `id` (string, required): Workflow ID

#### `list_executions`
List workflow executions.

**Parameters:**
- `workflowId` (string, optional): Filter by workflow ID

#### `get_execution`
Get detailed execution information.

**Parameters:**
- `id` (string, required): Execution ID

#### `delete_execution`
Delete an execution record.

**Parameters:**
- `id` (string, required): Execution ID

## Development

### Watch mode
```bash
npm run watch
```

### Build
```bash
npm run build
```

## Troubleshooting

### API Key Issues
- Ensure your API key is valid and has the necessary permissions
- For n8n Cloud, you need a paid plan to use the API

### Connection Issues
- Verify the `N8N_BASE_URL` is correct and accessible
- Check that your n8n instance is running
- Ensure there are no firewall issues blocking the connection

### MCP Server Not Showing
- Restart Claude Desktop after configuration changes
- Check the Claude Desktop logs for errors
- Verify the path to `index.js` is absolute and correct

## License

MIT