A comprehensive Model Context Protocol (MCP) server that provides AI assistants with full programmatic access to n8n workflows, executions, credentials, and more.
- Workflow Management: Create, read, update, delete, activate, deactivate workflows
- Execution Management: List, get, delete, trigger, retry, stop executions
- Credential Management: Create, read, update, delete, test credentials
- Tag Management: Create, list, delete tags
- User Management: List and get user information
- Variable Management: Create, read, update, delete variables
- File Upload: Upload files to n8n (if supported)
- Health Monitoring: Check API connectivity and health status
- Comprehensive Error Handling: Detailed error codes and messages
- Logging System: Winston-based logging with multiple levels and categories
- Input Validation: Zod-based schema validation for all inputs
- Retry Logic: Automatic retry for transient failures
- Rate Limiting: Built-in rate limit handling
- Type Safety: Full TypeScript support with strict typing
- Node.js 18.0.0 or higher
- n8n instance with API access
- n8n API key
-
Clone the repository
git clone https://github.com/your-org/n8n-mcp-server.git cd n8n-mcp-server -
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env
Edit
.envwith your n8n configuration:N8N_API_URL=http://localhost:5678/api/v1 N8N_API_KEY=your-api-key-here LOG_LEVEL=info NODE_ENV=development
-
Build the project
npm run build
npm startnpm run devnpm test
npm run test:coverageTo use this MCP server with Claude Desktop or other MCP clients, add the following configuration:
Add 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
{
"mcpServers": {
"n8n": {
"command": "node",
"args": ["/path/to/n8n-mcp-server/start.js"],
"env": {
"N8N_API_URL": "http://localhost:5678/api/v1",
"N8N_API_KEY": "your-n8n-api-key",
"LOG_LEVEL": "info"
}
}
}
}The MCP server accepts the following environment variables in the client configuration:
| Variable | Description | Required | Example |
|---|---|---|---|
N8N_API_URL |
n8n API base URL | Yes | http://localhost:5678/api/v1 |
N8N_API_KEY |
n8n API key for authentication | Yes | n8n_api_1234567890abcdef |
N8N_WEBHOOK_USERNAME |
Username for webhook authentication | No | webhook-user |
N8N_WEBHOOK_PASSWORD |
Password for webhook authentication | No | webhook-pass |
LOG_LEVEL |
Logging level | No | info, debug, error |
API_TIMEOUT |
API request timeout in milliseconds | No | 30000 |
API_RETRY_ATTEMPTS |
Number of retry attempts for failed requests | No | 3 |
API_RETRY_DELAY |
Delay between retries in milliseconds | No | 1000 |
- Log in to your n8n instance
- Go to Settings β API
- Generate a new API key
- Copy the key and add it to your MCP client configuration
Once configured, the MCP client should be able to:
- List available tools from the n8n server
- Execute workflow operations
- Manage credentials and executions
You can verify the connection by asking your AI assistant to list available n8n workflows or check the API connectivity status.
| Tool | Description | Parameters |
|---|---|---|
list_workflows |
List all workflows with filtering | active, limit, offset, tags, search |
get_workflow |
Get specific workflow by ID | workflowId |
create_workflow |
Create new workflow | name, nodes, connections, settings, tags |
update_workflow |
Update existing workflow | workflowId, name, nodes, connections, settings, tags |
delete_workflow |
Delete workflow | workflowId |
activate_workflow |
Activate workflow | workflowId |
deactivate_workflow |
Deactivate workflow | workflowId |
update_workflow_tags |
Update workflow tags | workflowId, tags |
transfer_workflow |
Transfer workflow ownership | workflowId, userId |
| Tool | Description | Parameters |
|---|---|---|
list_executions |
List executions with filtering | workflowId, status, limit, offset, since, until |
get_execution |
Get specific execution | executionId |
delete_execution |
Delete execution | executionId |
trigger_execution |
Manually trigger workflow | workflowId, data |
retry_execution |
Retry failed execution | executionId |
stop_execution |
Stop running execution | executionId |
| Tool | Description | Parameters |
|---|---|---|
list_credentials |
List all credentials | type |
get_credential |
Get specific credential | credentialId |
create_credential |
Create new credential | name, type, data, nodesAccess |
update_credential |
Update credential | credentialId, name, data, nodesAccess |
delete_credential |
Delete credential | credentialId |
test_credential |
Test credential | credentialId |
transfer_credential |
Transfer credential ownership | credentialId, userId |
| Tool | Description | Parameters |
|---|---|---|
list_tags |
List all tags | None |
create_tag |
Create new tag | name |
delete_tag |
Delete tag | tagId |
list_users |
List all users | None |
get_user |
Get specific user | userId |
list_variables |
List all variables | None |
create_variable |
Create new variable | key, value |
update_variable |
Update variable | variableId, key, value |
delete_variable |
Delete variable | variableId |
| Tool | Description | Parameters |
|---|---|---|
upload_file |
Upload file to n8n | filename, content, mimeType |
check_connectivity |
Check API connectivity | None |
get_health_status |
Get API health status | None |
| Variable | Description | Required | Default |
|---|---|---|---|
N8N_API_URL |
n8n API base URL | Yes | - |
N8N_API_KEY |
n8n API key | Yes | - |
N8N_WEBHOOK_USERNAME |
Webhook username | No | - |
N8N_WEBHOOK_PASSWORD |
Webhook password | No | - |
LOG_LEVEL |
Logging level | No | info |
PORT |
Server port | No | - |
NODE_ENV |
Environment | No | development |
API_TIMEOUT |
API timeout (ms) | No | 30000 |
API_RETRY_ATTEMPTS |
Retry attempts | No | 3 |
API_RETRY_DELAY |
Retry delay (ms) | No | 1000 |
error: Only error messageswarn: Warning and error messagesinfo: Info, warning, and error messagesdebug: Debug, info, warning, and error messagesverbose: All messages
n8n-mcp-server/
βββ src/
β βββ api/
β β βββ n8n-client.ts # n8n API client
β βββ config/
β β βββ environment.ts # Environment configuration
β β βββ server.ts # Server configuration
β βββ errors/
β β βββ error-codes.ts # Error code definitions
β β βββ index.ts # Error handling utilities
β βββ tools/
β β βββ base-handler.ts # Base tool handler classes
β β βββ workflow/ # Workflow tool handlers
β β βββ execution/ # Execution tool handlers
β β βββ credentials/ # Credential tool handlers
β β βββ upload/ # Upload tool handlers
β βββ types/
β β βββ index.ts # Type definitions
β βββ utils/
β β βββ logger.ts # Logging utilities
β βββ index.ts # Main entry point
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ fixtures/ # Test fixtures
β βββ mocks/ # Test mocks
βββ build/ # Compiled JavaScript
βββ logs/ # Log files
βββ templates/ # Workflow templates
βββ package.json
βββ tsconfig.json
βββ jest.config.js
βββ README.md
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Run specific test file
npm test -- --testNamePattern="list_workflows"- Unit Tests: Test individual functions and classes
- Integration Tests: Test API interactions and tool handlers
- Fixtures: Test data and mock responses
- Mocks: Mock implementations for external dependencies
GET /workflows- List workflowsGET /workflows/{id}- Get workflowPOST /workflows- Create workflowPUT /workflows/{id}- Update workflowDELETE /workflows/{id}- Delete workflowPOST /workflows/{id}/activate- Activate workflowPOST /workflows/{id}/deactivate- Deactivate workflowPOST /workflows/{id}/tags- Update workflow tagsPOST /workflows/{id}/transfer- Transfer workflow ownership
GET /executions- List executionsGET /executions/{id}- Get executionDELETE /executions/{id}- Delete executionPOST /executions- Trigger executionPOST /executions/{id}/retry- Retry executionPOST /executions/{id}/stop- Stop execution
GET /credentials- List credentialsGET /credentials/{id}- Get credentialPOST /credentials- Create credentialPUT /credentials/{id}- Update credentialDELETE /credentials/{id}- Delete credentialPOST /credentials/{id}/test- Test credentialPOST /credentials/{id}/transfer- Transfer credential ownership
GET /tags- List tagsGET /tags/{id}- Get tagPOST /tags- Create tagPUT /tags/{id}- Update tagDELETE /tags/{id}- Delete tag
GET /users- List usersGET /users/{id}- Get user
GET /variables- List variablesGET /variables/{id}- Get variablePOST /variables- Create variablePUT /variables/{id}- Update variableDELETE /variables/{id}- Delete variable
- API keys are stored securely in environment variables
- All API requests are authenticated
- Input validation prevents injection attacks
- Error messages don't expose sensitive information
- Logging excludes sensitive data
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]NODE_ENV=development
LOG_LEVEL=debugNODE_ENV=production
LOG_LEVEL=infoNODE_ENV=test
LOG_LEVEL=error- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write comprehensive tests
- Add JSDoc comments for all public APIs
- Follow the existing code style
- Update documentation for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Project Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- n8n - The workflow automation platform
- Model Context Protocol - The MCP specification
- Winston - Logging library
- Zod - TypeScript-first schema validation