set_dashcard_inline_parameters
Moves dashboard filter widgets from the header to render inline on specific dashcards, preserving existing inline parameters unless replace is set to true.
Instructions
Attach dashboard filters inline to specific dashcards.
By default, dashboard parameters render as filter widgets at the top of the
dashboard. Setting inline_parameters on a dashcard moves those filter
widgets to appear attached to that specific card instead of the header.
Each entry in inline_parameters must include:
dashcard_id: the dashcard to target (from get_dashboard_cards)
parameter_ids: list of dashboard parameter ids (strings) to render inline on this dashcard. The parameters must already exist on the dashboard (see update_dashboard).
Existing inline_parameters on each touched dashcard are preserved and
extended, unless replace=True (in which case the list on each touched
dashcard is fully replaced by the ids provided here). Dashcards not
referenced in inline_parameters are left untouched.
Note: the dashboard parameter should still be mapped to the card's
template tag via set_dashcard_parameter_mappings — inline placement
only affects where the widget renders, not how values are wired into the
card's query.
Args: dashboard_id: The ID of the dashboard. inline_parameters: List of entries as described above. replace: If True, replace inline_parameters on touched dashcards instead of appending.
Returns: The updated dashboard object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dashboard_id | Yes | ||
| inline_parameters | Yes | ||
| replace | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:1308-1427 (handler)The main handler function for set_dashcard_inline_parameters tool. Attaches dashboard filter widgets inline to specific dashcards by updating the inline_parameters field on dashcards, with support for merge or replace mode.
@mcp.tool async def set_dashcard_inline_parameters( dashboard_id: int, inline_parameters: list[dict[str, Any]], ctx: Context, replace: bool = False, ) -> dict[str, Any]: """ Attach dashboard filters inline to specific dashcards. By default, dashboard parameters render as filter widgets at the top of the dashboard. Setting `inline_parameters` on a dashcard moves those filter widgets to appear attached to that specific card instead of the header. Each entry in `inline_parameters` must include: - dashcard_id: the dashcard to target (from get_dashboard_cards) - parameter_ids: list of dashboard parameter ids (strings) to render inline on this dashcard. The parameters must already exist on the dashboard (see update_dashboard). Existing inline_parameters on each touched dashcard are preserved and extended, unless `replace=True` (in which case the list on each touched dashcard is fully replaced by the ids provided here). Dashcards not referenced in `inline_parameters` are left untouched. Note: the dashboard parameter should still be mapped to the card's template tag via `set_dashcard_parameter_mappings` — inline placement only affects where the widget renders, not how values are wired into the card's query. Args: dashboard_id: The ID of the dashboard. inline_parameters: List of entries as described above. replace: If True, replace inline_parameters on touched dashcards instead of appending. Returns: The updated dashboard object. """ if not inline_parameters: raise ToolError("`inline_parameters` must contain at least one entry.") grouped: dict[int, list[str]] = {} for idx, entry in enumerate(inline_parameters): dc_id = entry.get("dashcard_id") param_ids = entry.get("parameter_ids") if dc_id is None: raise ToolError(f"inline_parameters[{idx}] must include 'dashcard_id'.") if not isinstance(param_ids, list) or not param_ids: raise ToolError( f"inline_parameters[{idx}] must include non-empty 'parameter_ids' list." ) if not all(isinstance(p, str) for p in param_ids): raise ToolError( f"inline_parameters[{idx}].parameter_ids must contain only string ids." ) grouped.setdefault(int(dc_id), []).extend(param_ids) try: await ctx.info( f"Setting inline parameters on {len(grouped)} dashcard(s) of dashboard {dashboard_id}" ) dashboard = await metabase_client.request("GET", f"/dashboard/{dashboard_id}") existing_dashcards = dashboard.get("dashcards", dashboard.get("ordered_cards", [])) existing_ids = {dc.get("id") for dc in existing_dashcards} unknown = [dc_id for dc_id in grouped if dc_id not in existing_ids] if unknown: raise ToolError( f"Dashcard(s) {unknown} not found on dashboard {dashboard_id}." ) dashboard_param_ids = { p.get("id") for p in (dashboard.get("parameters") or []) if p.get("id") } for dc_id, param_ids in grouped.items(): missing = [p for p in param_ids if p not in dashboard_param_ids] if missing: raise ToolError( f"Parameter id(s) {missing} are not defined on dashboard " f"{dashboard_id}. Add them via update_dashboard first." ) 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 []), } new_for_dc = grouped.get(dc.get("id")) if new_for_dc is not None: if replace: entry["inline_parameters"] = list(new_for_dc) else: existing_inline = entry["inline_parameters"] for pid in new_for_dc: if pid not in existing_inline: existing_inline.append(pid) dashcards.append(entry) result = await metabase_client.request( "PUT", f"/dashboard/{dashboard_id}", json={"dashcards": dashcards} ) await ctx.info( f"Successfully updated inline parameters on dashboard {dashboard_id}" ) return result except ToolError: raise except Exception as e: error_msg = f"Error setting inline parameters on dashboard {dashboard_id}: {e}" await ctx.error(error_msg) raise ToolError(error_msg) from e - server.py:1308-1314 (registration)Registration of set_dashcard_inline_parameters as an MCP tool via the @mcp.tool decorator.
@mcp.tool async def set_dashcard_inline_parameters( dashboard_id: int, inline_parameters: list[dict[str, Any]], ctx: Context, replace: bool = False, ) -> dict[str, Any]: - server.py:1315-1346 (schema)Docstring/input schema for set_dashcard_inline_parameters defining parameters: dashboard_id (int), inline_parameters (list of dicts with dashcard_id and parameter_ids), ctx, and replace (bool).
""" Attach dashboard filters inline to specific dashcards. By default, dashboard parameters render as filter widgets at the top of the dashboard. Setting `inline_parameters` on a dashcard moves those filter widgets to appear attached to that specific card instead of the header. Each entry in `inline_parameters` must include: - dashcard_id: the dashcard to target (from get_dashboard_cards) - parameter_ids: list of dashboard parameter ids (strings) to render inline on this dashcard. The parameters must already exist on the dashboard (see update_dashboard). Existing inline_parameters on each touched dashcard are preserved and extended, unless `replace=True` (in which case the list on each touched dashcard is fully replaced by the ids provided here). Dashcards not referenced in `inline_parameters` are left untouched. Note: the dashboard parameter should still be mapped to the card's template tag via `set_dashcard_parameter_mappings` — inline placement only affects where the widget renders, not how values are wired into the card's query. Args: dashboard_id: The ID of the dashboard. inline_parameters: List of entries as described above. replace: If True, replace inline_parameters on touched dashcards instead of appending. Returns: The updated dashboard object. """