Skip to main content
Normally an agent calls tools one at a time, and every full response lands in its context window. With code mode, the agent writes one short TypeScript script. The gateway runs it, and only what the script returns goes back to the agent. Without code mode, five tool calls put five full responses in the agent's context window. With code mode, one script makes the same five calls and only its small result enters the window. Without code mode, five tool calls put five full responses in the agent's context window. With code mode, one script makes the same five calls and only its small result enters the window.

What the agent sees

Each service is a namespace of typed functions. This script searches a handbook and returns only the path and heading of each match:
A script can only call these functions. It cannot read files, run shell commands, or reach the web, and it stops after two minutes.

Turn it on

The context map and indexed sources use code mode already. For connected services, an admin turns it on one server at a time, and it works with any MCP server in the catalog.
  1. Open Admin → MCP servers and select Code mode on the server.
  2. Check that most of its tools are typed, shown as a count such as 23/23 typed.
  3. Turn on the Code mode switch.
A typed tool tells the script what shape its result has. If a tool is not typed, open it in the same panel, look at Recent responses, and save a JSON Schema for it. An agent connected to the admin MCP can do this for you.

Measure the saving

The Insights page shows how many tokens code mode kept out of your agents’ context windows.