Metabase MCP Server

Metabase MCP Server

Enables LLMs to interact with Metabase instances through 33 tools for querying cards, dashboards, databases, collections, and executing SQL queries against your Metabase installation.

Category
访问服务器

README

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

📖 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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选