Files
momentry_core/docs/N8N_API_FIX_SUMMARY.md
accusys 383201cacd feat: Initial v0.9 release with API Key authentication
## v0.9.20260325_144654

### Features
- API Key Authentication System
- Job Worker System
- V2 Backup Versioning

### Bug Fixes
- get_processor_results_by_job column mapping

Co-authored-by: OpenCode
2026-03-25 14:53:41 +08:00

2.8 KiB

n8n REST API Fix Summary

Issue

n8n REST API was returning 404 errors for all endpoints (/api/v1/workflows, /rest/workflows, etc.)

Root Cause

Port 5678 was occupied by the n8n worker process, preventing the main n8n instance from starting properly.

Solution

1. Identified Port Conflict

  • Worker process was listening on port 5678 (same as main instance)
  • Main n8n couldn't start because port was in use

2. Fixed Worker Configuration

Updated /Library/LaunchDaemons/com.momentry.n8n.worker.plist:

  • Added N8N_PORT=5680 to worker environment variables
  • Workers shouldn't need HTTP ports, but this prevents port conflict

3. Restarted Services

# Kill all n8n processes
sudo pkill -9 -f n8n

# Start main n8n (now successfully binds to port 5678)
sudo launchctl enable system/com.momentry.n8n.main
sudo launchctl bootstrap system /Library/LaunchDaemons/com.momentry.n8n.main.plist

Current Status

n8n Instance

API Key

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJlNjdiY2UzOS1iY2RkLTRjMjEtYmMwYy0yODNhYmI3ZjVjMjMiLCJpc3MiOiJuOG4iLCJhdWQiOiJwdWJsaWMtYXBpIiwiaWF0IjoxNzc0MTk4NzgwfQ.zke_Qc-saILl_tcwXm2K3J4slCmaXnzCfxVbdVPPvCE

MCP Configuration

File: ~/.config/opencode/opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "gitea": {
      "type": "local",
      "enabled": true,
      "command": [
        "/opt/homebrew/bin/gitea-mcp-server",
        "-token", "<GITEA_TOKEN>",
        "-host", "http://localhost:3000"
      ]
    },
    "n8n": {
      "type": "local",
      "enabled": true,
      "command": ["/opt/homebrew/bin/mcp-n8n"],
      "environment": {
        "N8N_BASE_URL": "http://localhost:5678",
        "N8N_API_KEY": "<N8N_API_KEY>"
      }
    }
  }
}

Verified Endpoints

List Workflows

curl -H "X-N8N-API-KEY: <API_KEY>" http://localhost:5678/api/v1/workflows

Result: 30 workflows returned

List Executions

curl -H "X-N8N-API-KEY: <API_KEY>" http://localhost:5678/api/v1/executions

Result: 100 executions returned

Next Steps

  1. Start n8n Worker (optional for MCP): Workers handle job processing but aren't required for API access.

  2. Test MCP Integration: Restart OpenCode to load the MCP configuration and test n8n integration.

  3. Verify Workflow Management:

    • Create workflow via API
    • Execute workflow
    • Monitor execution status

Files Modified

  • /Library/LaunchDaemons/com.momentry.n8n.worker.plist - Added N8N_PORT=5680

API Documentation

  • Base URL: http://localhost:5678/api/v1
  • Authentication: Header X-N8N-API-KEY: <token>
  • Available endpoints: workflows, executions, credentials, users, etc.

See full API reference: https://docs.n8n.io/api/