Skip to main content
Glama
voducdan

metabase-mcp

by voducdan

get_dashboard_cards

Retrieve all cards and their layout details (id, name, display type, size, position) for a specific Metabase dashboard.

Instructions

Get the cards and their layout information for a specific dashboard.

Returns each card's id, name, display type, size, and position on the dashboard grid (col, row, size_x, size_y).

Args: dashboard_id: The ID of the dashboard.

Returns: A list of dashboard card objects with layout and card metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dashboard_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Handler function for the get_dashboard_cards tool. Fetches dashboard data from Metabase API, extracts dashcard layout info (position, size, inline parameters), and optionally includes card metadata (name, display, description) from the nested card object.
    @mcp.tool
    async def get_dashboard_cards(dashboard_id: int, ctx: Context) -> list[dict[str, Any]]:
        """
        Get the cards and their layout information for a specific dashboard.
    
        Returns each card's id, name, display type, size, and position on the
        dashboard grid (col, row, size_x, size_y).
    
        Args:
            dashboard_id: The ID of the dashboard.
    
        Returns:
            A list of dashboard card objects with layout and card metadata.
        """
        try:
            await ctx.info(f"Fetching cards layout for dashboard {dashboard_id}")
            result = await metabase_client.request("GET", f"/dashboard/{dashboard_id}")
    
            dashcards = result.get("dashcards", result.get("ordered_cards", []))
            await ctx.info(
                f"Successfully retrieved {len(dashcards)} cards from dashboard {dashboard_id}"
            )
    
            cards_layout = []
            for dashcard in dashcards:
                card_info: dict[str, Any] = {
                    "dashcard_id": dashcard.get("id"),
                    "card_id": dashcard.get("card_id"),
                    "col": dashcard.get("col"),
                    "row": dashcard.get("row"),
                    "size_x": dashcard.get("size_x"),
                    "size_y": dashcard.get("size_y"),
                    "inline_parameters": dashcard.get("inline_parameters") or [],
                }
    
                card = dashcard.get("card")
                if card:
                    card_info["card_name"] = card.get("name")
                    card_info["card_display"] = card.get("display")
                    card_info["card_description"] = card.get("description")
    
                cards_layout.append(card_info)
    
            return cards_layout
        except Exception as e:
            error_msg = f"Error fetching dashboard {dashboard_id} cards: {e}"
            await ctx.error(error_msg)
            raise ToolError(error_msg) from e
  • server.py:1430-1431 (registration)
    Tool registration using the @mcp.tool decorator on the get_dashboard_cards function, registering it with the FastMCP server instance.
    @mcp.tool
    async def get_dashboard_cards(dashboard_id: int, ctx: Context) -> list[dict[str, Any]]:
  • Docstring defining the input schema (dashboard_id: int) and output schema (list of dashboard card objects with layout/card metadata).
    """
    Get the cards and their layout information for a specific dashboard.
    
    Returns each card's id, name, display type, size, and position on the
    dashboard grid (col, row, size_x, size_y).
    
    Args:
        dashboard_id: The ID of the dashboard.
    
    Returns:
        A list of dashboard card objects with layout and card metadata.
    """

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.4/5.0
Behavior2/5

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

No annotations provided, so the description carries full burden. It implies a read operation but does not explicitly state non-destructiveness, authorization needs, or side effects. Minimal behavioral disclosure.

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?

Concise, well-structured with Args and Returns sections. Every sentence is informative, no fluff.

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?

Tool is simple with one parameter and output schema exists. Description covers purpose and return fields well. Could mention error handling (e.g., invalid dashboard_id) but not critical.

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

Parameters3/5

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

Schema description coverage is 0%; description adds 'The ID of the dashboard' for the only parameter. Adds basic meaning but no additional details like source or constraints.

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 it retrieves cards and layout for a specific dashboard, listing returned fields. It distinguishes from siblings like list_cards (no dashboard context or layout).

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?

No guidance on when to use this tool versus alternatives (e.g., list_cards). The description does not mention when not to use it or provide context for selection.

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