describe_table
Analyze table structures by listing columns and their data types within a specified data source for better data understanding and query optimization.
Instructions
Lists columns and their types in the specified table of specified data source.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_id | Yes | The data source | |
| table_name | Yes | The table in the data source |
Implementation Reference
- zaturn/tools/core.py:45-67 (handler)The handler function for the describe_table tool. It retrieves the specified data source, calls the helper query_utils.describe_table, and returns the schema as a Markdown table.def describe_table(self, source_id: Annotated[ str, Field(description='The data source') ], table_name: Annotated[ str, Field(description='The table in the data source') ] ) -> str: """ Lists columns and their types in the specified table of specified data source. """ try: source = self.data_sources.get(source_id) if not source: return f"Source {source_id} Not Found" result = query_utils.describe_table(source, table_name) return result.to_markdown(index=False) except Exception as e: return str(e)
- zaturn/tools/core.py:46-52 (schema)Pydantic input schema definition for the describe_table tool parameters using Annotated and Field for MCP tool schema.source_id: Annotated[ str, Field(description='The data source') ], table_name: Annotated[ str, Field(description='The table in the data source') ] ) -> str:
- zaturn/tools/core.py:12-16 (registration)Registration of the describe_table handler as part of the Core class tools list.self.tools = [ self.list_data_sources, self.describe_table, self.run_query, ]
- zaturn/mcp/__init__.py:90-95 (registration)The ZaturnMCP function registers all ZaturnTools.tools (including describe_table) into the FastMCP server using Tool.from_function.zaturn_tools = ZaturnTools(sources) zaturn_mcp = FastMCP() for tool_function in zaturn_tools.tools: zaturn_mcp.add_tool(Tool.from_function(tool_function)) return zaturn_mcp
- zaturn/tools/query_utils.py:53-72 (helper)Supporting utility that performs the actual table description by running source-type-specific SQL queries via execute_query.def describe_table(source, table_name): match source['source_type']: case 'sqlite': return execute_query(source, f'PRAGMA table_info("{table_name}");' ) case 'postgresql' | 'mssql' | 'bigquery': return execute_query(source, f"SELECT column_name, data_type, is_nullable FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '{table_name}';" ) case "mysql" | "duckdb" | "csv" | "parquet" | "clickhouse": if ' ' in table_name: table_name = f'`{table_name}`' return execute_query(source, f'DESCRIBE {table_name};' )