list_dashboard_tab_cards
Get the list of dashcards from a specific dashboard tab, including layout and card metadata, by providing dashboard ID and tab ID.
Instructions
List the cards belonging to a specific tab on a dashboard.
Args: dashboard_id: The ID of the dashboard. tab_id: The ID of the tab (from list_dashboard_tabs).
Returns: A list of dashcards on the given tab with layout and card metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboard_id | Yes | ||
| tab_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:1515-1579 (handler)The handler function for the list_dashboard_tab_cards tool. It fetches dashboard data via GET /api/dashboard/{dashboard_id}, validates the tab exists, filters dashcards by dashboard_tab_id, and returns layout/card metadata for cards on that tab.
@mcp.tool async def list_dashboard_tab_cards( dashboard_id: int, tab_id: int, ctx: Context ) -> list[dict[str, Any]]: """ List the cards belonging to a specific tab on a dashboard. Args: dashboard_id: The ID of the dashboard. tab_id: The ID of the tab (from list_dashboard_tabs). Returns: A list of dashcards on the given tab with layout and card metadata. """ try: await ctx.info( f"Fetching cards for tab {tab_id} on dashboard {dashboard_id}" ) result = await metabase_client.request("GET", f"/dashboard/{dashboard_id}") tab_ids = {tab.get("id") for tab in (result.get("tabs") or [])} if tab_ids and tab_id not in tab_ids: raise ToolError( f"Tab {tab_id} not found on dashboard {dashboard_id}. " f"Available tab ids: {sorted(tid for tid in tab_ids if tid is not None)}" ) dashcards = result.get("dashcards", result.get("ordered_cards", [])) tab_dashcards = [ dc for dc in dashcards if dc.get("dashboard_tab_id") == tab_id ] await ctx.info( f"Found {len(tab_dashcards)} cards on tab {tab_id} of dashboard {dashboard_id}" ) cards_layout = [] for dashcard in tab_dashcards: card_info: dict[str, Any] = { "dashcard_id": dashcard.get("id"), "card_id": dashcard.get("card_id"), "dashboard_tab_id": dashcard.get("dashboard_tab_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 ToolError: raise except Exception as e: error_msg = ( f"Error fetching cards for tab {tab_id} on dashboard {dashboard_id}: {e}" ) await ctx.error(error_msg) raise ToolError(error_msg) from e - server.py:1515-1517 (registration)The tool is registered via the @mcp.tool decorator on the handler function itself, using the FastMCP framework's decorator pattern.
@mcp.tool async def list_dashboard_tab_cards( dashboard_id: int, tab_id: int, ctx: Context