list_tables
Retrieve all database tables to explore available data structures and identify relevant datasets for analysis.
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 primary MCP tool handler for 'list_tables'. It invokes the client's list_tables method, formats the response with success status, count, and handles errors.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)Registration of the 'list_tables' tool instance using FastMCP's Tool.from_function, binding it to the GigAPITools.list_tables method.Tool.from_function( tools_instance.list_tables, name="list_tables", description="List all tables in a database.", ),
- mcp_gigapi/client.py:213-238 (helper)Helper method in GigAPIClient that executes a 'SHOW TABLES' SQL query, parses NDJSON results to extract table names, and returns a list of strings.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