Skip to main content
Glama
aptro

Superset MCP Integration

by aptro

superset_auth_refresh_token

Refresh authentication tokens for Apache Superset access without re-entering credentials, maintaining continuous API connectivity for dashboard and data management tasks.

Instructions

Refresh the access token using the refresh endpoint

Makes a request to the /api/v1/security/refresh endpoint to get a new access token without requiring re-authentication with username/password.

Returns: A dictionary with the new access token or error information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:368-411 (handler)
    The handler function implementing the superset_auth_refresh_token MCP tool. It refreshes the Superset JWT access token by calling the /api/v1/security/refresh endpoint, updates the stored token and client headers upon success.
    @mcp.tool()
    @handle_api_errors
    async def superset_auth_refresh_token(ctx: Context) -> Dict[str, Any]:
        """
        Refresh the access token using the refresh endpoint
    
        Makes a request to the /api/v1/security/refresh endpoint to get a new access token
        without requiring re-authentication with username/password.
    
        Returns:
            A dictionary with the new access token or error information
        """
        superset_ctx: SupersetContext = ctx.request_context.lifespan_context
    
        if not superset_ctx.access_token:
            return {"error": "No access token to refresh. Please authenticate first."}
    
        try:
            # Use the refresh endpoint to get a new token
            response = await superset_ctx.client.post("/api/v1/security/refresh")
    
            if response.status_code != 200:
                return {
                    "error": f"Failed to refresh token: {response.status_code} - {response.text}"
                }
    
            data = response.json()
            access_token = data.get("access_token")
    
            if not access_token:
                return {"error": "No access token returned from refresh"}
    
            # Save and set the new access token
            save_access_token(access_token)
            superset_ctx.access_token = access_token
            superset_ctx.client.headers.update({"Authorization": f"Bearer {access_token}"})
    
            return {
                "message": "Successfully refreshed access token",
                "access_token": access_token,
            }
        except Exception as e:
            return {"error": f"Error refreshing token: {str(e)}"}
  • main.py:368-368 (registration)
    The @mcp.tool() decorator registers the superset_auth_refresh_token function as an MCP tool.
    @mcp.tool()
  • Helper function with_auto_refresh that automatically calls superset_auth_refresh_token when API calls return 401 Unauthorized.
        ctx: Context, api_call: Callable[[], Awaitable[httpx.Response]]
    ) -> httpx.Response:
        """
        Helper function to handle automatic token refreshing for API calls
    
        This function will attempt to execute the provided API call. If the call
        fails with a 401 Unauthorized error, it will try to refresh the token
        and retry the API call once.
    
        Args:
            ctx: The MCP context
            api_call: The API call function to execute (should be a callable that returns a response)
        """
        superset_ctx: SupersetContext = ctx.request_context.lifespan_context
    
        if not superset_ctx.access_token:
            raise HTTPException(status_code=401, detail="Not authenticated")
    
        # First attempt
        try:
            response = await api_call()
    
            # If not an auth error, return the response
            if response.status_code != 401:
                return response
    
        except httpx.HTTPStatusError as e:
            if e.response.status_code != 401:
                raise e
            response = e.response
        except Exception as e:
            # For other errors, just raise
            raise e
    
        # If we got a 401, try to refresh the token
        logger.info("Received 401 Unauthorized. Attempting to refresh token...")
        refresh_result = await superset_auth_refresh_token(ctx)
    
        if refresh_result.get("error"):
            # If refresh failed, try to re-authenticate
            logger.info(
                f"Token refresh failed: {refresh_result.get('error')}. Attempting re-authentication..."
            )
            auth_result = await superset_auth_authenticate_user(ctx)
    
            if auth_result.get("error"):
                # If re-authentication failed, raise an exception
                raise HTTPException(status_code=401, detail="Authentication failed")
    
        # Retry the API call with the new token
        return await api_call()
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly describes the action (makes a request to refresh endpoint) and the outcome (returns new token or error). However, it lacks details on authentication requirements, rate limits, error conditions, or whether this invalidates the previous token. For a security-related tool with zero annotation coverage, this leaves significant gaps.

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 perfectly structured and concise. The first sentence states the core purpose, the second explains the mechanism, and the third describes the return value. Every sentence adds essential information with zero wasted words, making it easy to parse quickly.

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 this is an authentication tool with security implications, no annotations, and no output schema, the description should provide more complete context. While it covers the basic purpose and mechanism, it lacks information about prerequisites (e.g., must have a valid refresh token), error handling, or what the returned dictionary contains. For this complexity level, the description is adequate but incomplete.

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 tool has 0 parameters with 100% schema description coverage, so the schema already fully documents the parameter situation. The description appropriately doesn't discuss parameters since none exist. It earns a 4 rather than 5 because it could have explicitly stated 'no parameters required' to be perfectly clear, but this is a minor omission.

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

Purpose5/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 specific verbs ('refresh', 'makes a request') and identifies the exact resource ('access token', '/api/v1/security/refresh endpoint'). It distinguishes this from sibling tools like 'superset_auth_authenticate_user' by emphasizing it works 'without requiring re-authentication with username/password', making the differentiation explicit.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: when needing a new access token without re-authentication. It implicitly contrasts with 'superset_auth_authenticate_user' by mentioning the alternative approach. However, it doesn't explicitly state when NOT to use it or list all possible alternatives, keeping it from a perfect score.

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