Skip to main content
Glama
Metabase MCP Server

Metabase MCP Server

by MikelA92

Metabase MCP Server

A Model Context Protocol (MCP) server that enables LLMs to interact with your Metabase instance. This server provides 33 tools for querying cards, dashboards, databases, collections, and executing queries against your Metabase installation.

šŸš€ Quick Start

Prerequisites

  • Node.js >= 18.0.0 (required by @modelcontextprotocol/sdk)

  • npm (comes with Node.js)

Installation

  1. Clone or navigate to the project directory:

    cd metabase-mcp-mab
  2. Install dependencies:

    npm install
  3. Verify Node.js version:

    node --version  # Should be >= 18.0.0

Configuration

The server requires environment variables to be set. When using with Cursor/Claude Desktop, configure these in your ~/.cursor/mcp.json file:

{
  "mcpServers": {
    "metabase-local": {
      "command": "node",
      "args": ["/path/to/metabase-mcp-mab/src/server/index.js"],
      "env": {
        "METABASE_URL": "https://your-metabase-instance.com",
        "METABASE_API_KEY": "your-api-key-here"
      }
    }
  }
}

Environment Variables

  • METABASE_URL (optional): Your Metabase instance URL. Defaults to https://data-metabase.swile.co

  • METABASE_API_KEY (required): Your Metabase API key. Must be provided - no default value for security.

Note: The API key is required and must be provided via environment variables. There is no hardcoded default for security reasons.

Getting Your Metabase API Key

  1. Log into your Metabase instance

  2. Go to Settings → Account Settings → API Keys

  3. Create a new API key or use an existing one

  4. Copy the key and add it to your mcp.json configuration

Related MCP server: Metabase MCP Server

šŸ“– Usage

With Cursor/Claude Desktop

Once configured in mcp.json, you can ask LLMs questions like:

"Get the SQL query for card ID 17033"
"List all cards in the database"
"Show me cards related to revenue"
"Execute card 17033 with parameters"
"What databases are available?"

Direct Server Usage

Run the server directly:

npm start

Or run in development mode with auto-reload:

npm run dev

Programmatic Usage

import { createDefaultClient } from './src/client/cards.js';

const client = createDefaultClient();

// Get a specific card
const card = await client.getCard(17033);
console.log(card.sqlQuery);

// List all cards
const cards = await client.listCards('all');

// Search for cards
const revenueCards = await client.searchCards('revenue');

// Execute a query
const results = await client.executeCardQuery(17033, {param: 'value'});

šŸ› ļø Available Tools

This MCP server provides 27 tools organized into categories:

Card Tools (Questions/Queries)

  • get_card - Get card details and SQL query

  • list_cards - List cards with filtering

  • execute_card_query - Execute saved queries

  • execute_query_builder_card - Execute query builder cards with parameters

  • get_generated_sql - Get generated SQL for query builder cards

  • get_card_with_parameters - Extract card info from dashboard URLs

Dashboard Tools

  • get_dashboard - Get dashboard details

  • list_dashboards - List all dashboards

Database & Table Tools

  • get_database - Get database information

  • list_databases - List all databases

  • get_database_metadata - Get comprehensive database schema

  • list_database_tables - List tables in a database

  • get_table_metadata - Get detailed table information

Collection Tools

  • list_collections - List all collections (folders)

  • get_collection_items - Get items in a collection

Query Execution

  • execute_native_query - Execute custom SQL queries

Field & Column Tools

  • get_field - Get field/column information

  • get_field_values - Get distinct values for a field

Segments & Metrics

  • list_segments - List saved filter segments

  • list_metrics - List saved aggregations

Activity & Users

  • get_activity - Get recent activity feed

  • get_current_user - Get current authenticated user

  • list_users - List all users (requires admin)

For detailed documentation on all tools, see TOOLS_REFERENCE.md.

šŸ“š Documentation

šŸ—ļø Project Structure

metabase-mcp-mab/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ server/
│   │   └── index.js          # Main MCP server implementation
│   └── client/
│       └── cards.js           # JavaScript client library
ā”œā”€ā”€ testing/
│   └── test-new-tools.js     # Test scripts
ā”œā”€ā”€ package.json              # Dependencies and scripts
ā”œā”€ā”€ README.md                 # This file
ā”œā”€ā”€ USAGE_GUIDE.md            # Usage documentation
└── TOOLS_REFERENCE.md        # Tools reference

šŸ”§ Development

Scripts

  • npm start - Run the server

  • npm run dev - Run the server with auto-reload (watch mode)

Dependencies

  • @modelcontextprotocol/sdk - MCP SDK framework

  • axios - HTTP client library (though native fetch is used)

  • dotenv - Environment variable management

Testing

Run test scripts:

node testing/test-new-tools.js

āš ļø Important Notes

Risk Levels

  • 🟢 SAFE tools: Read-only operations, no data modification

  • 🟔 MODERATE RISK tools: Execute queries (read-only but may be slow/resource-intensive)

Performance Considerations

  • list_cards can return 15k+ items - results are limited to first 50 in display

  • get_database_metadata returns ALL tables and columns - can be very large

  • execute_card_query and execute_native_query may take time for complex queries

  • Use search operations instead of listing everything when possible

Version Compatibility

Some tools may not be available in all Metabase versions (e.g., list_metrics, get_activity). The server gracefully handles missing endpoints.

šŸ› Troubleshooting

Server won't start

  1. Check Node.js version:

    node --version  # Must be >= 18.0.0
  2. Verify dependencies are installed:

    npm install
  3. Check environment variables:

    • Ensure METABASE_API_KEY is set in mcp.json

    • Verify METABASE_URL is correct (if custom)

API authentication errors

  • Verify your API key is correct and active

  • Check that the API key has the necessary permissions

  • Ensure the Metabase URL is accessible from your network

Connection issues

  • Verify your Metabase instance is running and accessible

  • Check network connectivity

  • Ensure firewall rules allow connections

šŸ“ License

ISC

šŸ¤ Contributing

Contributions welcome! Please ensure:

  • Node.js >= 18.0.0

  • All tests pass

  • Code follows existing patterns

Available Tools

23 tools
execute_card_queryA

ā–¶ļø [MODERATE RISK] Execute a saved card query and return results. Use this to get actual data from a card. May take time for complex queries. Risk: Moderate - executes queries that may be slow or resource-intensive. Does not modify data.

Inputs: cardId (required), parameters.

execute_native_queryA

āš ļø [MODERATE RISK] Execute an ad-hoc native SQL query directly against a database. Use this when you need to run custom SQL that doesn't exist as a saved card. Risk: Moderate - executes arbitrary SQL (read-only with API key, but can be slow or resource-intensive). Always validate SQL before executing.

Inputs: databaseId (required), query (required).

execute_query_builder_cardA

āš™ļø [MODERATE RISK] Execute a query-builder card with specific parameters. Use this to run query builder cards with custom filters and aggregations. Risk: Moderate - executes queries that may be slow or resource-intensive.

Inputs: cardId (required), parameters (required).

get_activityA

šŸ“œ [SAFE] Get recent activity feed showing views, edits, and other actions in Metabase. Use this to see what users are doing or what content is popular. Risk: None - read-only operation.

Inputs: limit.

get_cardA

šŸ” [SAFE] Get a Metabase card/question by ID, including its SQL query. Use this when you need to see the SQL behind a specific question or analyze how a card is built. Risk: None - read-only operation.

Inputs: cardId (required).

get_card_with_parametersA

šŸ”— [SAFE] Get a card with applied parameters from dashboard URL. Use this to extract card ID and parameters from Metabase dashboard URLs with filters. Risk: None - read-only operation.

Inputs: url (required).

get_collection_itemsA

šŸ“ [SAFE] Get all items (cards, dashboards, models) in a specific collection. Use this to see what content is organized in a folder. Risk: None - read-only operation.

Inputs: collectionId (required), models.

get_current_userA

šŸ‘¤ [SAFE] Get information about the currently authenticated user (you). Risk: None - read-only operation.

Inputs: no named parameters.

get_dashboardA

šŸ“Š [SAFE] Get a dashboard by ID including all its cards, layout, and parameters. Use this to understand dashboard structure or see all questions in a dashboard at once. Risk: None - read-only operation.

Inputs: dashboardId (required).

get_databaseA

šŸ—„ļø [SAFE] Get database information by ID including engine type and connection details. Use this to understand which database a card connects to. Risk: None - read-only operation.

Inputs: databaseId (required).

get_database_metadataA

šŸ” [SAFE] Get complete metadata for a database including ALL tables, columns, and field types. This is comprehensive and may return large amounts of data. Use this when you need to understand the full database schema. Risk: None - read-only, but returns large payloads.

Inputs: databaseId (required).

get_fieldA

šŸ” [SAFE] Get detailed information about a specific field/column including its type, description, and metadata. Use this to understand what a column contains. Risk: None - read-only operation.

Inputs: fieldId (required).

get_field_valuesA

šŸ” [SAFE] Get distinct values for a field (useful for understanding what values exist in a column). May return many values for high-cardinality fields. Risk: None - read-only, but may return large results.

Inputs: fieldId (required).

get_generated_sqlA

šŸ“ [MODERATE RISK] Get the generated SQL for a query-builder card with parameters. Use this to see the actual SQL that Metabase generates from query builder parameters. Risk: Moderate - executes queries to generate SQL.

Inputs: cardId (required), parameters (required).

get_table_metadataA

šŸ” [SAFE] Get detailed metadata for a specific table including all columns, data types, and foreign key relationships. Use this to understand table structure before writing queries. Risk: None - read-only operation.

Inputs: tableId (required).

list_cardsA

šŸ“‹ [SAFE] List Metabase cards/questions with optional filtering. Use this to discover available cards, find cards by type, or see all questions in the system. Can return large results (15k+ cards). Risk: None - read-only, but may be slow with many cards.

Inputs: filter, modelId.

list_collectionsA

šŸ“ [SAFE] List all collections (folders) in Metabase. Collections organize cards and dashboards. Use this to understand the organizational structure. Risk: None - read-only operation.

Inputs: namespace.

list_dashboardsA

šŸ“Š [SAFE] List all dashboards in Metabase. Use this to discover available dashboards or find dashboards by name. Risk: None - read-only operation.

Inputs: no named parameters.

list_databasesA

šŸ—„ļø [SAFE] List all available databases. Use this to see what data sources are connected to Metabase. Risk: None - read-only operation.

Inputs: no named parameters.

list_database_tablesA

šŸ“‘ [SAFE] List all tables in a specific database. Use this to see what tables are available before querying. Risk: None - read-only operation.

Inputs: databaseId (required).

list_metricsA

šŸ“Š [SAFE] List all metrics (saved aggregations) in Metabase. Metrics are reusable calculations like "Total Revenue" or "Average Order Value". Risk: None - read-only operation.

Inputs: no named parameters.

list_segmentsA

šŸŽÆ [SAFE] List all segments (saved filters) in Metabase. Segments are reusable filters like "Active Users" or "Premium Customers". Risk: None - read-only operation.

Inputs: no named parameters.

list_usersA

šŸ‘„ [SAFE - REQUIRES ADMIN] List all Metabase users. Requires admin permissions. Use this to see who has access to Metabase. Risk: None - read-only, but may fail if not admin.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 23 tools

    Disambiguation3/5

    Most tools have distinct purposes, but there is notable overlap among query execution tools (execute_card_query, execute_native_query, execute_query_builder_card) and metadata retrieval tools (get_database_metadata, get_table_metadata, get_field, get_field_values), which could cause confusion. Descriptions help differentiate them, but the boundaries are not entirely clear.

    Naming Consistency5/5

    Tool names follow a highly consistent verb_noun pattern throughout, with clear prefixes like 'execute_', 'get_', and 'list_'. There are no deviations in naming conventions, making the set predictable and easy to navigate.

    Tool Count3/5

    With 23 tools, the count feels heavy for a Metabase interface, as many tools are read-only metadata retrievals that could potentially be consolidated. While it covers many aspects, it borders on being overly granular for the domain.

    Completeness4/5

    The tool set provides comprehensive read-only coverage for querying, metadata, and listing resources in Metabase, with no major gaps for data retrieval. However, it lacks write operations (e.g., creating or updating cards, dashboards, or collections), which limits full lifecycle management.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Metabase analytics platform, allowing them to query databases, manage dashboards and cards, execute SQL queries, and access analytics data through natural language.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Metabase analytics platform, allowing users to query databases, manage dashboards and cards, execute SQL queries, and access analytics data through natural language.
      1
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Metabase analytics platform, allowing them to query databases, execute SQL, manage dashboards and cards, and access analytics data through natural language.
      -
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to interact with Metabase by providing access to dashboards, questions, and databases through the Metabase API. It allows users to list resources, execute existing cards, and run custom SQL queries to retrieve data through natural language.
      15 npm
      -