Skip to main content
Glama

get_symbol_source

Retrieve source code for the innermost symbol at a cursor position to analyze functions, methods, or classes in your codebase.

Instructions

Return the source code of the innermost symbol (function, method, class, struct, etc.) whose range contains the given cursor position. Calls textDocument/documentSymbol, walks the symbol tree to find the smallest enclosing symbol, then slices the file at that symbol's range. Returns symbol_name, symbol_kind, start_line (1-based), end_line (1-based), and source text. Use line+character or position_pattern (@@-syntax) to specify the cursor. character defaults to 1.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
language_idNo
lineNo
characterNo
position_patternNo
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it calls textDocument/documentSymbol, walks the symbol tree, slices the file, and returns specific fields (symbol_name, symbol_kind, start_line, end_line, source text). It also mentions defaults ('character defaults to 1') and input options ('Use line+character or position_pattern'). However, it lacks details on error handling, performance implications, or authentication needs.

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 description is appropriately sized and front-loaded, starting with the core purpose and progressively adding details. Every sentence adds value: the first states the action and target, the second explains the process, the third lists return values, and the fourth covers input specifics. There is no redundant or wasted text.

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

Completeness4/5

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

Given the tool's moderate complexity (5 parameters, no annotations, no output schema), the description is fairly complete. It covers the purpose, process, return values, and input usage. However, it lacks explicit error cases, output format details (beyond listed fields), or performance considerations, which could enhance completeness for an agent.

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 description coverage is 0%, so the description must compensate. It explains the purpose of parameters: 'file_path' is implied by context, 'line' and 'character' or 'position_pattern' specify the cursor position, and it clarifies defaults and alternatives. However, it does not explicitly mention 'language_id' or detail all five parameters, leaving some semantic gaps.

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?

The description clearly states the specific action ('Return the source code'), target resource ('innermost symbol'), and method ('walks the symbol tree to find the smallest enclosing symbol, then slices the file'). It distinguishes this from sibling tools like get_document_symbols (which lists symbols) or get_symbol_documentation (which returns documentation rather than source code).

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?

The description provides clear context for when to use this tool ('to specify the cursor' position within a file to get source code of the enclosing symbol). However, it does not explicitly state when not to use it or name alternatives (e.g., get_document_symbols for listing symbols or get_info_on_location for other location-based info), though the purpose differentiation implies some guidance.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/blackwell-systems/agent-lsp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server