npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-utcp-codemode

v2.1.2

Published

Cut AI Agent token costs by 96%. Chains multiple tool calls into a single TypeScript code execution in a secure sandbox.

Readme

n8n-nodes-utcp-codemode

Cut AI Agent token costs by 96%. Instead of making a separate LLM call for each tool, Code-Mode lets the AI write a single TypeScript code block that chains all tool calls in one execution.

This is the same pattern behind Anthropic's Programmatic Tool Calling, LangGraph CodeAct, and Manus — brought to n8n as a community node.

The Problem

Every tool call in an AI Agent workflow = another LLM round-trip carrying the full conversation history. Token usage grows quadratically:

| Tools in pipeline | LLM calls (traditional) | LLM calls (Code-Mode) | |---|---|---| | 1 | 2 | 1 | | 3 | 7 | 1 | | 5 | 11 | 1 | | 10 | 21 | 1 |

Benchmark Results

5-tool customer onboarding pipeline (validate email → classify company → score tier → generate message → format report):

| Metric | Traditional | Code-Mode | Savings | |---|---|---|---| | LLM API calls | 11 | 1 | 91% | | Total tokens | ~18,000 | ~700 | 96% | | Execution time | 12,483ms | 2,530ms | 80% | | Nodes fired | 22 | 3 | 86% |

At GPT-4o pricing ($2.50/M input, $10/M output):

| Executions/day | Traditional/year | Code-Mode/year | Annual savings | |---|---|---|---| | 100 | ~$1,643 | ~$64 | $1,579 | | 1,000 | ~$16,425 | ~$639 | $15,786 | | 10,000 | ~$164,250 | ~$6,388 | $157,862 |

Installation

cd ~/.n8n/nodes
npm install n8n-nodes-utcp-codemode

Restart n8n. The Code-Mode Tool appears under AI > Tools in the workflow editor.

How It Works

  1. Connect the Code-Mode Tool to any AI Agent node
  2. (v2.1) Connect other tool sub-nodes (HTTP Tool, Calculator, etc.) directly to Code-Mode Tool — they're auto-registered in the sandbox
  3. Add MCP servers via the preset dropdown, or configure custom tool sources as JSON
  4. The AI Agent receives a single execute_code_chain tool that accepts TypeScript
  5. Instead of calling tools one-by-one, the AI writes a complete pipeline as code
  6. Code executes in a secure V8 sandbox with access to all registered tools
Traditional:  Agent → LLM → tool_1 → LLM → tool_2 → LLM → tool_3 → ...
Code-Mode:    Agent → LLM → writes TypeScript → sandbox runs all tools → done

Auto-Register Sibling Tools (v2.1)

Connect other n8n tool sub-nodes (HTTP Request Tool, Calculator, etc.) directly to Code-Mode Tool's Sibling Tools input. They're automatically discovered and made callable inside the sandbox — zero configuration.

[HTTP Tool] ──┐
[Calculator] ──┤── Code-Mode Tool ── AI Agent
[Email Tool] ──┘

In the sandbox, sibling tools are namespaced as sibling.toolName():

// LLM-generated code can call all connected tools:
const data = sibling.httpRequest({ url: "https://api.example.com/data" });
const total = sibling.calculator({ expression: "sum(data.values)" });
sibling.emailSend({ to: "[email protected]", body: total });
return { data, total };

Toggle with the Auto-Register Sibling Tools checkbox (default: on).

Configuration

MCP Server Presets

Select from the dropdown — no JSON required:

| Preset | Package to install | Config field | |---|---|---| | Filesystem | @modelcontextprotocol/server-filesystem | Allowed directory path | | GitHub | @modelcontextprotocol/server-github | GitHub personal access token | | Brave Search | @modelcontextprotocol/server-brave-search | Brave API key | | SQLite | @modelcontextprotocol/server-sqlite | Database file path | | Memory | @modelcontextprotocol/server-memory | (none) |

Note: These @modelcontextprotocol/server-* packages were archived by Anthropic in 2025. They still work but no longer receive security patches. The JSON config field below lets you use any MCP server, including community-maintained alternatives.

Install the server package first:

cd ~/.n8n/nodes
npm install @modelcontextprotocol/server-filesystem

Custom Tool Sources (JSON)

For MCP servers or HTTP APIs not covered by presets:

[
  {
    "name": "custom",
    "call_template_type": "mcp",
    "config": {
      "mcpServers": {
        "myserver": {
          "transport": "stdio",
          "command": "node",
          "args": ["path/to/server.js", "/allowed/dir"]
        }
      }
    }
  }
]

Other Parameters

| Parameter | Default | Description | |---|---|---| | Auto-Register Siblings | true | Auto-discover connected tool sub-nodes (v2.1) | | Timeout | 30000ms | Max execution time for the sandbox | | Memory Limit | 128MB | Max memory for the V8 sandbox | | Enable Trace | false | Record tool call timing in output |

Output Transparency (v1.1+)

Every execution returns a _codeMode section showing what happened:

{
  "result": "...",
  "logs": [],
  "_codeMode": {
    "executedCode": "const files = fs.filesystem_list_directory({path: '/tmp'}); ...",
    "toolCallsInSandbox": 3,
    "registeredServers": ["fs"],
    "registeredToolCount": 14,
    "tokenEstimate": {
      "traditional": 10500,
      "codeMode": 700,
      "savingsPercent": "93%"
    }
  }
}

Example Workflow

See examples/filesystem-demo.json for a ready-to-import workflow using the Filesystem MCP preset.

Best With

  • Claude (via OpenRouter or Anthropic) — writes clean tool-chaining code
  • GPT-4o — reliable code generation
  • Gemini — works but needs more explicit prompting

How It's Built

The node implements both supplyData() (for AI Agent sub-node use) and execute() (for standalone Tool Executor use). All heavy dependencies are lazy-imported to avoid crashing n8n at startup.

Requirements

  • n8n >= 1.0.0
  • Node.js >= 18.0.0

Not using n8n?

code-mode-tools — Same engine as an MCP server for Claude Desktop, Claude Code, Cursor, and any MCP-compatible client. npm install -g code-mode-tools

Related

Code-First n8n Proving Ground — The bigger picture: how code-mode + n8nac cover the full n8n workflow lifecycle (write → deploy → test → debug → runtime), with POC templates and benchmarks.

License

MPL-2.0