Webhooks Out

Calling Your MCP Server From an n8n Flow

⏱ 18 min

Lesson 2 got WordPress events into n8n. This lesson runs the flow the other way: an n8n workflow reaching back into WordPress to do something, either through the MCP server you built in Course 2, or through n8n’s native WordPress node when the job is a plain post, page, or user operation that doesn’t need an ability at all.

What you'll learn in this lesson
When to reach for the native WordPress node
It covers Post, Page, and User create/get/get all/update, nothing more, nothing less.
Driving the MCP session protocol from HTTP Request nodes
Chaining initialize, notifications/initialized, and tools/call as three separate node calls.
Capturing the Mcp-Session-Id header in n8n
Using the HTTP Request node's full-response option to read a response header into the next node.
Authenticating both paths
WordPress Application Passwords, the same credential either way.
Prerequisites

Course 2’s my-plugin-content-server MCP server, registered with HttpTransport and at least one ability exposed through it, from the “Serving Abilities Over HTTP Transport” lesson. A WordPress user with an Application Password. An n8n instance you can build workflows in.

Step 1: Decide which path you actually need

n8n ships a real, native WordPress node covering three resources: Post, Page, and User, each with create, get, get all, and update operations. If the job in front of you is “create a page,” “update a post,” or “get a user,” use that node directly, it’s less setup than driving the MCP protocol by hand. It does not cover comments, media, categories, or anything defined as a custom ability, for any of that, or for calling a specific registered ability by name, you need the HTTP Request node against your MCP server instead.

Which n8n node to reach for
TaskNode
Create, get, or update a post, page, or userNative WordPress node
Anything else the REST API exposes (comments, media, categories)HTTP Request node, direct REST call
A specific custom ability you registered (e.g. create-draft-post with your own validation)HTTP Request node, MCP tools/call

Step 2: Set up the WordPress node credential

Add a WordPress node, and on its credential screen choose the basic-auth option. It asks for your WordPress username, an Application Password (the same one from Users → Profile → Application Passwords in wp-admin), and your site’s URL. This is the same authentication model the MCP Adapter itself relies on, one Application Password covers both paths.

For simple operations, that’s the whole setup: choose Resource (Post/Page/User), Operation (Create/Get/Get All/Update), fill in the fields, done.

Step 3: Drive the MCP session with HTTP Request nodes

For a specific ability, you need three chained HTTP Request nodes, mirroring the same session protocol from Course 2’s HTTP transport lesson, just driven from n8n instead of curl.

Three HTTP Request nodes, chained
1
1. Initialize
POST the initialize JSON-RPC method. Enable "Include Response Headers and Status" in the node's options so the session ID is readable afterward.
2
2. Send notifications/initialized
POST again, this time with the Mcp-Session-Id header set from an expression referencing node 1's output.
3
3. Call tools/call
POST the actual ability invocation, with the same session header, naming the tool and its arguments.

Node 1, Initialize:

// n8n HTTP Request node body (JSON)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-11-25",
    "capabilities": {},
    "clientInfo": { "name": "n8n-workflow", "version": "1.0.0" }
  }
}

Set Authentication to the Application Password credential (Basic Auth, generic credential type), Method to POST, URL to https://yoursite.example.com/wp-json/my-plugin/content-mcp, and under Options, enable “Include Response Headers and Status.” That last setting is what lets the next node read Mcp-Session-Id out of the response at all.

Node 2, notifications/initialized, add a header field:

Name: Mcp-Session-Id
Value: {{ $node["Initialize"].json["headers"]["mcp-session-id"] }}

with body:

{ "jsonrpc": "2.0", "method": "notifications/initialized" }

Node 3, tools/call, same Mcp-Session-Id header expression, body naming the ability (recall from Course 2 that a slash in the ability name becomes a hyphen in the MCP tool name):

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "my-plugin-create-draft-post",
    "arguments": { "title": "Drafted from n8n", "content": "Body text here." }
  }
}

Step 4: Test it

Run the three-node chain manually in n8n (the “Execute step” button on each node), and confirm node 3’s output includes a successful result rather than a JSON-RPC error object. Then check wp-admin for the new draft post. If node 3 fails with a session-related error, re-check node 2 actually fired and that the header expression in node 3 points at node 1’s output, not node 2’s, since only the initialize response carries the Mcp-Session-Id header in the first place.

The session doesn't survive between separate workflow runs

Each MCP HTTP session is scoped to the handshake that created it. Don’t cache a session ID from one workflow execution and reuse it in a later, unrelated run, if the server has since cycled or the session expired, every request in that later run will fail. Always run the full initialize, notifications/initialized, tools/call sequence within the same execution.

Recap

n8n’s native WordPress node handles Post, Page, and User create/get/get all/update without any MCP protocol involved, use it whenever the job fits. For a specific registered ability, chain three HTTP Request nodes: initialize (capturing the Mcp-Session-Id response header), notifications/initialized, and tools/call naming the ability and its arguments, all authenticated with the same WordPress Application Password either path uses. The next lessons build on this outbound call as one step in larger, multi-node workflows.

Resources & further reading

← Triggering an n8n Workflow From a WordPress Webhook Chaining WordPress Actions With CRMs and Email →