list_database_tables
Retrieve a detailed list of tables within a Panther Database, including names, descriptions, and log types. Requires valid database name and 'Query Data Lake' permission.
Instructions
List all available tables in a Panther Database.
Required: Only use valid database names obtained from list_databases
Returns: Dict containing: - success: Boolean indicating if the query was successful - tables: List of tables, each containing: - name: Table name - description: Table description - log_type: Log type - database: Database name - message: Error message if unsuccessful
Permissions:{'all_of': ['Query Data Lake']}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | The name of the database to list tables for |
Implementation Reference
- src/mcp_panther/panther_mcp_core/tools/data_lake.py:634-639 (registration)Registers the list_database_tables tool using the @mcp_tool decorator, specifying required permissions and read-only hint.@mcp_tool( annotations={ "permissions": all_perms(Permission.DATA_ANALYTICS_READ), "readOnlyHint": True, } )
- Pydantic input schema for the 'database' parameter using Annotated and Field for validation, description, and examples.database: Annotated[ str, Field( description="The name of the database to list tables for", examples=["panther_logs.public"], ), ],
- Core handler logic that fetches tables for the specified database using GraphQL LIST_TABLES_QUERY with pagination support, handles errors, and formats the response.async def list_database_tables( database: Annotated[ str, Field( description="The name of the database to list tables for", examples=["panther_logs.public"], ), ], ) -> Dict[str, Any]: """List all available tables in a Panther Database. Required: Only use valid database names obtained from list_databases Returns: Dict containing: - success: Boolean indicating if the query was successful - tables: List of tables, each containing: - name: Table name - description: Table description - log_type: Log type - database: Database name - message: Error message if unsuccessful """ logger.info("Fetching available tables") all_tables = [] page_size = 100 try: logger.info(f"Fetching tables for database: {database}") cursor = None while True: # Prepare input variables variables = { "databaseName": database, "pageSize": page_size, "cursor": cursor, } logger.debug(f"Query variables: {variables}") # Execute the query asynchronously async with await _create_panther_client() as session: result = await session.execute( LIST_TABLES_QUERY, variable_values=variables ) # Get query data result = result.get("dataLakeDatabaseTables", {}) for table in result.get("edges", []): all_tables.append(table["node"]) # Check if there are more pages page_info = result["pageInfo"] if not page_info["hasNextPage"]: break # Update cursor for next page cursor = page_info["endCursor"] # Format the response return { "success": True, "status": "succeeded", "tables": all_tables, "stats": { "table_count": len(all_tables), }, } except Exception as e: logger.error(f"Failed to fetch tables: {str(e)}") return {"success": False, "message": f"Failed to fetch tables: {str(e)}"}