find_references
Finds all references to a symbol at a specified file, line, and column, helping you identify where a symbol is used across the project.
Instructions
Find all references to the symbol at the given position across the project.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | ||
| line | Yes | ||
| column | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- fastapi_architect/server.py:25-38 (handler)The find_references MCP tool handler that uses Jedi to find all references to a symbol at a given file/line/column position across the project.
@mcp.tool() def find_references(file: str, line: int, column: int) -> list[dict]: """Find all references to the symbol at the given position across the project.""" script = jedi.Script(path=file, project=_project(file)) return [ { "file": str(r.module_path), "line": r.line, "column": r.column, "name": r.name, } for r in script.get_references(line=line, column=column) if r.module_path is not None ] - fastapi_architect/server.py:25-25 (registration)The @mcp.tool() decorator registers find_references as an MCP tool.
@mcp.tool() - fastapi_architect/server.py:9-15 (helper)Helper function used by find_references to locate the project root from a file path.
def _project(file: str) -> jedi.Project: """Walk up from file to find the project root.""" path = Path(file).resolve() for parent in [path.parent, *path.parents]: if any((parent / f).exists() for f in ("pyproject.toml", "requirements.txt", "setup.py")): return jedi.Project(path=str(parent)) return jedi.Project(path=str(path.parent))