metabase-mcp
Provides tools to execute SQL queries or saved Metabase cards with inline results, and export results to CSV or XLSX files, with security features such as read-only mode and database whitelist.
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-mcpshow top 5 customers from database 1"
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.
metabase-mcp
A Model Context Protocol (MCP) server for Metabase, designed to run in Claude Code via stdio transport.
Features
executetool — Run SQL queries or saved Metabase cards; results returned inline as a formatted tableexporttool — Same as execute, but writes results to CSV or XLSXRead-only mode — Blocks mutating SQL keywords and comment-injection by default
DB whitelist — Restricts queries to an explicit list of allowed database IDs
Audit log — Appends a JSON line per tool call to a local log file
Related MCP server: Universal Database MCP Server
Setup
1. Install dependencies
cd metabase-mcp
npm install2. Configure environment
cp .env.example .env
chmod 600 .envEdit .env and fill in your values:
Variable | Description |
| Base URL of your Metabase instance (no trailing slash) |
| Metabase API key (Settings → Admin → API Keys) |
| Comma-separated list of allowed database IDs (e.g. |
|
|
| Path to the audit log file (default: |
| Directory where export files are written (default: |
3. Build
npm run build4. Add to Claude Code
claude mcp add metabase-mcp -- node /absolute/path/to/metabase-mcp/build/index.jsReplace /absolute/path/to/metabase-mcp with the actual path on your machine.
Tool reference
execute
Run a SQL query or saved card and get results inline.
{
"mode": "sql",
"database_id": 1,
"query": "SELECT id, name FROM users LIMIT 10",
"row_limit": 100
}{
"mode": "card",
"card_id": 42,
"card_parameters": [],
"row_limit": 50
}export
Write results to a file.
{
"mode": "sql",
"database_id": 1,
"query": "SELECT * FROM orders",
"format": "csv",
"filename": "orders_export"
}{
"mode": "card",
"card_id": 7,
"format": "xlsx"
}Security model
Authentication: API key via
X-API-KEYheader only. No email/password fallback.DB whitelist: If
METABASE_ALLOWED_DB_IDSis set, any query targeting an unlisted database is blocked before any network call is made.Read-only mode: Rejects SQL containing
INSERT,UPDATE,DELETE,DROP,TRUNCATE,ALTER,CREATE,GRANT,REVOKE(whole-word match) and comment syntax (--,/*,*/).Path traversal: Export filenames are sanitized and the resolved path is checked to ensure it stays within
EXPORT_DIRECTORY.
Error categories
Category | Meaning |
| API key rejected by Metabase |
| Blocked by read-only mode or DB whitelist |
| Bad input or missing env vars |
| Metabase API returned an error |
| File write failure |
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
An MCP server giving access to Grafana dashboards, data and more.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Related MCP Servers
- AlicenseAqualityCmaintenanceAn MCP server that enables AI assistants to query databases, execute SQL, and manage Metabase resources like dashboards, cards, and collections through natural language.22MIT
- FlicenseNot gradedqualityDmaintenanceA versatile MCP server that connects to multiple relational databases (MySQL, PostgreSQL, Oracle, SQL Server, SQLite) and enables secure read-only SQL query execution and metadata access.4-
- AlicenseAqualityDmaintenanceA MCP server for Metabase that gives AI assistants direct access to dashboards, cards, and query execution.3321 PyPI1MIT
- AlicenseNot gradedqualityDmaintenanceRead-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.MIT