N8N MCP Server for Claude.ai and ChatGPT
π Production-ready MCP server that brings N8N workflow automation to both Claude.ai and ChatGPT (via ChatGPT Connectors).
Works over HTTP(S) using SSE or WebSocket and provides an OAuth flow for browsers. SSE mode is compatible with ChatGPT Connectors, and OAuth/SSE modes work with Claude web.
π Table of Contents
- π― What Makes This Special
- β¨ Features
- π οΈ Available Tools
- π Quick Start
- βοΈ Configuration
- π Authentication Flow
- π Production Deployment
- ποΈ Architecture
- ποΈ Architecture
- π₯οΈ Admin Dashboard
- π§ Troubleshooting
- π€ Contributing
- π¬ Support
π― What Makes This Special
- π Web-First Design: Works with Claude.ai web interface (not just desktop)
- π¬ Protocol Breakthrough: Solves Claude.ai's non-standard MCP implementation
- π’ Multi-Tenant Architecture: Multiple users, multiple N8N instances
- π Production Ready: Docker deployment with Traefik integration
- π Universal Access: Connect any N8N instance dynamically
Visual: Claude.ai seamlessly integrated with N8N workflows
β¨ Features
- π OAuth 2.1 Authentication - Secure authentication flow for Claude.ai integration
- π Dynamic N8N Configuration - Enter any N8N instance credentials during login
- π Comprehensive Workflow Management - Create, read, update, delete, and execute workflows
- β‘ Real-time Execution Control - Start, stop, and monitor workflow executions
- π₯ Multi-tenant Support - Each user session maintains separate N8N credentials
- π³ Docker Ready - Containerized deployment with Traefik integration
- π WebSocket Transport - Native WS endpoint for ChatGPT Connectors
- π SSE Transport - SSE endpoint compatible with ChatGPT Connectors
- π₯οΈ Admin Dashboard - Manage multiple N8N API hosts (add/remove, test, set defaults)
π§© ChatGPT Connector (SSE)
For ChatGPT Connectors, run the SSE server variant and restrict CORS to ChatGPT domains.
Environment (Docker or compose):
MCP_MODE=sse
PORT=3004
# Allow ChatGPT + your domain(s)
CORS_ORIGIN=https://chat.openai.com,https://chatgpt.com,https://n8n-mcp.right-api.com
# Optional: Preconfigure N8N (SSE also supports setting via tool or query params)
N8N_HOST=https://your-n8n.example.com
N8N_API_KEY=your-n8n-api-key
Endpoints:
- GET SSE stream:
GET /ssewithAccept: text/event-stream - Send messages:
POST /sse/message(or/message) withsessionId
Notes:
- Set
CORS_ORIGINto a comma-separated allowlist. Use the exact origins ChatGPT uses (currentlyhttps://chat.openai.comand/orhttps://chatgpt.com). - The server persists
N8N_HOST/N8N_API_KEYunder/app/data/n8n-credentials.jsonwhen set via theset_n8n_credentialstool or SSE?n8n_host=&n8n_key=query.
π OAuth Mode (ChatGPT Connector)
For a production ChatGPT Connector run the OAuth flavour (MCP_MODE=oauth). This exposes the same SSE endpoint at /mcp, but requires the user to sign in before a session is created.
Environment highlights:
MCP_MODE=oauth
PORT=3007 # Default OAuth port
SERVER_URL=https://mcp.example.com # Optional public base URL for discovery
ADMIN_USERNAME=admin # Change these in production
ADMIN_PASSWORD=changeme
Workflow:
- Start the server and visit
https://your-server/adminto sign in. Add one or more n8n hosts (URL + API key) and choose a default. - ChatGPT Connector hits
/.well-known/openid-configurationand completes OAuth against/oauth/authorizeand/oauth/token. - After login the issued access token stores the selected
host_id(or the admin-set default). The ChatGPT client connects toGET /mcpwithAccept: text/event-streamand reuses the returnedhost_idfor future calls. - Additional hosts can be targeted per request with a query such as
/mcp?host_id=h2.
Endpoints exposed in OAuth mode:
- GET
/.well-known/openid-configurationβ discovery document - GET
/oauth/authorizeβ handles the login + consent flow - POST
/oauth/tokenβ issues access tokens (PKCE supported) - GET
/mcpβ SSE stream (requiresAuthorization: Bearer <token>) - POST
/mcp/messageβ send JSON-RPC messages (requiresmcp-session-id) - DELETE
/mcp/sessionβ close a session
βΉοΈ Environment variables
N8N_HOST/N8N_API_KEYstill work as a fallback host when no admin-configured hosts exist.
π Quick Curl Test (SSE)
Start the SSE server (compose or
MCP_MODE=sse PORT=3004).In one terminal, open the SSE stream and note the session id from the first event lines (look for
id:):
curl -N -H "Accept: text/event-stream" \
https://n8n-mcp.right-api.com/sse
- In another terminal, post a JSON-RPC request to list tools. Replace SESSION_ID with the id captured from step 2:
curl -X POST \
-H "Content-Type: application/json" \
-H "mcp-session-id: SESSION_ID" \
-d '{
"jsonrpc":"2.0",
"id":"1",
"method":"tools/list"
}' \
https://n8n-mcp.right-api.com/sse/message
You should receive a JSON-RPC result with the available tools. You can then call a tool, e.g.:
curl -X POST \
-H "Content-Type: application/json" \
-H "mcp-session-id: SESSION_ID" \
-d '{
"jsonrpc":"2.0",
"id":"2",
"method":"tools/call",
"params": {"name":"get_n8n_status","arguments":{}}
}' \
https://n8n-mcp.right-api.com/sse/message
π οΈ Available Tools
The MCP server provides 9 N8N tools for workflow automation:
π Workflow Management
- π
get_workflows- List all workflows - π
get_workflow- Get specific workflow details - β
create_workflow- Create new workflows - βοΈ
update_workflow- Update existing workflows - ποΈ
delete_workflow- Delete workflows - βΆοΈ
activate_workflow- Activate workflows - βΈοΈ
deactivate_workflow- Deactivate workflows
β‘ Execution Management
- π
execute_workflow- Execute workflows manually - π
get_executions- View execution history and status
π Quick Start
πΈ Complete visual guide with real screenshots of the integration process
Screenshot: Claude.ai successfully managing N8N workflows
1οΈβ£ Clone and Setup
git clone https://github.com/yourusername/n8nmcp.git
cd n8nmcp
cp .env.example .env
2οΈβ£ Configure Environment
Edit .env file with your settings:
# Required
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your-secure-password
SERVER_URL=https://your-domain.com
# Allow Claude and/or ChatGPT
CORS_ORIGIN=https://claude.ai,https://chat.openai.com,https://chatgpt.com
# Optional (can be set via login form)
N8N_HOST=https://your-n8n-instance.com
N8N_API_KEY=your-n8n-api-key
3οΈβ£ Deploy with Docker
# Make sure you're in the n8nmcp directory
docker-compose up -d
# Check logs
docker logs n8n-mcp-server -f
4οΈβ£ Alternative: Quick Deploy with Cloudflare Tunnel
For instant HTTPS access without domain setup:
# Install Cloudflare Tunnel
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb
# Start the N8N MCP server locally
docker run -d --name n8n-mcp-server -p 3005:3000 \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD=your-secure-password \
-e CORS_ORIGIN="https://claude.ai,https://chat.openai.com,https://chatgpt.com" \
your-built-image
# Create instant HTTPS tunnel
cloudflared tunnel --url http://localhost:3005
This creates a public HTTPS URL like:
https://random-words-generated.trycloudflare.com
Use this URL for Claude.ai integration - the server auto-detects the domain!
5οΈβ£ Integrate with Claude.ai
Screenshot: Adding MCP integration in Claude.ai Settings
Open Claude.ai β Settings β Integrations
Add Custom Integration:
Screenshot: MCP server configuration form- Name:
N8N Workflow Manager - URL:
https://your-domain.com/orhttps://your-tunnel.trycloudflare.com/ - Type:
MCP Server
- Name:
OAuth Authorization: Login with admin credentials
Screenshot: OAuth authorization page with admin loginConnect N8N: Enter your N8N instance URL and API key
Screenshot: N8N credentials formAuthorization Success:
Screenshot: Successful authorizationIntegration Connected:
Screenshot: MCP integration showing as connected
5οΈβ£ First Test
Screenshot: Claude.ai showing available N8N tools
Screenshot: Claude.ai displaying N8N workflows
Ask Claude: "What MCP tools do you have available?"
Ask Claude: "Can you list my N8N workflows?"
βοΈ Configuration
π§ Environment Variables
| Variable | Description | Required |
|---|---|---|
PORT |
Server port (default: 3007) | No |
HOST |
Server host (default: 0.0.0.0) | No |
SERVER_URL |
Override server URL for OAuth endpoints | No** |
ADMIN_USERNAME |
Admin login username | Yes |
ADMIN_PASSWORD |
Admin password hash | Yes |
N8N_HOST |
Default N8N instance URL | No* |
N8N_API_KEY |
Default N8N API key | No* |
CORS_ORIGIN |
Comma-separated list of allowed origins (e.g. https://claude.ai,https://chat.openai.com,https://chatgpt.com) |
Yes |
*N8N credentials can be provided via environment variables as fallback or entered dynamically during login.
**Server URL auto-detects from request headers (works with Cloudflare tunnels, ngrok, custom domains)
π³ Docker Compose
The included docker-compose.yml provides:
- N8N MCP Server container
- Traefik reverse proxy integration
- Automatic SSL certificates
- Health checks
π ChatGPT Connector (WebSocket)
ChatGPT Connectors work best over WebSocket. This repo now exposes a native WS endpoint:
- WS endpoint:
wss://n8n-mcp.right-api.com/ws - Health:
http://<your-host>/health - Default port:
3006(configurable viaPORT)
Steps:
- Deploy the WS server:
node mcp-ws-server.js(or bake into your container entrypoint) - In ChatGPT β Connectors β Add custom MCP server, use
wss://n8n-mcp.right-api.com/ws - Set
N8N_HOSTandN8N_API_KEYin the container env so tools can call your n8n instance
Notes:
- If you are behind a reverse proxy (Traefik), ensure WebSocket upgrade is enabled for the
/wspath. - For production, prefer
wss://with TLS termination at your proxy. - HTTPβHTTPS redirect is configured for host
n8n-mcp.right-api.com.
Traefik example (labels)
Labels used in docker-compose.standalone.yml:
traefik.http.routers.n8n-mcp-ws.rule=Host(\n8n-mcp.right-api.com`) && PathPrefix(`/ws`)`traefik.http.services.n8n-mcp-ws.loadbalancer.server.port=3006- Optional headers to force upgrade:
traefik.http.middlewares.n8n-mcp-ws-headers.headers.customrequestheaders.Upgrade=websockettraefik.http.middlewares.n8n-mcp-ws-headers.headers.customrequestheaders.Connection=Upgrade
SSE and OAuth endpoints share the same host with paths:
- SSE:
https://n8n-mcp.right-api.com/sse - OAuth:
https://n8n-mcp.right-api.com/oauth
π§± Two-Container Setup (WS/SSE + OAuth/Admin)
Run the WS/SSE server and the OAuth/Admin server as separate containers behind the same domain:
- WS/SSE container: serves
/,/ws,/sse,/healthand runs the MCP tools. - OAuth/Admin container: serves
/oauth/*,/.well-known/*, and/admin(dashboard).
With this repoβs docker-compose.standalone.yml:
- Start all:
docker compose up -d n8n-mcp-ws n8n-mcp-server n8n-mcp-oauth - Or just the admin:
docker compose up -d n8n-mcp-oauth - Both share
./data:/app/dataso saved hosts and defaults propagate to WS/SSE.
Traefik routes are pre-set via labels:
/ws,/health,/β WS container/sse,/messageβ SSE container/oauth/*,/.well-known/*,/adminβ OAuth/Admin container
If you run containers manually, copy these label routes, put both containers on the Traefik network, and mount a shared data volume.
π Authentication Flow
Diagram: Complete OAuth 2.1 authentication process
- OAuth Authorization - Claude.ai redirects to authorization endpoint
- Admin Login - Enter admin credentials and N8N instance details
- Consent Page - Review and approve access permissions
- Token Exchange - OAuth 2.1 PKCE flow completes
- Session Management - Server maintains session with N8N credentials
π API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/ |
GET/POST | MCP protocol endpoint |
/health |
GET | Health check |
/oauth/authorize |
GET | OAuth authorization |
/oauth/token |
POST | Token exchange |
/oauth/login |
POST | Admin authentication |
/.well-known/oauth-authorization-server |
GET | OAuth discovery |
π‘οΈ Security Features
- OAuth 2.1 with PKCE - Modern authentication standard
- Session Isolation - Each user session maintains separate credentials
- Secure Credential Storage - N8N credentials stored per-session, not globally
- CORS Protection - Configurable origin restrictions
- Environment Variable Protection - Sensitive data via environment variables
π» Development
π Local Development
npm install
npm start
π§ͺ Testing
# Test MCP tools directly
curl -X POST http://localhost:3007/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-token" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
π Production Deployment
Diagram: Production deployment with Traefik, Docker, and SSL
π Prerequisites
- Domain name with DNS pointing to your server
- Docker and Docker Compose installed
- Traefik proxy running (or configure your own reverse proxy)
π Step-by-Step Deployment
- Server Setup
# Clone to your server
git clone https://github.com/yourusername/n8nmcp.git
cd n8nmcp
# Configure environment
cp .env.example .env
nano .env # Edit with your settings
- Environment Configuration
# Generate secure password hash
node -e "console.log(require('crypto').createHash('sha256').update('your-password').digest('hex'))"
# Update .env file
SERVER_URL=https://your-domain.com
ADMIN_USERNAME=admin
ADMIN_PASSWORD=generated-hash-above
CORS_ORIGIN=https://claude.ai
- Deploy with Docker
# Add to existing docker-compose.yml or create new one
docker-compose up -d
# Verify deployment
docker ps | grep n8n-mcp
docker logs n8n-mcp-server
- SSL/Domain Setup (if using Traefik)
# Already configured in docker-compose.yml
labels:
- "traefik.enable=true"
- "traefik.http.routers.n8n-mcp.rule=Host(`your-domain.com`)"
- "traefik.http.routers.n8n-mcp.entrypoints=websecure"
- "traefik.http.routers.n8n-mcp.tls.certresolver=mytlschallenge"
- Test Deployment
# Health check
curl https://your-domain.com/health
# OAuth discovery
curl https://your-domain.com/.well-known/oauth-authorization-server
ποΈ Architecture & Diagrams
Quick diagram references (export SVGs to PNG as needed):
- Architecture (SSE/WS/OAuth):
screenshots/architecture-diagram.svg - OAuth 2.1 + PKCE (English):
screenshots/oa2-flow-diagram.svg - ΧͺΧ¨Χ©ΧΧ OAuth 2.1 + PKCE (Χ’ΧΧ¨ΧΧͺ):
screenshots/oa2-flow-diagram-he.svg
Tip: Export to PNG with Inkscape for high-DPI posting:inkscape screenshots/architecture-diagram.svg --export-type=png --export-filename=screenshots/architecture-diagram.png --export-dpi=192
Diagram: Complete system architecture and data flow
π₯οΈ Admin Dashboard
Password-protected dashboard to centrally manage N8N API hosts and keys:
- Add/remove/update N8N hosts (name, URL, API key)
- Test connectivity and set a default host for the server
- Persists to
/app/data/n8n-hosts.jsonand default creds to/app/data/n8n-credentials.json - Route:
https://n8n-mcp.right-api.com/admin(usesADMIN_USERNAME/ADMIN_PASSWORD)
How to enable (docker compose):
- Ensure the OAuth service mounts
./data:/app/dataand Traefik routes/adminto it (already configured indocker-compose.standalone.yml). - Start the OAuth service:
docker compose up -d n8n-mcp-oauth - Visit
/admin, login, add your N8N host + API key, and click βMake Defaultβ.
Notes:
- The SSE/WS servers read
/app/data/n8n-credentials.json, so the default you set in the dashboard is used by tools immediately. - You can still override via SSE query params (
?n8n_host=&n8n_key=) or theset_n8n_credentialstool.
Users & Tokens
- Admin login uses environment variables:
ADMIN_USERNAME,ADMIN_PASSWORD(plaintext password; set a strong value).
- A single admin account is supported per OAuth container. Run multiple containers for separate admin creds if needed.
- Programmatic access tokens for integrations:
- Create tokens in the dashboard under βAPI Tokensβ or via HTTP:
- Create:
POST /tokens/registerwith JSON{ "description": "string", "scope": "mcp" } - List:
GET /tokens - Revoke:
DELETE /tokens/{raw_token}
- Create:
- All token endpoints require an authenticated admin session (the dashboard uses your session cookie).
- Create tokens in the dashboard under βAPI Tokensβ or via HTTP:
graph TD
A[π€ Claude.ai User] --> B[π OAuth 2.1 Flow]
B --> C[π₯οΈ N8N MCP Server]
C --> D[π Session Management]
D --> E[π Per-User N8N Credentials]
E --> F[π€ N8N Instance]
style A fill:#4A90E2
style B fill:#28A745
style C fill:#17A2B8
style D fill:#6F42C1
style E fill:#FFC107
style F fill:#DC3545
π€ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
π§ Troubleshooting
Screenshot: Debug console showing MCP protocol messages
β οΈ Common Issues
π« Tools not appearing in Claude.ai
# Check authentication
docker logs n8n-mcp-server | grep "AUTH"
# Verify OAuth flow
curl https://your-domain.com/.well-known/oauth-authorization-server
# Test tool discovery
docker logs n8n-mcp-server | grep "tools/list"
β±οΈ Connection timeouts
# Check server connectivity
curl -I https://your-domain.com/health
# Verify SSL certificate
openssl s_client -connect your-domain.com:443 -servername your-domain.com
# Check Docker networking
docker network ls
docker logs traefik | grep your-domain.com
π N8N API errors
# Test N8N connectivity directly
curl -H "Authorization: Bearer your-api-key" https://your-n8n.com/api/v1/workflows
# Check API key permissions in N8N settings
# Verify N8N instance is accessible from Docker network
π§ Response size issues
- Large workflow lists may cause timeouts
- Server automatically truncates responses to prevent this
- Check logs for "Response truncated" messages
π Debug Commands
# Complete server logs
docker logs n8n-mcp-server -f
# Filter for errors only
docker logs n8n-mcp-server 2>&1 | grep -E "(ERROR|error|Error)"
# Check authentication flow
docker logs n8n-mcp-server 2>&1 | grep -E "(oauth|auth|session)"
# Monitor MCP protocol
docker logs n8n-mcp-server 2>&1 | grep -E "(MCP|tools|prompts)"
π Getting Help
If you're still having issues:
- Check GitHub Issues: Look for similar problems
- Enable Debug Logging: Set
DEBUG=truein environment - Share Logs: Include relevant log snippets (remove sensitive data)
- Describe Setup: OS, Docker version, domain configuration
π License
MIT License - see LICENSE file for details
ποΈ Advanced Features & Enhancements
π§ Recent Improvements
- Enterprise-Grade Architecture: Production-ready with comprehensive error handling
- Multi-Authentication Support: JWT, OAuth2, and Access Token strategies
- Advanced Security: Rate limiting, input validation, audit logging
- Real-time Monitoring: SSE streaming with heartbeat and client management
- Resilient N8N Integration: Circuit breaker pattern and retry logic
- Performance Optimizations: Response caching and connection pooling
π Upcoming Features
- Workflow Templates: Pre-built automation patterns
- Multi-Instance Support: Connect multiple N8N instances
- Advanced Analytics: Usage metrics and performance insights
- Real-time Collaboration: Multiple users managing workflows
- Enhanced Monitoring: Comprehensive health checks and observability
π Architecture Excellence
- Type Safety: Full TypeScript implementation with strict typing
- Modular Design: Clean separation of concerns and dependency injection
- Scalable Streaming: Efficient SSE implementation with client management
- Security First: Multi-layer security with OAuth 2.1 and input validation
- Production Ready: Docker deployment with health checks and monitoring
π¬ Support
We're here to help! Open an issue for support.
- GitHub Issues: Report bugs and feature requests
- Documentation: See docs/ directory
- Examples: See examples/ directory
π― This implementation represents the most advanced n8n-MCP integration available, specifically optimized for Claude.ai web interface compatibility.
Screenshot: MCP server configuration form
Screenshot: OAuth authorization page with admin login
Screenshot: N8N credentials form
Screenshot: Successful authorization
Screenshot: MCP integration showing as connected