A FastMCP (Model Context Protocol) server for Metabase, built with Python. This server provides tools to interact with Metabase databases, execute queries, manage cards, and work with collections.
- List and manage Metabase databases
- Execute SQL queries and saved questions/cards
- Create and manage cards (questions)
- Work with collections
- List tables and fields
- Full authentication support (API Key or Session-based)
-
Install uv if not already installed: Please refer to uv
-
Clone and setup:
uv sync # Install dependencies and create virtual environment- Configure environment:
cp .env.example .env
# Edit .env with your Metabase configurationpip install -r requirements.txtSet the following environment variables in your .env file:
METABASE_URL: Your Metabase instance URLMETABASE_API_KEY: Your Metabase API key (preferred method)
OR
METABASE_USER_EMAIL: Your Metabase user emailMETABASE_PASSWORD: Your Metabase password
# STDIO transport (default)
uv run python server.py
# SSE transport (uses HOST=0.0.0.0, PORT=8000 by default)
uv run python server.py --sse
# HTTP transport (uses HOST=0.0.0.0, PORT=8000 by default)
uv run python server.py --http
# Custom host and port via environment variables
HOST=localhost PORT=9000 uv run python server.py --sse
HOST=192.168.1.100 PORT=8080 uv run python server.py --http
# Set environment variables persistently
export HOST=localhost
export PORT=9000
uv run python server.py --sse# Run with FastMCP CLI
fastmcp run server.py
# Install as Claude Desktop MCP server
fastmcp install server.py -n "Metabase MCP"For Cursor IDE integration:
uv run python scripts/install-cursor.py# Install with SSE transport
uv run python scripts/install-cursor.py --sse # Uses PORT environment variable or default 8000
# Or use the dedicated SSE installer
uv run python scripts/install-cursor-sse.py # Uses PORT environment variable or default 8000Important for SSE: You must start the server before using Cursor:
# Use environment variables for host/port configuration
HOST=0.0.0.0 PORT=8000 uv run python server.py --sseAfter running uv sync, you can find the Python executable at /path/to/repo/.venv/bin/python.
To integrate with Claude, add or update the configuration file at ~/Library/Application\ Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"metabase-mcp-server": {
"command": "/path/to/repo/.venv/bin/python",
"args": ["/path/to/repo/server.py"]
}
}
}list_databases: List all databases in Metabaselist_tables: List all tables in a database with formatted outputget_table_fields: Get all fields/columns in a table
list_cards: List all questions/cards in Metabase (WARNING: Large dataset)list_cards_paginated: List cards with pagination to avoid timeout issuesexecute_card: Execute a Metabase question/card and get resultsexecute_query: Execute a SQL query against a Metabase databasecreate_card: Create a new question/card in Metabase
list_collections: List all collections in Metabaselist_cards_by_collection: List cards in a specific collection (focused dataset)create_collection: Create a new collection in Metabase
search_metabase: Universal search using Metabase search API (cards, dashboards, collections)find_candidate_collections: Find collections by name/description matching (fast)search_cards_in_collections: Search for cards within specific collections (targeted)
The server supports multiple transport methods:
- STDIO (default): For IDE integration (Cursor, Claude Desktop)
- SSE: Server-Sent Events for web applications
- HTTP: Standard HTTP for API access
uv run python server.py # STDIO (default)
uv run python server.py --sse # SSE (HOST=0.0.0.0, PORT=8000)
uv run python server.py --http # HTTP (HOST=0.0.0.0, PORT=8000)
HOST=localhost PORT=9000 uv run python server.py --sse # Custom host/port# Install development dependencies (Python 3.12+)
uv sync --group dev
# Run tests
uv run pytest
# Format and lint code
uv run ruff check . # Lint
uv run ruff format . # Format
uv run black . # Alternative formatter
uv run isort . # Import sorting
# Type checking
uv run mypy server.py# Validate installation
uv run python scripts/validate.pyCheck out the example files for usage patterns:
examples/examples.py- Basic usage examplesexamples/quick-start.py- Quick start guideexamples/sse-example.py- SSE transport usage example
server.py- Main FastMCP serverpyproject.toml- Modern Python project configurationscripts/install-cursor.py- Cross-platform Cursor installationscripts/install-cursor-sse.py- SSE-specific Cursor installationscripts/validate.py- Installation validationexamples/- Usage examples and quick start guidestests/test_server.py- Basic server testsconfig/cursor-config.json- Example Cursor configuration