Skip to content

Python Support: Code Mode Now Available in Python and TypeScript

Latest

Choose a tag to compare

@h3xxit h3xxit released this 23 Nov 12:50

🐍 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