go_to_definition
Locate the definition of a symbol by specifying its file, line, and column. Jump directly to the source file and line where a function, class, or variable is defined.
Instructions
Return the file and line where the symbol at the given position is defined.
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:70-78 (handler)The main tool handler for 'go_to_definition' – uses Jedi to find the definition location of a symbol at a given position.
@mcp.tool() def go_to_definition(file: str, line: int, column: int) -> dict | None: """Return the file and line where the symbol at the given position is defined.""" script = jedi.Script(path=file, project=_project(file)) defs = script.goto(line=line, column=column) for d in defs: if d.module_path: return {"file": str(d.module_path), "line": d.line, "column": d.column, "name": d.name} return None - fastapi_architect/server.py:70-71 (registration)The tool is registered via the @mcp.tool() decorator on line 70, which registers it with the FastMCP server instance.
@mcp.tool() def go_to_definition(file: str, line: int, column: int) -> dict | None: - fastapi_architect/server.py:9-15 (helper)The helper function _project() is used by go_to_definition to find the Jedi project root for the given file.
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))