Skip to main content
Glama

find_usages

Locate all references to a Python symbol at a specific position in your codebase to understand usage patterns and dependencies.

Instructions

Find all references to symbol at position (1-based).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
lineYes
columnYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'find_usages' MCP tool, which finds references using the language server client.
    async def find_usages(file_path: str, line: int, column: int) -> str:
        """Find all references to 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.find_references(path, line - 1, column - 1)
    
            if not locations:
                return _not_found(f"No references at {path.name}:{line}:{column}")
    
            refs = []
            for loc in locations:
                ref_path = _uri_to_path(loc.uri)
                refs.append({
                    "file": ref_path.name,
                    "path": str(ref_path),
                    "line": loc.range.start.line + 1,
                    "column": loc.range.start.character + 1
                })
    
            files = list(set(r["file"] for r in refs))
            return _ok({"count": len(refs), "files_count": len(files), "references": refs})
        except Exception as e:
            return _error(str(e))
  • The registration decorator for the 'find_usages' tool.
    @mcp.tool()
    async def find_usages(file_path: str, line: int, column: int) -> str:
Behavior3/5

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

No annotations provided, so description carries full burden. It successfully discloses the 1-based indexing behavior for coordinates. However, it omits whether results include the definition site, performance characteristics, or error behaviors.

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 with no redundancy. However, given the 0% schema coverage and lack of annotations, it is arguably too terse and front-loads insufficient context for safe invocation.

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?

Having an output schema reduces the burden on description to explain return values. The coordinate system is specified (1-based), but with zero schema descriptions and no annotations, the description should have explicitly mapped the three required parameters.

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

Parameters2/5

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

Schema coverage is 0% with no descriptions on file_path, line, or column. The description mentions 'position' which implicitly maps to line/column, but fails to explicitly document the 'file_path' parameter or clarify that line/column are 1-based integers.

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 'Find' and resource 'references to symbol' distinguishes from siblings like 'get_definition' (which gets the definition) and 'search_symbol' (which searches by name). The '1-based' qualifier adds specific technical scope.

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?

No explicit guidance on when to use this versus 'get_definition' or 'search_symbol'. No prerequisites or constraints mentioned (e.g., project must be started first).

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