Skip to content

Releases: universal-tool-calling-protocol/code-mode

Python Support: Code Mode Now Available in Python and TypeScript

23 Nov 12:50

Choose a tag to compare

🐍 Announcing Python Library for Code Mode

Code Mode now supports both Python and TypeScript! The same powerful code-execution approach to tool calling is now available across the two most popular AI development languages.

What's New

Python Library (code-mode on PyPI)

  • Full feature parity with TypeScript library
  • Native Python async/await syntax
  • Process sandboxing with RestrictedPython
  • Auto-generated TypedDict interfaces
  • Same 60%+ token savings and performance gains

Why This Matters: Multi-Language AI Development

AI teams often split between Python (data science, ML frameworks) and TypeScript (web services, tooling). Now you can use Code Mode in both ecosystems:

Python Teams:

from utcp_code_mode import CodeModeUtcpClient

client = await CodeModeUtcpClient.create()
await client.register_manual({'name': 'github', ...})
result = await client.call_tool_chain("# Python code here")

TypeScript Teams:

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

const client = await CodeModeUtcpClient.create();
await client.registerManual({ name: 'github', ... });
const { result } = await client.callToolChain(`/* TypeScript */`);

✨ Highlights in v2.0.0

Python Library (NEW)

  • Package: code-mode on PyPI (v0.0.3)
  • Secure execution: Process sandboxing with RestrictedPython
  • Python-native interfaces: Auto-generated TypedDict definitions
  • Enterprise features: Timeout protection, console capture, no network access
  • Universal protocol support: MCP, HTTP, File, CLI sources

TypeScript Library (Stable)

  • Package: @utcp/code-mode on npm (v1.0.4)
  • VM sandboxing: Node.js isolated execution contexts
  • TypeScript interfaces: Auto-generated type definitions
  • Production-ready: Used in enterprise deployments

Both Libraries Share:

  • Progressive tool discovery via search_tools
  • Runtime introspection (__interfaces, __get_tool_interface)
  • Multi-protocol support (MCP, HTTP, File, CLI)
  • Complete observability (logs + results)
  • Proven 60%+ token reduction vs traditional tool calling

🧪 Quickstart

Python

pip install code-mode
from utcp_code_mode import CodeModeUtcpClient

client = await CodeModeUtcpClient.create()
await client.register_manual({'name': 'github', 'call_template_type': 'mcp', ...})
result = await client.call_tool_chain('''
pr = await github.get_pull_request(owner='microsoft', repo='vscode', pull_number=1234)
return {"title": pr["title"], "state": pr["state"]}
''')

TypeScript

npm install @utcp/code-mode
import { CodeModeUtcpClient } from '@utcp/code-mode';

const client = await CodeModeUtcpClient.create();
await client.registerManual({ name: 'github', call_template_type: 'mcp', ... });
const { result } = await client.callToolChain(`
  const pr = await github.get_pull_request({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
  return { title: pr.title, state: pr.state };
`);

🔐 Security & Enterprise Features

Both libraries provide:

  • Isolated sandboxing – Process (Python) / VM (TypeScript) isolation
  • Timeout protection – Configurable execution limits
  • Zero external access – Tools only via registered servers
  • Complete observability – Full console logs + error handling
  • Restricted builtins – Dangerous functions blocked

📚 Documentation

If you made it this far, would be amazing if you support our Product Hunt launch! https://www.producthunt.com/products/utcp/launches/code-mode

v1.0.5 – Announcing first public release of Code Mode

15 Nov 14:31
ea4e322

Choose a tag to compare

🚀 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:

npm install @utcp/code-mode

Use:

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.