metabase-mcp-server
Provides read-only access to a Metabase instance, enabling AI agents to explore schemas, query databases via MBQL or native SQL, run saved questions, compare data across databases, and export results.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@metabase-mcp-server How many orders did we get last month?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
An MCP server that gives AI agents read-only access to any Metabase instance. Explore schemas, query databases, run saved questions, compare data across databases, and export results — all through natural conversation.
Works with Claude Code, Cursor, and any MCP-compatible client.
Quick Start
git clone https://github.com/arkanji/metabase-mcp-server.git
cd metabase-mcp-server
npm install && npm run buildThen add it to your AI client:
{
"mcpServers": {
"metabase": {
"command": "node",
"args": ["/path/to/metabase-mcp-server/dist/index.js"],
"env": {
"METABASE_URL": "https://metabase.example.com",
"METABASE_API_KEY": "mb_xxxxxxxxxxxxx"
}
}
}
}{
"mcpServers": {
"metabase": {
"command": "node",
"args": ["/path/to/metabase-mcp-server/dist/index.js"],
"env": {
"METABASE_URL": "https://metabase.example.com",
"METABASE_API_KEY": "mb_xxxxxxxxxxxxx"
}
}
}
}Related MCP server: Metabase MCP Server
Configuration
Variable | Required | Default | Description |
| Yes | — | Your Metabase instance URL. Do not include |
| Yes | — | How to generate one — go to Admin > Settings > API Keys. |
| No |
| Where |
Tools
Discovery
Tool | What it does |
| List all connected databases |
| List tables in a database |
| Get column names, IDs, and types for a table |
| Sample rows to understand data shape |
| Find saved questions, dashboards, or tables by keyword |
Querying
Tool | What it does |
| Run structured MBQL queries (aggregations, filters, breakouts) |
| Run raw SQL queries (requires SQL permission on API key) |
| Execute an existing saved question by ID |
| Inspect a saved question's definition without running it |
| List all saved questions, optionally by database |
Dashboards
Tool | What it does |
| List all dashboards |
| Get a dashboard's cards and layout details |
Analysis & Export
Tool | What it does |
| Find overlapping values across two databases (e.g. shared emails between CRM and marketing) |
| Export up to 500K rows to CSV/JSON with auto-pagination |
Examples
"How many orders did we get last month?"
The agent will:
list_databases→ find your orders databaselist_tables→ find the orders tableget_table_fields→ get the date and status field IDsquery_dataset→ run a count aggregation with a date filter
"Export all active customers to a CSV"
The agent will:
Discover the table and field IDs
export_dataset→ auto-paginates through the 2,000-row Metabase cap, writes to~/Downloads/
"Which customers exist in both our CRM and marketing databases?"
The agent will:
Identify the email field in both databases
cross_db_overlap→ fetches both sides, computes the intersection in memory
How It Works
You ──→ AI Agent ──→ MCP Server ──→ Metabase REST API ──→ Your Databases
(Claude, (this (x-api-key auth,
Cursor) project) read-only)Key things to know:
Read-only — no write operations. Native SQL queries are validated to reject
INSERT,UPDATE,DELETE,DROP, etc.2,000-row cap — Metabase limits query results to 2,000 rows. Use aggregations for analytics, or
export_datasetfor full data extraction (auto-paginates up to 500K rows).30s timeout — each API request times out after 30 seconds to prevent hung connections.
MBQL — Metabase's structured query language. Columns are referenced by field ID (not name), so always call
get_table_fieldsfirst to look them up.
Security
API keys are passed via environment variables and sent as
x-api-keyheaders. They are never logged or exposed in tool responses.Write-operation guard —
run_native_queryrejects queries that start with write keywords (INSERT,UPDATE,DELETE,DROP,ALTER,TRUNCATE,CREATE,GRANT,REVOKE). This is a basic prefix check, not a comprehensive SQL parser — Metabase's own permission system is the primary access control.No secrets in code — the server reads credentials only from env vars at startup.
Troubleshooting
Problem | Cause | Fix |
| Missing env var | Set |
| Invalid or expired API key | Generate a new key in Metabase Admin > Settings > API Keys |
| Key lacks permission for this action | Check your key's permission group in Metabase. Native SQL requires explicit "native query" permission. |
| URL is wrong or Metabase is down | Verify |
| SQL query starts with INSERT/UPDATE/etc. | This server is read-only. Use SELECT queries only. |
Queries return empty results | Wrong field IDs or filters | Call |
Export hangs | Very large dataset + slow Metabase | Add filters to reduce row count. Exports are capped at 500K rows. |
Development
npm run dev # Watch mode — recompiles on save
npm run build # One-time build
npm start # Run the serverShould work with any Metabase version that supports the /api/dataset endpoint and API key authentication (generally v0.44+).
Contributing
Issues and PRs are welcome. Please open an issue first to discuss significant changes.
License
Available Tools
14 toolscross_db_overlapA
Compare a field across two databases to find overlapping values (e.g. find which email addresses exist in both your CRM and marketing databases). Handles cross-DB join limitations by fetching both sets and computing intersection in memory. Caps at 500K rows per side — add filters for larger tables. Supports cancellation.
Inputs: source_a (required), source_b (required), filter_a, filter_b, +1 more.
export_datasetA
Export full row-level data to a local CSV or JSON file. Auto-paginates through the 2000-row Metabase cap internally. The file path is returned in the response. Use this when you need complete data for external analysis (Excel, Google Sheets). For analytical queries, use query_dataset with aggregations instead. Caps at 500K rows — add filters for larger tables. Output directory is configurable via METABASE_EXPORT_DIR env var (defaults to ~/Downloads/).
Inputs: table_id (required), database_id (required), fields, filter, +2 more.
get_card_metadataA
Get a saved question's definition (query type, database, SQL/MBQL) without executing it.
Inputs: card_id (required).
get_dashboardA
Get a dashboard's cards and layout.
Inputs: dashboard_id (required).
get_table_fieldsA
Get field IDs, names, and types for a table. You MUST call this before building query_dataset calls — field IDs are required for filters and aggregations.
Inputs: table_id (required).
list_dashboardsA
List all dashboards.
Inputs: no named parameters.
list_databasesA
List all databases connected to Metabase with their ID, name, and engine type.
Inputs: no named parameters.
list_saved_questionsA
List all saved questions/cards, optionally filtered by database.
Inputs: database_id.
list_tablesA
List all tables in a database. Returns table ID, name, and schema.
Inputs: database_id (required).
preview_tableA
Return a small sample of rows from a table to understand its data shape. Useful for inspecting JSON column structures or understanding field formats before writing queries.
Inputs: table_id (required), database_id (required), limit.
query_datasetA
Run an MBQL query against a Metabase database. Metabase enforces a hard server-side cap of 2000 rows — use aggregations to work around this. If is_truncated is true and you need more rows, call again with offset: 2000, then 4000, etc. Only do this for small result sets (<10K rows). For larger exports, use export_dataset instead. For time comparisons (WoW, MoM, trends), use a single query with a date breakout instead of multiple queries. MBQL examples: aggregation: [["count"]] or [["sum", ["field", 87, null]]]. filter: ["=", ["field", 10, null], "active"]. breakout: [["field", 42, {"temporal-unit": "month"}]].
Inputs: table_id (required), database_id (required), limit, filter, +3 more.
run_native_queryA
Run a native SQL query against a Metabase database. Requires that your API key has native query (SQL) permission in Metabase. IMPORTANT: You must include a LIMIT clause in your SQL to avoid large result sets. Write operations (INSERT, UPDATE, DELETE, DROP, etc.) and multi-statement queries are rejected. The server strips SQL comments before validation.
Inputs: query (required), database_id (required).
run_saved_questionB
Execute a saved question (card) by ID. Works for both MBQL and native SQL cards.
Inputs: card_id (required).
searchA
Search across questions, dashboards, and tables by keyword.
Inputs: query (required), type.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool has a clearly distinct purpose: list/get for metadata, query/run for execution, and specialized tools for cross-db and export. The overlap between query_dataset and run_native_query is clearly separated by MBQL vs SQL. No ambiguity.
Most tools follow a verb_noun pattern (list_*, get_*, run_*), with consistent use of list for collections and get for single items. The exception is 'cross_db_overlap', which is a noun phrase rather than a verb-led name, creating a minor deviation.
With 14 tools, the server is well-scoped for Metabase data exploration and querying. Each tool serves a distinct need, and the count is within the ideal range for a focused MCP server.
The toolset covers the full data exploration lifecycle: discovering databases, tables, fields, previewing data, running queries, and exporting results. It also includes saved questions, dashboards, and cross-database overlap, but lacks write operations like creating or updating cards/dashboards, which are not the primary focus.
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Amazon Ads, Seller Central, Vendor Central and AMC data for AI agents. Read-only by default.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Metabase databases and dashboards, allowing users to list and execute queries, access data visualizations, and interact with database resources through natural language.151-
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with Metabase through its API, allowing them to list, read, execute, and manage databases, tables, dashboards, cards, collections, and queries with support for multiple export formats.-
- FlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to interact with Metabase by providing access to dashboards, questions, and databases through the Metabase API. It allows users to list resources, execute existing cards, and run custom SQL queries to retrieve data through natural language.15 npm-
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Metabase for database operations, SQL queries, dashboard management, and analytics automation.28MIT