Code Mode
Let an agent write a short script against the Lookio API in a sandbox, with two tools, search and execute, the same scopes and strict limits.
Code Mode is a second MCP server, for agents that work better when they write code than when they chain many tool calls.
https://mcp.lookio.app/mcp/codeIt has two tools. The standard server at /mcp stays the default.
| Tool | What it does |
|---|---|
search | Finds API operations. The agent sends a JavaScript filter that runs on the API description in the sandbox. Without a filter, it returns all operations in short form: a few hundred tokens. |
execute | Runs a JavaScript program with a request() function that calls the API. |
The API description stays in the sandbox and does not fill the agent’s context.
Calling the API
In execute, request({ method, path, query, body }) calls an endpoint and returns the parsed response: { data, request_id }, and has_more and next_cursor for a list. A failed call throws an Error with the API’s message.
const failed = [];
let cursor;
do {
const page = await request({
method: "GET",
path: "/v1/resources",
query: { limit: 100, ...(cursor ? { cursor } : {}) },
});
for (const resource of page.data) {
if (resource.status === "failed") {
await request({ method: "POST", path: `/v1/resources/${resource.id}/reindex` });
failed.push({ id: resource.id, title: resource.title });
}
}
cursor = page.next_cursor;
} while (cursor);
return { reindexed: failed.length, failed };Only what the script returns or logs with console.log goes back to the agent. Filter and summarise in the script. Do not return raw rows.
Limits
| Limit | Value |
|---|---|
| Time for one execution | 30 seconds |
| Size of a program | 64 KB |
| Size of the result | 256 KB. A longer result is cut and marked [truncated by Lookio]. |
| Log output | 200 lines and 32 KB |
request() calls per execution | 100. Going over fails the whole run. |
Every request() counts against the credential’s rate limit, like the HTTP call.
Same permissions, same costs
Code Mode uses the same routes, checks and scopes as an HTTP request. A path without its scope fails with insufficient_scope. A script cannot do more than the connection.
Costs are the same, and a loop multiplies them: 100 calls to POST /v1/assistants/{assistant_id}/query cost 100 answers. Do not grant query to a Code Mode connection without need, and tell the agent to ask before it loops over questions.
What a script cannot do
- Open a network connection. There is no
fetchand no file system.request()is the only way out. - Upload a file or stream an answer.
- Set headers, including
Idempotency-Key. - Reach the engine, the database or another workspace.
Connecting
Connect to the Code Mode URL like the standard server. See Connect an AI client. A token for the standard server only does not work here, and the reverse. A token without resource works for both.
The sandbox protects against the code, not against the content. Text from your resources goes back to the agent and can try to change the next script. Narrow scopes limit the risk. See Safety and permissions.