MCP ExplorerExplorer

Metabase Mcp

@cheukyin175on a year ago
4 MIT
FreeCommunity
AI Systems
Metabase MCP server provides integration with the Metabase API, enabling LLM with MCP capabilites to directly interact with your analytics data, this server acts as a bridge between your analytics platform and conversational AI.

Overview

What is Metabase Mcp

Metabase MCP is a Model Context Protocol server that integrates AI assistants with the Metabase analytics platform, allowing LLM with MCP capabilities to directly interact with analytics data.

Use cases

Use cases include generating reports from dashboards, executing SQL queries, managing dashboards and cards, and providing insights through conversational interfaces.

How to use

To use Metabase MCP, connect your AI assistant to the server, authenticate using either session-based or API key methods, and utilize the provided tools to access and manage your Metabase resources.

Key features

Key features include intuitive resource access via ‘metabase://’ URIs, support for two authentication methods, structured JSON data responses, comprehensive logging for debugging, and robust error handling.

Where to use

Metabase MCP can be used in various fields such as business intelligence, data analytics, and any environment where conversational AI needs to interact with analytics data.

Content

Metabase FastMCP Server

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.

Features

  • 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)

Installation

Quick Start with uv (Recommended)

  1. Install uv if not already installed:
    Please refer to uv

  2. Clone and setup:

uv sync  # Install dependencies and create virtual environment
  1. Configure environment:
cp .env.example .env
# Edit .env with your Metabase configuration

Alternative Installation (pip)

pip install -r requirements.txt

Configuration

Set the following environment variables in your .env file:

  • METABASE_URL: Your Metabase instance URL
  • METABASE_API_KEY: Your Metabase API key (preferred method)

OR

  • METABASE_USER_EMAIL: Your Metabase user email
  • METABASE_PASSWORD: Your Metabase password

Usage

Run the Server

# STDIO transport (default)
uv run python server.py

# SSE transport on port 8000
uv run python server.py --sse

# SSE transport on custom port
uv run python server.py --sse 9000

# HTTP transport on port 8000
uv run python server.py --http

FastMCP CLI Integration

# Run with FastMCP CLI
fastmcp run server.py

# Install as Claude Desktop MCP server
fastmcp install server.py -n "Metabase MCP"

Cursor Integration

For Cursor IDE integration:

STDIO Transport (Default)

uv run python scripts/install-cursor.py

SSE Transport

# Install with SSE transport
uv run python scripts/install-cursor.py --sse        # Port 8000 (default)
uv run python scripts/install-cursor.py --sse 9000   # Custom port

# Or use the dedicated SSE installer
uv run python scripts/install-cursor-sse.py          # Port 8000
uv run python scripts/install-cursor-sse.py 9000     # Custom port

Important for SSE: You must start the server before using Cursor:

uv run python server.py --sse 8000

Available Tools

  • list_databases: List all databases in Metabase
  • list_cards: List all questions/cards in Metabase
  • execute_card: Execute a Metabase question/card and get results
  • execute_query: Execute a SQL query against a Metabase database
  • create_card: Create a new question/card in Metabase
  • list_collections: List all collections in Metabase
  • create_collection: Create a new collection in Metabase
  • list_tables: List all tables in a database
  • get_table_fields: Get all fields/columns in a table

Transport Methods

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 on port 8000
uv run python server.py --http   # HTTP on port 8000

Development

Development Setup

# 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

Validation

# Validate installation
uv run python scripts/validate.py

Examples

Check out the example files for usage patterns:

  • examples/examples.py - Basic usage examples
  • examples/quick-start.py - Quick start guide
  • examples/sse-example.py - SSE transport usage example

Files Overview

  • server.py - Main FastMCP server
  • pyproject.toml - Modern Python project configuration
  • scripts/install-cursor.py - Cross-platform Cursor installation
  • scripts/install-cursor-sse.py - SSE-specific Cursor installation
  • scripts/validate.py - Installation validation
  • examples/ - Usage examples and quick start guides
  • tests/test_server.py - Basic server tests
  • config/cursor-config.json - Example Cursor configuration

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers