Skip to main content
Glama
metabase-mcp

metabase-mcp

by livingroot

Metabase MCP Server

Completely vibecoded a TypeScript/Node.js MCP (Model Context Protocol) server that wraps the Metabase REST API, giving AI agents (Claude Desktop, Claude Code) full programmatic access to a Metabase v0.59.x instance. Agents can execute queries, explore schemas, and build dashboards entirely through structured tool calls — no human click-through required.

Prerequisites

  • Node.js 20 LTS or later

  • Docker (for running a local Metabase instance during development)

  • A Metabase instance reachable over HTTP/HTTPS with an API key

Related MCP server: Gel Database MCP Server

Setup

  1. Install dependencies:

    npm install
  2. Build the server:

    npm run build

    Compiled output is written to dist/. The entry point is dist/index.js.

  3. Configure environment variables (copy .env.example and fill in values):

    cp .env.example .env
  4. (Optional) Start a local Metabase instance for development:

    docker compose up -d

    Metabase is available at http://localhost:3000 once healthy (allow ~2 minutes on first boot).

Transports

The server supports two transport modes, selected via the TRANSPORT environment variable.

stdio (default)

Used by Claude Desktop and Claude Code when running the server as a local process. The MCP protocol runs over stdin/stdout.

HTTP (remote MCP)

Runs an HTTP server implementing the MCP Streamable HTTP transport. Each client authenticates with its own Metabase API key passed as a URL query parameter — there is no shared key on the server.

Start the HTTP server:

METABASE_URL=https://your-metabase.example.com \
TRANSPORT=http \
PORT=4000 \
node dist/index.js

Connect from Claude Desktop / Claude Code (remote MCP):

The API key is passed as a Bearer token in the Authorization header — not in the URL.

{
  "mcpServers": {
    "metabase": {
      "url": "https://your-mcp-host:4000/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_METABASE_API_KEY"
      }
    }
  }
}

Docker (full stack):

# Build and start Metabase + MCP server
docker compose up --build

# Or publish a multi-platform image to Docker Hub
make publish

The compose stack exposes the MCP server on port 4000. Connect with Authorization: Bearer <key>.

Curl smoke-test:

curl -s -X POST http://localhost:4000/mcp \
  -H "Authorization: Bearer YOUR_METABASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"0.1"}}}' \
  -D -
# Response headers will include: mcp-session-id: <uuid>

Environment Variables

stdio mode

Variable

Required

Description

METABASE_URL

Yes

Base URL of your Metabase instance, e.g. http://localhost:3000

METABASE_API_KEY

Yes

API key created in Admin → Settings → Authentication → API Keys

HTTP mode

Variable

Required

Description

TRANSPORT

Yes

Set to http to enable HTTP transport

METABASE_URL

Yes

Base URL of your Metabase instance (shared for all sessions)

PORT

No

Port to listen on (default: 4000)

HOST

No

Host to bind to (default: 0.0.0.0)

METABASE_API_KEY

—

Not used in HTTP mode. Each client passes Authorization: Bearer <key>.

API Key Permissions: The API key must belong to a Metabase group with sufficient permissions for the operations you need. For full agent access (read schema, execute queries, create/edit cards and dashboards), the key's group should have access to all relevant databases and admin capabilities. A key with only basic viewer permissions will return 403 errors on write operations.

Adding to Claude Desktop (stdio)

Add the following to your Claude Desktop MCP config file (typically ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "metabase": {
      "command": "node",
      "args": ["/absolute/path/to/metabase-mcp/dist/index.js"],
      "env": {
        "METABASE_URL": "http://localhost:3000",
        "METABASE_API_KEY": "your-api-key-here"
      }
    }
  }
}

Replace /absolute/path/to/metabase-mcp with the actual path to this project.

Adding to Claude Code (stdio)

Add the same config to your Claude Code MCP settings:

{
  "mcpServers": {
    "metabase": {
      "command": "node",
      "args": ["/absolute/path/to/metabase-mcp/dist/index.js"],
      "env": {
        "METABASE_URL": "http://localhost:3000",
        "METABASE_API_KEY": "your-api-key-here"
      }
    }
  }
}

Verifying the Connection

Once connected, ask the agent to call the server_ping tool:

"Call the server_ping tool to verify the Metabase MCP server is running."

A successful response looks like:

{"ok": true, "server": "metabase-mcp", "version": "0.1.0"}

Development

# Run tests
npm test

# Watch mode
npm run test:watch

# Lint
npm run lint

# Type check without building
npm run typecheck

# Build
npm run build

# Run server on stdio (requires env vars set)
npm start

# Run server on HTTP transport (port 4000)
npm run start:http

Architecture

  • src/client.ts — MetabaseClient class (HTTP, X-Api-Key auth, typed errors) and MetabaseApiError

  • src/index.ts — MCP server factory (createServer(credentials?)), all tool registrations, stdio and HTTP bootstrap

  • src/types.ts — Hand-written TypeScript interfaces for Metabase API responses

All MCP server logging goes to stderr exclusively. stdout is reserved for the JSON-RPC protocol stream — any non-protocol bytes there would corrupt the MCP session.

Metabase Version

This server targets Metabase v0.59.x. APIs introduced after this version are not used.

Available Tools

27 tools
cards_createA

Create a native SQL saved question in Metabase from a database ID, SQL query, and display name. Returns the new card ID. Field Filter widget_type is auto-detected from the target field's type when omitted and validated against it before saving.

Inputs: sql (required), name (required), database_id (required), display, +3 more.

cards_deleteA

Delete a saved question by ID. Permanently removes the card from Metabase.

Inputs: card_id (required).

cards_executeA

Run a saved Metabase question (card) by ID and return results as a Markdown table. Defaults to 50 rows; pass max_rows to adjust. Only native SQL cards are fully supported.

Inputs: card_id (required), max_rows, parameters.

cards_findA

Find saved questions by name and return their SQL. Use this when you know (part of) the card name. Returns ID, name, and SQL for each match — no need to call cards_get separately.

Inputs: name (required).

cards_getA

Retrieve the full saved question including its SQL query definition and template-tags configuration (name, type, field_id, widget_type, default, required) as structured JSON. Returns SQL in a fenced code block for native SQL cards.

Inputs: card_id (required).

cards_listA

List saved questions (cards). Optionally filter by name substring. Returns ID, name, description, database ID, creator, and last-updated date as a Markdown table.

Inputs: name_filter.

cards_updateA

Update a saved question's name, description, or SQL. Only the provided fields are changed. Requires database_id when updating sql. Pass ref_card_id to copy template-tag types from another card (fixes broken filter types). Field Filter widget_type is auto-detected from the target field's type when omitted and validated against it before saving.

Inputs: card_id (required), sql, name, display, +6 more.

dashboards_add_cardA

Add an existing saved question to a dashboard at an optional grid position. Returns the dashcard ID — capture it; it is the placement ID needed for remove/reposition/filter-connect operations (it is NOT the card ID). Pass tab_id to place the card on a specific tab.

Inputs: card_id (required), dashboard_id (required), col, row, +3 more.

dashboards_add_filterA

Add a filter parameter to a dashboard. Provide a unique parameter_id string; reuse the same parameter_id in dashboards_connect_filter to wire it to a card. Use values_source_type to control the dropdown source: 'static-list' for a fixed list, 'card' for values from a saved question, 'fields' for values from connected fields (requires a dimension tag_config on the card).

Inputs: name (required), type (required), dashboard_id (required), parameter_id (required), +4 more.

dashboards_add_text_cardA

Add a markdown text block or heading to a dashboard. Use 'text' for multi-line markdown content (supports headers, lists, bold, etc.) and 'heading' for a single-line section title. Returns the dashcard ID.

Inputs: text (required), dashboard_id (required), col, row, +4 more.

dashboards_connect_filterA

Wire a dashboard filter parameter to a native SQL card's template tag so the filter affects that card's results. The parameter_id must match one added via dashboards_add_filter; tag_name is the {{tag_name}} variable in the card's SQL. For text/date/number tags (type='text'|'date'|'number'), use target_type='variable' (default). For dimension tags created with tag_config field_id, and for 'temporal-unit' (time grouping) tags, use target_type='dimension'.

Inputs: tag_name (required), dashcard_id (required), dashboard_id (required), parameter_id (required), +1 more.

dashboards_createA

Create a new empty dashboard. Requires a name; description is optional. Returns the new dashboard ID.

Inputs: name (required), description.

dashboards_create_tabA

Create a new tab on a dashboard. Returns the new tab ID — use it in dashboards_add_card's tab_id parameter to place cards on this tab.

Inputs: name (required), dashboard_id (required).

dashboards_deleteA

Delete a dashboard by ID. Permanently removes the dashboard from Metabase.

Inputs: dashboard_id (required).

dashboards_getA

Retrieve full dashboard details: name, description, filter parameter definitions, and all placed cards with their positions, sizes, and dashcard IDs.

Inputs: dashboard_id (required).

dashboards_listA

List dashboards. Optionally filter by name substring. Returns ID, name, description, card count, and last-updated date as a Markdown table.

Inputs: name_filter.

dashboards_remove_cardA

Remove a single card from a dashboard using its dashcard placement ID (the ID returned by dashboards_add_card or shown in dashboards_get — NOT the card ID).

Inputs: dashcard_id (required), dashboard_id (required).

dashboards_updateA

Update a dashboard's metadata. Only the provided fields are changed. Preserves parameters, tabs, and all other dashboard fields via read-modify-write.

Inputs: dashboard_id (required), name, width, description, +1 more.

dashboards_update_cardB

Reposition, resize, or move a card between tabs on a dashboard. Identified by its dashcard placement ID. Other cards on the dashboard are preserved.

Inputs: dashcard_id (required), dashboard_id (required), col, row, +3 more.

databases_get_schemaA

Retrieve the full schema tree for a database: all tables with columns, data types, and display labels. A single call returns the complete DB → tables → fields metadata.

Inputs: database_id (required).

databases_listA

List all databases connected to this Metabase instance. Returns ID, name, engine type, and sync status as a Markdown table.

Inputs: no named parameters.

fields_getB

Retrieve metadata and valid values for a specific field (column): data type, display name, semantic type, and enumerated valid values for low-cardinality fields.

Inputs: field_id (required).

queries_execute_sqlA

Execute raw SQL against a database and return results as a Markdown table. Defaults to 50 rows; pass max_rows to adjust. Use queries_export for result sets exceeding 2,000 rows.

Inputs: sql (required), database_id (required), max_rows, parameters.

queries_exportA

Export a full query result set as raw CSV text via /api/dataset/csv. Bypasses the 2,000-row JSON cap that queries_execute_sql hits. Returns the complete result set with no row limit.

Inputs: sql (required), database_id (required), parameters.

server_pingA

Ping the MCP server to verify it is running and reachable.

Inputs: no named parameters.

tables_getA

Retrieve column-level metadata for a specific table: column names, data types, semantic types, display names, and nullable/required flags.

Inputs: table_id (required).

tables_listA

List all tables in a database. Returns ID, name, schema name, and estimated row count as a flat Markdown table. Does not include column-level detail.

Inputs: database_id (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 27 tools

    Disambiguation4/5

    Most tools target a distinct resource+action, and the descriptions explicitly differentiate tricky pairs like dashboards_update (metadata) vs dashboards_update_card (layout) and dashboards_delete vs dashboards_remove_card. The main residual overlap is in read paths: cards_list / cards_find / cards_get / cards_execute all touch saved questions, and tables_list / tables_get / databases_get_schema overlap in metadata scope, though the descriptions do explain the differences.

    Naming Consistency5/5

    Every tool follows the same plural-resource_verb pattern (dashboards_*, cards_*, databases_*, tables_*, fields_*, queries_*, server_ping), with snake_case throughout. Sub-resource operations like dashboards_add_card and dashboards_connect_filter stay within the same convention, so names are highly predictable.

    Tool Count3/5

    27 tools is on the heavy side; the 12 dashboard tools in particular are very granular (separate tools for adding text cards, tabs, filters, repositioning). The breadth is partly justified by the genuinely broad domain (dashboards, cards, DB metadata, queries), but some layout operations could be consolidated into fewer parameterized tools.

    Completeness3/5

    Core lifecycle is covered for dashboards and cards (create/list/get/update/delete/execute), plus solid metadata exploration and SQL execution/export. However, several dead ends exist: tabs can be created but not renamed or deleted, filters can be added and connected but not updated or removed, and collections (where Metabase cards actually live) are entirely absent from the surface.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      MCP-compatible server that enables AI assistants to interact with Lightdash analytics data, providing tools to list and retrieve projects, spaces, charts, dashboards, and metrics through a standardized interface.
      13
      23 npm
      27
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A TypeScript-based MCP server that enables LLM agents to interact with Gel databases through natural language, providing tools to learn database schemas, validate and execute EdgeQL queries.
      2
      12
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that enables AI assistants to query databases, execute SQL, and manage Metabase resources like dashboards, cards, and collections through natural language.
      22
      MIT