update_dashboard_card_position
Reposition or resize a specific card on a Metabase dashboard. Provide the dashboard ID and card ID, then optionally set new column, row, width, or height. Only supplied fields are updated; others remain unchanged.
Instructions
Reposition or resize a single card on a dashboard.
Only the provided fields are updated; omitted fields keep their current values.
Args: dashboard_id: The ID of the dashboard. dashcard_id: The ID of the dashcard (from get_dashboard_cards) to move or resize. col: New column position on the dashboard grid. row: New row position on the dashboard grid. size_x: New width in grid units. size_y: New height in grid units.
Returns: The updated dashboard object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboard_id | Yes | ||
| dashcard_id | Yes | ||
| col | No | ||
| row | No | ||
| size_x | No | ||
| size_y | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:1655-1737 (handler)Handler function that repositions/resizes a single dashcard on a dashboard by fetching existing dashcards, updating the target dashcard's col/row/size_x/size_y, and PUTting the full dashcards array back to the Metabase API.
@mcp.tool async def update_dashboard_card_position( dashboard_id: int, dashcard_id: int, ctx: Context, col: int | None = None, row: int | None = None, size_x: int | None = None, size_y: int | None = None, ) -> dict[str, Any]: """ Reposition or resize a single card on a dashboard. Only the provided fields are updated; omitted fields keep their current values. Args: dashboard_id: The ID of the dashboard. dashcard_id: The ID of the dashcard (from get_dashboard_cards) to move or resize. col: New column position on the dashboard grid. row: New row position on the dashboard grid. size_x: New width in grid units. size_y: New height in grid units. Returns: The updated dashboard object. """ if col is None and row is None and size_x is None and size_y is None: raise ToolError("At least one of col, row, size_x, or size_y must be provided.") try: await ctx.info( f"Updating position of dashcard {dashcard_id} on dashboard {dashboard_id}" ) dashboard = await metabase_client.request("GET", f"/dashboard/{dashboard_id}") existing_dashcards = dashboard.get("dashcards", dashboard.get("ordered_cards", [])) found = False dashcards = [] for dc in existing_dashcards: entry = { "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 []), } if dc.get("id") == dashcard_id: found = True if col is not None: entry["col"] = col if row is not None: entry["row"] = row if size_x is not None: entry["size_x"] = size_x if size_y is not None: entry["size_y"] = size_y dashcards.append(entry) if not found: raise ToolError( f"Dashcard {dashcard_id} not found on dashboard {dashboard_id}." ) result = await metabase_client.request( "PUT", f"/dashboard/{dashboard_id}", json={"dashcards": dashcards} ) await ctx.info( f"Successfully updated dashcard {dashcard_id} on dashboard {dashboard_id}" ) return result except ToolError: raise except Exception as e: error_msg = ( f"Error updating dashcard {dashcard_id} on dashboard {dashboard_id}: {e}" ) await ctx.error(error_msg) raise ToolError(error_msg) from e - server.py:1655-1655 (registration)Registration via @mcp.tool decorator that registers update_dashboard_card_position as a FastMCP tool.
@mcp.tool