Purpose
metabase-mcp is a headless, AI-enhanced Metabase MCP server used to connect Claude to Metabase, enabling natural language data analysis, dashboard management, and SQL queries. It is mainly aimed at scenarios that the official MCP server cannot cover: headless/agent use (the official MCP endpoint only supports OAuth, requires a browser flow and an accessible HTTPS instance, whereas this server uses Metabase API key authentication through MCP and can work in CI, autonomous agents, and self-hosted instances behind a VPN), server built-in AI (NLQ to SQL, SQL explanation/optimization/validation, automatic insights and trend analysis, using your own Anthropic key, independent of the connected AI client), operational controls (read/write/full modes, per-tool allow/deny lists, SQL injection protection, tiered rate limits, risk-scored audit logs), composable capabilities (batch_execute and run_workflow have no official equivalent), and support for any Metabase version (including instances before v0.60).
Main capabilities
- 30 tools, covering read, batch, workflow, write, NLQ, and insight categories.
- Batch execution: run up to 20 operations in parallel in a single call (reads are always available; non-destructive writes are supported in write/full mode).
- Workflow pipelines: chain tools in sequence using $stepName.path output references, including write steps.
- Compact responses by default: all tools return compact JSON (about 50% fewer tokens), and pretty printing can be selected via format: "default".
- Natural language to SQL: ask questions and get SQL + results (powered by Claude).
- SQL protection: injection detection, DDL/DML blocking, dangerous pattern enforcement.
- Tiered rate limits: configurable per-minute limits for read, write, and LLM operations.
- Audit logs: every operation is logged with a risk assessment.
- Three server modes: read (safe default), write, or full (including AI insights).
- Schema caching: provides fast NLQ context for large databases.
Usage
One-click install (recommended): download the latest metabase-mcp-*.mcpb from GitHub Releases, double-click to install in Claude Desktop, and enter the Metabase URL and API key when prompted (securely stored in the operating system keychain).
Or set environment variables or create a .env file (see .env.example).
Generate a Metabase API key: go to your Metabase instance, navigate to Admin > Settings > API Keys, click Create API Key, copy the key, and set it as METABASE_API_KEY.
Claude Desktop integration: add it to the Claude Desktop configuration (on macOS, ~/Library/Application Support/Claude/claude_desktop_config.json).
Available tools:
- Read (always available): list_dashboards, get_dashboard, list_cards, get_card, execute_card, list_databases, get_database_schema, execute_query, search_content, get_collections.
- Batch and workflow (always available): batch_execute, run_workflow. In write/full mode, both also accept non-destructive write tools (create_card, update_card, create_dashboard, update_dashboard, add_card_to_dashboard, create_collection, move_to_collection). Delete/remove operations can never be batched and must be explicit single-tool calls.
- Write (write/full mode): create_card, update_card, delete_card, create_dashboard, update_dashboard, delete_dashboard, add_card_to_dashboard, remove_card_from_dashboard, create_collection, move_to_collection.
- NLQ (requires ANTHROPIC_API_KEY): nlq_to_sql, explain_sql, optimize_sql, validate_sql.
- Insights (full mode + ANTHROPIC_API_KEY): ask_data, generate_insights, compare_metrics, trend_analysis.
Per-tool access control: server mode provides coarse-grained control (read/write/full); MCP_TOOLS_ALLOW and MCP_TOOLS_DENY refine per tool. Denied tools are not registered with the MCP client at all, and the same policy is enforced within nested operations inside batch_execute and run_workflow. Deny always takes precedence over allow.
When to use
- Running agents or CI that cannot perform an OAuth browser flow.
- Self-hosted Metabase that is not publicly accessible.
- Need server-side AI-generated insights.
- Need audit logs and rate limiting.
- Using a Metabase version earlier than v0.60.
If you are using v62+, the instance is accessible via OAuth, and per-user permission scoping or inline interactive charts matter more than the above, you should use the official Metabase MCP.
Limitations
- By default, only SELECT and WITH queries are allowed; DDL/DML statements (DROP, DELETE, INSERT, etc.) are blocked.
- Injection patterns (UNION, comments, multiple statements, file operations, time-based attacks) are detected and rejected.
- Even inside SELECT, patterns such as UNION SELECT, SQL comments (--, /* */), xp_cmdshell, INTO OUTFILE, etc. are blocked.
- To execute DML (INSERT, UPDATE, DELETE), you must run in write or full mode, and the SQL must still pass the guard (by design it will not pass).
- Default rate limits: reads 120/minute, writes 30/minute, LLM calls 20/minute, adjustable via the RATE_LIMIT_REQUESTS_PER_MINUTE environment variable.
- NLQ tools require ANTHROPIC_API_KEY; insighttools additionally require MCP_MODE=full.
- When using NLQ or insight tools, query result data is sent to the Anthropic API for analysis. If a query returns sensitive data (PII, financial records, etc.), that data will be processed by Claude.
- This extension does not collect telemetry, analytics, or usage data.
- This extension does not retain any data. Audit logs (if enabled via AUDIT_LOG_FILE) are written only to the local file system with owner-only permissions (0600).
- Requires node --version >= 20.
Data privacy
This extension collects: Metabase API key and URL (stored locally in the OS keychain, never transmitted to us); Anthropic API key (if provided, stored locally in the OS keychain, never transmitted to us). This extension transmits: all Metabase API calls (queries, dashboards, cards) go directly from your machine to your own Metabase instance; NLQ/insight tool usage sends natural language questions, database schema context, and query result samples to the Anthropic API for processing (subject to Anthropic's privacy policy). If no Anthropic API key is provided, no data is sent to Anthropic—NLQ and insight tools will be disabled.
Troubleshooting
- "Cannot connect to Metabase" / 401 error: verify that METABASE_URL is correct and accessible (test: curl $METABASE_URL/api/health); verify that METABASE_API_KEY is valid; the API key must have permission for the database to be queried.
- "Blocked SQL pattern detected" error: by default, only SELECT and WITH queries are allowed.
- "Rate limit exceeded" error: default limits are 120 reads/minute, 30 writes/minute, 20 LLM calls/minute; adjust using the RATE_LIMIT_REQUESTS_PER_MINUTE environment variable; wait for the retry-after time shown in the error.
- NLQ tools unavailable: requires ANTHROPIC_API_KEY; check that it Starts with sk- and has remaining quota; the insights tool additionally requires MCP_MODE=full.
- Claude Desktop: The extension is installed but the tools do not appear: fully quit and restart Claude Desktop; check the logs at ~/Library/Logs/Claude/mcp*.log (macOS); verify node --version >= 20.