Skip to main content
Glama
CW-Codewalnut

Metabase MCP Server

create_metabase_card

Create visual charts and tables in Metabase using SQL or MBQL queries to display data insights through various visualization types.

Instructions

Create a new card (chart or table) in Metabase via the /api/card endpoint.

This function creates a visual card using either SQL or MBQL queries and supports all chart types including pie, donut, bar, table, and KPI-style metrics.

Args: name (str): Display name of the card in Metabase.

dataset_query (dict):
    Defines the query behind the chart.
    Required structure:
    - "type": "native" or "query"
    - "native": { "query": "..." }, for SQL
    - "query": {...}, for MBQL
    - "database": database ID

display (str):
    Visualization type. Common values:
    - "table", "bar", "line", "pie", "area", "scatter", "funnel", "pivot-table", "map"

type (str, optional):
    Card type, defaults to "question".
    - "question": general chart or table
    - "metric": for KPI display
    - "model": reserved/legacy

visualization_settings (dict, optional):
    Controls chart appearance and formatting. Structure varies by chart type.

    ── 📊 Bar / Line / Area ──
    {
      "graph": {
        "x_axis": "destination",
        "y_axis": ["seatsSold"],
        "series": "flightType",
        "metrics": ["seatsSold"],
        "x_axis_label": "Destination",
        "y_axis_label": "Seats Sold",
        "x_axis_formatting": {
          "scale": "ordinal",
          "label_rotation": 45
        },
        "y_axis_formatting": {
          "number_style": "decimal",
          "suffix": " pax"
        }
      },
      "show_legend": true,
      "legend_position": "bottom"
    }

    ── 🥧 Pie / Donut Charts ──
    {
      "pie": {
        "category": "destination",         # Label or group for slices
        "metric": "seatsSold",             # Size of each slice
        "labels": true,                    # Show category names
        "show_values": true,               # Show numeric values inside slices
        "inner_radius": 0.6,               # Enables donut (0 = full pie)
        "outer_radius": 0.95,              # Size scaling (0.0 to 1.0)
        "outer_ring": true                 # Enables dual-ring charts
      },
      "show_legend": true,
      "legend_position": "right"
    }

    Notes on ring options:
      - `inner_radius` creates a donut shape. Recommended: 0.5–0.8.
      - `outer_radius` controls the size of the entire chart area.
      - `outer_ring` enables comparison across rings, useful when the query returns multiple groupings/metrics.

    ── 📋 Table ──
    {
      "table.pivot_column": "flightType",
      "column_settings": {
        "seatsSold": {
          "number_style": "decimal",
          "suffix": " pax"
        }
      }
    }

collection_id (int, optional):
    Save card into a specific Metabase collection (folder).

description (str, optional):
    Description or help text for the card.

parameter_mappings (list, optional):
    Used when linking dashboard filters to this card.
    Example:
    [
      {
        "parameter_id": "flightType",
        "card_id": 123,
        "target": ["dimension", ["template-tag", "flightType"]]
      }
    ]

collection_position (int, optional):
    Optional order in the collection.

result_metadata (list, optional):
    Optional field metadata describing result set.

cache_ttl (int, optional):
    Cache duration (in seconds). 0 disables caching.

parameters (list, optional):
    List of query parameters for SQL or MBQL filters.
    Example: [{"name": "region", "type": "category", "slug": "region"}]

dashboard_id (int, optional):
    Adds this card to an existing dashboard.

dashboard_tab_id (int, optional):
    If the dashboard has tabs, specify the tab ID to attach the card to.

entity_id (str, optional):
    External or custom ID for embedding/syncing cards.

Returns: Dict[str, Any]: A dictionary representing the created card including: - id (int) - name (str) - dataset_query (dict) - visualization_settings (dict) - created_at, updated_at, etc.

Example: >>> await create_metabase_card( name="Seats Sold by Destination (Donut with Outer Ring)", display="pie", dataset_query={ "type": "native", "native": { "query": "SELECT destination, SUM("seatsSold") AS total_seats_sold FROM "Flight" GROUP BY destination" }, "database": 2 }, visualization_settings={ "pie": { "category": "destination", "metric": "total_seats_sold", "labels": true, "inner_radius": 0.6, "outer_radius": 0.95, "show_values": true, "outer_ring": true }, "show_legend": true, "legend_position": "right" }, collection_id=3 )

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
dataset_queryYes
displayYes
typeNoquestion
visualization_settingsNo
collection_idNo
descriptionNo
parameter_mappingsNo
collection_positionNo
result_metadataNo
cache_ttlNo
parametersNo
dashboard_idNo
dashboard_tab_idNo
entity_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes that this is a creation operation (implying mutation), specifies it uses the /api/card endpoint, and provides detailed examples of visualization settings. However, it doesn't mention authentication requirements, rate limits, or error handling, which are important for a tool with 15 parameters.

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

Conciseness3/5

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

While the description is comprehensive, it's quite lengthy with detailed formatting examples and notes that could be condensed. The front-loaded purpose is clear, but the extensive parameter documentation and examples make it less concise than ideal, though all content appears relevant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (15 parameters, nested objects, no annotations), the description provides complete coverage: clear purpose, detailed parameter explanations, return value documentation, and a comprehensive example. With an output schema present, the description appropriately focuses on usage rather than return structure, making it fully adequate for this complex tool.

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?

Given 0% schema description coverage and 15 parameters, the description compensates excellently by providing detailed explanations for all parameters, including required structures, common values, optional defaults, and extensive examples for visualization_settings. It adds substantial meaning beyond what the bare schema provides, making parameter usage clear.

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 tool creates a new card (chart or table) in Metabase via a specific API endpoint, specifying it supports SQL or MBQL queries and all chart types. This distinguishes it from sibling tools like create_metabase_dashboard or create_metabase_collection by focusing on visual cards rather than other Metabase entities.

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 provides clear context for when to use this tool (creating visual cards with queries) and implies alternatives through sibling tools like update_metabase_card for modifications or get_metabase_cards for retrieval. However, it lacks explicit guidance on when NOT to use it or direct comparisons to alternatives like create_metabase_dashboard for dashboard creation.

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/CW-Codewalnut/metabase-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server