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.
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
-
Clone or navigate to the project directory:
cd metabase-mcp-mab -
Install dependencies:
npm install -
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 tohttps://data-metabase.swile.coMETABASE_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
- Log into your Metabase instance
- Go to Settings → Account Settings → API Keys
- Create a new API key or use an existing one
- Copy the key and add it to your
mcp.jsonconfiguration
📖 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 querylist_cards- List cards with filteringexecute_card_query- Execute saved queriesexecute_query_builder_card- Execute query builder cards with parametersget_generated_sql- Get generated SQL for query builder cardsget_card_with_parameters- Extract card info from dashboard URLs
Dashboard Tools
get_dashboard- Get dashboard detailslist_dashboards- List all dashboards
Database & Table Tools
get_database- Get database informationlist_databases- List all databasesget_database_metadata- Get comprehensive database schemalist_database_tables- List tables in a databaseget_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 informationget_field_values- Get distinct values for a field
Segments & Metrics
list_segments- List saved filter segmentslist_metrics- List saved aggregations
Activity & Users
get_activity- Get recent activity feedget_current_user- Get current authenticated userlist_users- List all users (requires admin)
For detailed documentation on all tools, see TOOLS_REFERENCE.md.
📚 Documentation
- USAGE_GUIDE.md - Complete usage guide with examples
- TOOLS_REFERENCE.md - Detailed reference for all 27 tools
🏗️ 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 servernpm run dev- Run the server with auto-reload (watch mode)
Dependencies
@modelcontextprotocol/sdk- MCP SDK frameworkaxios- HTTP client library (though nativefetchis 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_cardscan return 15k+ items - results are limited to first 50 in displayget_database_metadatareturns ALL tables and columns - can be very largeexecute_card_queryandexecute_native_querymay 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
-
Check Node.js version:
node --version # Must be >= 18.0.0 -
Verify dependencies are installed:
npm install -
Check environment variables:
- Ensure
METABASE_API_KEYis set inmcp.json - Verify
METABASE_URLis correct (if custom)
- Ensure
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
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。