list_databases
Retrieve all database names from your GigAPI cluster to manage timeseries data storage and organization.
Instructions
List all databases on your GigAPI cluster.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input_data | Yes |
Implementation Reference
- mcp_gigapi/tools.py:79-98 (handler)The main tool handler function that lists databases by calling the client method and formats the response with success status and count.def list_databases(self, database: str = "mydb") -> Dict[str, Any]: """List all databases on GigAPI. Returns: List of databases """ try: databases = self.client.list_databases(database) return { "databases": databases, "success": True, "count": len(databases) } except GigAPIClientError as e: logger.error(f"Failed to list databases: {e}") return { "error": str(e), "success": False, "databases": [] }
- mcp_gigapi/tools.py:231-235 (registration)Registration of the 'list_databases' tool using FastMCP Tool.from_function with a lambda to handle input data.Tool.from_function( lambda input_data: tools_instance.list_databases(input_data.get("database", "mydb")), name="list_databases", description="List all databases on your GigAPI cluster.", ),
- mcp_gigapi/client.py:189-212 (helper)Helper method in the GigAPIClient that executes the 'SHOW DATABASES' SQL query and extracts database names from the response.def list_databases(self, database: str = "mydb") -> List[str]: """List all databases. Returns: List of database names """ query = "SHOW DATABASES" response = self.execute_query(query, database) logger.debug(f"Raw SHOW DATABASES response: {response}") if response.error: raise GigAPIClientError(f"Failed to list databases: {response.error}") # Extract database names from NDJSON results databases = [] for result in response.results: if "database_name" in result: databases.append(result["database_name"]) elif "name" in result: databases.append(result["name"]) elif "databases" in result: databases.extend(result["databases"]) return databases