metabase-mcp

metabase-mcp

An MCP server for Metabase that enables executing SQL queries and saved cards, with options to export results as CSV or XLSX, while enforcing read-only mode and database whitelisting for security.

Category
Visit Server

README

metabase-mcp

A Model Context Protocol (MCP) server for Metabase, designed to run in Claude Code via stdio transport.

Features

  • execute tool — Run SQL queries or saved Metabase cards; results returned inline as a formatted table
  • export tool — Same as execute, but writes results to CSV or XLSX
  • Read-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

Setup

1. Install dependencies

cd metabase-mcp
npm install

2. Configure environment

cp .env.example .env
chmod 600 .env

Edit .env and fill in your values:

Variable Description
METABASE_URL Base URL of your Metabase instance (no trailing slash)
METABASE_API_KEY Metabase API key (Settings → Admin → API Keys)
METABASE_ALLOWED_DB_IDS Comma-separated list of allowed database IDs (e.g. 1,2,3). Leave empty to allow all.
METABASE_READ_ONLY_MODE true (default) blocks INSERT/UPDATE/DELETE/DROP/etc. and comment syntax
AUDIT_LOG_PATH Path to the audit log file (default: ./audit.log)
EXPORT_DIRECTORY Directory where export files are written (default: ./exports)

3. Build

npm run build

4. Add to Claude Code

claude mcp add metabase-mcp -- node /absolute/path/to/metabase-mcp/build/index.js

Replace /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-KEY header only. No email/password fallback.
  • DB whitelist: If METABASE_ALLOWED_DB_IDS is 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
AUTH_ERROR API key rejected by Metabase
SECURITY_ERROR Blocked by read-only mode or DB whitelist
VALIDATION_ERROR Bad input or missing env vars
METABASE_ERROR Metabase API returned an error
EXPORT_ERROR File write failure

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured