Skip to main content
Glama

get_definition

Navigate to symbol definitions in Python code using precise line and column positions for accurate code analysis and editing.

Instructions

Go to definition of symbol at position (1-based).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
lineYes
columnYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_definition' tool implementation in 'src/mcp_ty/server.py' which handles the request, converts 1-based line/column to 0-based for the underlying client, and formats the output.
    @mcp.tool()
    async def get_definition(file_path: str, line: int, column: int) -> str:
        """Go to definition of symbol at position (1-based)."""
        client = _get_client()
    
        path = Path(file_path).resolve()
        if not path.exists():
            return _error(f"File not found: {file_path}")
    
        try:
            await client.open_document(path)
            locations = await client.get_definition(path, line - 1, column - 1)
    
            if not locations:
                return _not_found(f"No definition at {path.name}:{line}:{column}")
    
            defs = []
            for loc in locations:
                def_path = _uri_to_path(loc.uri)
                defs.append({
                    "file": def_path.name,
                    "path": str(def_path),
                    "line": loc.range.start.line + 1,
                    "column": loc.range.start.character + 1
                })
    
            return _ok({"definitions": defs})
        except Exception as e:
            return _error(str(e))
Behavior2/5

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

No annotations provided, so description carries full behavioral burden. 'Go to' implies navigation but MCP tools return data; description does not clarify what gets returned (location? source?) or behavior when symbol is not found or position is invalid.

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?

Single sentence efficiently front-loaded with the action. The '1-based' parenthetical is high-value information that earns its place. Slightly cryptic for novices, but appropriately sized for an IDE tool.

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

Completeness3/5

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

With 3 simple parameters and an existing output schema, the core operation is identifiable, but the 0% input schema coverage and lack of behavioral disclosure (error handling, file path format) leave notable gaps for reliable invocation.

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 coverage is 0%, requiring description compensation. It adds crucial semantics that line/column are '1-based' (avoiding off-by-one errors), but fails to document file_path expectations (absolute path? URI? extension required?). Minimal compensation for the schema gap.

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?

Clear verb phrase 'Go to definition' identifies the LSP operation, and 'at position' scopes it to coordinate-based lookup. However, it does not distinguish from sibling get_type_info (which also uses position) or clarify when to use this versus search_symbol.

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

Usage Guidelines2/5

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

Provides only the coordinate system constraint '(1-based)'. No guidance on when to use this over find_usages or search_symbol, no mention of file_path format requirements (absolute vs relative), and no error conditions.

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/qinsehm1128/mcp-ty'

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