Skip to main content
Glama
voducdan

metabase-mcp

by voducdan

update_card_parameters

Update the parameters list on a Metabase card to control filter widgets and dashboard parameter wiring. Each parameter defines widget type, target, and defaults. Allows merge or full replacement.

Instructions

Set the card-level parameters list on a saved question.

Card parameters drive the filter widgets shown on a card's own page AND are what Metabase uses to wire dashboard parameters into the card. For a date filter to render as a date picker (instead of a plain text box), the card must have a matching parameter entry — the template-tag type alone is not enough.

Each parameter is a dict. Common keys:

  • id: the template-tag's UUID (must match dataset_query.native.template-tags[name].id)

  • name: display name, e.g. "Start date"

  • slug: URL slug, e.g. "start_date"

  • type: widget type, e.g. "date/single", "date/range", "date/all-options", "category", "string/=", "number/="

  • target: link back to the template tag, e.g. ["variable", ["template-tag", "start_date"]] (for text/number/date vars) ["dimension", ["template-tag", "start_date"]] (for field filters)

  • default: default value (optional)

  • values_source_type / values_source_config: dropdown data source (optional)

  • values_query_type: "list" | "search" | "none" (optional)

Args: card_id: The ID of the card whose parameters should be updated. parameters: List of parameter configs. When merge=False (default) this replaces the card's entire parameters list. When merge=True, entries are matched by id (or by slug if id is missing) and merged into existing parameters; new entries are appended.

Returns: The updated card object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
card_idYes
parametersYes
mergeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The `update_card_parameters` tool registered with FastMCP via @mcp.tool decorator. Sets card-level `parameters` list on a saved question. Supports merge mode (by id/slug) or full replacement. Sends PUT /card/{card_id} with the parameters payload.
    async def update_card_parameters(
        card_id: int,
        parameters: list[dict[str, Any]],
        ctx: Context,
        merge: bool = False,
    ) -> dict[str, Any]:
        """
        Set the card-level `parameters` list on a saved question.
    
        Card parameters drive the filter widgets shown on a card's own page AND
        are what Metabase uses to wire dashboard parameters into the card. For a
        date filter to render as a date picker (instead of a plain text box), the
        card must have a matching parameter entry — the template-tag type alone is
        not enough.
    
        Each parameter is a dict. Common keys:
          - id: the template-tag's UUID (must match `dataset_query.native.template-tags[name].id`)
          - name: display name, e.g. "Start date"
          - slug: URL slug, e.g. "start_date"
          - type: widget type, e.g. "date/single", "date/range", "date/all-options",
                  "category", "string/=", "number/="
          - target: link back to the template tag, e.g.
                   ["variable", ["template-tag", "start_date"]] (for text/number/date vars)
                   ["dimension", ["template-tag", "start_date"]] (for field filters)
          - default: default value (optional)
          - values_source_type / values_source_config: dropdown data source (optional)
          - values_query_type: "list" | "search" | "none" (optional)
    
        Args:
            card_id: The ID of the card whose parameters should be updated.
            parameters: List of parameter configs. When `merge=False` (default)
                this replaces the card's entire parameters list. When `merge=True`,
                entries are matched by `id` (or by `slug` if `id` is missing) and
                merged into existing parameters; new entries are appended.
    
        Returns:
            The updated card object.
        """
        if not parameters:
            raise ToolError("`parameters` must contain at least one entry.")
    
        try:
            await ctx.info(f"Updating parameters on card {card_id}")
    
            if merge:
                card = await metabase_client.request("GET", f"/card/{card_id}")
                existing: list[dict[str, Any]] = list(card.get("parameters") or [])
    
                def key(p: dict[str, Any]) -> Any:
                    return p.get("id") or p.get("slug")
    
                by_key = {key(p): dict(p) for p in existing if key(p) is not None}
                ordered_keys = [key(p) for p in existing if key(p) is not None]
    
                for incoming in parameters:
                    k = key(incoming)
                    if k is None:
                        raise ToolError(
                            "When merge=True, each parameter must include 'id' or 'slug'."
                        )
                    if k in by_key:
                        by_key[k].update(incoming)
                    else:
                        by_key[k] = dict(incoming)
                        ordered_keys.append(k)
    
                new_params = [by_key[k] for k in ordered_keys]
            else:
                new_params = list(parameters)
    
            result = await metabase_client.request(
                "PUT", f"/card/{card_id}", json={"parameters": new_params}
            )
            await ctx.info(
                f"Successfully updated {len(new_params)} parameter(s) on card {card_id}"
            )
            return result
        except ToolError:
            raise
        except Exception as e:
            error_msg = f"Error updating parameters on card {card_id}: {e}"
            await ctx.error(error_msg)
            raise ToolError(error_msg) from e
  • server.py:1095-1178 (registration)
    The tool is registered via the @mcp.tool decorator on the `update_card_parameters` async function, using FastMCP's automatic tool registration mechanism.
    @mcp.tool
    async def update_card_parameters(
        card_id: int,
        parameters: list[dict[str, Any]],
        ctx: Context,
        merge: bool = False,
    ) -> dict[str, Any]:
        """
        Set the card-level `parameters` list on a saved question.
    
        Card parameters drive the filter widgets shown on a card's own page AND
        are what Metabase uses to wire dashboard parameters into the card. For a
        date filter to render as a date picker (instead of a plain text box), the
        card must have a matching parameter entry — the template-tag type alone is
        not enough.
    
        Each parameter is a dict. Common keys:
          - id: the template-tag's UUID (must match `dataset_query.native.template-tags[name].id`)
          - name: display name, e.g. "Start date"
          - slug: URL slug, e.g. "start_date"
          - type: widget type, e.g. "date/single", "date/range", "date/all-options",
                  "category", "string/=", "number/="
          - target: link back to the template tag, e.g.
                   ["variable", ["template-tag", "start_date"]] (for text/number/date vars)
                   ["dimension", ["template-tag", "start_date"]] (for field filters)
          - default: default value (optional)
          - values_source_type / values_source_config: dropdown data source (optional)
          - values_query_type: "list" | "search" | "none" (optional)
    
        Args:
            card_id: The ID of the card whose parameters should be updated.
            parameters: List of parameter configs. When `merge=False` (default)
                this replaces the card's entire parameters list. When `merge=True`,
                entries are matched by `id` (or by `slug` if `id` is missing) and
                merged into existing parameters; new entries are appended.
    
        Returns:
            The updated card object.
        """
        if not parameters:
            raise ToolError("`parameters` must contain at least one entry.")
    
        try:
            await ctx.info(f"Updating parameters on card {card_id}")
    
            if merge:
                card = await metabase_client.request("GET", f"/card/{card_id}")
                existing: list[dict[str, Any]] = list(card.get("parameters") or [])
    
                def key(p: dict[str, Any]) -> Any:
                    return p.get("id") or p.get("slug")
    
                by_key = {key(p): dict(p) for p in existing if key(p) is not None}
                ordered_keys = [key(p) for p in existing if key(p) is not None]
    
                for incoming in parameters:
                    k = key(incoming)
                    if k is None:
                        raise ToolError(
                            "When merge=True, each parameter must include 'id' or 'slug'."
                        )
                    if k in by_key:
                        by_key[k].update(incoming)
                    else:
                        by_key[k] = dict(incoming)
                        ordered_keys.append(k)
    
                new_params = [by_key[k] for k in ordered_keys]
            else:
                new_params = list(parameters)
    
            result = await metabase_client.request(
                "PUT", f"/card/{card_id}", json={"parameters": new_params}
            )
            await ctx.info(
                f"Successfully updated {len(new_params)} parameter(s) on card {card_id}"
            )
            return result
        except ToolError:
            raise
        except Exception as e:
            error_msg = f"Error updating parameters on card {card_id}: {e}"
            await ctx.error(error_msg)
            raise ToolError(error_msg) from e
Behavior4/5

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

Despite no annotations, the description details the merge behavior (replace vs. merge by id/slug) and explains the role of parameters in dashboard wiring. It does not cover auth or error conditions, but the key behavioral traits are disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement, explanatory context, and an Args section. It is slightly lengthy but every sentence adds value. Front-loading ensures the agent grasps the core quickly.

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 the tool's operation, merge modes, and parameter structure. Given the complexity of the parameters array and the absence of an output schema, it provides sufficient information for an agent to use the tool correctly, though error handling and permissions are omitted.

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?

With 0% schema description coverage, the description fully compensates by detailing card_id, parameters (including common keys like id, name, slug, type, target), and merge with its default behavior. This adds meaning far beyond the raw JSON schema.

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 begins with a specific verb+resource: 'Set the card-level `parameters` list on a saved question.' This clearly identifies the primary action and object, distinguishing it from sibling tools like update_card, which handles broader card updates.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use the tool (to set parameters for filter widgets) and provides insight into why it's necessary (e.g., for date pickers). However, it does not explicitly mention when not to use it or compare with alternatives like set_card_template_tags.

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