get_completions
Get completion suggestions at a given cursor position in a FastAPI file to improve development speed.
Instructions
Return completion suggestions at the given cursor position.
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:82-88 (handler)The handler function for the 'get_completions' tool. It uses Jedi to compute completion suggestions at a given cursor position (file, line, column) and returns a list of dicts with name, type, and description.
def get_completions(file: str, line: int, column: int) -> list[dict]: """Return completion suggestions at the given cursor position.""" script = jedi.Script(path=file, project=_project(file)) return [ {"name": c.name, "type": c.type, "description": c.docstring(raw=True)[:120]} for c in script.complete(line=line, column=column) ] - fastapi_architect/server.py:81-82 (registration)The tool registration via the @mcp.tool() decorator on line 81, which registers 'get_completions' with the FastMCP server.
@mcp.tool() def get_completions(file: str, line: int, column: int) -> list[dict]: - fastapi_architect/server.py:9-15 (helper)The _project helper function used by get_completions to locate the project root by walking up from the file looking for pyproject.toml, requirements.txt, or setup.py.
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))