---
title: "Connect Metabase to ChatGPT: Run Queries & Manage Dashboards"
slug: connect-metabase-to-chatgpt-run-queries-manage-dashboards
date: 2026-10-25
author: Uday Gajavalli
categories: ["AI & Agents"]
excerpt: "Learn how to securely connect Metabase to ChatGPT using Truto's MCP Server. Enable AI agents to run SQL, manage dashboards, and query analytics data."
tldr: "Connect Metabase to ChatGPT via an auto-generated Truto MCP Server. This guide shows how to expose Metabase APIs to LLMs securely, configure tool access, and execute autonomous data workflows."
canonical: https://truto.one/blog/connect-metabase-to-chatgpt-run-queries-manage-dashboards/
---

# Connect Metabase to ChatGPT: Run Queries & Manage Dashboards


If you need to connect Metabase to ChatGPT so your AI agents can run raw SQL queries, generate live dashboards, search internal data catalogs, and dynamically answer analytical questions, you need a [Model Context Protocol (MCP) server](https://truto.one/what-is-mcp-and-mcp-servers-and-how-do-they-work/). This server acts as the translation layer between ChatGPT's JSON-RPC tool calls and Metabase's complex REST API. You can either build and maintain this infrastructure yourself, or use a managed integration platform like [Truto](https://truto.one/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/) to dynamically generate a secure, authenticated MCP server URL.

If your team uses Claude, check out our guide on [connecting Metabase to Claude](https://truto.one/connect-metabase-to-claude-build-reports-audit-data-usage/) or explore our broader architectural overview on [connecting Metabase to AI Agents](https://truto.one/connect-metabase-to-ai-agents-control-sql-data-permissions/).

Giving a Large Language Model (LLM) read and write access to a BI platform like Metabase is a massive engineering challenge. You have to handle abstract query compilation payloads (MBQL), deeply nested visualization schemas, and strict data access policies. Every time a new chart type or parameter is added, your custom server code must be updated, redeployed, and tested.

This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for Metabase, connect it natively to ChatGPT, and execute complex analytical workflows using natural language.

> Stop writing boilerplate API integration code. Let Truto generate secure, managed MCP servers for your AI agents in seconds.
>
> [Talk to us](https://truto.one/book-a-demo/)

## The Engineering Reality of the Metabase API

A [custom MCP server](https://truto.one/what-is-mcp-and-mcp-servers-and-how-do-they-work/) is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, implementing it against Metabase's analytical API surface is exceptionally painful. 

If you decide to build a custom MCP server for Metabase, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Metabase:

### MBQL vs. Native SQL Compilation
Metabase is fundamentally driven by the Metabase Query Language (MBQL). When an LLM wants to interact with data, it usually generates raw SQL. However, passing raw SQL into Metabase requires specific wrappers and base64 encoding (e.g., via the `/api/agent/construct_native_query` or `/api/agent/v1/execute_sql` endpoints). If your MCP server doesn't map the LLM's SQL output perfectly into Metabase's expected execution schema, the query compiler will reject the request with an opaque 400 error. 

### Nested Dashcard execution
Executing a saved query or filtering a dashboard isn't a matter of appending `?date=today` to a GET request. Metabase dashboards contain "Dashcards" which have specific parameter mapping graphs. To filter a dashboard via the API, your server must resolve the parameter mapping, identify the correct underlying `dashcard_id`, and submit the values in a highly specific JSON payload. 

### Rate Limiting and Analytical Compute
Running large analytical queries consumes massive compute resources on the underlying data warehouse. Metabase APIs are heavily rate-limited to protect the instance. **It is critical to note how Truto handles this:** Truto does not retry, throttle, or apply backoff on rate limit errors. When an upstream API returns HTTP 429, Truto passes that error directly to the caller. Truto normalizes upstream rate limit info into standardized headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`) per the IETF spec. The caller (or the LLM orchestration framework) is entirely responsible for implementing retry and backoff logic. Do not build an agent that assumes the middleware will absorb 429s.

## Connecting Metabase to ChatGPT (Step-by-Step)

Instead of building a server from scratch, you can use Truto to generate a [documentation-driven MCP endpoint](https://truto.one/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/). Truto derives the tool definitions directly from Metabase's API schema, ensuring that ChatGPT always has the correct JSON Schema for queries and request bodies.

### Step 1: Connect Metabase as an Integrated Account
First, you need to establish a secure connection to your Metabase instance. In the Truto dashboard, navigate to **Integrated Accounts**, select Metabase, and input your API credentials or session tokens. Truto securely vaults these credentials, meaning the LLM never sees your raw API keys.

Grab your `integrated_account_id`. You can copy this from the Truto UI or via the API:

```bash
curl https://api.truto.one/integrated-account \
  -H "Authorization: Bearer $TRUTO_API_TOKEN"
```

### Step 2: Generate the MCP Server
Truto creates a unique, dedicated server endpoint for this specific Metabase connection.

**Method A: Via the Truto UI**
1. Navigate to the integrated account page for your Metabase connection.
2. Click the **MCP Servers** tab.
3. Click **Create MCP Server**.
4. Select your desired configuration (e.g., allowed methods like `read` or `custom`, and tags like `dashboards` or `queries`).
5. Click create and copy the generated MCP server URL (e.g., `https://api.truto.one/mcp/a1b2c3...`).

**Method B: Via the API**
You can programmatically generate the server. This scopes the server to specific endpoints to prevent the LLM from executing destructive actions.

```bash
curl -X POST https://api.truto.one/integrated-account/$INTEGRATED_ACCOUNT_ID/mcp \
  -H "Authorization: Bearer $TRUTO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Metabase SQL Agent",
    "config": {
      "methods": ["read", "write", "custom"],
      "tags": ["agent", "dashboards", "queries"]
    }
  }'
```
The response will return the secure URL. Treat this URL as a secret - it contains a hashed routing token that authenticates the connection.

### Step 3: Connect the Server to ChatGPT
Now you must point your ChatGPT client to the newly created Truto MCP server.

**Method A: Via the ChatGPT UI**
1. Open ChatGPT and navigate to **Settings -> Apps -> Advanced settings**.
2. Enable **Developer mode** (MCP support requires this flag on Pro, Plus, Business, Enterprise, or Education accounts).
3. Under **MCP servers / Custom connectors**, click add a new server.
4. Set the **Name** (e.g., "Metabase Agent").
5. Paste the Truto MCP URL into the **Server URL** field and save. ChatGPT will instantly handshake with Truto and load the available Metabase tools.

**Method B: Via Manual Config File (for local dev or Claude Desktop)**
If you are running a local orchestrator or Claude Desktop, you can configure the MCP connection using the server-sse transport layer:

```json
{
  "mcpServers": {
    "metabase-truto": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/YOUR_TRUTO_TOKEN"
      ]
    }
  }
}
```

## Metabase Hero Tools for AI Agents

When you connect Metabase to ChatGPT via Truto, the LLM gains access to highly specific API endpoints. Because Truto's tools share a flat input namespace, the LLM just passes arguments, and Truto automatically maps them to the correct query string or JSON body properties. 

Here are the most powerful tools available for your agent workflows:

### metabase_agents_search
Search Metabase for tables, models, metrics, saved questions, and dashboards. This tool is vital for agent context-gathering. Before an agent writes a SQL query, it should search the semantic layer to find the correct table IDs and existing metrics, avoiding hallucinations.

> "Search Metabase for all tables related to 'subscription revenue' and list their IDs."

### create_a_metabase_agent_execute_sql
Execute a raw SQL query against a connected Metabase database. The tool requires the `database_id` and the `sql` string. Truto handles the translation to Metabase's specific execution envelope, returning the data rows, column metadata, and execution time.

> "Run a SQL query on database ID 4 to select the top 10 customers by total spend over the last 30 days."

### create_a_metabase_agent_question
Save a previously constructed query as a named question (card) in Metabase. This turns an ad-hoc LLM analysis into a persistent asset that other human team members can view. You must supply the `name` and the `query` object.

> "Save the query results we just generated as a new question named 'Top 10 Customers Last 30 Days' in the root collection."

### create_a_metabase_agent_dashboard
Create a new Metabase dashboard, optionally populated with existing saved questions passed as an array of `question_ids`. Metabase will automatically position the cards on the grid based on their display type.

> "Create a new dashboard named 'Q3 Executive Summary' and add the questions with IDs 105, 106, and 108 to it."

### create_a_metabase_query
Run the query associated with an existing Metabase card. If the LLM knows a card exists that already computes a complex metric (like MRR or Churn), it can execute this tool instead of rewriting the SQL from scratch.

> "Run the query for card ID 250 (Monthly Churn Rate) and summarize the results for the last quarter."

### list_all_metabase_dashboards
Fetch a list of all dashboards available in the Metabase instance. This includes the dashboard `id`, `name`, and `collection_id`, giving the LLM a map of the existing reporting infrastructure.

> "List all dashboards in Metabase, then find the ID for the 'Marketing KPIs' dashboard."

For a complete list of all available Metabase tools, including schema definitions and required parameters, visit the [Truto Metabase integration page](https://truto.one/integrations/detail/metabase).

## Workflows in Action

Exposing individual endpoints is useful, but the real power of connecting Metabase to ChatGPT via MCP comes from multi-step autonomous workflows. Here is how specific personas use these tools in production.

### Scenario 1: The Zero-to-Dashboard Pipeline (Data Analyst)
An analyst needs to quickly spin up a new dashboard for a marketing campaign but doesn't want to write the SQL and arrange the UI manually.

> "Search our Metabase instance for tables related to 'Campaign Conversions'. Write a SQL query to get the daily conversion rate for the last week on that table, save it as a new question, and put that question onto a brand new dashboard called 'Weekly Campaign Health'."

**How the agent executes this:**
1. Calls `metabase_agents_search` with the query "Campaign Conversions" to locate the correct `database_id` and table structure.
2. Calls `create_a_metabase_agent_execute_sql` to test the SQL syntax and ensure data returns correctly.
3. Calls `create_a_metabase_agent_question` using the validated SQL to persist the card in Metabase.
4. Calls `create_a_metabase_agent_dashboard` passing the newly created question ID to generate the final dashboard asset.

```mermaid
sequenceDiagram
    participant Agent as AI Agent
    participant Truto as Truto MCP
    participant Metabase as Metabase API
    
    Agent->>Truto: metabase_agents_search("Campaign Conversions")
    Truto->>Metabase: GET /api/search
    Metabase-->>Agent: Returns table ID and schema
    
    Agent->>Truto: create_a_metabase_agent_execute_sql(db_id, sql)
    Truto->>Metabase: POST /api/agent/v1/execute_sql
    Metabase-->>Agent: Returns query results
    
    Agent->>Truto: create_a_metabase_agent_question(name, query)
    Truto->>Metabase: POST /api/agent/question
    Metabase-->>Agent: Returns question ID (e.g., 402)
    
    Agent->>Truto: create_a_metabase_agent_dashboard(name, question_ids: [402])
    Truto->>Metabase: POST /api/agent/dashboard
    Metabase-->>Agent: Dashboard created successfully
```

### Scenario 2: Ad-Hoc Executive Q&A (Revenue Ops)
A RevOps leader needs an immediate answer based on existing verified reporting logic, rather than risking the LLM writing a flawed SQL query.

> "Find the 'Enterprise Sales Pipeline' card in Metabase, run it, and tell me the total pipeline value for Q4. Then, disable the user account for 'john.doe@company.com' since he just left the team."

**How the agent executes this:**
1. Calls `metabase_agents_search` to find the exact `card_id` for "Enterprise Sales Pipeline".
2. Calls `create_a_metabase_query` using that `card_id` to retrieve the cached or live data matrix, summarizing the output.
3. Calls `list_all_metabase_users` to find the internal `id` mapping for john.doe@company.com.
4. Calls `delete_a_metabase_user_by_id` to securely disable the user's Metabase access.

## Security and Access Control

When connecting ChatGPT to a data platform like Metabase, security is paramount. Truto MCP servers operate entirely on a pass-through architecture - Truto does not retain or cache your LLM payloads or API responses. 

You can tightly control the MCP server using Truto's configuration parameters during creation:

* **Method Filtering:** Restrict the server to safe operations. By passing `"methods": ["read"]` during server creation, you ensure the LLM can only execute `get` and `list` operations (e.g., running queries), physically blocking it from creating or deleting resources.
* **Tag Filtering:** Constrain the LLM to specific API domains. Passing `"tags": ["dashboards"]` ensures the LLM only sees tools related to dashboard operations, hiding user-management or system-level APIs.
* **Time-to-Live (`expires_at`):** For temporary workflows, you can set an ISO datetime for the server to automatically self-destruct, supported by scheduled infrastructure alarms.
* **Dual Authentication (`require_api_token_auth`):** For enterprise environments, possessing the MCP URL is not enough. Enabling this flag requires the MCP client to also pass a valid Truto API Bearer token in the connection headers.

Connecting Metabase to ChatGPT transforms a static BI tool into a proactive, conversational data layer. By leveraging Truto to auto-generate and manage the underlying MCP server, engineering teams can skip the weeks of writing schema mappers and dealing with base64 MBQL compilation, and go straight to building agentic data workflows.
