Skip to main content
Glama
wrale

mcp-server-tree-sitter

by wrale

find_usage

Locate symbol usage across a codebase by providing project name, symbol, and optional file or language filters. Returns detailed usage locations for efficient code analysis.

Instructions

Find usage of a symbol.

    Args:
        project: Project name
        symbol: Symbol name to find
        file_path: Optional file to look in (for local symbols)
        language: Language to search in

    Returns:
        List of usage locations
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathNo
languageNo
projectYes
symbolYes

Implementation Reference

  • The main handler function for the 'find_usage' MCP tool. It is decorated with @mcp_server.tool() for registration and implements the tool logic by constructing a Tree-sitter query to find identifier usages matching the given symbol and executing it via query_code.
    @mcp_server.tool()
    def find_usage(
        project: str,
        symbol: str,
        file_path: Optional[str] = None,
        language: Optional[str] = None,
    ) -> List[Dict[str, Any]]:
        """Find usage of a symbol.
    
        Args:
            project: Project name
            symbol: Symbol name to find
            file_path: Optional file to look in (for local symbols)
            language: Language to search in
    
        Returns:
            List of usage locations
        """
        # Detect language if not provided but file_path is
        if not language and file_path:
            language = language_registry.language_for_file(file_path)
    
        if not language:
            raise ValueError("Either language or file_path must be provided")
    
        # Build a query to find references to the symbol
        query = f"""
        (
          (identifier) @reference
          (#eq? @reference "{symbol}")
        )
        """
    
        from ..tools.search import query_code
    
        return query_code(
            project_registry.get_project(project), query, language_registry, tree_cache, file_path, language
        )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that it returns a 'List of usage locations,' which hints at read-only behavior, but doesn't cover critical aspects like whether it performs a search across files, requires specific permissions, has rate limits, or handles errors. This is inadequate for a tool with 4 parameters and no annotation coverage.

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?

The description is front-loaded with the main purpose, followed by a structured list of args and returns. It's efficient with minimal waste, though the formatting as a docstring could be slightly improved for readability. Every sentence serves a purpose, making it appropriately concise.

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?

Given the complexity (4 parameters, no annotations, no output schema), the description is incomplete. It lacks details on behavioral traits, error handling, and output format beyond a vague 'List of usage locations.' For a tool that likely performs code analysis, this leaves significant gaps in how an agent should invoke it effectively.

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 0%, so the description must compensate. It lists all 4 parameters with brief explanations (e.g., 'Optional file to look in (for local symbols)'), adding some semantic context beyond the schema's titles. However, it doesn't provide detailed usage examples, constraints, or default behaviors, leaving gaps in understanding how parameters interact.

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?

The description clearly states the tool's purpose: 'Find usage of a symbol.' It specifies the verb ('find') and resource ('usage of a symbol'), making it understandable. However, it doesn't explicitly differentiate from sibling tools like 'find_similar_code' or 'find_text', which could have overlapping search functionality, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. It lists parameters but doesn't mention scenarios, prerequisites, or exclusions. For example, it doesn't clarify if this is for code analysis versus general text search, leaving the agent to infer usage from context alone.

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

Related 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/wrale/mcp-server-tree-sitter'

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