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.
    """
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as side effects, error handling, authentication requirements, or rate limits. It only describes input and output format.

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 concise and well-structured: first sentence states purpose, then lists return fields, then defines argument and return sections. No unnecessary words.

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?

The description adequately covers input, output, and return structure. It is fairly complete for a simple read tool with one parameter and an output schema, though it lacks error handling context.

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?

With only one parameter and 0% schema coverage in the input schema, the description adds a brief explanation for dashboard_id. However, this is minimal and could be more precise (e.g., specifying it comes from list_dashboards).

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 it retrieves cards and layout info for a specific dashboard, listing specific return fields. However, it doesn't explicitly differentiate from sibling tools like 'list_dashboard_tab_cards' which may have similar functionality.

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 implies the user needs a dashboard_id, but provides no guidance on when to use this tool versus alternatives, nor does it mention prerequisites or scenarios where it should not be used.

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/voducdan/matebase-mcp'

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