execute_code
Run custom TypeScript/JavaScript code to call MCP tools, process large data with TOON compression, and implement complex workflows.
Instructions
WHEN TO USE:
Batching 3+ MCP tool calls (saves round-trips, maintains state)
Processing large structured data (TOON compression: 30-90% savings)
Complex logic with conditionals/loops across tool results
DO NOT USE:
Single simple tool call → use direct MCP
Unstructured prose → TOON compression <10%
AVAILABLE SERVERS: LAZY-LOAD ON DEMAND:
WORKFLOWS (use execute_workflow instead for these):
k8s-detective: Comprehensive Kubernetes cluster security and health auditor | USAGE: Scans pods, deployments, services, and events for security vulnerabilities, resource inefficiencies, and stability issues. Outputs detailed findings with severity ratings. EXAMPLE: "Audit my production cluster for security risks" PARAMETERS:
outputFile: Path to save TOON-compressed audit data (required)
namespace: Specific namespace to scan (optional, default: all)
includeEvents: Analyze recent events for warnings (optional, default: true) REQUIRES: kubectl configured with cluster access NOTES: Requires kubectl in PATH. Large clusters auto-TOON-encode. Run from bastion or local with kubeconfig.
post-mortem: Intelligent log analysis with pattern clustering and anomaly detection | USAGE: Parses log files, clusters similar messages by signature, extracts dynamic data (timestamps, IDs, IPs), identifies anomalies and errors, and generates an actionable report. EXAMPLE: "Analyze application logs from the outage and find the root cause" PARAMETERS:
logFile: Path to the log file to analyze (required)
outputFile: Path to save TOON-compressed analysis (required)
maxExamples: Max example lines per cluster (optional, default: 5)
includePatterns: Include normal patterns in output (optional, default: true) REQUIRES: filesystem access NOTES: Supports large files via streaming. Auto-detects log levels and categories.
research: Multi-source research aggregator with parallel execution and synthesis | USAGE: Orchestrates data fetching from Context7 (library docs), Wikipedia (concepts), and Perplexity (web Q&A). Supports parallel execution, retry logic, rate limiting, optional LLM synthesis, and file output. EXAMPLE: "Research xsync library performance vs sync.Map with benchmarks and theory. libraryIDs: ['puzpuzpuz/xsync'], wikipediaTopics: ['Hash table']" PARAMETERS:
goal: Primary research objective (required)
libraryIDs: Context7 library IDs for docs ["puzpuzpuz/xsync"] (optional)
queries: Perplexity questions ["xsync benchmarks?"] (optional)
wikipediaTopics: Wikipedia articles ["Lock-free data structures"] (optional)
synthesize: LLM synthesis of findings (optional, default: false)
outputFile: Path to save TOON-compressed results (optional)
batchSize: Max parallel requests per source (optional, default: 5) REQUIRES: At least one of: context7, wikipedia, perplexity (optional: brave-search as fallback) NOTES: Gracefully degrades if MCPs unavailable. Large outputs auto-TOON-encode.
USAGE PATTERN:
// 1. Discover tools first
const api = await get_tool_api({serverName: 'perplexity'});
// 2. Call tools via proxy
const result = await servers['perplexity'].perplexity_ask({
messages: [{role: 'user', content: 'Your query'}]
});
// 3. Compress large results
console.log(TOON.encode(result));ERROR RECOVERY:
"Server not found" → list_servers shows available
"Tool undefined" → get_tool_api({serverName}) shows tools
"Timeout (60s)" → break into smaller operations
All results TOON-compressed by default.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | TypeScript/JavaScript code. Use servers['name'].tool({params}) to call MCP tools. |