Creating a CUSTOM Node Tool

Description

I’m currently trying to develop a custom node that can be used as a tool by an AI agent.
I managed to go through your documentation on how to Build a programmatic-style node.
My custom nodes are working, and the next step I’m looking into is allowing the AI agent to use them.
I found how to link them to the tool used by the AI agent by adding the value usableAsTool: true, in my CustomNode.node.ts file.

Encountered Error

Sadly, when I test my workflow, I get the following error:

Question

I suppose CUSTOM tool nodes aren’t available yet, but is there a workaround?
I just need to trigger it for a PoC.

Setup

  • n8n version: 1.78.0
  • Database: SQLite
  • Running n8n via: NPM
  • Operation system: Windows 11

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

I look forward to more technical details on how “usableAsTool” support should be implemented in custom nodes.

So far, the addition of usableAsTool is the only thing I’ve found.

Did you see this? Unrecognized node type: n8n-nodes-searxng.searxngTool · Issue #7 · sammcj/n8n-nodes-searxng

1 Like

I looked into it, and here’s what I’ve tried so far.

I install the n8n-nodes-searxng to test if installing a community nodes will work and it was working for me.

What I tried was installing my node as a community node, but only locally, by creating the node’s repository in ~/.n8n, adding the following line to package.json:
n8n-nodes-friendgrid: "C:/Users/<MyUser>/n8n-nodes-friendgrid"
and then running npm install inside the directory.

Right now the error message is still the same but the name of the tool called is different.

The weird thing is that n8n is getting all this info from the node, but the agent doesn’t recognize it.

Note: I didn’t really understand what is the nightly release they are talking about.

I guess the answer is here… Custom Node as an AI tool · Issue #12593 · n8n-io/n8n · GitHub.

But i don’t understand why Searxng which is a custom community node is available as a tool because i can run it.

I found the solution in your link using the following command:

sed -i "s/nodeType.startsWith('n8n-nodes-base') && //g" /usr/local/lib/node_modules/n8n/dist/node-types.js

I found out that inside the file node-type.js, lines 33 to 35 were checking the type of nodes while excluding custom ones.
I replaced

nodeType.startsWith('n8n-nodes-base')

by

true

Thanks for posting this update. I also ran into this issue and had long long debugging sessions to fix my nodes. I created subnodes with xxxTool name, tried implementing langchain Tool, tried implementing supplyData() to no luck.

I didn’t know this is gated behind a check. It looks like there is now also a env variable that we can set: N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE

So tl;dr:

  • Set this env variable
  • Enable usableAsTool

The error could have been better :cry:

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