get_schema
Retrieve database schema details like table structures and column definitions to understand bakery POS data organization.
Instructions
Get the database schema information including table structures and column definitions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/bakery_data_mcp/server.py:537-569 (handler)Implementation of the get_schema tool handler within the call_tool function. It retrieves database table schemas from sqlite_master, column information using PRAGMA table_info, and row counts for each table, then returns the structured schema information as JSON text content.elif name == "get_schema": # Get all table information cursor.execute(""" SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name """) tables = cursor.fetchall() schema_info = { "tables": {} } for table in tables: table_name = table["name"] schema_info["tables"][table_name] = { "create_sql": table["sql"] } # Get column info cursor.execute(f"PRAGMA table_info({table_name})") columns = cursor.fetchall() schema_info["tables"][table_name]["columns"] = columns # Get row count cursor.execute(f"SELECT COUNT(*) as count FROM {table_name}") row_count = cursor.fetchone()["count"] schema_info["tables"][table_name]["row_count"] = row_count return [TextContent( type="text", text=json.dumps(schema_info, ensure_ascii=False, indent=2) )]
- src/bakery_data_mcp/server.py:225-232 (registration)Registration of the get_schema tool in the list_tools function, defining its name, description, and empty input schema (no parameters required).Tool( name="get_schema", description="Get the database schema information including table structures and column definitions.", inputSchema={ "type": "object", "properties": {} } )
- Input schema definition for the get_schema tool, specifying an empty object (no input parameters required).inputSchema={ "type": "object", "properties": {} }