Skip to main content
Glama
CW-Codewalnut

Metabase MCP Server

get_dashboard_by_id

Retrieve dashboard metadata including cards and tabs from Metabase by specifying a dashboard ID. This tool enables access to business intelligence dashboards for data analysis and reporting.

Instructions

Get a dashboard by ID.

Args: dashboard_id (int): ID of the dashboard.

Returns: Dict[str, Any]: Dashboard metadata including id, name, cards, and tabs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dashboard_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_dashboard_by_id' tool. It takes a dashboard_id parameter and makes a GET request to the Metabase API endpoint /api/dashboard/{dashboard_id}, returning dashboard metadata including id, name, cards, and tabs.
    async def get_dashboard_by_id(dashboard_id: int) -> Dict[str, Any]:
        """
        Get a dashboard by ID.
    
        Args:
            dashboard_id (int): ID of the dashboard.
    
        Returns:
            Dict[str, Any]: Dashboard metadata including id, name, cards, and tabs.
        """
        logger.info(f"Getting dashboard {dashboard_id}")
        return await make_metabase_request(RequestMethod.GET, f"/api/dashboard/{dashboard_id}")
  • The @mcp.tool() decorator registers the get_dashboard_by_id function as an MCP tool, making it available to MCP clients.
    @mcp.tool()
  • The make_metabase_request helper function handles all HTTP communication with the Metabase API. It constructs and executes HTTP requests with proper error handling, authentication, and logging.
    async def make_metabase_request(
        method: RequestMethod,
        endpoint: str,
        data: Optional[Dict[str, Any] | bytes] = None,
        params: Optional[Dict[str, Any]] = None,
        json: Any = None,
        headers: Optional[Dict[str, str]] = None,
    ) -> Dict[str, Any]:
        """
        Make a request to the Metabase API.
        
        Args:
            method: HTTP method to use (GET, POST, PUT, DELETE)
            endpoint: API endpoint path
            data: Request data (for form data)
            params: URL parameters
            json: JSON request body
            headers: Additional headers
            
        Returns:
            Dict[str, Any]: Response data
            
        Raises:
            MetabaseConnectionError: When the Metabase server is unreachable
            MetabaseResponseError: When Metabase returns a non-2xx status code
            RuntimeError: For other errors
        """
        
        if not METABASE_URL or not METABASE_API_KEY:
            raise RuntimeError("METABASE_URL or METABASE_API_KEY environment variable is not set. Metabase API requests will fail.")
    
        if session is None:
            raise RuntimeError("HTTP session is not initialized. Ensure app_lifespan was called.")
    
        try:
            request_headers = headers or {}
            
            logger.debug(f"Making {method.name} request to {METABASE_URL}{endpoint}")
            
            # Log request payload for debugging (omit sensitive info)
            if json and logger.level <= logging.DEBUG:
                sanitized_json = {**json}
                if 'password' in sanitized_json:
                    sanitized_json['password'] = '********'
                logger.debug(f"Request payload: {sanitized_json}")
                
            response = await session.request(
                method=method.name,
                url=endpoint,
                timeout=aiohttp.ClientTimeout(total=30),
                headers=request_headers,
                data=data,
                params=params,
                json=json,
            )
    
            try:
                # Handle 500 errors with more detailed info
                if response.status >= 500:
  • Schema definition for DashboardCard model, representing a card within a Metabase dashboard with attributes like id, card_id, position (row, col), size (size_x, size_y), and parameter mappings.
    from dataclasses import dataclass, field
    from typing import List, Dict, Any
    
    @dataclass
    class DashboardCard:
        """
        Represents a card within a Metabase dashboard.
        
        Attributes:
            id (int): Use negative numbers to auto generate the ids 
                or use any unique value but,
                it must be unique within the dashboard
            card_id (int): The ID of the card/visualization
            row (int): The row position in the dashboard grid
            col (int): The column position in the dashboard grid
            size_x (int): The width of the card in grid units
            size_y (int): The height of the card in grid units
            parameter_mappings (List[Dict[str, Any]]): Parameter mappings for the card
        """
        id: int  # Use negative numbers to auto generate the ids
        card_id: int
        row: int
        col: int
        size_x: int
        size_y: int
        parameter_mappings: List[Dict[str, Any]] = field(default_factory=list)
  • Schema definition for DashboardTab model, representing a tab within a Metabase dashboard with id and name attributes.
    from dataclasses import dataclass
    from typing import Optional
    
    @dataclass
    class DashboardTab:
        """
        Represents a tab within a Metabase dashboard.
        
        Attributes:
            id (Optional[int]): The tab ID, optional for new tabs
            name (str): The name of the tab
        """
        id: Optional[int] = None
        name: str = "" 
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 states this is a 'Get' operation, implying read-only behavior, but doesn't disclose important traits like whether it requires authentication, what happens with invalid IDs (e.g., errors vs. null returns), rate limits, or pagination. The description adds minimal behavioral context beyond the basic operation.

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: a clear purpose statement followed by well-formatted Args and Returns sections. Every sentence earns its place, with no redundant information. The front-loaded purpose makes it immediately scannable.

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

Completeness4/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 (single parameter, read operation) and the presence of an output schema (which handles return values), the description is reasonably complete. It covers the parameter semantics adequately. However, it lacks context about authentication requirements and error handling, which would be helpful despite the output schema.

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 explicitly documents the single parameter 'dashboard_id' with its type (int) and meaning ('ID of the dashboard'), adding semantic value beyond the schema which has 0% description coverage. This fully compensates for the schema gap. However, it doesn't provide examples or constraints (e.g., valid ID ranges).

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 verb ('Get') and resource ('a dashboard by ID'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'get_metabase_dashboards' (plural) by specifying retrieval of a single dashboard via ID. However, it doesn't explicitly contrast with other get_* tools like 'get_dashboard_cards' or 'get_dashboard_items'.

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 when to choose this over 'get_metabase_dashboards' for listing dashboards, or how it relates to 'get_dashboard_cards'/'get_dashboard_items'. There's also no information about prerequisites like authentication or permissions needed to access dashboards.

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/CW-Codewalnut/metabase-mcp-server'

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