Skip to main content
Glama

get_error_context

Extract source snippets and git diffs from error logs, stripping framework noise and redacting credentials.

Instructions

Extracts focused source code snippets and git diffs from a raw error log or stack trace, stripping framework noise (node_modules, site-packages) and redacting credentials.

• Side Effects: None. Strictly read-only; does not modify workspace files, git state, or environment variables. • Auth & Permissions: None required. Reads local filesystem within the current workspace boundary. • Rate Limits: None. Runs entirely locally on native machine code. • Return Shape: Returns a JSON object with 'sanitized_trace' (string without secrets/noise), 'source_frames' (array of objects with file, line, code_snippet), and 'git_diff' (string or null). • Failure Modes: If source files referenced in the trace do not exist locally, omits code snippets for those frames while still returning the sanitized trace. Returns an error JSON on unreadable input. • When to use: Call immediately when receiving a runtime exception, test failure, or compiler error to isolate the root cause before planning code fixes. • When NOT to use: Do NOT use to search web solutions (use search_stack_overflow), do NOT use to modify files (use apply_code_patch), and do NOT use to statically lint clean code without an error log (use analyze_code). • Prerequisites: Workspace directory must be accessible locally; git repository recommended for diff extraction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
logYesRaw error stack trace, compiler panic, or terminal stderr string to analyze (e.g. Python traceback, Node.js error, Rust panic). Must be non-empty UTF-8 text up to 1MB. Automatically sanitized of API keys, JWTs, and passwords.
strategyNoContext pruning and token budgeting strategy. Options: 'aggressive' (default: excises all framework internals and idle threads), 'conservative' (retains boundary transition frames), or 'lossless_compact' (preserves all frames, compressing only whitespace and redacting credentials).
context_linesNoNumber of source code lines to retrieve above and below each detected error line. Integer between 0 and 100. Defaults to 10 lines. Larger values expand the context window but consume more LLM tokens.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv1.1.8
    • addedInput schema / properties / context_lines / description
      Added value: +"Number of source code lines to retrieve above and below each detected error line. Integer between 0 and 100. Defaults to 10 lines. Larger values expand the context window but consume more LLM tokens."
    • addedInput schema / properties / log / description
      Added value: +"Raw error stack trace, compiler panic, or terminal stderr string to analyze (e.g. Python traceback, Node.js error, Rust panic). Must be non-empty UTF-8 text up to 1MB. Automatically sanitized of API keys, JWTs, and passwords."
    • addedInput schema / properties / strategy
      Added value: +{
      +  "description": "Context pruning and token budgeting strategy. Options: 'aggressive' (default: excises all framework internals and idle threads), 'conservative' (retains boundary transition frames), or 'lossless_compact' (preserves all frames, compressing only whitespace and redacting credentials).",
      +  "enum": [
      +    "aggressive",
      +    "conservative",
      +    "lossless_compact"
      +  ],
      +  "type": "string"
      +}
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

With zero annotations provided, the description carries the full burden and discharges it completely: it declares no side effects (read-only, no workspace/git/env mutation), no auth required, no rate limits (local execution), the JSON return shape with field-level detail, and concrete failure modes (missing source files → omitted snippets with sanitized trace still returned; unreadable input → error JSON). It also lists prerequisites. Nothing about actual behavior is left to inference.

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?

The definition is long but every bullet earns its place: purpose sentence up front, then tightly grouped bullets for side effects, auth, rate limits, return shape, failure modes, usage routing, and prerequisites. Since annotations and output schema are both absent, this length is justified rather than padded — each section answers a distinct question an agent would have before invoking.

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

Completeness5/5

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

Despite having no annotations and no output schema, the description covers every category an agent needs: purpose, when/when-not with alternatives, behavioral safety profile, exact return structure (including nullable git_diff), failure modes, and prerequisites. A tool with 3 parameters, one enum, and nuanced output is fully specified for correct invocation with no unresolved questions.

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 description coverage is 100%, so per the rubric the baseline is 3. The schema's own descriptions are thorough — log includes format/size/sanitization semantics, strategy explains each enum value with its default, and context_lines gives range, default, and token tradeoff. The description's Return Shape section adds light contextual interplay (strategy affects output) but doesn't need to compensate for any schema gap.

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?

Opens with a specific verb-and-resource statement: 'Extracts focused source code snippets and git diffs from a raw error log or stack trace.' The scope is precise (error logs/traces only, noise stripped, credentials redacted), and the 'When NOT to use' section names each sibling tool with its distinct purpose, so an agent can unambiguously tell this apart from search_stack_overflow, apply_code_patch, and analyze_code.

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 to use' states the exact trigger conditions: 'Call immediately when receiving a runtime exception, test failure, or compiler error.' The 'When NOT to use' section gives exclusion criteria AND names the correct alternative for each (web search → search_stack_overflow, file modification → apply_code_patch, linting clean code → analyze_code). This is the gold standard for routing guidance.

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