USAGE_GUIDE.mdā¢3.88 kB
# š Metabase MCP Server - Complete Usage Guide
## ā
 What You Have Now
You now have a **fully functional MCP server** that allows LLMs to interact with your Metabase instance! Here's what's working:
### **ā
 Server Features**
- **5 MCP Tools** available for LLM interaction
- **API Key Authentication** with your Metabase instance
- **Comprehensive Error Handling**
- **SQL Query Extraction** from Metabase cards
### **ā
 Client Library**
- **Complete JavaScript client** for direct API usage
- **All Metabase endpoints** covered
- **Search and filtering** capabilities
- **Connection testing**
---
## šÆ How to Use This MCP Server
### **Method 1: With Cursor/Claude Desktop (Recommended)**
Your MCP server is already configured in `~/.cursor/mcp.json` as `metabase-local`. 
**To use it, simply ask me (or any LLM) 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"
```
**The LLM will automatically use these tools:**
- `get_card` - Get card details and SQL
- `list_cards` - List cards with filtering
- `execute_card_query` - Execute queries
- `get_database` - Get database info
- `list_databases` - List all databases
### **Method 2: Direct Client Usage**
```javascript
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'});
```
### **Method 3: Test Script**
Run the demo to see everything in action:
```bash
cd /Users/michel.abifadel/Documents/dev_ai/metabase-mcp-mab
node demo.js
```
---
## š§ Configuration
### **Environment Variables**
The server **requires** these environment variables to be set:
- `METABASE_URL` - Your Metabase instance URL (optional, defaults to `https://data-metabase.swile.co`)
- `METABASE_API_KEY` - Your API key (**required**)
### **Configuration via mcp.json**
When using with Cursor/Claude Desktop, configure these in your `~/.cursor/mcp.json` file:
```json
{
  "mcpServers": {
    "metabase-local": {
      "command": "node",
      "args": ["/path/to/metabase-mcp-mab/src/server/index.js"],
      "env": {
        "METABASE_URL": "https://data-metabase.swile.co",
        "METABASE_API_KEY": "your-api-key-here"
      }
    }
  }
}
```
**Note**: The API key is required and must be provided via environment variables. There is no hardcoded default for security reasons.
---
## š What You Can Do Now
### **1. Ask LLMs to analyze your data:**
```
"Show me the SQL query for the '1pact_par boutique' card"
"What cards are related to revenue analysis?"
"Execute the card with ID 17033 and show me the results"
```
### **2. Use the client programmatically:**
```javascript
// Get SQL from any card
const sql = await client.getCardSQL(17033);
// Find cards by database
const snowflakeCards = await client.getCardsByDatabase(8);
// Search for specific topics
const giftCards = await client.searchCards('gift');
```
### **3. Integrate with other tools:**
- Use the MCP server with any LLM that supports MCP
- Build dashboards that pull SQL from Metabase
- Create automated reports using the client
---
## š Success! 
Your MCP server is **fully functional** and ready to use! The demo showed:
ā
 **Connection successful**  
ā
 **20 databases found**  
ā
 **15,880 cards available**  
ā
 **SQL queries extracted** (like the complex 1pact query)  
ā
 **Search functionality working** (162 revenue-related cards found)
**You can now ask me to analyze any Metabase card, get SQL queries, or help you explore your data!**