sample_table_data
Extract a defined number of random rows from a specified Azure Data Explorer table to analyze or test data, with a default sample size of 10.
Instructions
Retrieves a random sample of rows from the specified table in the Azure Data Explorer database. The sample_size parameter controls how many rows to return (default: 10).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sample_size | No | ||
| table_name | Yes |
Implementation Reference
- src/adx_mcp_server/server.py:237-255 (handler)The handler function for the 'sample_table_data' tool. It is decorated with @mcp.tool, which handles registration and schema inference from the function signature. Executes a KQL query to sample rows from the specified table using the Kusto client.@mcp.tool(description="Retrieves a random sample of rows from the specified table in the Azure Data Explorer database. The sample_size parameter controls how many rows to return (default: 10).") async def sample_table_data(table_name: str, sample_size: int = 10) -> List[Dict[str, Any]]: """Get sample data from a table.""" logger.info("Sampling table data", table_name=table_name, sample_size=sample_size, database=config.database) if not config.cluster_url or not config.database: logger.error("Missing ADX configuration") raise ValueError("Azure Data Explorer configuration is missing. Please set ADX_CLUSTER_URL and ADX_DATABASE environment variables.") try: client = get_kusto_client() query = f"{table_name} | sample {sample_size}" result_set = client.execute(config.database, query) results = format_query_results(result_set) logger.info("Sample data retrieved successfully", table_name=table_name, row_count=len(results)) return results except Exception as e: logger.error("Failed to sample table data", table_name=table_name, error=str(e), exception_type=type(e).__name__) raise