get_table_schema
Retrieve table structure and metadata from GigAPI Timeseries Lake to understand data organization and relationships for effective querying.
Instructions
Get schema information for a specific table.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data | Yes |
Implementation Reference
- mcp_gigapi/tools.py:126-151 (handler)Primary handler for the get_table_schema MCP tool. Calls the client method and wraps the response with success/error handling.def get_table_schema(self, database: str, table: str) -> Dict[str, Any]: """Get table schema information. Args: database: The name of the database table: The name of the table Returns: Table schema information """ try: schema = self.client.get_table_schema(database, table) return { "schema": schema, "success": True, "database": database, "table": table } except GigAPIClientError as e: logger.error(f"Failed to get table schema: {e}") return { "error": str(e), "success": False, "database": database, "table": table }
- mcp_gigapi/tools.py:241-247 (registration)Tool registration in create_tools function, defining the handler lambda, name, and description for FastMCP.Tool.from_function( lambda input_data: tools_instance.get_table_schema( input_data["database"], input_data.get("table", "") ), name="get_table_schema", description="Get schema information for a specific table.", ),
- mcp_gigapi/client.py:240-257 (helper)Core helper function in GigAPIClient that executes the DESCRIBE SQL query to retrieve the table schema.def get_table_schema(self, database: str, table: str) -> List[Dict[str, Any]]: """Get table schema information. Args: database: Database name table: Table name Returns: List of column information """ query = f"DESCRIBE {table}" response = self.execute_query(query, database) if response.error: raise GigAPIClientError(f"Failed to get table schema: {response.error}") return response.results
- mcp_gigapi/mcp_server.py:40-42 (registration)Adds all tools, including get_table_schema, to the FastMCP server instance.tools = create_tools(client) for tool in tools: mcp.add_tool(tool)