5.5 KiB
5.5 KiB
OpenCode n8n MCP 整合設定
| 項目 | 內容 |
|---|---|
| 建立者 | Warren |
| 建立時間 | 2026-03-23 |
| 文件版本 | V1.0 |
版本歷史
| 版本 | 日期 | 目的 | 操作人 | 工具/模型 |
|---|---|---|---|---|
| V1.0 | 2026-03-23 | 創建 n8n MCP 整合設定文件 | Warren | OpenCode |
建立時間: 2026-03-23 更新時間: 2026-03-23
n8n MCP 工具列表 (43 個)
Workflows (10)
| 工具 | 說明 |
|---|---|
n8n_list_workflows |
列出所有 workflows |
n8n_get_workflow |
取得 workflow 詳情 |
n8n_create_workflow |
建立新 workflow |
n8n_update_workflow |
更新 workflow |
n8n_delete_workflow |
刪除 workflow |
n8n_activate_workflow |
啟用 workflow |
n8n_deactivate_workflow |
停用 workflow |
n8n_execute_workflow |
執行 workflow |
n8n_get_workflow_tags |
取得 workflow 標籤 |
n8n_update_workflow_tags |
更新 workflow 標籤 |
Executions (3)
| 工具 | 說明 |
|---|---|
n8n_list_executions |
列出執行記錄 |
n8n_get_execution |
取得執行詳情 |
n8n_delete_execution |
刪除執行記錄 |
Data Tables (8)
| 工具 | 說明 |
|---|---|
n8n_list_datatables |
列出資料表 |
n8n_create_datatable |
建立資料表 |
n8n_get_datatable |
取得資料表結構 |
n8n_get_datatable_rows |
取得資料表列 |
n8n_insert_datatable_rows |
插入資料列 |
n8n_update_datatable_rows |
更新資料列 |
n8n_upsert_datatable_row |
插入或更新資料列 |
n8n_delete_datatable_rows |
刪除資料列 |
Tags (5)
| 工具 | 說明 |
|---|---|
n8n_list_tags |
列出所有標籤 |
n8n_get_tag |
取得標籤 |
n8n_create_tag |
建立標籤 |
n8n_update_tag |
更新標籤 |
n8n_delete_tag |
刪除標籤 |
Credentials (4)
| 工具 | 說明 |
|---|---|
n8n_list_credentials |
列出憑證 |
n8n_create_credential |
建立憑證 |
n8n_delete_credential |
刪除憑證 |
n8n_get_credential_schema |
取得憑證 schema |
Users (3)
| 工具 | 說明 |
|---|---|
n8n_list_users |
列出使用者 |
n8n_get_user |
取得使用者 |
n8n_delete_user |
刪除使用者 |
Variables (3)
| 工具 | 說明 |
|---|---|
n8n_list_variables |
列出變數 |
n8n_create_variable |
建立變數 |
n8n_delete_variable |
刪除變數 |
其他 (7)
| 工具 | 說明 |
|---|---|
n8n_list_projects |
列出專案 |
n8n_create_project |
建立專案 |
n8n_update_project |
更新專案 |
n8n_delete_project |
刪除專案 |
n8n_generate_audit |
產生安全審計報告 |
n8n_health_check |
健康檢查 |
n8n_trigger_webhook |
觸發 webhook |
安裝步驟
1. 安裝 n8n MCP Server
npm install -g @nextoolsolutions/mcp-n8n
驗證:
which mcp-n8n
# /opt/homebrew/bin/mcp-n8n
2. 取得 n8n API Key
- 開啟 n8n UI:
http://localhost:5678 - 登入後點擊右上角 Settings → API
- 點擊 Create New API Key
- 複製產生的 key
3. 設定 OpenCode MCP 設定檔
建立或編輯 ~/.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>"
}
}
}
}
4. 驗證 MCP 運作
重啟 OpenCode,確認 n8n MCP tools 可用。
n8n API 端點
n8n v2 REST API 路徑為 /rest/(不是 /api/v1/)
| 端點 | 方法 | 說明 |
|---|---|---|
/rest/workflows |
GET | 列出 workflows |
/rest/workflows/:id |
GET | 取得 workflow |
/rest/workflows |
POST | 建立 workflow |
/rest/workflows/:id |
PUT | 更新 workflow |
/rest/workflows/:id |
DELETE | 刪除 workflow |
/rest/workflows/:id/activate |
POST | 啟用 workflow |
/rest/workflows/:id/deactivate |
POST | 停用 workflow |
/rest/workflows/:id/execute |
POST | 執行 workflow |
認證方式:
curl -H "X-N8N-API-KEY: YOUR_API_KEY" \
http://localhost:5678/rest/workflows
疑難排解
API 404 問題
如果 API 傳回 404,檢查:
-
n8n 是否運行中
curl http://localhost:5678 -
n8n 初始設定(重要!)
- 第一次使用必須在瀏覽器完成初始化
- 開啟
http://localhost:5678 - 按照畫面指示建立管理員帳號
- 完成後才能使用 API
-
API Key 是否正確
curl -H "X-N8N-API-KEY: YOUR_KEY" \ http://localhost:5678/rest/workflows
n8n 初始設定(第一次使用)
- 開啟瀏覽器:
http://localhost:5678 - 輸入 email 和密碼建立管理員帳號
- 完成後進入 Settings → API
- 建立 API Key 並複製
CLI Import vs PostgreSQL
n8n 使用 PostgreSQL 儲存資料:
- CLI
n8n import:workflow可能寫入 SQLite - 手動在 UI import 會寫入 PostgreSQL
建議直接使用 UI 或 MCP import。
相關文件
- OPENCODE_GUIDE.md - OpenCode 使用規範
- INSTALL_N8N.md - n8n 安裝指南
- N8N_DEMO_WORKFLOW.md - n8n Workflow 範例