Skip to main content
Glama

save_token_exec

Run persistent JavaScript REPL sessions to execute code, shell commands, and fetch URLs while compacting or indexing large outputs, reducing token use across AI agent turns.

Instructions

Universal token-saving JS REPL across code, data, docs, static web, and CLIs: persists state across turns, runs await $`...`.compact(), tools.fetchText(url), tools.compactOutput(), tools.detectClis(), tools.saveMemory/loadMemory, tools.*, and indexes large output into SQLite FTS5+Trigram.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "save_token_exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNoWorking directory for relative paths and shell commands.
codeYesAsync JavaScript body (supports `await`, `return`, `state`, `$`, `tools`, `console`).
modeNoSafety lock: defaults to 'readonly'. Set to 'write' to allow file edits/writes.readonly
intentNoBM25 search intent to return only matching chunks when output is large.
timeoutMsNoTimeout in ms (1000..300000).
resetStateNoClear in-memory `state` before running.
maxOutputCharsNoContext budget cap (500..32000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

B3.3/5.0
Behavior3/5

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

With no annotations at all, the description carries the full disclosure burden. It does add real behavioral facts beyond the schema: `state` persists across turns and large output is indexed into SQLite FTS5+Trigram. However, it says nothing about arbitrary code/shell side effects, permission or sandbox implications, error semantics, or what happens when output exceeds the cap — the safety lock lives only in the `mode` schema description.

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

Conciseness3/5

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

The core capability is front-loaded in the opening clause, which is good. But the rest is one runaway sentence stuffed with backticked method names (`tools.fetchText`, `tools.compactOutput`, `tools.detectClis`, `tools.saveMemory`/`loadMemory`, `tools.*`) — the trailing `tools.*` makes the whole enumeration redundant and the sentence hard to scan.

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

Completeness3/5

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

For a high-power arbitrary-code-execution tool with no annotations and no output schema, the description covers inputs and helper surface but omits the things an agent most needs to act safely: what executes (shell? filesystem?), what is returned, and how failures surface. The persistence and indexing notes are valuable, but the omission of side-effect/safety framing keeps this at minimum-viable.

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

Parameters3/5

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

Schema coverage is 100% and every parameter (cwd, code, mode, intent, timeoutMs, resetState, maxOutputChars) is documented in the schema itself, so the baseline is 3. The description only adds marginal meaning, chiefly that `state` persists across turns (relevant to `resetState`) and that `tools.*` is available inside `code`; it does not explain how `intent` interacts with the FTS5 indexing it mentions.

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

Purpose4/5

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

The description states a concrete verb and resource: a persistent JavaScript REPL for code, data, docs, static web, and CLI work, with named helpers (`$`, `tools.fetchText`, `tools.detectClis`, memory tools). It is clearly an execution tool rather than a memory/search tool, but it never explicitly differentiates itself from the sibling set (handoff/poll/resume/search/stats), which it arguably overlaps with via `tools.saveMemory`.

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

Usage Guidelines3/5

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

Usage is only implied by the domain list ('across code, data, docs, static web, and CLIs') and by the enumeration of helpers. There is no statement of when to prefer this tool over `save_token_search` or `save_token_handoff`, nor when-not to use it (e.g., for simple one-off lookups). The agent must infer routing from the tool name and capability list.

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