The MCP Server Trigger node turns any n8n workflow into an MCP-compatible tool server. AI clients like Claude Code and n8n's own AI Agent node can discover and call your tools over HTTP without writing any server code.
Requires n8n 1.76 or later.
Add the Trigger
- Create a new workflow
- Search for MCP Server Trigger in the node panel (it's under
@n8n/n8n-nodes-langchain) - Set the Path — this becomes your MCP endpoint URL:
http://your-n8n:5678/mcp/{path} - Set Response Mode to
Last Node(the output of your final node becomes the tool response)
Connect Tool Workflow Nodes
Each tool is a Tool Workflow node connected to the trigger's ai_tool output:
- Add a Tool Workflow node
- Set a Name — this is what the AI sees in its tool list (e.g.,
kv_get) - Write a Description — include the expected input format:
Get a value. Input JSON: {"key": "my-key"} - Under Workflow, select Define below and build an inline sub-workflow
- Connect it to the MCP Server Trigger
Repeat for each tool. All Tool Workflow nodes connect to the same trigger — the MCP protocol handles routing.
Inline Sub-Workflow Structure
Each Tool Workflow node contains a mini workflow:
Execute Workflow Trigger → [Your Logic] → [Output Node]
The trigger receives a query field (string) containing the JSON that the AI sent. Parse it in a Code node:
const input = JSON.parse($json.query);
const key = input.key || '';
if (!key) return { json: { error: 'key is required' } };
return { json: { key } };
The last node's output becomes the tool response sent back to the AI.
Database Tools: Use Parameterized Queries
If your tools query a database, never interpolate user input into SQL strings. Use the Postgres node's queryReplacement option:
SELECT * FROM my_table WHERE key = $1 LIMIT 1
In the Postgres node settings, set Query Parameters to =undefined. The node binds it safely as $1.
Bearer Token Auth
The MCP Server Trigger supports bearer token authentication. Set it in the trigger node's Authentication section. Clients must send Authorization: Bearer your-token with every request.
See the MCP Authentication with Bearer Tokens guide for token generation and configuration.
Test It
- Activate the workflow
- From a terminal, verify the endpoint responds:
curl -X POST http://your-n8n:5678/mcp/my-tools \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
You should get back a JSON-RPC response listing your tools.
Configuration Notes
- alwaysOutputData: Enable this on Postgres and HTTP Request nodes inside your sub-workflows. Without it, a query that returns zero rows produces no output, and the tool silently returns nothing to the AI. With it enabled, empty results still flow through to the next node.
- Path naming: Use lowercase with hyphens. The path is part of the URL, so
my-toolsbecomes/mcp/my-tools. - One trigger per workflow: Each MCP Server Trigger creates one endpoint. Multiple tools connect to the same trigger — don't create separate workflows per tool.
- Reactivation required: After adding or removing Tool Workflow nodes, deactivate and reactivate the workflow. The tool registry is built at activation time.
- Response Mode: Always use
Last Node. TheImmediatelymode sends the response before your tools finish executing, which means the AI gets an empty result.