Skip to main content
Glama
aptro

Superset MCP Integration

by aptro

superset_database_schemas

Retrieve all available schema names from a specific database in Apache Superset to understand database structure for dashboard and chart creation.

Instructions

Get schemas for a specific database

Makes a request to the /api/v1/database/{id}/schemas/ endpoint to retrieve all schemas available in the database.

Args: database_id: ID of the database

Returns: A dictionary with list of schema names

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_idYes

Implementation Reference

  • main.py:857-874 (handler)
    The main execution handler for the superset_database_schemas MCP tool. This function takes a database_id parameter and delegates to the make_api_request helper to perform a GET request to the Superset REST API endpoint /api/v1/database/{database_id}/schemas/ to fetch available schemas.
    @requires_auth
    @handle_api_errors
    async def superset_database_schemas(ctx: Context, database_id: int) -> Dict[str, Any]:
        """
        Get schemas for a specific database
    
        Makes a request to the /api/v1/database/{id}/schemas/ endpoint to retrieve
        all schemas available in the database.
    
        Args:
            database_id: ID of the database
    
        Returns:
            A dictionary with list of schema names
        """
        return await make_api_request(
            ctx, "get", f"/api/v1/database/{database_id}/schemas/"
        )
  • Key helper function used by the tool handler to execute the HTTP GET request to the Superset API. Handles authentication headers, CSRF tokens, automatic token refresh on 401 errors, and error handling.
    async def make_api_request(
        ctx: Context,
        method: str,
        endpoint: str,
        data: Dict[str, Any] = None,
        params: Dict[str, Any] = None,
        auto_refresh: bool = True,
    ) -> Dict[str, Any]:
        """
        Helper function to make API requests to Superset
    
        Args:
            ctx: MCP context
            method: HTTP method (get, post, put, delete)
            endpoint: API endpoint (without base URL)
            data: Optional JSON payload for POST/PUT requests
            params: Optional query parameters
            auto_refresh: Whether to auto-refresh token on 401
        """
        superset_ctx: SupersetContext = ctx.request_context.lifespan_context
        client = superset_ctx.client
    
        # For non-GET requests, make sure we have a CSRF token
        if method.lower() != "get" and not superset_ctx.csrf_token:
            await get_csrf_token(ctx)
    
        async def make_request() -> httpx.Response:
            headers = {}
    
            # Add CSRF token for non-GET requests
            if method.lower() != "get" and superset_ctx.csrf_token:
                headers["X-CSRFToken"] = superset_ctx.csrf_token
    
            if method.lower() == "get":
                return await client.get(endpoint, params=params)
            elif method.lower() == "post":
                return await client.post(
                    endpoint, json=data, params=params, headers=headers
                )
            elif method.lower() == "put":
                return await client.put(endpoint, json=data, headers=headers)
            elif method.lower() == "delete":
                return await client.delete(endpoint, headers=headers)
            else:
                raise ValueError(f"Unsupported HTTP method: {method}")
    
        # Use auto_refresh if requested
        response = (
            await with_auto_refresh(ctx, make_request)
            if auto_refresh
            else await make_request()
        )
    
        if response.status_code not in [200, 201]:
            return {
                "error": f"API request failed: {response.status_code} - {response.text}"
            }
    
        return response.json()
  • Decorator applied to the handler that ensures the user is authenticated (has a valid access token) before executing the tool.
    def requires_auth(
        func: Callable[..., Awaitable[Dict[str, Any]]],
    ) -> Callable[..., Awaitable[Dict[str, Any]]]:
        """Decorator to check authentication before executing a function"""
    
        @wraps(func)
        async def wrapper(ctx: Context, *args, **kwargs) -> Dict[str, Any]:
            superset_ctx: SupersetContext = ctx.request_context.lifespan_context
    
            if not superset_ctx.access_token:
                return {"error": "Not authenticated. Please authenticate first."}
    
            return await func(ctx, *args, **kwargs)
    
        return wrapper
  • Decorator applied to the handler that catches exceptions and returns standardized error responses.
    def handle_api_errors(
        func: Callable[..., Awaitable[Dict[str, Any]]],
    ) -> Callable[..., Awaitable[Dict[str, Any]]]:
        """Decorator to handle API errors in a consistent way"""
    
        @wraps(func)
        async def wrapper(ctx: Context, *args, **kwargs) -> Dict[str, Any]:
            try:
                return await func(ctx, *args, **kwargs)
            except Exception as e:
                # Extract function name for better error context
                function_name = func.__name__
                return {"error": f"Error in {function_name}: {str(e)}"}
    
        return wrapper
  • main.py:141-145 (registration)
    Initialization of the FastMCP server instance where all @mcp.tool() decorated functions are automatically registered as MCP tools.
    mcp = FastMCP(
        "superset",
        lifespan=superset_lifespan,
        dependencies=["fastapi", "uvicorn", "python-dotenv", "httpx"],
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the API endpoint and return format, but lacks critical details such as authentication requirements, rate limits, error handling, or whether this is a read-only operation (though implied by 'Get'). For a tool with zero annotation coverage, 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.

Conciseness5/5

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

The description is well-structured and front-loaded with the core purpose, followed by API details and parameter/return explanations. Every sentence adds value without redundancy, making it efficient and easy to parse.

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 tool's low complexity (one parameter, no output schema, no annotations), the description covers the basics adequately. However, it lacks completeness for real-world use, such as authentication needs, error cases, or pagination details, which are important for a tool interacting with a database API.

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?

The description adds meaningful context for the single parameter 'database_id', explaining it as the 'ID of the database', which clarifies its purpose beyond the schema's basic type (integer). With 0% schema description coverage and only one parameter, this compensation is adequate, though it could benefit from examples or format details.

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 with a specific verb ('Get') and resource ('schemas for a specific database'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'superset_database_get_tables' or 'superset_database_get_catalogs', which might retrieve related but different database metadata.

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 any prerequisites, context for usage, or comparisons to sibling tools like 'superset_database_get_tables' or 'superset_database_get_catalogs', leaving the agent with no usage direction beyond the basic purpose.

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