Download Latest Version Python Support_ Code Mode Now Available in Python and TypeScript source code.tar.gz (66.8 kB)
Email in envelope

Get an email when there's a new version of Code-Mode

Home / v1.0.5
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2025-11-14 2.7 kB
v1.0.5 - Announcing first public release of Code Mode source code.tar.gz 2025-11-14 21.6 kB
v1.0.5 - Announcing first public release of Code Mode source code.zip 2025-11-14 25.4 kB
Totals: 3 Items   49.6 kB 0

🚀 UTCP Code Mode: First library for agents to call tools via code execution

Code Mode is a plug-and-play library that lets AI agents call MCP and UTCP tools via TypeScript code execution, instead of juggling dozens of brittle tool definitions.

Idea:
LLMs are much better at writing code than orchestrating long chains of tool calls. So instead of exposing hundreds of tools directly, you give the model one powerful tool: a TypeScript sandbox with access to your entire tool universe.

This repo provides that sandbox and the glue around it.


⚡ Why this is interesting: Cut your token usage by over 60%

Based on published work from Apple, Cloudflare, Anthropic and independent benchmarks, code-execution-based workflows can deliver:

  • Fewer API round trips for multi-step workflows
  • Lower token usage (no repeated context stuffing)
  • Better “cognitive” fit for LLMs (write code, not JSON tool graphs)

Code Mode packages that pattern for UTCP + MCP:

  • One client
  • Many tool ecosystems (MCP, HTTP, file-based, CLI)
  • Executed as a single TypeScript program inside a secure VM

✨ Highlights in v0.1.0

Core:

  • CodeModeUtcpClient for connecting to UTCP/MCP tools
  • Secure Node.js VM sandbox for TypeScript execution
  • Simple callToolChain(code, timeout?) API to run multi-step workflows in one shot

Tooling & discovery:

  • registerManual to register tools from MCP, HTTP, file-based or CLI sources
  • searchTools and runtime interface introspection (__interfaces, __getToolInterface) for progressive tool discovery
  • Auto-generated TypeScript interfaces for tools so agents can type-check their own calls

Enterprise-ish features:

  • Execution timeouts per call
  • Full console log capture (logs alongside result)
  • No direct network access except via registered tools
  • Works cleanly with existing MCP servers and UTCP configs

🧪 Quickstart (3 lines)

Install:

:::bash
npm install @utcp/code-mode

Use:

:::ts
import { CodeModeUtcpClient } from '@utcp/code-mode';

const client = await CodeModeUtcpClient.create();                    // 1. Initialize
await client.registerManual({ name: 'github', /* MCP config */ });   // 2. Register tools
const { result } = await client.callToolChain(`/* TypeScript */`);   // 3. Execute code

Now your agent can replace a whole graph of tool calls with a single code execution.


👉 Please star the repo to follow development and signal that this is useful. Early feedback and issues are especially welcome.

Source: README.md, updated 2025-11-14