list_models
List all Pydantic BaseModel classes defined in a specified Python file to inspect data models in FastAPI projects.
Instructions
List all Pydantic BaseModel classes defined in a file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- fastapi_architect/server.py:161-170 (handler)The tool 'list_models' is defined as an MCP tool via @mcp.tool() decorator. It parses a Python file with AST, walks the tree, and returns the names of all classes that inherit from BaseModel (i.e., Pydantic models).
@mcp.tool() def list_models(file: str) -> list[str]: """List all Pydantic BaseModel classes defined in a file.""" tree = _parse(file) return [ node.name for node in ast.walk(tree) if isinstance(node, ast.ClassDef) and any(isinstance(b, ast.Name) and b.id == "BaseModel" for b in node.bases) ] - fastapi_architect/server.py:161-161 (registration)The 'list_models' tool is registered with the FastMCP server via the @mcp.tool() decorator on line 161.
@mcp.tool() - fastapi_architect/server.py:162-162 (schema)The handler signature defines 'file: str' as input and returns 'list[str]' — the list of model names found.
def list_models(file: str) -> list[str]: