list_tables
Retrieve a list of all tables within a specified database using the MCP server for efficient data management and querying in GigAPI Timeseries Lake.
Instructions
List all tables in a database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes |
Implementation Reference
- mcp_gigapi/tools.py:100-124 (handler)The main handler function for the 'list_tables' tool. It invokes the client's list_tables method, formats the response with success status, table list, count, and handles errors appropriately.def list_tables(self, database: str) -> Dict[str, Any]: """List all tables in a database. Args: database: The name of the database Returns: List of tables """ try: tables = self.client.list_tables(database) return { "tables": tables, "success": True, "database": database, "count": len(tables) } except GigAPIClientError as e: logger.error(f"Failed to list tables: {e}") return { "error": str(e), "success": False, "database": database, "tables": [] }
- mcp_gigapi/tools.py:236-240 (registration)Registers the list_tables handler as an MCP tool using FastMCP's Tool.from_function, specifying the name and description.Tool.from_function( tools_instance.list_tables, name="list_tables", description="List all tables in a database.", ),
- mcp_gigapi/client.py:213-239 (helper)Supporting client method that performs a 'SHOW TABLES' query on the GigAPI server to retrieve and parse the list of tables.def list_tables(self, database: str) -> List[str]: """List all tables in a database. Args: database: Database name Returns: List of table names """ query = "SHOW TABLES" response = self.execute_query(query, database) logger.debug(f"Raw SHOW TABLES response: {response}") if response.error: raise GigAPIClientError(f"Failed to list tables: {response.error}") # Extract table names from NDJSON results tables = [] for result in response.results: if "table_name" in result: tables.append(result["table_name"]) elif "name" in result: tables.append(result["name"]) elif "tables" in result: tables.extend(result["tables"]) return tables