Skip to main content
Glama
n8n MCP Server

n8n MCP Server

by Jaskey15
README.md
# n8n MCP Server

An MCP (Model Context Protocol) server that enables Claude to interact with your self-hosted n8n workflows. This server provides tools to list, inspect, and monitor n8n workflows directly from Claude.

## Features

- **list_workflows** - Get all workflows with their IDs, names, and active status
- **get_workflow** - Retrieve complete workflow definition including nodes and connections
- **get_executions** - View recent execution history with status and error details

## Prerequisites

- Node.js 18 or higher
- A self-hosted n8n instance with API access enabled
- n8n API key

## Installation

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

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

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

## Configuration

### Getting your n8n API Key

1. Log in to your n8n instance
2. Go to Settings → API
3. Click "Create API Key" if you don't have one
4. Copy the API key

### Setting up Environment Variables

Create a `.env` file in your project root or set environment variables directly:

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

**Important:**
- The `N8N_URL` should be your full n8n instance URL (e.g., `https://n8n.example.com`)
- Do not include a trailing slash in the URL
- Keep your API key secure and never commit it to version control

### Configuring 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`

**Linux:** `~/.config/Claude/claude_desktop_config.json`

Add the following configuration:

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

Replace `/absolute/path/to/n8n-mcp-server` with the actual path to this project.

## Usage

Once configured, restart Claude Desktop. You can now ask Claude to interact with your n8n workflows:

### Example Prompts

- "List all my n8n workflows"
- "Show me the details of workflow ID abc123"
- "Get the recent execution history for my data sync workflow"
- "What workflows do I have that are currently active?"
- "Check if my Slack notification workflow has been running successfully"

## Available Tools

### 1. list_workflows

Lists all workflows in your n8n instance.

**Returns:**
```json
{
  "success": true,
  "count": 5,
  "workflows": [
    {
      "id": "1",
      "name": "My Workflow",
      "active": true,
      "createdAt": "2024-01-01T00:00:00.000Z",
      "updatedAt": "2024-01-02T00:00:00.000Z",
      "tags": []
    }
  ]
}
```

### 2. get_workflow

Fetches the complete workflow definition including all nodes and connections.

**Parameters:**
- `workflow_id` (string, required): The ID of the workflow to fetch

**Returns:**
```json
{
  "success": true,
  "workflow": {
    "id": "1",
    "name": "My Workflow",
    "active": true,
    "nodes": [...],
    "connections": {...},
    "settings": {...}
  }
}
```

### 3. get_executions

Gets recent execution history for a workflow.

**Parameters:**
- `workflow_id` (string, required): The ID of the workflow
- `limit` (number, optional): Number of executions to return (default: 10, max: 100)

**Returns:**
```json
{
  "success": true,
  "workflowId": "1",
  "count": 3,
  "executions": [
    {
      "id": "exec1",
      "workflowId": "1",
      "finished": true,
      "mode": "manual",
      "startedAt": "2024-01-01T00:00:00.000Z",
      "stoppedAt": "2024-01-01T00:01:00.000Z",
      "status": "success",
      "error": null
    }
  ]
}
```

## Limitations

This MCP server is focused on **workflow inspection and monitoring**, not execution.

**What this server does:**
- ✅ List and inspect workflow configurations
- ✅ Monitor execution history and status
- ✅ Debug workflow issues by examining execution data
- ✅ Understand workflow structure (nodes, connections, settings)

**What this server doesn't do:**
- ❌ Trigger workflow executions programmatically
- ❌ Modify workflow configurations
- ❌ Create or delete workflows

**Why no workflow triggering?**

Workflows should be triggered via their native trigger types:
- **Webhooks:** Use the webhook URL for HTTP-triggered workflows
- **Manual triggers:** Use the "Test workflow" or "Execute workflow" buttons in n8n UI
- **Schedule triggers:** Configure cron expressions in n8n
- **Other triggers:** Use n8n's built-in trigger mechanisms

Programmatic workflow execution is complex because different trigger types require different data formats and handling. This server keeps things simple and reliable by focusing on inspection and monitoring.

## Example Usage with Claude

Here's a real conversation showing the MCP server in action:

**User:** "Can you show me all my n8n workflows?"

**Claude:** *[Uses list_workflows tool]*

"You have 5 workflows:
1. 'Customer Onboarding Email' (ID: 1, Active)
2. 'Slack Notification Pipeline' (ID: 3, Active)
3. 'Data Sync to Airtable' (ID: 7, Inactive)
4. 'Weekly Report Generator' (ID: 12, Active)
5. 'Test Workflow' (ID: 15, Inactive)"

---

**User:** "Show me the details of the Slack notification workflow"

**Claude:** *[Uses get_workflow tool with ID 3]*

"The Slack Notification Pipeline workflow has 4 nodes:
1. Webhook trigger (listening on /webhook/slack-alerts)
2. Filter node (checks if severity is 'high' or 'critical')
3. Set node (formats message for Slack)
4. Slack node (sends to #alerts channel)

The workflow is currently active and will trigger when it receives POST requests to the webhook URL."

---

**User:** "Has this workflow been running successfully? Check the last 10 executions"

**Claude:** *[Uses get_executions tool with ID 3, limit 10]*

"Recent execution history for Slack Notification Pipeline:

✅ 8 successful executions
❌ 2 failed executions

The failures occurred on 2025-12-13 at 14:23 and 15:45. Both failed at the Slack node with error: 'channel_not_found - Channel #alerts does not exist'

Recommendation: Check that the #alerts channel exists in your Slack workspace, or update the workflow to use a different channel."

## Development

### Building

```bash
npm run build
```

### Watch Mode

```bash
npm run watch
```

### Development Mode

```bash
npm run dev
```

## Error Handling

The server includes comprehensive error handling:

- **Authentication errors (401/403)**: Invalid or missing API key
- **Not found errors (404)**: Workflow or resource doesn't exist
- **Network errors**: Connection issues with n8n instance
- **Invalid parameters**: Missing or invalid tool parameters

All errors are returned in a structured format with clear messages.

## Security Considerations

- Never commit your API key to version control
- Use environment variables or secure configuration management
- Ensure your n8n instance uses HTTPS in production
- Regularly rotate your API keys
- Limit API key permissions if possible

## Troubleshooting

### "N8N_URL environment variable is required"
Ensure you've set the `N8N_URL` in your Claude Desktop configuration.

### "Authentication failed"
Check that your API key is correct and has the necessary permissions.

### "Resource not found"
Verify the workflow ID exists and your API key has access to it.

### Connection timeout
Ensure your n8n instance is accessible and not behind a firewall that blocks the requests.

## License

MIT

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a distinct operation: listing workflows, fetching one workflow's full JSON, and retrieving execution history. There is no overlap in purpose or output, so an agent can select correctly without ambiguity.

Naming Consistency5/5

All three tools follow a strict verb_noun snake_case pattern (list_workflows, get_workflow, get_executions). The convention is uniform and immediately readable.

Tool Count3/5

Three tools is thin for a workflow automation platform, covering only read paths on workflows and executions. Each earns its place, but the surface feels minimal rather than well-scoped.

Completeness2/5

The server is read-only: there is no create, update, delete, activate/deactivate, or execute/trigger workflow operation, nor any way to inspect a single execution's detail. An agent asked to build or run automations would hit a dead end.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues