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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| line | Yes | ||
| column | Yes |
Implementation Reference
- src/mcp_ty/server.py:378-406 (handler)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)) - src/mcp_ty/server.py:377-378 (registration)The registration decorator for the 'find_usages' tool.
@mcp.tool() async def find_usages(file_path: str, line: int, column: int) -> str: