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 "Install 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: Metabase MCP Plus
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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/itsshreyanshhere/internal-metabase-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server