list_databases
Retrieve a comprehensive list of all databases within your GigAPI cluster, enabling efficient management and querying of timeseries data.
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 primary handler function for the 'list_databases' MCP tool. It invokes the client's list_databases method, formats the response with success status and count, and handles errors.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's Tool.from_function, wrapping the handler in a lambda to handle input parameters.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 a 'SHOW DATABASES' SQL query to retrieve the list of databases, parsing the NDJSON 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