Skip to main content
Glama

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

ctx_execute_file
Destructive

Run sandboxed code against a file and get only the printed output, so raw file content never enters your 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.
timeoutNoMax execution time in ms. When omitted, no server-side timer fires — the MCP host's RPC timeout governs.
languageYesRuntime language
Behavior1/5

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

The description claims the tool is sandboxed and that 'file bytes stay in the sandbox', implying safe, non-destructive execution. However, annotations declare destructiveHint=true and readOnlyHint=false, which contradicts this safety implication. Per the rule, this is an annotation contradiction and scores 1.

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?

The description is front-loaded with a clear purpose, uses structured sections (WHEN, WHEN NOT, RETURNS, EXAMPLE) for scannability, and includes relevant examples. It is long but every section earns its place; no filler or tautology.

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?

Even without an output schema, the description explains return behavior ('Only what your code prints'), large-output auto-indexing, and the memory rationale. Combined with thorough usage guidance and examples, it is nearly complete for a tool of this complexity, only undermined by the annotation contradiction.

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 coverage is 100%, so baseline is 3, but the description adds significant value: it explains the FILE_CONTENT variable, clarifies that only console.log output is returned, details the intent param's auto-indexing behavior, and provides concrete examples for code and path. This goes beyond the schema's terse descriptions.

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?

The description uses a specific verb+resource pattern: 'Read a file into a sandboxed FILE_CONTENT variable and run code over it.' It also explicitly distinguishes itself from sibling ctx_execute by saying 'Same principle as ctx_execute, scoped to one named file via the FILE_CONTENT variable.' This clearly differentiates it from alternatives.

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?

The description includes explicit 'WHEN' and 'WHEN NOT' sections, listing specific scenarios for use and alternatives such as Read, ctx_execute, and ctx_search. It names exact tools and conditions, making the choice logic unambiguous.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Everflow-Utilities/context-mode'

If you have feedback or need assistance with the MCP directory API, please join our Discord server