universal-tool-calling-protocol/code-mode

๐Ÿ”Œ Plug-and-play library to enable agents to call MCP and UTCP tools via code execution.

1,519 โ˜…100 forksTypeScriptUpdated 1mo ago

What you need to know

The first library for tool calls via code execution โ€” instead of exposing hundreds of MCP/UTCP tools directly, it gives an AI agent one tool that executes TypeScript code with sandboxed access to the whole toolkit, replacing many round trips with a single execution.

Install

npm install @utcp/code-mode
For shell agents (preferred): npx -y @utcp/code-mode-cli prompt (self-configuring CLI, no server needed)
For MCP-only clients: {"mcpServers":{"code-mode":{"command":"npx","args":["@utcp/code-mode-mcp"],"env":{"UTCP_CONFIG_FILE":"/path/to/.utcp_config.json"}}}
Transport plugins: npm install @utcp/mcp (or @utcp/http, @utcp/text, etc.)

Usage

  • โ€ขconst client = await CodeModeUtcpClient.create(); await client.registerManual({name:"github", call_template_type:"mcp", config:{...}});
  • โ€ขconst { result, logs } = await client.callToolChain(`...code...`, timeoutMs);
  • โ€ขDiscover tools instead of loading 500 definitions: await client.searchTools("github pull request")
  • โ€ขCLI: npx -y @utcp/code-mode-cli search "<task>" / run / login (interactive OAuth)

Key features

  • โœ“Code-mode execution: single TypeScript code block replaces 15+ traditional tool calls (67-88% faster per independent benchmark)
  • โœ“Progressive tool discovery and auto-generated TypeScript interfaces for IDE IntelliSense
  • โœ“Multi-protocol tool chains mixing MCP, HTTP/REST (with auto-discovery), File (JSON/YAML), and CLI tools in one execution
  • โœ“Enterprise-ready: Node.js VM sandboxing, no filesystem/network access by default, configurable timeouts, full console log capture
  • โœ“Ships AGENT_PROMPT_TEMPLATE for any AI framework plus a ready-to-use MCP server and a self-configuring utcp CLI

Best for

Coding agents (Claude Code, Cursor, Codex, Claude Cowork) that want fewer, larger tool executions with lower token cost and context bloat.

Caveats

  • โš Cost-savings claims ($9,536/year at 1,000 scenarios/day) come from an independent Python benchmark study, not first-party
  • โš Prefer the CLI when the agent has shell access; the MCP server is for MCP-only clients like Claude Desktop
  • โš License: MPL-2.0
Clients: Claude Code ยท Cursor ยท Codex ยท Claude Cowork ยท Claude Desktop (via MCP server)
Documentation โ†—

Reviewed 2026-08-07

Topics

ai-agentscodemodemcpmodel-context-protocoltoolchainutcp
View on GitHub โ†—
Stars
1,519โ˜…
Forks
100
Language
TypeScript
License
MPL-2.0
Created
2025-11-11
Last push
2026-06-18