list_tables
Retrieve all table names in a specified database to quickly see available data structures.
Instructions
List all tables in a database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes |
Implementation Reference
- mcp_gigapi/tools.py:100-124 (handler)The `list_tables` method on the `GigAPITools` class. This is the primary handler that calls the client and returns a dictionary with tables, success status, database name, and count.
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/client.py:213-238 (helper)The `list_tables` method on the `GigAPIClient` class. Executes 'SHOW TABLES' query and extracts table names from the NDJSON response.
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 - mcp_gigapi/tools.py:236-240 (registration)Registration of the `list_tables` tool via `Tool.from_function(tools_instance.list_tables, name='list_tables', description='List all tables in a database.')` inside `create_tools()`.
Tool.from_function( tools_instance.list_tables, name="list_tables", description="List all tables in a database.", ), - mcp_gigapi/tools.py:21-24 (schema)The `DatabaseInput` Pydantic model used as the schema for the `database` input parameter of `list_tables`.
class DatabaseInput(BaseModel): """Input model for database operations.""" database: str = Field(..., description="The name of the database")