Skip to main content
Glama
zademy
by zademy

Run code over a file (executes code, reads the given path)

ctx_execute_file
Destructive

Run code over a file in a sandbox and return only printed results, so raw file bytes stay out of conversation context.

Instructions

Read a file into a sandboxed FILE_CONTENT variable and run code over it. Only what you console.log() enters your conversation — the file bytes stay in the sandbox.

Think-in-Code applied to file-level analysis: Reading the whole file means every byte enters your conversation memory and costs reasoning capacity for the rest of the session. Running code over it here lets you keep the raw bytes out and only the derived answer in. Same principle as ctx_execute, scoped to one named file via the FILE_CONTENT variable.

WHEN:

  • You want to KNOW SOMETHING ABOUT a file (line count, matches of a pattern, parsed structure, statistical aggregate) without needing to SEE all of it

  • The file is structured (CSV, JSON, log, code) and a code-level derivation is cheaper than reading verbatim

  • The file is large enough that reading the full content would burn meaningful conversation memory you need for the actual work

  • The derivation may itself produce a large output you want recall-by-topic on later — pass an intent string; outputs over ~5KB are auto-indexed and only matching sections come back, retrievable via ctx_search

WHEN NOT:

  • You intend to EDIT the file — use Read so the subsequent Edit can match the exact text

  • You only need one specific line and you know its offset — Read with offset/limit is the simplest path

  • The file is small AND you will consume all of it for understanding/editing — Read directly

RETURNS: Only what your code prints. The FILE_CONTENT variable holds the raw bytes inside the sandbox; nothing else leaves. When intent is set and output exceeds the auto-index threshold, the response carries searchable section titles + previews instead of the raw stdout.

EXAMPLE: ctx_execute_file(path: "huge.log", language: "javascript", code: "const errs = FILE_CONTENT.split('\n').filter(l => /ERROR|FATAL/.test(l)); console.log(${errs.length} error lines); console.log(errs.slice(-5).join('\n'))") EXAMPLE: ctx_execute_file(path: "data.csv", language: "javascript", code: "const rows = FILE_CONTENT.split('\n'); console.log(rows: ${rows.length - 1}, header: ${rows[0]})")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCode to process FILE_CONTENT (file_content in Elixir). Print summary via console.log/print/echo/IO.puts/Console.WriteLine.
pathYesAbsolute file path or relative to project root
intentNoWhat you're looking for in the output. When provided and output is large (>5KB), returns only matching sections via BM25 search instead of truncated output.
languageYesRuntime language
timeoutMsNoMax execution time in MILLISECONDS — timeoutMs: 120000 is two minutes, timeoutMs: 120 is 0.12 seconds. When omitted, the host's own RPC timeout governs where it has one; on hosts that do not bound a call (Pi, Antigravity CLI) a generous server-side default applies instead.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations by disclosing sandbox isolation, that only console.log output returns, the ~5KB auto-index behavior with `intent`, and the retrieval path via ctx_search. It does not, however, reconcile its reassuring 'bytes stay in the sandbox' framing with the destructiveHint=true / openWorldHint=true annotations — arbitrary executed code can still mutate the host or reach the network, and that risk is unaddressed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well front-loaded — purpose, then principle, then WHEN/WHEN NOT, RETURNS, and examples. Slightly long: the sandbox/'bytes stay out of conversation' idea is restated in the header, the think-in-code paragraph, and RETURNS, and two examples where one would carry the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates fully by explaining what returns (stdout only, or indexed sections under `intent`) plus two worked examples. The only material omission is any note that the executed code runs with real side-effect potential, which the annotations flag as destructive/open-world.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3, but the description adds a genuine mental model for the `intent` parameter (why to pass it, auto-index threshold, recall-by-topic) and for the FILE_CONTENT variable that the code operates on, which the schema only gestures at.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Read a file into a sandboxed FILE_CONTENT variable and run code over it') and explicitly positions itself as 'the same principle as ctx_execute, scoped to one named file', which cleanly separates it from the ctx_execute sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit WHEN / WHEN NOT sections with named alternatives and the conditions that select them (edit → Read for exact-match, single known line → Read with offset/limit, small file consumed whole → Read directly). Nothing is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.