Skip to main content
Glama
aptro

Superset MCP Integration

by aptro

superset_sqllab_execute_query

Execute SQL queries against databases in Apache Superset to retrieve data or run analysis through the SQL Lab interface.

Instructions

Execute a SQL query in SQL Lab

Makes a request to the /api/v1/sqllab/execute/ endpoint to run a SQL query against the specified database.

Args: database_id: ID of the database to query sql: SQL query to execute

Returns: A dictionary with query results or execution status for async queries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_idYes
sqlYes

Implementation Reference

  • The handler function for the 'superset_sqllab_execute_query' tool. It is registered via @mcp.tool() decorator and implements the logic to execute a SQL query against a Superset database by making a POST request to the /api/v1/sqllab/execute/ endpoint. Includes decorators for authentication (@requires_auth) and error handling (@handle_api_errors).
    @mcp.tool()
    @requires_auth
    @handle_api_errors
    async def superset_sqllab_execute_query(
        ctx: Context, database_id: int, sql: str
    ) -> Dict[str, Any]:
        """
        Execute a SQL query in SQL Lab
    
        Makes a request to the /api/v1/sqllab/execute/ endpoint to run a SQL query
        against the specified database.
    
        Args:
            database_id: ID of the database to query
            sql: SQL query to execute
    
        Returns:
            A dictionary with query results or execution status for async queries
        """
        # Ensure we have a CSRF token before executing the query
        superset_ctx: SupersetContext = ctx.request_context.lifespan_context
        if not superset_ctx.csrf_token:
            await get_csrf_token(ctx)
    
        payload = {
            "database_id": database_id,
            "sql": sql,
            "schema": "",
            "tab": "MCP Query",
            "runAsync": False,
            "select_as_cta": False,
        }
    
        return await make_api_request(ctx, "post", "/api/v1/sqllab/execute/", data=payload)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions that it 'runs a SQL query' and returns 'results or execution status for async queries', which hints at mutation (execution) and possible async behavior. However, it lacks critical details: whether it's read-only or modifies data, authentication requirements, rate limits, error handling, or what 'async queries' entail. For a tool that executes arbitrary SQL with no safety annotations, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded: the first sentence states the purpose, followed by implementation details and parameter explanations. Each sentence adds value, with no redundant information. It could be slightly more structured (e.g., bullet points), but it's efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (SQL execution tool with potential data mutation), no annotations, no output schema, and 2 parameters, the description is minimally adequate. It covers the basic purpose and parameters but lacks critical context: no output details (beyond 'dictionary'), no error information, no async behavior explanation, and no safety warnings. It meets the bare minimum but leaves significant gaps for an agent to operate safely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'database_id: ID of the database to query' and 'sql: SQL query to execute', which clarifies the purpose of each parameter beyond their schema titles ('Database Id', 'Sql'). However, it doesn't provide format examples (e.g., SQL syntax, database ID sources) or constraints, so it's not a full 5.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Execute a SQL query in SQL Lab' specifies the verb (execute) and resource (SQL query in SQL Lab). It distinguishes from siblings like 'superset_sqllab_format_sql' (which formats rather than executes) and 'superset_sqllab_estimate_query_cost' (which estimates rather than executes). However, it doesn't explicitly mention how it differs from all siblings, so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication, database availability), when to choose it over other query tools like 'superset_database_validate_sql', or any constraints (e.g., query size limits, async vs sync). The agent must infer usage from the name and context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aptro/superset-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server