Skip to main content
Glama
voducdan

metabase-mcp

by voducdan

add_card_to_dashboard

Add a card to a dashboard at a custom grid position and size. Provide the dashboard ID and card ID, then optionally set column, row, width, and height.

Instructions

Add an existing card to a dashboard at a specified position and size.

Args: dashboard_id: The ID of the dashboard to add the card to. card_id: The ID of the card to add. col: Column position on the dashboard grid (default: 0). row: Row position on the dashboard grid (default: 0). size_x: Width of the card in grid units (default: 6). size_y: Height of the card in grid units (default: 4).

Returns: The created dashboard card object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dashboard_idYes
card_idYes
colNo
rowNo
size_xNo
size_yNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `add_card_to_dashboard` tool implementation. It fetches the existing dashboard, preserves current dashcards with their layout and mappings, appends a new dashcard entry (with id=-1 to signal a new card), and PUTs the updated dashcards array to the Metabase API.
    @mcp.tool
    async def add_card_to_dashboard(
        dashboard_id: int,
        card_id: int,
        ctx: Context,
        col: int = 0,
        row: int = 0,
        size_x: int = 6,
        size_y: int = 4,
    ) -> dict[str, Any]:
        """
        Add an existing card to a dashboard at a specified position and size.
    
        Args:
            dashboard_id: The ID of the dashboard to add the card to.
            card_id: The ID of the card to add.
            col: Column position on the dashboard grid (default: 0).
            row: Row position on the dashboard grid (default: 0).
            size_x: Width of the card in grid units (default: 6).
            size_y: Height of the card in grid units (default: 4).
    
        Returns:
            The created dashboard card object.
        """
        try:
            await ctx.info(f"Adding card {card_id} to dashboard {dashboard_id}")
    
            # Fetch existing dashboard to get current dashcards
            dashboard = await metabase_client.request("GET", f"/dashboard/{dashboard_id}")
            existing_dashcards = dashboard.get("dashcards", dashboard.get("ordered_cards", []))
    
            # Preserve existing dashcards with their current layout and mappings
            dashcards = [
                {
                    "id": dc["id"],
                    "card_id": dc.get("card_id"),
                    "row": dc.get("row"),
                    "col": dc.get("col"),
                    "size_x": dc.get("size_x"),
                    "size_y": dc.get("size_y"),
                    "parameter_mappings": list(dc.get("parameter_mappings") or []),
                    "visualization_settings": dc.get("visualization_settings") or {},
                    "inline_parameters": list(dc.get("inline_parameters") or []),
                }
                for dc in existing_dashcards
            ]
    
            # Append new card with id: -1 to indicate a new entry
            dashcards.append({
                "id": -1,
                "card_id": card_id,
                "row": row,
                "col": col,
                "size_x": size_x,
                "size_y": size_y,
                "parameter_mappings": [],
                "visualization_settings": {},
            })
    
            result = await metabase_client.request(
                "PUT", f"/dashboard/{dashboard_id}", json={"dashcards": dashcards}
            )
            await ctx.info(
                f"Successfully added card {card_id} to dashboard {dashboard_id} at ({col}, {row})"
            )
    
            return result
        except Exception as e:
            error_msg = f"Error adding card {card_id} to dashboard {dashboard_id}: {e}"
            await ctx.error(error_msg)
            raise ToolError(error_msg) from e
  • server.py:1582-1582 (registration)
    The tool is registered via the `@mcp.tool` decorator on line 1582, which registers `add_card_to_dashboard` as an MCP tool on the FastMCP server instance.
    @mcp.tool
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the return value but does not disclose side effects (e.g., whether the card is linked to the dashboard, if existing position is overwritten, or any state changes). 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?

The description is concise and well-structured: a clear one-sentence purpose followed by structured Args/Returns sections. Every sentence adds value, with no redundancy.

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 covers all parameters and the return value. Given the tool's moderate complexity (6 params, 2 required) and the presence of an output schema, it is fairly complete. However, it lacks context on when to use this tool vs. siblings, slightly lowering the score.

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

Parameters5/5

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

Schema description coverage is 0%, but the description includes a full docstring covering all 6 parameters with meanings (e.g., 'col: Column position on the dashboard grid'), adding significant semantic value beyond the schema's type/default fields.

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 action: 'Add an existing card to a dashboard at a specified position and size.' It uses a specific verb and resource, and distinguishes this from sibling tools like 'update_dashboard_card_position' (which repositions existing cards) and 'create_card' (which creates new cards).

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 (e.g., 'reposition_dashboard_cards', 'create_card'), nor does it mention prerequisites like the card and dashboard must exist. The agent must infer usage from the name alone.

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