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 )

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