Metabase AI Assistant MCP server

Integrates with Metabase analytics platforms and direct database connections to enable automated creation of SQL queries, dashboards, questions, metrics, and visualizations through natural language descriptions.
Back to servers
Setup instructions
Provider
ONMARTECH LLC
Release date
Aug 21, 2025
Language
JavaScript
Stats
3 stars

The Metabase AI Assistant is an MCP (Model Context Protocol) server that connects Claude Desktop and Claude Code to Metabase and PostgreSQL databases. It enables AI-powered data analysis by providing direct database access along with Metabase API integration for creating models, SQL queries, metrics, and dashboards.

Installation

Prerequisites

  • Node.js 18+
  • Claude Desktop or Claude Code
  • PostgreSQL Database
  • Metabase instance (v0.48+)

Setup

# Clone the repository
git clone https://github.com/onmartech/metabase-ai-assistant.git
cd metabase-ai-assistant

# Install dependencies
npm install

# Create environment file
cp .env.example .env

Configuration

Edit the .env file with your credentials:

# Metabase Configuration
METABASE_URL=http://your-metabase-instance.com
METABASE_USERNAME=your_username
METABASE_PASSWORD=your_password
METABASE_API_KEY=your_metabase_api_key

# AI Provider (at least one required)
ANTHROPIC_API_KEY=your_anthropic_key
# or
OPENAI_API_KEY=your_openai_key

# Application Settings
LOG_LEVEL=info

Claude Desktop Integration

To integrate with Claude Desktop:

Step 1: Edit Claude Desktop Config

Edit the configuration file located at ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "metabase-ai-assistant": {
      "command": "node",
      "args": ["/path/to/your/metabase-ai-assistant/src/mcp/server.js"],
      "env": {
        "METABASE_URL": "http://your-metabase-instance.com",
        "METABASE_USERNAME": "your_username",
        "METABASE_PASSWORD": "your_password",
        "ANTHROPIC_API_KEY": "your_anthropic_key"
      }
    }
  }
}

Step 2: Restart Claude Desktop

After saving the configuration, restart Claude Desktop to activate the MCP tools.

Claude Code Integration

For Claude Code integration:

Step 1: Global Installation

# Install the MCP server globally
npm link

# Verify installation
which metabase-ai-mcp
npm list -g | grep metabase-ai-assistant

Step 2: Environment Setup

Ensure your .env file is properly configured with your Metabase credentials.

Step 3: Test MCP Server

# Test the MCP server directly
node src/mcp/server.js

# Test with environment variables
export METABASE_URL="http://your-instance.com"
export METABASE_USERNAME="your_username"
export METABASE_PASSWORD="your_password"
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | node src/mcp/server.js

Step 4: Verify Integration

In Claude Code, ask: "What MCP tools do you have available?"

You should see 27 Metabase AI Assistant tools available, including database tools, Metabase tools, AI-powered tools, and documentation tools.

Usage

Interactive CLI

Start the interactive command-line interface:

npm start

Programmatic Usage

import { MetabaseClient } from './src/metabase/client.js';
import { MetabaseAIAssistant } from './src/ai/assistant.js';

// Create client
const client = new MetabaseClient({
  url: 'http://your-metabase.com',
  username: 'user',
  password: 'pass'
});

// Initialize AI Assistant
const assistant = new MetabaseAIAssistant({
  metabaseClient: client,
  aiProvider: 'anthropic',
  anthropicApiKey: 'your-key'
});

// Create model
const model = await assistant.createModel(
  'Customer segmentation model',
  databaseId
);

// Generate SQL query
const sql = await assistant.generateSQL(
  'Total sales for the last 30 days',
  schema
);

Example Scenarios

E-Commerce Dashboard

// Create sales model
await assistant.createModel(
  'Daily sales summary - product, category, amount',
  databaseId
);

// Define metrics
await assistant.createMetric(
  'Average basket value',
  tableId
);

// Create dashboard
await assistant.createDashboard(
  'E-Commerce Executive Panel',
  questions
);

Customer Analysis

// Customer segmentation query
const sql = await assistant.generateSQL(
  'Customer segments using RFM analysis',
  schema
);

// Churn prediction model
await assistant.createModel(
  'Customer churn prediction model',
  databaseId
);

Financial Reporting

// Income-expense analysis
await assistant.createQuestion(
  'Monthly profit-loss statement',
  databaseId
);

// Budget comparison dashboard
await assistant.createDashboard(
  'Budget vs Actual',
  budgetQuestions
);

Production Deployment

Using PM2 Process Manager (Recommended)

# Install PM2 globally
npm install -g pm2

# Start MCP server with PM2
npm run pm2:start

# Monitor and manage
npm run pm2:logs
npm run pm2:restart
npm run pm2:stop

# Auto-restart on system reboot
pm2 startup
pm2 save

Using Docker Container

# Build and run with Docker Compose
npm run docker:run

# Monitor logs
npm run docker:logs

# Stop containers
npm run docker:stop

Using Systemd Service (Linux)

# Copy service file
sudo cp metabase-ai-mcp.service /etc/systemd/system/

# Enable and start service
sudo systemctl enable metabase-ai-mcp
sudo systemctl start metabase-ai-mcp

# Monitor service
sudo systemctl status metabase-ai-mcp
sudo journalctl -u metabase-ai-mcp -f

Troubleshooting

Connection Errors

  • Verify Metabase URL is accessible
  • Ensure API key and credentials are valid
  • Check network connectivity and firewall settings
  • Confirm environment variables are properly set

MCP Integration Issues

  • Ensure npm link was run successfully
  • Verify MCP server binary is in PATH: which metabase-ai-mcp
  • Check environment variables are exported: echo $METABASE_URL
  • Test MCP server directly: node src/mcp/server.js
  • Restart Claude Code after global installation

Query Errors

  • Validate SQL syntax and formatting
  • Verify table and column names exist
  • Check database permissions and schema access
  • Ensure proper schema selection for operations

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "metabase-ai-assistant" '{"command":"node","args":["/path/to/your/metabase-ai-assistant/src/mcp/server.js"],"env":{"METABASE_URL":"http://your-metabase-instance.com","METABASE_USERNAME":"your_username","METABASE_PASSWORD":"your_password","ANTHROPIC_API_KEY":"your_anthropic_key"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "metabase-ai-assistant": {
            "command": "node",
            "args": [
                "/path/to/your/metabase-ai-assistant/src/mcp/server.js"
            ],
            "env": {
                "METABASE_URL": "http://your-metabase-instance.com",
                "METABASE_USERNAME": "your_username",
                "METABASE_PASSWORD": "your_password",
                "ANTHROPIC_API_KEY": "your_anthropic_key"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "metabase-ai-assistant": {
            "command": "node",
            "args": [
                "/path/to/your/metabase-ai-assistant/src/mcp/server.js"
            ],
            "env": {
                "METABASE_URL": "http://your-metabase-instance.com",
                "METABASE_USERNAME": "your_username",
                "METABASE_PASSWORD": "your_password",
                "ANTHROPIC_API_KEY": "your_anthropic_key"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later