개별적인 도구 호출 대신 TypeScript 코드를 작성하고 실행하여 AI agent가 복잡한 도구 워크플로우를 수행할 수 있도록 합니다.
다른 이름 universal-tool-calling-protocol/code-mode
- 스타
- 1,667
- Tools
- —
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 8월 25일
- 라이선스
- MPL-2.0
Code-Mode MCP란?
Code-Mode은(는) MCP server입니다. 개별적인 도구 호출 대신 TypeScript 코드를 작성하고 실행하여 AI agent가 복잡한 도구 워크플로우를 수행할 수 있도록 합니다.
프로젝트 README에서 생성된 요약
Code-Mode MCP server 정보
개발자는 TypeScript를 사용하여 복잡한 워크플로우를 오케스트레이션함으로써 AI agent를 단순한 도구 호출기에서 효율적인 코드 실행기로 변환할 수 있습니다. 수십 번의 개별 API 호출을 수행하는 대신, agent는 전체 툴킷과 한 번에 상호작용하는 단일 코드 블록을 작성할 수 있습니다. 이 방식은 복잡한 작업을 수행하는 데 필요한 반복 횟수를 줄여주며, 컨텍스트 재처리 과정을 최소화하여 운영 비용을 크게 낮출 수 있습니다.
사용자는 Claude Desktop과 같은 클라이언트를 위한 전용 MCP server를 사용하거나, Cursor 또는 Claude Code와 같은 셸 기반 agent를 위한 CLI를 통해 이를 구현할 수 있습니다. 시스템은 MCP, HTTP, 로컬 파일, CLI 도구를 포함한 다양한 프로토콜을 지원합니다. Node.js 샌드박싱을 사용하여 보안 환경을 제공하며, agent가 적절한 도구를 동적으로 찾아 사용할 수 있도록 점진적 도구 탐색, 자동 생성된 TypeScript 인터페이스, 런타임 인트로스펙션 등의 기능을 포함합니다.
활용 사례
- 1다단계 도구 워크플로우 실행AI agent는 풀 리퀘스트 데이터를 가져오고 댓글을 분석하는 것과 같은 여러 작업을 단일 요청 내에서 체인 형태로 연결하여 수행할 수 있습니다.
- 2도구 동적 탐색수백 개의 정의를 한꺼번에 로드하는 대신, agent는 특정 작업에 필요한 관련 도구만 검색하여 로드할 수 있습니다.
- 3이기종 도구 생태계 오케스트레이션개발자는 MCP를 통해 GitHub에서 데이터를 가져오고, 로컬 파일을 통해 데이터베이스를 쿼리하며, HTTP를 통해 Slack 알림을 동시에 보내는 코드를 작성할 수 있습니다.
- 4셸 기반 agent 설정 자동화셸 액세스 권한이 있는 agent의 경우, CLI가 설정 파일을 작성하고 대화형 OAuth 로그인을 처리함으로써 스스로 설정할 수 있습니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
구성
UTCP_CONFIG_FILE
| 이름 | 설명 | 유형 |
|---|---|---|
| UTCP_CONFIG_FILE | — |
자동 검사
2026년 11월 13일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능통과
- 오픈 소스 라이선스 (OSI)통과
- 최근 1년 내 커밋 또는 릴리스통과
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 원격 엔드포인트가 HTTPS 사용검사되지 않음
- 파괴적인 도구에 라벨 표시됨검사되지 않음
- 모델에 대한 숨겨진 지침 없음통과
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
README
GitHub에서 보기Transform your AI agents from clunky tool callers into efficient code executors — in just 3 lines.
Why This Changes Everything
LLMs excel at writing code but struggle with tool calls. Instead of exposing hundreds of tools directly, give them ONE tool that executes TypeScript code with access to your entire toolkit.
Apple, Cloudflare, and Anthropic say that Code-Mode is a more efficient way to approach tool calling compared to the traditional dump function information and then extract a JSON for function calling.
Benchmarks
Independent Python benchmark study validates the performance claims with $9,536/year cost savings at 1,000 scenarios/day:
| Scenario Complexity | Traditional | Code Mode | Improvement |
|---|---|---|---|
| Simple (2-3 tools) | 3 iterations | 1 execution | 67% faster |
| Medium (4-7 tools) | 8 iterations | 1 execution | 75% faster |
| Complex (8+ tools) | 16 iterations | 1 execution | 88% faster |
Why Code Mode Dominates:
Batching Advantage - Single code block replaces multiple API calls
Cognitive Efficiency - LLMs excel at code generation vs. tool orchestration
Computational Efficiency - No context re-processing between operations
Getting Started
Get Started in 3 Lines
import { CodeModeUtcpClient } from '@utcp/code-mode';
const client = await CodeModeUtcpClient.create(); // 1. Initialize
await client.registerManual({ name: 'github', /* MCP config */ }); // 2. Add tools
const { result } = await client.callToolChain(`/* TypeScript */`); // 3. Execute code
That's it. Your AI agent can now execute complex workflows in a single request instead of dozens.
What You Get
Progressive Tool Discovery
// Agent discovers tools dynamically, loads only what it needs
const tools = await client.searchTools('github pull request');
// Instead of 500 tool definitions → 3 relevant tools
Natural Code Execution
const { result, logs } = await client.callToolChain(`
// Chain multiple operations in one request
const pr = await github.get_pull_request({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
const comments = await github.get_pull_request_comments({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
const reviews = await github.get_pull_request_reviews({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
// Process data efficiently in-sandbox
return {
title: pr.title,
commentCount: comments.length,
approvals: reviews.filter(r => r.state === 'APPROVED').length
};
`);
// Single API call replaces 15+ traditional tool calls
Auto-Generated TypeScript Interfaces
namespace github {
interface get_pull_requestInput {
/** Repository owner */
owner: string;
/** Repository name */
repo: string;
/** Pull request number */
pull_number: number;
}
}
Enterprise-Ready
- Secure VM Sandboxing – Node.js isolates prevent unauthorized access
- Timeout Protection – Configurable execution limits prevent runaway code
- Complete Observability – Full console output capture and error handling
- Zero External Dependencies – Tools only accessible through registered UTCP/MCP servers
- Runtime Introspection – Dynamic interface discovery for adaptive workflows
If you're working at an enterprise, and need support, book a consultation here.
Universal Protocol Support
Works with any tool ecosystem:
| Protocol | Description | Usage |
|---|---|---|
| MCP | Model Context Protocol servers | call_template_type: 'mcp' |
| HTTP | REST APIs with auto-discovery | call_template_type: 'http' |
| File | Local JSON/YAML configurations | call_template_type: 'file' |
| CLI | Command-line tool execution | call_template_type: 'cli' |
Installation
npm install @utcp/code-mode
Recommended for shell agents: the utcp CLI
If your agent can run shell commands (Claude Code, Cursor, Codex, Claude Cowork, etc.), the utcp CLI is the preferred way to use Code Mode — no MCP server, no client config, no env vars. The agent self-configures by writing a .utcp_config.json and drives everything from the shell.
Just point the agent at the built-in guide:
npx -y @utcp/code-mode-cli prompt
Hand it a description of the API to use — a UTCP call template, an OpenAPI spec, or a plain-English description — and it writes the config, discovers tools, runs tool-chains, and even completes interactive OAuth logins (e.g. Notion), all from the shell:
npx -y @utcp/code-mode-cli search "<task>" # discover tools + TS interfaces
npx -y @utcp/code-mode-cli run <<'EOF' # run a tool-chain
const r = await openlibrary.read_search_json_search_json_get({ q: "tolkien", limit: 3 });
return r.docs.map(b => b.title);
EOF
npx -y @utcp/code-mode-cli login <manual> # interactive OAuth, writes token to .env
CLI vs MCP: prefer the CLI whenever the agent has shell access (most coding agents) — it's simpler and self-configuring. Use the MCP server (below) only for MCP-only clients like Claude Desktop. Both wrap the same
@utcp/code-modeengine.
See code-mode-cli/ for full docs.
Ready-to-Use MCP Server
On an MCP-only client (e.g. Claude Desktop)? Use our plug-and-play MCP server. (If your agent has a shell, prefer the utcp CLI above.)
{
"mcpServers": {
"code-mode": {
"command": "npx",
"args": ["@utcp/code-mode-mcp"],
"env": {
"UTCP_CONFIG_FILE": "/path/to/your/.utcp_config.json"
}
}
}
}
That's it! No installation, no Node.js knowledge required. The Code Mode MCP Server automatically:
- Downloads and runs the latest version via
npx - Loads your tool configurations from JSON
- Provides code execution capabilities to Claude Desktop
- Gives you
call_tool_chainas an MCP tool for TypeScript execution
Perfect for non-developers who want Code Mode power in Claude Desktop!
Direct TypeScript Usage
1. MCP Server Integration
Connect to any Model Context Protocol server:
Each
call_template_typeis a separate plugin package. Install and import the package once at startup so it can register itself with the client; the plugin registers as a side effect of being imported. Formcp, that's@utcp/mcp. The same pattern applies to other transports:@utcp/http,@utcp/text, etc.npm install @utcp/mcp
import '@utcp/mcp'; // registers the 'mcp' call template
import { CodeModeUtcpClient } from '@utcp/code-mode';
const client = await CodeModeUtcpClient.create();
// Connect to GitHub MCP server
await client.registerManual({
name: 'github',
call_template_type: 'mcp',
config: {
mcpServers: {
github: {
transport: 'stdio', // required by @utcp/mcp
command: 'docker',
args: ['run', '-i', '--rm', '-e', 'GITHUB_PERSONAL_ACCESS_TOKEN', 'mcp/github'],
env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN }
}
}
}
});
2. Execute Multi-Step Workflows
Replace 15+ tool calls with a single code execution:
const { result, logs } = await client.callToolChain(`
// Traditional: 4 separate API round trips → Code Mode: 1 execution
const pr = await github.get_pull_request({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
const comments = await github.get_pull_request_comments({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
const reviews = await github.get_pull_request_reviews({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
const files = await github.get_pull_request_files({ owner: 'microsoft', repo: 'vscode', pull_number: 1234 });
// Process data in-sandbox (no token overhead)
const summary = {
title: pr.title,
state: pr.state,
author: pr.user.login,
stats: {
comments: comments.length,
reviews: reviews.length,
filesChanged: files.length,
approvals: reviews.filter(r => r.state === 'APPROVED').length
},
topDiscussion: comments.slice(0, 3).map(c => ({
author: c.user.login,
preview: c.body.substring(0, 100) + '...'
}))
};
console.log(\`PR "\${pr.title}" analysis complete\`);
return summary;
`);
console.log('Analysis Result:', result);
// console output: 'PR "Fix memory leak in hooks" analysis complete'
Advanced Features
Multi-Protocol Tool Chains
Mix and match different tool ecosystems in a single execution:
// Register multiple tool sources
await client.registerManual({ name: 'github', call_template_type: 'mcp', /* config */ });
await client.registerManual({ name: 'slack', call_template_type: 'http', /* config */ });
await client.registerManual({ name: 'db', call_template_type: 'file', file_path: './db-tools.json' }); // This loads a UTCP manual from a json file
const result = await client.callToolChain(`
// Fetch PR data from GitHub (MCP)
const pr = await github.get_pull_request({ owner: 'company', repo: 'api', pull_number: 42 });
// Query deployment status from database (File)
const deployment = await db.get_deployment_status({ pr_id: pr.id });
// Send notification to Slack (HTTP)
await slack.post_message({
channel: '#releases',
text: \`PR #42 "\${pr.title}" deployed to \${deployment.environment}\`
});
return { pr: pr.title, environment: deployment.environment };
`);
Runtime Interface Introspection
Tools can dynamically discover and adapt to available interfaces:
const result = await client.callToolChain(`
// Discover available tools at runtime
console.log('Available interfaces:', __interfaces);
// Get specific tool interface for validation
const prInterface = __getToolInterface('github.get_pull_request');
console.log('PR tool expects:', prInterface);
// Use interface info for dynamic workflows
const hasSlackTools = __interfaces.includes('namespace slack');
if (hasSlackTools) {
await slack.post_message({ channel: '#dev', text: 'Analysis complete' });
}
return { toolsAvailable: hasSlackTools };
`);
Context-Efficient Data Processing
Process large datasets without bloating the model's context:
const result = await client.callToolChain(`
// Fetch large dataset
const allIssues = await github.list_repository_issues({ owner: 'facebook', repo: 'react' });
console.log('Fetched', allIssues.length, 'total issues');
// Process efficiently in-sandbox
const criticalBugs = allIssues
.filter(issue => issue.labels.some(l => l.name === 'bug'))
.filter(issue => issue.labels.some(l => l.name === 'high priority'))
.map(issue => ({
number: issue.number,
title: issue.title,
author: issue.user.login,
daysOld: Math.floor((Date.now() - new Date(issue.created_at)) / (1000 * 60 * 60 * 24))
}))
.sort((a, b) => b.daysOld - a.daysOld);
// Only return processed summary (not 10,000 raw issues)
return {
totalIssues: allIssues.length,
criticalBugs: criticalBugs.slice(0, 10), // Top 10 oldest critical bugs
summary: \`Found \${criticalBugs.length} critical bugs, oldest is \${criticalBugs[0]?.daysOld} days old\`
};
`);
Error Handling & Observability
Built-in error handling with complete execution transparency:
const { result, logs } = await client.callToolChain(`
try {
console.log('Starting multi-step workflow...');
const data = await external_api.fetch_data({ id: 'user-123' });
console.log('Data fetched successfully');
const processed = await data_processor.transform(data);
console.warn('Processing completed with', processed.warnings.length, 'warnings');
return processed;
} catch (error) {
console.error('Workflow failed:', error.message);
throw error; // Propagates to outer error handling
}
`, 30000); // 30-second timeout
// Complete observability
console.log('Result:', result);
console.log('Execution logs:', logs);
// ['Starting multi-step workflow...', 'Data fetched successfully', '[WARN] Processing completed with 2 warnings']
Custom Timeouts
Configure execution limits for different workload types:
// Quick operations (5 seconds)
const quickResult = await client.callToolChain(`return await ping.check();`, 5000);
// Heavy data processing (2 minutes)
const heavyResult = await client.callToolChain(`
const bigData = await database.export_full_dataset();
return await analytics.process_dataset(bigData);
`, 120000);
AI Agent Integration
Plug-and-play with any AI framework. The built-in prompt template handles all the complexity:
import { CodeModeUtcpClient } from '@utcp/code-mode';
const systemPrompt = `
You are an AI assistant with access to tools via UTCP CodeMode.
${CodeModeUtcpClient.AGENT_PROMPT_TEMPLATE}
Additional instructions...
`;
// Works with any AI library
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: 'Analyze the latest PR in microsoft/vscode' }
]
});
The template provides comprehensive guidance on:
- Tool discovery workflow (
searchTools→__interfaces→callToolChain) - Hierarchical access patterns (
manual.tool()syntax) - Interface introspection (
__getToolInterface()) - Error handling and best practices
API Reference
Core Methods
callToolChain(code: string, timeout?: number)
Execute TypeScript code with full tool access and observability.
- Returns:
{result: any, logs: string[]}with execution result and captured console output - Default timeout: 30 seconds
getAllToolsTypeScriptInterfaces()
Generate complete TypeScript interfaces for IDE integration.
- Returns: String containing all interface definitions with namespaces
searchTools(query: string) (from UtcpClient)
Discover tools using natural language queries.
- Returns: Array of relevant tools with descriptions and interfaces
Static Methods
CodeModeUtcpClient.create(root_dir?, config?)
Create a new client instance with optional configuration.
CodeModeUtcpClient.AGENT_PROMPT_TEMPLATE
Production-ready prompt template for AI agents.
Security & Performance
Secure by Design
- Node.js VM sandboxing – Isolated execution context
- No filesystem access – Tools only through registered servers
- Timeout protection – Configurable execution limits
- Zero network access – No external dependencies or API keys exposed
Performance Optimized
- Minimal memory footprint – VM contexts are lightweight
- Efficient tool caching – TypeScript interfaces cached automatically
- Streaming console output – Real-time log capture without buffering
- Identifier sanitization – Handles invalid TypeScript identifiers gracefully
Development Experience
IDE Integration
Generate TypeScript definitions for full IntelliSense support:
# Generate tool interfaces
const interfaces = await client.getAllToolsTypeScriptInterfaces();
await fs.writeFile('generated-tools.d.ts', interfaces);
# Add to tsconfig.json
{
"compilerOptions": {
"typeRoots": ["./generated-tools.d.ts"]
}
}
Debug & Monitor
Built-in observability for production deployments:
const { result, logs } = await client.callToolChain(userCode);
// Ship logs to your monitoring system
logs.forEach(log => {
if (log.startsWith('[ERROR]')) monitoring.error(log);
if (log.startsWith('[WARN]')) monitoring.warn(log);
});
Benchmark Methodology
The comprehensive Python study tested 16 realistic scenarios across:
- Financial workflows (invoicing, expense tracking)
- DevOps operations (deployments, monitoring)
- Data processing (analysis, reporting)
- Business automation (CRM, notifications)
Models tested: Claude Haiku, Gemini Flash
Pricing basis: $0.25/1M input, $1.25/1M output tokens
Scale: 1,000 scenarios/day = $9,536/year savings with Code Mode
Learn More
- Cloudflare Research – Original code mode whitepaper
- Anthropic Study – MCP code execution benefits
- Python Benchmark Study – Comprehensive performance analysis
- UTCP Specification – Official TypeScript implementation
- Report Issues – Bug reports and feature requests
License
MPL-2.0 – Open source with commercial-friendly terms.
Code-Mode MCP 질문
Claude Desktop에서 Code-Mode를 사용할 수 있나요?
네, 플러그 앤 플레이 방식의 MCP server를 사용하여 Claude Desktop에 코드 실행 기능을 제공할 수 있습니다.