list_databases
Retrieve a list of all available datalake databases in Panther, including names and descriptions. Requires 'Query Data Lake' permissions to fetch database information effectively.
Instructions
List all available datalake databases in Panther.
Returns: Dict containing: - success: Boolean indicating if the query was successful - databases: List of databases, each containing: - name: Database name - description: Database description - message: Error message if unsuccessful
Permissions:{'all_of': ['Query Data Lake']}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The @mcp_tool decorated handler function that implements the list_databases tool logic, executing a GraphQL query to retrieve available databases.@mcp_tool( annotations={ "permissions": all_perms(Permission.DATA_ANALYTICS_READ), "readOnlyHint": True, } ) async def list_databases() -> Dict[str, Any]: """List all available datalake databases in Panther. Returns: Dict containing: - success: Boolean indicating if the query was successful - databases: List of databases, each containing: - name: Database name - description: Database description - message: Error message if unsuccessful """ logger.info("Fetching datalake databases") try: # Execute the query asynchronously async with await _create_panther_client() as session: result = await session.execute(LIST_DATABASES_QUERY) # Get query data databases = result.get("dataLakeDatabases", []) if not databases: logger.warning("No databases found") return {"success": False, "message": "No databases found"} logger.info(f"Successfully retrieved {len(databases)} results") # Format the response return { "success": True, "status": "succeeded", "databases": databases, "stats": { "database_count": len(databases), }, } except Exception as e: logger.error(f"Failed to fetch database results: {str(e)}") return { "success": False, "message": f"Failed to fetch database results: {str(e)}", }
- GraphQL query constant used by the list_databases tool to fetch the list of databases.LIST_DATABASES_QUERY = gql(""" query ListDatabases { dataLakeDatabases { name description } } """)
- src/mcp_panther/panther_mcp_core/tools/registry.py:75-109 (registration)The register_all_tools function that registers all @mcp_tool decorated functions with the MCP instance, including list_databases.def register_all_tools(mcp_instance) -> None: """ Register all tools marked with @mcp_tool with the given MCP instance. Args: mcp_instance: The FastMCP instance to register tools with """ logger.info(f"Registering {len(_tool_registry)} tools with MCP") # Sort tools by name sorted_funcs = sorted(_tool_registry, key=lambda f: f.__name__) for tool in sorted_funcs: logger.debug(f"Registering tool: {tool.__name__}") # Get tool metadata if it exists metadata = getattr(tool, "_mcp_tool_metadata", {}) annotations = metadata.get("annotations", {}) # Create tool decorator with metadata tool_decorator = mcp_instance.tool( name=metadata.get("name"), description=metadata.get("description"), annotations=annotations, ) if annotations and annotations.get("permissions"): if not tool.__doc__: tool.__doc__ = "" tool.__doc__ += f"\n\n Permissions:{annotations.get('permissions')}" # Register the tool tool_decorator(tool) logger.info("All tools registered successfully")