Skip to main content
Glama
aptro

Superset MCP Integration

by aptro

superset_database_get_by_id

Retrieve detailed configuration information for a specific database connection by its ID from Apache Superset.

Instructions

Get details for a specific database

Makes a request to the /api/v1/database/{id} endpoint to retrieve detailed information about a specific database connection.

Args: database_id: ID of the database to retrieve

Returns: A dictionary with complete database configuration information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
database_idYes

Implementation Reference

  • main.py:761-777 (handler)
    The handler function implementing the 'superset_database_get_by_id' tool. It makes a GET request to the Superset API endpoint /api/v1/database/{database_id} using the shared make_api_request helper, which handles authentication, CSRF tokens, and auto-refresh.
    @mcp.tool() @requires_auth @handle_api_errors async def superset_database_get_by_id(ctx: Context, database_id: int) -> Dict[str, Any]: """ Get details for a specific database Makes a request to the /api/v1/database/{id} endpoint to retrieve detailed information about a specific database connection. Args: database_id: ID of the database to retrieve Returns: A dictionary with complete database configuration information """ return await make_api_request(ctx, "get", f"/api/v1/database/{database_id}")
  • Core helper function used by the tool to perform authenticated API requests to Superset, handling token refresh, CSRF tokens, and error responses.
    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 ensuring authentication is present before execution.
    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 for consistent error handling and reporting.
    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-144 (registration)
    The FastMCP server instance where all tools, including superset_database_get_by_id, are automatically registered via the @mcp.tool() decorator.
    mcp = FastMCP( "superset", lifespan=superset_lifespan, dependencies=["fastapi", "uvicorn", "python-dotenv", "httpx"],

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