superset_sqllab_format_sql
Format SQL queries for improved readability by applying standard formatting rules to enhance code structure and clarity.
Instructions
Format a SQL query for better readability
Makes a request to the /api/v1/sqllab/format_sql endpoint to apply standard formatting rules to the provided SQL query.
Args: sql: SQL query to format
Returns: A dictionary with the formatted SQL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes |
Implementation Reference
- main.py:1220-1239 (handler)The main handler function implementing the 'superset_sqllab_format_sql' tool. It formats the provided SQL string by making a POST request to Superset's /api/v1/sqllab/format_sql endpoint using the shared make_api_request helper.@mcp.tool() @requires_auth @handle_api_errors async def superset_sqllab_format_sql(ctx: Context, sql: str) -> Dict[str, Any]: """ Format a SQL query for better readability Makes a request to the /api/v1/sqllab/format_sql endpoint to apply standard formatting rules to the provided SQL query. Args: sql: SQL query to format Returns: A dictionary with the formatted SQL """ payload = {"sql": sql} return await make_api_request( ctx, "post", "/api/v1/sqllab/format_sql", data=payload )