ARTIFACT // N8N-MCP-LOCAL-TOOL-AGENT.JSON (JSON)
n8n + MCP 协议客户端 + 本地 Qwen3 工具调用工作流(内置工具白名单与防死循环熔断) (n8n-mcp-local-tool-agent.json)
可直接导入的 n8n 智能体工作流:通过 SSE 接入本地 MCP Server,使用 Qwen3 `/no_think` 确定性路由调用只读工具,并强制开启工具白名单与 5 步死循环熔断。
[核心实测结论 / TL;DR]本配置包「n8n + MCP 协议客户端 + 本地 Qwen3 工具调用工作流(内置工具白名单与防死循环熔断)」(文件名:n8n-mcp-local-tool-agent.json,格式:JSON)是 Tinker AI 实测工坊配套指南《n8n-mcp-server-client-local-llm-tool-calling》的参数化生产模板。支持在本地浏览器实时定制 Ollama 接口地址 (OLLAMA_BASE_URL=http://host.docker.internal:11434)、本地工具调用模型 Tag (TOOL_MODEL=qwen3:8b)、MCP Server SSE 接口地址 (MCP_SSE_URL=http://mcp-sqlite-readonly:3001/sse)、允许暴露的 MCP 工具白名单 (ALLOWED_MCP_TOOLS=list_tables,describe_table,read_query) 等 4 项核心变量,默认遵循 127.0.0.1 回环绑定与最小权限规范。
02 // WORKFLOW无代码工作流· 验证日期:2026-10-27
查看全部 42 套配置附件 →n8n-mcp-local-tool-agent.json
查看配套实测指南 →n8n + MCP 协议客户端 + 本地 Qwen3 工具调用工作流(内置工具白名单与防死循环熔断)
可直接导入的 n8n 智能体工作流:通过 SSE 接入本地 MCP Server,使用 Qwen3 `/no_think` 确定性路由调用只读工具,并强制开启工具白名单与 5 步死循环熔断。
参数化定制变量 (Variables — 自动保存在本地浏览器)
UTF-8 编码 · 零延迟实时编译
{
"name": "Tinker AI — Local Qwen3 + MCP Client Tool Agent (Guide #23)",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "mcp-local-agent",
"responseMode": "lastNode",
"options": {}
},
"name": "Agent Request Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [220, 300]
},
{
"parameters": {
"promptType": "define",
"text": "=/no_think User task: {{ $json.body.query || 'Check system status table and summarize anomalies' }}",
"options": {
"systemMessage": "You are a deterministic local operations agent connected to an MCP Server. RULES: 1) Always prefix internal routing with /no_think so tool-call JSON arguments are emitted immediately without <think> blocks. 2) Only invoke tools from the approved allowlist (list_tables,describe_table,read_query). 3) Never retry the same failing tool arguments more than once.",
"maxIterations": 5,
"returnIntermediateSteps": true
}
},
"name": "Local MCP Tool Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.7,
"position": [520, 300]
},
{
"parameters": {
"model": "qwen3:8b",
"options": {
"baseURL": "http://host.docker.internal:11434",
"temperature": 0.1,
"numCtx": 16384
}
},
"name": "Ollama Qwen3 Router",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"typeVersion": 1,
"position": [440, 520]
},
{
"parameters": {
"sseEndpoint": "http://mcp-sqlite-readonly:3001/sse",
"include": "selected",
"includeTools": "list_tables,describe_table,read_query"
},
"name": "Sandboxed MCP Client (SSE)",
"type": "@n8n/n8n-nodes-langchain.mcpClientTool",
"typeVersion": 1,
"position": [640, 520]
}
],
"connections": {
"Agent Request Webhook": {
"main": [[{ "node": "Local MCP Tool Agent", "type": "main", "index": 0 }]]
},
"Ollama Qwen3 Router": {
"ai_languageModel": [[{ "node": "Local MCP Tool Agent", "type": "ai_languageModel", "index": 0 }]]
},
"Sandboxed MCP Client (SSE)": {
"ai_tool": [[{ "node": "Local MCP Tool Agent", "type": "ai_tool", "index": 0 }]]
}
}
}
PARAMETER SPECIFICATION // 参数化变量规范说明表
「n8n-mcp-local-tool-agent.json」可定制环境变量与默认值说明
本配置模板(JSON 格式)支持 4 项运行时参数注入,所有替换均在本地浏览器内完成。
| 模板占位符 | 参数用途说明 | 安全默认值 | 填写示例 |
|---|---|---|---|
{{OLLAMA_BASE_URL}} | Ollama 接口地址 | http://host.docker.internal:11434 | http://host.docker.internal:11434 |
{{TOOL_MODEL}} | 本地工具调用模型 Tag | qwen3:8b | qwen3:8b |
{{MCP_SSE_URL}} | MCP Server SSE 接口地址 | http://mcp-sqlite-readonly:3001/sse | http://mcp-sqlite-readonly:3001/sse |
{{ALLOWED_MCP_TOOLS}} | 允许暴露的 MCP 工具白名单 | list_tables,describe_table,read_query | list_tables,describe_table,read_query |
PAIRED HARDWARE MANIFEST // 配套实测环境与边界记录
配套指南《n8n + MCP 协议 (Model Context Protocol) + 本地 Qwen3 工具调用工作流:沙箱读写、工具白名单与死循环熔断》验证基线
实测硬件与操作系统 (Hardware & OS)
Mac mini M4 Pro(24GB 统一内存 · 273 GB/s)与 Ubuntu 24.04 容器宿主机(RTX 4070 12GB 显存)双环境验证
锁定软件栈与模型版本 (Pinned Versions)
n8n 1.82.x (with MCP Client Tool)Ollama 0.6.2qwen3:8b / qwen3:30b-a3bmcp-server-sqlite 0.6.x (SSE wrapper)
离线与安全边界 (100% 局域网 / 内网全离线闭环)
n8n 容器、MCP Server 容器与宿主机 Ollama 全部通过内部网桥通信,无需任何云端 API 密钥。
已知限制与失败边界 (Known Limits)
- 若在 n8n MCP Client 节点保留默认的 `Include: All Tools`,当 MCP 服务端包含 20+ 个工具时,每轮对话都会注入约 6,000 Tokens 的 Schema 定义,导致 8B 本地模型选错工具的概率飙升(准确率从 96% 跌至 61%)。
- Qwen3 等混合推理模型在多轮工具调用中默认每步都输出长篇 `<think>` 思考过程;若不在工具路由提示词中声明 `/no_think`,3 步 MCP 调用耗时会被拉长至 18.4 秒(开启后仅需 2.9 秒)。
DEPLOYMENT CHECKLIST // 配置落地核验步骤
部署 n8n-mcp-local-tool-agent.json 后的 3 步验收清单
- 已将 n8n MCP Client 节点从全量暴露改为 `Selected` 白名单模式,仅勾选不超过 6 个只读工具。
- 已在 Agent 提示词中加入 `/no_think` 指令,并在 Ollama 模型节点显式设置 `numCtx: 16384` 与 `temperature: 0.1`。
- 已在 Agent 节点设置 `maxIterations: 5` 最大迭代熔断,并将 MCP 容器的数据卷挂载为 `:ro` 只读权限。