Skip to main content
Glama

get_code_snippet

Retrieve source code for a named symbol with configurable context lines, so you can inspect exact code without reading entire files.

Instructions

Read source code for a symbol by its name. More precise than reading entire files.

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

Input Schema

NameRequiredDescriptionDefault
nameYesSymbol name
projectNoProject namedefault
context_linesNoLines of context before/after

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.0

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full behavioral burden. It implies a read-only operation but says nothing about what is returned (definition body, file path, line range), what happens if the symbol name is ambiguous across projects or occurs multiple times, or how errors are surfaced.

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?

Two short sentences with the core action front-loaded and no filler. The second sentence earns its place by giving a comparative rationale, though the whole definition is arguably too terse for a tool with no annotations.

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

Completeness2/5

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

With no annotations, no output schema, and a lookup-by-name operation prone to ambiguity, the description should explain return shape and disambiguation. Instead it leaves an agent unable to predict what comes back or how to handle duplicate symbol names.

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 all three parameters (name, project, context_lines) are already documented in structured form. The description adds only the redundant "by its name" and no extra semantics such as name format, ambiguity resolution, or the effect of context_lines.

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?

States a specific verb and resource ("Read source code for a symbol by its name") and implicitly scopes it against whole-file reading. It does not, however, distinguish itself from adjacent siblings such as get_symbol_info or search_symbols, which an agent must choose between.

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?

"More precise than reading entire files" gives one implied usage condition, effectively a comparison against file-level retrieval. There is no explicit when-not guidance and no named alternative among the many sibling tools that could also resolve a symbol.

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