Error handling of MCP Tool nodes

Hi everyone,

I’m very new to n8n but already very impressed of what can be achieved with it in a very short time. Thanks to everyone involved in this great piece of software.

I started my n8n journey by creating agents that should use an MCP server to interact with my smart home. However I haven’t figured out how to correctly handle errors from the MCP Client Tool node. I realize that the MCP Tool nodes are pretty new so in case this is just a bug I want to ask here if you have more experience with it. However more likely I haven’t grasped a key concept here:

Describe the problem/error/question

I have created my own MCP Server and it works fine in general. I was using it successfully with the Windsurf Cascade agent for a while. However especially inputting or changing data in the system can be a complex task. In my experience LLMs often make smaller or bigger mistakes when they have to provide a complex json input. Therefore I make sure to handle errors based on invalid input in my MCP server and return meaningful error messages to the client.

What is the error message (if any)?

The problem is, that these error messages are simply ignored by the AI agent. The agent does not feed the error message back into the LLM and therefore the output in the chat and thus also the output of the agent node is always like: “I created this and that successfully”. However during the execution I can see that the MCP client node transfers into an error state and of course the data has not been created in the system. Of course in parallel I also try to improve my MCP tools to make these less error prone but there should be a clean way to handle these kind of errors as they cannot be avoided everytime. Cascade did a very fine job analysing these error messages and it usually helped to get things done correctly on the second or third try.

Please share your workflow

This is my first simple example of the workflow. I setup a more complex multi-agent workflow but its the same issue: When my data input agent fails to create some input but reports success the whole workflow is failing miserably.

Share the output returned by the last node

The tag “UPS” for an uninterruptible power supply has been successfully created. If you need any further assistance, just let me know.

Information on your n8n setup

  • n8n version: 1.95.3
  • Database: Postgres
  • n8n EXECUTIONS_PROCESS setting: Don’t really know what it is but haven’t changed it so it should be default
  • Running n8n via: Docker
  • Operating system: Ubuntu 24.04

Wow I finally got behind this issue: the problem was that the python MCP implementation was not returning standard conform tool error messages by default. The n8n client node seems to strictly follow the specification. I could fix this now by handling all my tool calls with this logic:

try:
        return openhab_client.get_item_details(item_name)
    except ValueError as e:
        return {
            "isError": True,
            "content": [
                TextContent(type="text", text=str(e))
            ]
        }
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.