Skip to main content
Glama

map_to_code

Maps stack trace application frames to real project files, resolves path mismatches, and shows the offending source line with context so you can locate crash sites quickly.

Instructions

Map the application frames of a trace onto files in the project and show the code.

Works when the trace's paths differ from the local ones: container paths (/app/src/x.py vs ./src/x.py), Windows vs POSIX separators, webpack/vite URLs, Java package paths. Frames are matched on their trailing path components against files that actually exist under the sandbox directory. For each frame it reports FOUND / NOT FOUND / ambiguous, whether the line number exists, the offending line with +-context lines, and warns when the source line recorded in the trace differs from the file (the code changed since the crash). Paths in the trace are treated as data: '../' tricks cannot reach outside --dir and symlinks that resolve outside it are refused.

Args: text: The trace (max 5,000,000 characters). project_dir: Directory to search; must be inside --dir. Default: the first --dir. context: Lines of context before/after the offending line (0-10, default 3). max_frames: Maximum application frames to map (default 8). index: Which trace if the text contains several (0-based). redact: Remove secrets etc. from the output, including source lines (default true).

Input Schema

NameRequiredDescriptionDefault
textYes
indexNo
redactNo
contextNo
max_framesNo
project_dirNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. 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 no annotations, the description carries the full behavioral burden and does so in detail: matching via trailing path components against real files, FOUND/NOT FOUND/ambiguous outcomes, line-number validation, context lines, and a staleness warning when the trace line differs from the file. It also discloses security behavior — '../' traversal is refused and symlinks resolving outside --dir are rejected — plus default redaction of secrets in output.

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?

Front-loads the purpose and behavior before a clearly delimited Args section, so it is easy to scan. It is somewhat long and the path-format enumeration (container paths, Windows/POSIX separators, webpack/vite URLs, Java packages) is dense, but each clause carries real information rather than filler.

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?

Although an output schema exists, the description still explains the report contents (FOUND status, line existence, offending line with context, staleness warning), which is the operationally important part. For a matching tool with path-remapping and security constraints, nothing an agent needs to invoke it correctly is missing.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it does: text is capped at 5,000,000 characters, project_dir must lie inside --dir and defaults to the first one, context is bounded 0-10 with default 3, max_frames defaults to 8, index is 0-based for multi-trace input, and redact defaults to true. These meanings and constraints go well beyond the bare typed properties.

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 object ('Map the application frames of a trace onto files in the project and show the code'), which is clearly distinct from siblings like parse_trace, fingerprint, or explain_exception. An agent can identify the tool's role without opening the schema.

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

Usage Guidelines4/5

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

Gives clear context for when the tool is applicable ('Works when the trace's paths differ from the local ones') with concrete examples of path mismatches. It does not explicitly name sibling alternatives or state exclusions (e.g., when to prefer parse_trace or explain_exception), so it stops short of full when/when-not guidance.

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