superset_sqllab_export_query_results
Export SQL query results to CSV format for data analysis and sharing. Use this tool to download query outputs from Apache Superset for further processing.
Instructions
Export the results of a SQL query to CSV
Makes a request to the /api/v1/sqllab/export/{client_id} endpoint to download query results in CSV format.
Args: client_id: Client ID of the query
Returns: A dictionary with the exported data or error information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| client_id | Yes |
Implementation Reference
- main.py:1294-1326 (handler)The handler function implementing the 'superset_sqllab_export_query_results' tool. It makes a GET request to the Superset API endpoint /api/v1/sqllab/export/{client_id} to export query results as CSV and returns the data or error information.@mcp.tool() @requires_auth @handle_api_errors async def superset_sqllab_export_query_results( ctx: Context, client_id: str ) -> Dict[str, Any]: """ Export the results of a SQL query to CSV Makes a request to the /api/v1/sqllab/export/{client_id} endpoint to download query results in CSV format. Args: client_id: Client ID of the query Returns: A dictionary with the exported data or error information """ superset_ctx: SupersetContext = ctx.request_context.lifespan_context try: response = await superset_ctx.client.get(f"/api/v1/sqllab/export/{client_id}") if response.status_code != 200: return { "error": f"Failed to export query results: {response.status_code} - {response.text}" } return {"message": "Query results exported successfully", "data": response.text} except Exception as e: return {"error": f"Error exporting query results: {str(e)}"}