Skip to main content
Glama

ctx_expand

Read-only

Retrieve a specific slice of stored command output by handle—regex matches with context, line ranges, or tail—to inspect only relevant log lines and stay within a token budget.

Instructions

Fetch part of a stored ctx_run output by handle: lines matching a regex (grep, optional context), a line range (start/end), or the tail.

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": {
      "handle": "<handle>"
    },
    "name": "ctx_expand"
  }
}

Input Schema

NameRequiredDescriptionDefault
endNoLast line of a range (inclusive).
grepNoRegular expression (case-insensitive); returns matching lines with line numbers.
tailNoThe last N lines.
startNoFirst line of a range (1-based).
handleYesThe handle ctx_run printed, e.g. "r3".
contextNoLines of context around each grep match.
budget_tokensNoHard cap on the tokens returned (estimate; default 2000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so the safety profile is covered. The description adds that retrieval is scoped to a previously stored run's output rather than live data, but says nothing about truncation when budget_tokens is hit, behavior on an unknown/expired handle, or whether grep matches are capped.

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

Conciseness5/5

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

A single sentence with the resource stated first and the three modes enumerated in parallel; no filler and nothing redundant with the schema.

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?

With seven parameters and no output schema, the definition covers mode selection adequately but leaves the agent guessing about the returned shape (aside from what the grep param says), truncation semantics, and error behavior for a bad handle. Adequate, but not complete for a tool whose budget cap can silently cut results.

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 the baseline is 3; the description earns above that by grouping the seven parameters into three mutually exclusive modes via 'or', telling the agent these are alternatives rather than combinable filters. It still leaves budget_tokens and handle usage to the schema.

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 gives a specific verb ('Fetch part of') and resource ('a stored ctx_run output by handle'), then enumerates the three retrieval modes (regex grep with optional context, start/end range, tail). It cleanly links this tool to the producing sibling ctx_run, though it never contrasts itself with ctx_read or ctx_search, which also read stored output.

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?

The three modes imply when to use each (pattern search, positional slice, last-N lines), which is useful implied guidance. However there is no explicit 'use this instead of ctx_read/ctx_search when...' statement, nor any note about prerequisites such as the handle having to come from a prior ctx_run.

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