Skip to main content

Overview

n8n can sit in front of a hosted MCP server as a lightweight workflow layer. A common pattern is:
  1. Trigger the workflow from a Webhook, Manual Trigger, or Schedule Trigger.
  2. Normalize the incoming JSON, form data, or uploaded CSV in Code nodes.
  3. Call the MCP endpoint with an n8n MCP Client node or with HTTP Request nodes.
  4. Resolve stored outputs with result_get when a tool returns a result_id.
  5. Assemble a JSON, log, email, or chat response from sanitized result fields.

Safe Workflow Exports

Workflow exports can include API keys, credential IDs, email addresses, chat recipients, webhook paths, and delivery-service settings. Do not publish raw n8n workflow JSON unless it has been reviewed and scrubbed. When sharing a workflow:
  • Keep secrets in n8n Credentials or environment variables.
  • Replace webhook paths with examples such as my-factor-report.
  • Remove credential id / name blocks from exported nodes.
  • Remove delivery recipients and bot/channel identifiers.
  • Keep only endpoint URLs, tool names, request shapes, and routing notes.

MCP Client Node Pattern

Use this when your n8n installation has an MCP Client node that supports streamable HTTP.
FieldValue
Connection typeHTTP / Streamable HTTP
Endpoint URLServer-specific MCP URL
OperationExecute tool
Tool nameServer-specific tool name
Tool parameters{"request": {...}}
For example, a Statistical Factor Models workflow can route validated input to complete-panel-factor-extractor-fit, swfactor-extractor-fit, or bmfactor-extractor-fit through separate MCP Client nodes.

HTTP Request Node Pattern

Use this when you want explicit session control or need to call helper tools such as result_get.

1. Initialize

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-03-26",
    "capabilities": {},
    "clientInfo": {
      "name": "n8n",
      "version": "1.0"
    }
  }
}
Store the mcp-session-id response header.

2. Send Initialized

{
  "jsonrpc": "2.0",
  "method": "notifications/initialized",
  "params": {}
}
Send it with the stored MCP-Session-Id header.

3. Call a Tool

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "result_get",
    "arguments": {
      "request": {
        "result_id": "<result-id>"
      }
    }
  }
}
Keep Content-Type: application/json and Accept: application/json, text/event-stream on every HTTP Request node. If the endpoint is protected, add the Authorization header through n8n Credentials instead of hard-coding it.

Webhook Pattern

For user-facing workflows, configure a Webhook Trigger with POST and responseMode: responseNode. Typical body shapes:
{
  "tickers": ["MSFT", "AAPL"],
  "runMode": "once",
  "delivery": "webhook"
}
{
  "algorithm": "stock-watson",
  "panelCsv": "series,date,value\nSPY,2024-01-01,0.01",
  "extractorInitKwargs": {
    "n_factors_max": 2,
    "flow_series": {},
    "flow_series_diff": {}
  }
}
The workflow should validate input early and route errors to a Respond to Webhook node with {"ok": false, "error": "..."}.

Server Examples

ServerTrigger shapeMCP calls
Fama-French ReplicateManual, scheduled, or webhook portfolio reportget-proxy-ff-factors, get-loadings-and-alpha, result_get
Statistical Factor ModelsWebhook or manual panel fitcomplete-panel-factor-extractor-*, swfactor-extractor-*, bmfactor-extractor-*, result_get
Jump ModelsScheduled or webhook regime reportDataloader fetch-ohlcvs, jump-model-create, jump-model-fit, jump-model-predict-proba-online, jump-model-predict, result_get
EP Ratio ScreenerScheduled or webhook ticker screenload_skills, screen-tickers

Delivery

Keep delivery separate from MCP calls. The MCP nodes should produce structured JSON; delivery nodes can then send:
  • webhook JSON response;
  • n8n execution logs;
  • email report;
  • chat or bot notification;
  • saved CSV or image artifact.
Do not put delivery API keys or recipients into Code node constants. Use n8n Credentials, workflow variables, or environment variables.

Checklist

  • The MCP URL is the server-specific /mcp/... URL, not the /health URL.
  • Every tool payload is wrapped as {"request": {...}}.
  • Direct HTTP Request flows keep and reuse MCP-Session-Id.
  • Stored outputs are resolved with result_get before formatting reports.
  • Workflow exports are scrubbed before they are shared or committed.