Skip to main content
Glama

get_symbol_source

Return source code of the innermost symbol (function, class, struct) at a cursor position by walking the language server symbol tree and slicing the file range.

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
lineNo
characterNo
file_pathYes
language_idNo
position_patternNo
Behavior4/5

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

Description discloses the algorithm (calls textDocument/documentSymbol, walks symbol tree, slices file at symbol range) and lists return fields (symbol_name, symbol_kind, start_line, end_line, source text). No annotations are provided, so the description carries full behavioral burden. It could mention error handling (e.g., if no symbol found) but otherwise is transparent.

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?

Four sentences front-load the main purpose with no redundancy. Every sentence adds value, explaining mechanism, output, and parameter usage efficiently.

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 complexity of LSP symbol resolution, description explains algorithm and output structure. However, it lacks information on error conditions (e.g., no symbol at position) and does not cover language_id parameter. With no output schema, describing return fields helps but is incomplete without error handling.

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 0%, so description must compensate. It adds meaning by describing line, character, and position_pattern usage, including character default. However, language_id is not mentioned, and its purpose remains unclear. Overall, description adds significant value for position parameters.

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?

Description clearly states the tool returns source code of the innermost symbol at a cursor position, specifying the resource (symbol source) and verb (return). It distinguishes from siblings like get_document_symbols (returns all symbols) by focusing on a specific position-driven selection.

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?

Description explains how to specify cursor position using line+character or position_pattern and notes character defaults to 1. It does not explicitly state when not to use or recommend alternatives, but the context implies it is for retrieving source code of a symbol at a location, which is distinct from siblings.

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