Expose n8n Workflows as an MCP Server

Build an MCP server in n8n and connect Claude Desktop to your tools.

Introduction

30 Second Summary

Automation tools can do incredible things behind the scenes, but your AI assistant has no way to reach them. You end up copy-pasting between tools like a human relay.

In this project, you will build an MCP server inside n8n that exposes your automation workflows as tools any AI assistant can discover and call. You will connect Claude Desktop to your server and watch it invoke your workflows during a live conversation.

What You'll Build

You type a question into Claude Desktop, and behind the scenes it discovers your n8n tool, sends your input, and returns structured results right in the conversation.

By the end of this project, you'll have:

  • A live Claude Desktop conversation where you ask Claude to analyze a paragraph and it calls your n8n Text Analyzer tool, returning word count, character count, and sentence count in the chat.
  • A Password Generator tool that Claude discovers on its own when you add it to the server. No config changes or restarts needed on the client side.
  • Firsthand proof of dynamic tool discovery: add a tool to your MCP server, and every connected AI client knows about it immediately.
  • Secret Mission: Build a resilient third tool with input validation and error handling, then chain all three tool calls in one Claude conversation.

Are there any prerequisites?

This project assumes you have Docker installed on your machine and are comfortable with n8n workflow basics like nodes, triggers, and expressions. You will also need Node.js v18 or higher, which you will verify in Step 1.

Before We Start

Before we dive in, let's lock in what you're about to build and why it matters to you.

Set Up n8n and Verify Your Tools

Your MCP server will sit on top of three tools working together. n8n hosts the server and your tool workflows, Claude Desktop acts as the AI client that discovers and calls those tools, and Node.js powers the mcp-remote bridge that connects them.

None of this works if even one piece is missing or misconfigured. In this step, you'll spin up a local n8n instance using Docker Compose, verify Node.js is at the right version, and confirm Claude Desktop and mcp-remote are both reachable.

In this step, get ready to:
  • Create a Docker Compose file and start n8n at http://localhost:5678.
  • Verify Node.js v18 or higher is installed.
  • Confirm Claude Desktop, n8n, and mcp-remote are all reachable.
Create the Docker Compose file and start n8n

n8n runs as a Docker container on your machine. You'll create a minimal Docker Compose file that maps n8n's default port and persists your workflow data in a named volume.

  • Move to your Desktop and create a project folder by running these commands:
cd ~/Desktop
mkdir n8n-mcp-server
cd n8n-mcp-server
  • Inside your n8n-mcp-server folder, create a new file called docker-compose.yml using your preferred text editor. Paste the following content:
services:
  n8n:
    image: docker.io/n8nio/n8n
    ports:
      - "5678:5678"  # Expose n8n on localhost:5678
    volumes:
      - n8n_data:/home/node/.n8n  # Persist workflow data across restarts

volumes:
  n8n_data:

What does this file do?

This Compose file defines a single service called n8n. It pulls the official n8n image from docker.io/n8nio/n8n and maps port 5678 so you can reach n8n at http://localhost:5678.

The named volume n8n_data stores your workflows, credentials, and settings inside the container's /home/node/.n8n directory. Without this volume, everything would disappear every time the container stops.

  • Save docker-compose.yml.
  • Start n8n by running this command:
docker compose up -d

What does this command do?

The -d flag runs the container in detached mode, so it starts in the background and gives you your terminal back. If the n8n image is not already cached locally, Docker downloads it first. This may take a minute or two.

You should see output confirming the network was created and the container started.

  • Open your web browser and navigate to http://localhost:5678.

You'll see the n8n setup screen. Enter your name, email address, and a password to create your owner account. Follow any remaining prompts to complete the setup.

After completing setup, you'll land on the empty n8n workflow canvas. This is your home base for building tool workflows in the next steps.

Page not loading at localhost:5678?

  • n8n can take 10-15 seconds to fully initialize. Wait a moment, then refresh the page.
  • Make sure Docker is running. Run docker compose ps in your terminal and check that the n8n container's state shows Up.
  • If the container exited, check logs with docker compose logs n8n for error details.

Still stuck? Help me troubleshoot why n8n is not loading at localhost:5678 after running docker compose up.

✔️ Awesome, I've got everything!

Great. Double check you've saved your docker-compose.yml file.

ⓧ I'd like to double check the full code

Here is the complete docker-compose.yml file. Make sure yours matches exactly:

services:
  n8n:
    image: docker.io/n8nio/n8n
    ports:
      - "5678:5678"  # Expose n8n on localhost:5678
    volumes:
      - n8n_data:/home/node/.n8n  # Persist workflow data across restarts

volumes:
  n8n_data:
Verify Node.js is installed

The mcp-remote bridge connects Claude Desktop to n8n's MCP endpoint. It runs on Node.js and requires version v18 or higher.

  • Check your Node.js version by running:
node --version

✔️ I see version 18 or higher

Node.js is ready. You should see something like v18.20.0 or higher. Move on to the next substep.

ⓧ I see an older version

Your current Node.js version is too old for mcp-remote, which requires v18 or higher.

  • Visit the Node.js downloads page and follow the instructions for your Linux distribution to install version 18 or higher.
  • Alternatively, use a version manager like nvm. Follow the install instructions at the nvm repository, then run nvm install 18.
  • After installing, close and reopen your terminal, then run node --version again to confirm you see v18 or higher.

ⓧ Command not found

Node.js is not installed on your system.

  • Visit the Node.js downloads page and follow the instructions for your Linux distribution to install version 18 or higher.
  • Alternatively, install via nvm by following the instructions at the nvm repository, then run nvm install 18.
  • After installing, close and reopen your terminal, then run node --version to confirm you see v18 or higher.
Confirm all three tools are reachable

n8n is already running from the previous substep. Two more tools need a quick check: Claude Desktop and the mcp-remote bridge.

  • Press the Super key (the Windows key on most keyboards) to open your application launcher.
  • Type Claude and press Enter to open Claude Desktop.

You should see the Claude Desktop chat interface. This confirms it is installed and ready. You can close Claude Desktop for now.

Claude Desktop not opening?

If Claude Desktop is not installed, add the Anthropic apt repository and install it by running these commands:

sudo curl -fsSLo /usr/share/keyrings/claude-desktop-archive-keyring.asc https://downloads.claude.ai/claude-desktop/key.asc

echo "deb [signed-by=/usr/share/keyrings/claude-desktop-archive-keyring.asc] https://downloads.claude.ai/claude-desktop/apt/stable stable main" | sudo tee /etc/apt/sources.list.d/claude-desktop.list

sudo apt update && sudo apt install claude-desktop

After installation, launch Claude Desktop by running claude-desktop in your terminal or by searching for it in your application launcher.

Still stuck? Help me install Claude Desktop on Linux.

The last tool to verify is mcp-remote. This bridge translates between Claude Desktop's local stdio transport and n8n's SSE/HTTP endpoint. It runs via npx, so there is nothing to install separately.

Before you run this next command, do you think it will succeed on the first try, or will something be missing?

  • Back in your terminal, verify mcp-remote is accessible by running:
npx mcp-remote --help

Seeing a prompt to install mcp-remote?

If npx asks you to confirm installing the mcp-remote package, type y and press Enter. This is normal. npx downloads and caches the package automatically.

The command runs without errors, confirming Node.js, npx, and the mcp-remote package all work together. All three tools are confirmed: n8n at http://localhost:5678, Claude Desktop launches, and mcp-remote is accessible.

Seeing a TypeError or command error?

  • If you see a URL parsing error, you may have an older cached version. Run npx mcp-remote@latest --help to force the latest version.
  • If npx itself is not found, Node.js is not installed correctly. Go back to the Node.js verification tabs above.

Still stuck? Help me troubleshoot npx mcp-remote errors.

Your environment is locked in. In the next step, you'll build your first tool workflow inside n8n that processes real text input and returns structured results.

Build Your First Tool Workflow

In Step 1, you set up your environment with n8n, Claude Desktop, and Node.js. Now it is time to build the first tool your MCP server will expose.

Before you can expose anything as an MCP tool, you need a workflow that does something useful on its own. This step creates a Text Analyzer that takes a string input and returns structured stats like word count, character count, and sentence count.

In this step, get ready to:
  • Build a Text Analyzer workflow with a trigger and a Code node.
  • Test the workflow manually and verify the JSON output.
  • Convert the trigger so the workflow can be called as a sub-workflow by your MCP server.
Create the Text Analyzer workflow

You will start by building a standalone workflow that analyzes text. Using a Manual Trigger lets you test the logic quickly before wiring it into the MCP server later.

  • Switch back to n8n in your browser at http://localhost:5678.
  • Click the + Create Workflow button (or click + Add first step on the canvas).
  • Click the workflow name at the top of the canvas (it defaults to something like My workflow) and rename it to Text Analyzer Tool.
  • In the node picker, search for Manual Trigger and select it to place the trigger node on your canvas.

Why start with a Manual Trigger?

A Manual Trigger lets you execute the workflow on demand by clicking a button. This is the fastest way to test your logic before wiring it into a larger system.

Now add the Code node that performs the actual text analysis.

  • Click the + connector on the right side of the Manual Trigger node.
  • Search for Code and select the Code node.
  • In the Code node panel, make sure Language is set to JavaScript.
  • Delete any default code in the editor and paste the following:
// Get the input text from the previous node
const text = $input.first().json.text;

// Count words by splitting on whitespace
const wordCount = text.split(/\s+/).filter(w => w.length > 0).length;

// Count total characters
const characterCount = text.length;

// Count sentences by splitting on sentence-ending punctuation
const sentenceCount = text.split(/[.!?]+/).filter(s => s.trim().length > 0).length;

// Return the analysis as a JSON object
return [{
  json: {
    wordCount,
    characterCount,
    sentenceCount
  }
}];

What does this code do?

`$input.first().json.text` grabs the text field from whatever data the previous node passes in. Right now the Manual Trigger sends an empty object, so you will provide test data in the next substep.

The three counters each use a different splitting strategy. wordCount splits on whitespace. characterCount reads the string length. sentenceCount splits on ., !, or ?. The result is returned in n8n's required [{ json: { ... } }] format so downstream nodes can read it.

Test the workflow with sample text

The Code node references $input.first().json.text, but the Manual Trigger does not send a text field by default. You can use n8n's pin data feature to inject test data into the trigger node.

  • Click the Manual Trigger node on the canvas to open its panel.
  • In the OUTPUT section, select JSON to switch to JSON view.
  • Select Edit.
  • Replace the default content with the following JSON:
[
  {
    "text": "The quick brown fox jumps over the lazy dog. It was a sunny day! Was the fox really quick?"
  }
]
  • Select Save. n8n saves your edits and pins this data to the node.

What is pinned data?

Pinning data on a node locks its output to a specific value you define. When you execute the workflow, n8n skips the node's normal behavior and uses your pinned data instead. This is a quick way to simulate inputs without building an upstream data source.

  • Close the Manual Trigger panel by clicking the X in the top right of the panel.
  • Before you run this, what do you think the word count will be for that sample text?
  • Click the Execute Workflow button at the bottom of the canvas to run the workflow.
  • Click on the Code node to open its output panel.

You should see a JSON object with wordCount of 19, characterCount of 89, and sentenceCount of 3.

Seeing an error or unexpected output?

  • If you see an error about text being undefined, make sure you pinned data on the Manual Trigger node and that the JSON contains a text key (lowercase).
  • If the counts look wrong, double-check that you pasted the Code node content exactly as shown. Extra or missing characters in the regex patterns change the results.
  • Help me debug my Code node output.
Convert the trigger for sub-workflow calling

Your Text Analyzer works, but it uses a Manual Trigger. For the MCP server to call this workflow as a tool, it needs a trigger that accepts structured input from another workflow.

  • Right-click the Manual Trigger node on the canvas and select Delete. This removes the trigger but keeps your Code node.
  • Click the + Add first step button that appears on the canvas (or click the + button and search for triggers).
  • Search for Execute Sub-workflow under trigger nodes. It also appears as When Executed by Another Workflow. Select it.

What is the Execute Sub-workflow Trigger?

This trigger starts a workflow when another workflow calls it. The Call n8n Workflow Tool node (which you will use in the MCP server) sends data to this trigger. By defining an input schema here, you tell the calling workflow exactly what fields it needs to provide.

  • In the trigger node panel, find the Input data mode dropdown and set it to Define using fields below.
  • Click Add Field.
  • Set the Name to text.
  • Set the Type to String.
  • Connect the new trigger node to the Code node by dragging from the trigger's output connector to the Code node's input connector.

Now verify the workflow still produces correct output with the new trigger.

  • Click the Execute Sub-workflow Trigger node to open its panel.
  • In the OUTPUT section, select JSON, then select Edit.
  • Paste the same test data as before:
[
  {
    "text": "The quick brown fox jumps over the lazy dog. It was a sunny day! Was the fox really quick?"
  }
]
  • Select Save to pin the data.
  • Close the trigger panel and click Execute Workflow.
  • Click on the Code node to view its output.

You should see the same results: wordCount of 19, characterCount of 89, and sentenceCount of 3.

  • Save the workflow by pressing Ctrl+S.

Code node showing an error after the trigger swap?

  • Make sure the Execute Sub-workflow Trigger is connected to the Code node. If the connection line is missing, drag from the trigger's output to the Code node's input.
  • Double-check that the field name is text (lowercase, no spaces). The Code node uses $input.first().json.text, so the field name must match exactly.
  • Help me debug the trigger swap.

✔️ Awesome, I've got everything!

Great. Make sure you have saved the workflow by pressing Ctrl+S.

ⓧ I'd like to double check the full code

Your Text Analyzer Tool workflow should have two nodes connected in this order:

  • Execute Sub-workflow Trigger with Input data mode set to Define using fields below and one field: text (String).
  • Code node (JavaScript) containing:
// Get the input text from the previous node
const text = $input.first().json.text;

// Count words by splitting on whitespace
const wordCount = text.split(/\s+/).filter(w => w.length > 0).length;

// Count total characters
const characterCount = text.length;

// Count sentences by splitting on sentence-ending punctuation
const sentenceCount = text.split(/[.!?]+/).filter(s => s.trim().length > 0).length;

// Return the analysis as a JSON object
return [{
  json: {
    wordCount,
    characterCount,
    sentenceCount
  }
}];

The trigger should be connected to the Code node with a single line on the canvas.

Your Text Analyzer tool is built, tested, and ready to be called by other workflows. Next up, you will create the MCP server that exposes this tool to AI clients like Claude Desktop.

Create the MCP Server and Expose the Tool

Your Text Analyzer workflow is built and tested. It accepts text, crunches the numbers, and returns structured stats as JSON.

The problem is that no AI client can discover or call this workflow yet. In this step, you will create an MCP Server inside n8n that exposes your tool through a URL any MCP-compatible client can connect to.

In this step, get ready to:
  • Create a new workflow with an MCP Server Trigger node.
  • Wire the Text Analyzer Tool into the server using a Call n8n Workflow Tool node.
  • Put the server into listening mode and confirm the Test URL.
Create the MCP Server workflow

The MCP Server Trigger node turns an n8n workflow into a server that AI clients can connect to. You need a dedicated workflow to hold this trigger and the tools it exposes.

  • Switch back to n8n at http://localhost:5678.
  • On the Overview page, click Create Workflow to start a new workflow.
  • Click on the workflow name at the top of the canvas and rename it to My MCP Server.

You should see a blank canvas with the name My MCP Server at the top and an Add first step prompt on the canvas.

  • Click Add first step to open the nodes panel.
  • Search for MCP Server Trigger in the search bar.
  • Click MCP Server Trigger to add it to the canvas.
  • In the node's settings panel, find the Authentication dropdown and set it to None.

The MCP Server Trigger node now sits on your canvas with Authentication set to None. You should also see Test URL and Production URL toggles near the top of the node panel.

What is the MCP Server Trigger?

The MCP Server Trigger node turns your n8n workflow into an MCP server. It exposes a URL that any MCP-compatible client (like Claude Desktop) can connect to for discovering and calling tools.

It supports SSE and streamable HTTP transport. Unlike instance-level MCP (which exposes all workflows across your n8n instance), the MCP Server Trigger lets you choose exactly which tools to make available from a single workflow.

Why set Authentication to None?

Your n8n instance is running on localhost with no reverse proxy. Adding bearer or header authentication would require credential setup in n8n and token management in the Claude Desktop config. For local development, skipping auth keeps the focus on learning MCP concepts.

Don't see MCP Server Trigger in the node list?

Make sure your n8n Docker container is running the latest image. The MCP Server Trigger node is available in recent versions of n8n.

Try refreshing the page and searching again. If the node still does not appear, check that your container is using the docker.io/n8nio/n8n image.

Help me find the MCP Server Trigger node in n8n.

Wire the Text Analyzer into the server

The MCP Server Trigger creates the endpoint, but it does not know about your tools yet. You need to attach each tool workflow using a Call n8n Workflow Tool node.

  • Click the Add node connector on the right side of the MCP Server Trigger node.
  • Search for Call n8n Workflow Tool in the nodes panel.
  • Click Call n8n Workflow Tool to add it and connect it to the trigger.

Your canvas now shows two connected nodes. Next, configure the Call n8n Workflow Tool to point at your Text Analyzer.

  • In the Call n8n Workflow Tool's settings panel, set Source to Database.
  • In the Workflow dropdown, select Text Analyzer Tool.
  • In the Description field, enter Analyze a block of text and return word count, character count, and sentence count. Input should be a text string.

The Call n8n Workflow Tool settings now show it pointing to the Text Analyzer Tool workflow with a filled-in description.

What does the Description field do?

The Description tells AI clients when and how to use this tool. When Claude connects to your MCP server, it reads each tool's description to decide which one matches the user's request.

A clear, specific description leads to better tool selection. Vague descriptions like "does stuff with text" would leave the AI guessing.

Text Analyzer Tool not appearing in the Workflow dropdown?

Make sure you saved the Text Analyzer Tool workflow in the previous step. Unsaved workflows do not appear in the dropdown.

Confirm that the Text Analyzer Tool uses a Workflow Input Trigger (not a Manual Trigger). Workflows with a Manual Trigger cannot be called as sub-workflows.

Help me connect my Text Analyzer Tool workflow to the Call n8n Workflow Tool node.

Put the server into listening mode

The MCP Server is wired up, but it is not active yet. You need to start it listening for incoming connections before any client can discover your tools.

  • Click on the MCP Server Trigger node to open its settings panel.
  • Make sure the Test URL toggle is selected at the top of the node panel (not Production URL).

Before you activate the server, what do you think will happen when you click Listen for Test Event? Will external clients be able to connect immediately?

  • Click Listen for Test Event at the top of the node panel.

The workflow enters listening mode. The MCP Server Trigger node displays a Test URL at the top of the settings panel. This is the URL that MCP clients will connect to in order to discover and call your tools.

Test URL vs Production URL

The Test URL is active only while you are in listening mode. n8n keeps it active for 120 seconds at a time. When you stop listening, the URL stops working.

n8n also provides a Production URL that becomes active when you publish the workflow. For local development, you will use the Test URL.

Workflow not entering listening mode?

Make sure the MCP Server Trigger node is connected to the Call n8n Workflow Tool node with a visible line between them on the canvas.

Check that the Call n8n Workflow Tool node has a valid workflow selected in its Workflow dropdown. An empty selection can prevent the server from starting.

Help me get my n8n MCP Server into listening mode.

Your MCP server is live and listening. Next, you will connect Claude Desktop to this URL and watch it discover and call your Text Analyzer tool in real time.

Connect Claude Desktop and Call Your Tool

Your MCP server has a Test URL and is actively listening for connections. The hard part of building the server is done.

The question is: does it actually work with a real AI client? In this step, you'll point Claude Desktop at your n8n MCP server and watch it discover and call your Text Analyzer tool in a live conversation.

In this step, get ready to:
  • Configure Claude Desktop's MCP connection using npx mcp-remote.
  • Verify that the Text Analyzer tool appears in Claude Desktop's Connectors panel.
  • Invoke the Text Analyzer tool in a live Claude Desktop conversation.
Copy the Test URL and configure Claude Desktop

Claude Desktop communicates with MCP servers over stdio transport. Your n8n MCP Server Trigger speaks SSE and streamable HTTP. These two protocols do not talk to each other directly.

The mcp-remote bridge sits in between and translates. You'll set up a config file that tells Claude Desktop to launch mcp-remote whenever it needs to reach your n8n server.

  • Switch back to n8n in your browser at http://localhost:5678.
  • In the "My MCP Server" workflow, click on the MCP Server Trigger node.
  • Copy the Test URL displayed at the top of the node panel. You'll paste this into the config file shortly.

Where is the Test URL?

The MCP Server Trigger node shows two URLs at the top of its panel: a Test URL and a Production URL. The Test URL is active while the workflow is in listening mode (which you set up in the previous step). The Production URL activates when the workflow is published.

For development, you'll use the Test URL. It starts with http://localhost:5678 followed by a randomly generated path.

Make sure you have Test URL selected (not Production URL) before copying.

  • Open a new terminal window.
  • Create the Claude Desktop configuration directory by running this command:
mkdir -p ~/.config/Claude
  • Open the configuration file in a text editor by running:
nano ~/.config/Claude/claude_desktop_config.json
  • Paste the following JSON configuration into the file, replacing the URL placeholder with the Test URL you just copied:
{
  "mcpServers": {
    "n8n": {
      "command": "npx",
      "args": ["mcp-remote", "[[MCP_TEST_URL=\"your MCP Server Trigger Test URL\"]]"]
    }
  }
}

What does this configuration do?

The mcpServers block tells Claude Desktop about external MCP servers it can connect to. Each entry under it defines one server.

The command and args fields tell Claude Desktop to run npx mcp-remote with your n8n Test URL as the target. When Claude Desktop launches, it starts this process to bridge its stdio transport to n8n's SSE endpoint.

Since you set Authentication to "None" on the MCP Server Trigger, you do not need an authorization header or token in this config.

  • Save the file by pressing Ctrl+O, then Enter to confirm the filename, then Ctrl+X to exit nano.
  • Confirm the file saved correctly by running:
cat ~/.config/Claude/claude_desktop_config.json

You should see your JSON configuration with the Test URL in place of the placeholder.

File looks empty or has errors?

  • If the file is empty, you may have exited nano without saving. Reopen it with nano ~/.config/Claude/claude_desktop_config.json, paste the JSON again, and save with Ctrl+O.
  • Make sure the JSON is valid. A missing comma, bracket, or trailing comma after the last entry will silently break the config.
  • Double-check that the Test URL you pasted starts with http://localhost:5678 and is enclosed in double quotes.

Help me debug my Claude Desktop config file for connecting to n8n's MCP server.

Relaunch Claude Desktop and verify the connector

Claude Desktop only reads its configuration file at launch. Closing the window is not enough because the app may still be running in the background.

  • Fully quit Claude Desktop. Use the system tray icon to select Quit, or close all Claude Desktop windows and confirm the process is no longer running.
  • Relaunch Claude Desktop by running:
claude-desktop

Why the full restart?

Claude Desktop loads claude_desktop_config.json once at startup. If you only close the window, the app's background process keeps running with the old config. A full quit and relaunch forces it to pick up your new mcpServers entry.

  • Once Claude Desktop opens, click the Add files, connectors, and more indicator at the bottom-left of the chat input.
  • Hover over Connectors.

You should see the n8n MCP server listed with the Text Analyzer tool available.

Don't see the n8n connector?

  • Make sure you fully quit Claude Desktop before relaunching. Closing the window alone does not reload the config.
  • Confirm the "My MCP Server" workflow in n8n is still in listening mode. If it timed out, click Listen for Test Event again in the MCP Server Trigger node.
  • Verify the Test URL in your config file matches exactly what the MCP Server Trigger node shows. Even a single extra character or missing path segment breaks the connection.
  • Check that Node.js is accessible. Run node --version in a terminal to confirm it returns v18 or higher. Claude Desktop needs npx to launch mcp-remote.

Help me figure out why Claude Desktop can't see my n8n MCP server.

Send your first tool call

The connector is live. Claude Desktop now knows your Text Analyzer tool exists. Time to call it.

Before you send this message, what do you think will happen? Will Claude call the Text Analyzer tool automatically, or will it try to count the words on its own?

  • Type the following message into the Claude Desktop chat input and press Enter:
Can you analyze this text for me: The quick brown fox jumps over the lazy dog.

Claude calls the Text Analyzer tool behind the scenes. You should see a tool-call indicator in the chat showing that Claude invoked the tool, followed by the structured analysis in its response: word count, character count, and sentence count.

What just happened behind the scenes?

When you sent that message, Claude recognized it matched the Text Analyzer tool's description. It packaged the text as input and sent a tool call through mcp-remote to your n8n MCP Server Trigger.

The MCP Server Trigger routed the call to the Call n8n Workflow Tool node, which executed the Text Analyzer Tool workflow. The Code node counted words, characters, and sentences, then returned the JSON result back through the same chain to Claude's response.

If Claude answers with accurate counts without showing a tool-call indicator, it may be answering from its own knowledge rather than actually calling your tool. Ask it to analyze a unique or unusual paragraph to confirm the tool is truly being invoked.

Claude not calling the tool?

  • If Claude answers the question without invoking the tool, try being more explicit: "Use the Text Analyzer tool to analyze this text."
  • Switch back to n8n and check whether the "My MCP Server" workflow is still in listening mode. If it stopped, click Listen for Test Event again and retry the message in Claude.
  • If you see connection errors, run rm -rf ~/.mcp-auth in your terminal to clear any stale cached data from mcp-remote. Then fully quit and relaunch Claude Desktop.

Help me troubleshoot why Claude is not calling my n8n Text Analyzer tool.

Your first live tool call is working. Claude asked your n8n server what tools were available, picked the right one, and returned real results from your workflow. That is the full MCP loop in action.

One tool proves the connection works. Next, you'll add a second tool to the server and prove the real power of MCP: Claude discovers it automatically without any config changes on its side.

Add a Second Tool and Witness Dynamic Discovery

Claude just called your Text Analyzer tool and returned real results in a live conversation. Your MCP server works.

One tool proves the connection, but the real power of MCP is dynamic tool discovery. In this step, you will add a second tool to the server and watch Claude find it automatically, without changing Claude's configuration file or restarting it.

In this step, get ready to:
  • Create a Password Generator tool workflow in n8n.
  • Wire the new tool into your existing MCP Server alongside the Text Analyzer.
  • Watch Claude discover and call the new tool without any client-side changes.
Create the Password Generator Tool workflow

Just like the Text Analyzer, each tool your MCP server exposes lives in its own workflow. This new workflow will accept a desired password length and a complexity preference, then return a randomly generated password.

  • Switch to your n8n browser tab at http://localhost:5678.
  • Click the n8n logo in the upper-left corner to go to the workflows list.
  • Click the + button to create a new workflow.
  • Name the workflow Password Generator Tool by clicking on the workflow name at the top.
  • Click Add first step on the canvas.
  • Search for Execute Sub-workflow Trigger (also listed as When Executed by Another Workflow) and select it.
  • Set Input data mode to Define using fields below.
  • Add a field with Name set to length and Type set to Number.
  • Add a second field with Name set to includeSpecialChars and Type set to Boolean.

Your trigger node now defines two input fields that the MCP server will pass to this workflow when Claude calls the tool.

  • Close the trigger node to return to the canvas.
  • Click the + button on the right edge of the trigger node to add a new node.
  • Search for Code and select it.
  • Leave Mode on the default Run Once for All Items.
  • Replace the placeholder code with the following password generation logic:
// Get the input parameters from the trigger
const length = $input.item.json.length || 12;
const includeSpecialChars = $input.item.json.includeSpecialChars !== false;

// Define character sets for password generation
let chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if (includeSpecialChars) {
  chars += '!@#$%^&*()_+-=';
}

// Build the password one character at a time
let password = '';
for (let i = 0; i < length; i++) {
  password += chars.charAt(Math.floor(Math.random() * chars.length));
}

// Rate the password strength based on length and complexity
let strength = 'weak';
if (length >= 12 && includeSpecialChars) {
  strength = 'strong';
} else if (length >= 8) {
  strength = 'medium';
}

// Return the result in n8n's required data format
return [{ json: { password, strength } }];

What does this code do?

The code reads the length and includeSpecialChars values passed in through the trigger node's input schema. It builds a character pool from letters and digits, optionally adding symbols like !@#$%.

The loop runs length times, picking a random character each iteration to build the password string. The strength rating is then determined by whether the password is at least 12 characters long and includes special characters.

  • Save the workflow by pressing Ctrl+S.

How do I test a sub-workflow?

A workflow with an Execute Sub-workflow Trigger can only run when called by another workflow. You cannot click Execute Workflow to test it standalone the way you did with the Manual Trigger in Step 2.

The real test comes in a moment when you wire this workflow into the MCP Server and let Claude call it.

Wire the Password Generator into the MCP Server

Your MCP Server workflow currently exposes only the Text Analyzer. Adding a second Call n8n Workflow Tool node tells the server about this new tool.

  • Click the n8n logo again to return to the workflows list.
  • Open the My MCP Server workflow.
  • Click the + button on the MCP Server Trigger node to add a new node alongside the existing Text Analyzer connection.
  • Search for Call n8n Workflow Tool and select it.
  • In the new Call n8n Workflow Tool node, set Source to Database.
  • Select Password Generator Tool from the workflow list.
  • In the Description field, enter:
Generate a secure random password. Accepts length (number) and includeSpecialChars (boolean) parameters.

Why does the description matter?

The Description field is how Claude decides when to use this tool. When Claude receives a user prompt, it reads the descriptions of all available tools and picks the one that best matches the request.

A clear, specific description leads to more accurate tool selection. Vague descriptions make it harder for the AI to choose the right tool.

  • Close the node to return to the canvas.
  • Confirm you now see two Call n8n Workflow Tool nodes connected to the MCP Server Trigger: one for the Text Analyzer and one for the Password Generator.
  • Save the workflow by pressing Ctrl+S.
  • Click Listen for Test Event on the MCP Server Trigger node to put the server back into listening mode.

The MCP Server Trigger node should show the Test URL and indicate it is listening. Your server now advertises two tools to any connected client.

Don't see the Password Generator in the workflow list?

  • Make sure you saved the Password Generator Tool workflow (Ctrl+S) before switching back to the MCP Server workflow.
  • Check that the Password Generator workflow has an Execute Sub-workflow Trigger as its first node, not a Manual Trigger.

Why can't I see my Password Generator workflow in the Call n8n Workflow Tool node?

Test dynamic tool discovery with Claude

This is the moment that proves the architecture. You added a second tool to your server, but you have not touched Claude's configuration file or restarted Claude Desktop.

  • Switch to Claude Desktop.
  • Start a new conversation.

Before you send a message, think about this: do you think Claude already knows about the Password Generator tool? You have not changed Claude's config file or restarted it.

  • Click the Add files, connectors, and more indicator at the bottom-left of the chat input.
  • Hover over Connectors and confirm you now see the Password Generator tool listed alongside the Text Analyzer.

Why does Claude already know?

Each time Claude starts a new conversation with an MCP connector, it asks the server for the current list of available tools. Because you added the Password Generator to the server, the server now reports two tools instead of one.

This is dynamic tool discovery. The server is the single source of truth for available tools. You can add, remove, or modify tools without ever touching the client configuration.

  • Send Claude this message:
Generate me a 16-character password with special characters.

Watch Claude invoke the Password Generator tool. Claude's response includes a generated password and a strength rating, both pulled from your n8n workflow.

What just happened?

Claude read the descriptions of all available tools, matched your request to the Password Generator, and called it with length: 16 and includeSpecialChars: true.

Your n8n Code node ran, generated a random password, rated its strength, and returned the result. Claude then formatted that result into a natural-language response for you.

Claude not calling the Password Generator?

  • Switch back to n8n and confirm the MCP Server Trigger is still in listening mode. If it timed out, click Listen for Test Event again.
  • Try starting a new conversation in Claude Desktop. Existing conversations may cache the tool list from a previous session.
  • Make sure the Password Generator Tool's Call n8n Workflow Tool node is connected to the MCP Server Trigger node with a visible line on the canvas.

Claude is not discovering my new Password Generator tool even though I added it to the MCP Server workflow.

You just proved the core value of the MCP architecture. Adding a new capability to your server required zero changes on the client side. This is the pattern that makes MCP servers powerful for production automation.

Secret mission

Build a Resilient Third Tool with Input Validation

Your MCP server works with two tools, but can it handle bad input without crashing? Build a Unit Converter tool with structured input validation and graceful error handling. Then stress-test the full server by chaining all three tools in a single Claude conversation.

Clean Up Your Resources

Clean Up Your Resources

This project runs entirely on your local machine, so there are no ongoing cloud costs. Decide whether to keep your resources running, pause them to come back later, or delete them entirely.

Resources you used:

  • n8n Docker container running on localhost:5678.
  • n8n workflows: Text Analyzer Tool, Password Generator Tool, and My MCP Server. If you completed the Secret Mission, you also have the Unit Converter Tool.
  • Claude Desktop MCP configuration in ~/.config/Claude/claude_desktop_config.json.
  • Project folder containing your docker-compose.yml file.

Keep everything running

No action needed. Choose this if you are still actively building or experimenting with your MCP server.

  • Docker keeps running and n8n stays available at localhost:5678 at no cost.
  • Your Claude Desktop configuration stays in place and you can continue invoking your tools.

Pause - I'll come back to this later

Stop the containers to free up system resources without losing your workflows or data. Your n8n workflows are preserved inside the Docker volumes.

  • Open a terminal and navigate to the folder containing your docker-compose.yml file.
  • Stop the n8n container by running:
docker compose stop
  • When you are ready to resume, start the container again by running:
docker compose start
  • n8n will be available again at localhost:5678 with all your workflows intact.

Delete - I don't want to use this again

Remove all project resources and start fresh. This deletes the Docker containers, volumes (which contain your n8n workflows and data), and the project folder.

  • Open a terminal and navigate to the folder containing your docker-compose.yml file.
  • Stop and remove the containers and volumes by running:
docker compose down -v
  • Navigate up to the parent directory and remove the project folder by running:
cd ..
rm -rf $(basename $OLDPWD)
  • Remove the MCP server configuration from Claude Desktop. Open ~/.config/Claude/claude_desktop_config.json in a text editor and delete the entire mcpServers block.

What about the n8n workflows?

Your n8n workflows (Text Analyzer Tool, Password Generator Tool, My MCP Server, and Unit Converter Tool if you completed the Secret Mission) are stored inside the Docker volume. The -v flag in docker compose down -v removes all named volumes, so the workflows are deleted along with the containers.

That's a Wrap!

That's a Wrap!

Nice work! You just turned n8n into a live MCP server that any AI client can discover tools from and invoke on demand.

You've learned how to:

  • Built standalone n8n tool workflows that accept structured inputs and return JSON outputs, then exposed them through an MCP Server Trigger node paired with Call n8n Workflow Tool nodes.
  • Connected Claude Desktop as an MCP client using the mcp-remote bridge, and watched Claude discover and invoke your tools in a live conversation.
  • Proved dynamic tool discovery by adding a second tool to the server with zero client-side configuration changes. The server is the single source of truth for available tools.
  • Secret Mission: Built a third tool with structured input validation and graceful error handling, then stress-tested the server with chained tool calls across all three tools in a single conversation.

Ready to quiz yourself?