DocsCode Mode for large APIs

Runtime

Code Mode for large APIs

Large APIs overwhelm agents when every route becomes a separate tool. Code Mode gives the agent two focused capabilities: search documentation, then submit constrained SDK-shaped code that Astrail routes through endpoint maps.

Updated Jun 25, 20267 min read

Implementation

Path to ship.

1
Generate an MCP server with Code Mode enabled.
2
Call search_docs to find the relevant method, parameters, and auth notes.
3
Call execute with a small SDK-shaped snippet for the selected operation.
4
Inspect the structured result, trace id, and runtime mode after execution.

Guide

Why Code Mode exists

A huge tool list looks powerful but usually hurts agent performance. The model has to choose from too many names, context gets crowded, and parameter mistakes become more common.

Code Mode keeps the active interface small. The agent searches docs when it needs detail, then asks Astrail to execute a constrained call path.

Guide

No arbitrary eval

Astrail does not need arbitrary JavaScript evaluation for Code Mode execution. Supported SDK-shaped calls are parsed and routed through generated endpoint maps.

That gives teams a safer path for expressive agent calls while preserving auth, policy checks, observability, and rate limits at the MCP boundary.

FAQ

Common questions.

Does Code Mode run arbitrary code?

No. Astrail supports constrained SDK-shaped calls and routes them through endpoint maps rather than open-ended eval.

When should I use Code Mode?

Use it for large APIs where a searchable catalog plus focused execution is clearer than exposing every route as an active tool.