Skip to main content
Code Mode replaces hundreds of individual MCP tools with just two: search and execute. The agent writes JavaScript that runs in a sandboxed V8 isolate — and that code can fan out dozens of internal API calls, run them in parallel, aggregate results, and return a summary. All in one tool invocation.

Why It Works

LLMs have seen millions of lines of real-world JavaScript but only contrived tool-calling examples. Writing Promise.all() with a .map() is natural for them — chaining individual tool calls is not. The sandbox provides:
  • cnap.request() — typed API client with auth injected server-side
  • Full JavaScriptPromise.all, Array.map, Date.now(), error handling, any logic the agent needs
  • Up to 50 API calls per execution — enough for complex multi-step workflows
  • No network escape — requests only reach the CNAP API, never the open internet
The agent’s code filters, aggregates, and formats data inside the sandbox before returning — so only the summary hits the context window, not raw API responses.

Examples

What Agents Can Do

PromptWhat happens
”Count log lines across all pods”Parallel log fetches, line counting, sorted summary — 506ms
”Audit resource requests and limits”CPU/memory unit parsing, per-pod aggregation — 56ms
”Audit the cluster for security”9 checks across pods, RBAC, secrets, network policies
”Create network policies for my installs”Discovers ports, generates and applies policies per namespace
”Why is my app returning 500s?”Adaptive triage: pod health → events → logs → rollout history
”What’s the largest table in Postgres?”Runs psql inside the container via exec
”Are my clusters on the same version?”Parallel fan-out across all clusters, drift detection
”What CRDs are installed?”Discovers custom APIs, reads schemas, queries instances
Each row is one or two tool calls. The agent writes the code, the sandbox executes it, and only the results reach the context window.