metabase-mcp-server
Enables AI agents to read-onlyly access Metabase instances, query databases using MBQL or SQL, explore schemas, run saved questions, and export data.
README
<h1 align="center">Metabase MCP Server</h1>
<p align="center"> Connect any AI agent to your Metabase instance.<br/> Read-only tools · MBQL + native SQL · cross-DB analysis · data export </p>
<p align="center"> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="MIT License"/></a> <img src="https://img.shields.io/badge/Node.js-18%2B-green.svg" alt="Node 18+"/> <img src="https://img.shields.io/badge/MCP-compatible-purple.svg" alt="MCP Compatible"/> </p>
<p align="center"> <a href="#quick-start">Quick Start</a> · <a href="#tools">Tools</a> · <a href="#configuration">Configuration</a> · <a href="#examples">Examples</a> · <a href="#troubleshooting">Troubleshooting</a> </p>
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 build
Then add it to your AI client:
<details> <summary><strong>Claude Code</strong> — <code>.mcp.json</code></summary>
{
"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"
}
}
}
}
</details>
<details> <summary><strong>Cursor</strong> — <code>.cursor/mcp.json</code></summary>
{
"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"
}
}
}
}
</details>
Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
METABASE_URL |
Yes | — | Your Metabase instance URL. Do not include /api. |
METABASE_API_KEY |
Yes | — | How to generate one — go to Admin > Settings > API Keys. |
METABASE_EXPORT_DIR |
No | ~/Downloads/ |
Where export_dataset writes CSV/JSON files. |
Tools
Discovery
| Tool | What it does |
|---|---|
list_databases |
List all connected databases |
list_tables |
List tables in a database |
get_table_fields |
Get column names, IDs, and types for a table |
preview_table |
Sample rows to understand data shape |
search |
Find saved questions, dashboards, or tables by keyword |
Querying
| Tool | What it does |
|---|---|
query_dataset |
Run structured MBQL queries (aggregations, filters, breakouts) |
run_native_query |
Run raw SQL queries (requires SQL permission on API key) |
run_saved_question |
Execute an existing saved question by ID |
get_card_metadata |
Inspect a saved question's definition without running it |
list_saved_questions |
List all saved questions, optionally by database |
Dashboards
| Tool | What it does |
|---|---|
list_dashboards |
List all dashboards |
get_dashboard |
Get a dashboard's cards and layout details |
Analysis & Export
| Tool | What it does |
|---|---|
cross_db_overlap |
Find overlapping values across two databases (e.g. shared emails between CRM and marketing) |
export_dataset |
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 |
|---|---|---|
METABASE_URL environment variable is required |
Missing env var | Set METABASE_URL in your .mcp.json env block or shell |
Metabase API error 401 |
Invalid or expired API key | Generate a new key in Metabase Admin > Settings > API Keys |
Metabase API error 403 |
Key lacks permission for this action | Check your key's permission group in Metabase. Native SQL requires explicit "native query" permission. |
Metabase API returned empty response |
URL is wrong or Metabase is down | Verify METABASE_URL points to your instance (no trailing /api) |
Write operations are not allowed |
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 get_table_fields to verify field IDs, then preview_table to check data shape |
| 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 server
Should 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
<p align="center"> Built by <a href="https://github.com/arkanji">Arkanji</a> </p>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。