Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

docs - mcp edits (#76627)

Jeff Bruemmerf941dc5964a6
diff --git a/docs/ai/images/inline-bar-chart.png b/docs/ai/images/inline-bar-chart.png
new file mode 100644
index 00000000000..a5e766d90ca
Binary files /dev/null and b/docs/ai/images/inline-bar-chart.png differ
diff --git a/docs/ai/mcp.md b/docs/ai/mcp.md
index 1f58b56ada2..23ecae925e0 100644
--- a/docs/ai/mcp.md
+++ b/docs/ai/mcp.md
@@ -7,57 +7,128 @@ summary: Connect MCP-compatible AI clients to Metabase to search, explore, and q
![A metric viewed through an MCP client connected to Metabase](./images/metric-in-mcp.png)
-Metabase includes an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server (using Streamable HTTP transport) that lets AI clients connect directly to your Metabase, all scoped to the connecting person's permissions.
+Metabase includes an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server that lets AI clients connect directly to your Metabase, all scoped to the connecting person's permissions.
-## Enable MCP server
+## Connect a client to your Metabase MCP server's URL
-_Admin > AI > MCP_
+Your Metabase's MCP server is served from the `/api/metabase-mcp` endpoint.
-MCP server and Agent API settings live on their own subpage. From **Admin > AI**, open the **MCP** tab in the left sidebar.
+If your admin has turned on [your Metabase's MCP server](#enable-mcp-server), all you need to do is point your MCP client at your Metabase's MCP server's URL.
-Use the **MCP server** toggle to turn external access to the [MCP server](./mcp.md) on or off.
+```
+https://{your-metabase.example.com}/api/metabase-mcp
+```
-### Supported MCP clients
+Replace `{your-metabase.example.com}` with your Metabase's URL. Admins can also find your instance's MCP URL in **Admin > AI > MCP > Settings > MCP server URL**.
-Under **Supported MCP clients**, switch on any clients you want to allow:
+Your client will direct you to an authentication page for your Metabase.
-- **Claude** (Claude Desktop and Claude on the web)
-- **Cursor and VS Code**
-- **ChatGPT**, including **Codex**
-
-Toggling on a client automatically adds that client's sandbox domains to Metabase's CORS allowlist, which is what lets browser-based MCP clients make cross-origin requests to your Metabase.
+Once authenticated, you can approve or block the tools you want your Agent to have access to in your client (not in your Metabase).
-Some clients run outside the browser (like Claude Code on your own machine) and don't need a CORS allowlist entry. You can connect those clients without toggling anything on (assuming you've turned on the main MCP server setting).
+### Connecting Claude Code to your Metabase's MCP server
-### Custom MCP client domains
+To connect Claude Code:
-If you run a self-hosted MCP client, or a client that isn't in the supported list, add the client's domain to the **Custom MCP client domains** field. Separate values with a space, for example:
+1. Run a command to add the MCP server.
```
-https://mcp.internal.example.com https://*.staging.example.com
+claude mcp add --transport http metabase https://{your-metabase-url}/api/metabase-mcp
```
-The field accepts wildcards (`*`) for subdomains. Changes take effect in about a minute. Might be a good time to get up and pour yourself a glass of water.
+Replace `{your-metabase-url}` with your Metabase address.
-## Connect a client to your Metabase MCP server
+2. Start Claude Code with `claude`.
-If your admin has turned on [your Metabase's MCP server](#enable-mcp-server), all you need to do is point your MCP client at Metabase's MCP endpoint, `/api/metabase-mcp`. For example:
+3. In Claude Code, run `/mcp`.
-```
-https://{your-metabase.example.com}/api/metabase-mcp
-```
+4. Select the Metabase MCP server.
+
+5. Click **Authenticate**, and authenticate with your Metabase. (You may first need to **Enable** the Metabase MCP server).
+
+Once authenticated, ask your agent about your Metabase. You should see your agent use Metabase tools to interact with your Metabase.
+
+See [Claude Code MCP docs](https://code.claude.com/docs/en/mcp).
+
+### Connect via Claude web
+
+If you use Claude on the web or Claude Desktop, go to [Claude's connector directory](https://claude.ai/directory/connectors/metabase) and enter your [Metabase's MCP URL](#connect-a-client-to-your-metabase-mcp-servers-url).
+
+One of your Metabase admins will still need to have [turned on your Metabase's MCP server](#enable-mcp-server). You'll authenticate against your own Metabase during setup.
+
+## Available tools
+
+Some clients (like Claude Desktop) will ask you to approve each tool the first time it's used. We've grouped the tools below, but your client may simply list the available tools.
+
+### Interactive tools
+
+These render inline visualizations in your AI client, and only work in clients that support inline charts.
+
+- **Render drill through** (`render_drill_through`): Render the chart a person drilled into from an inline visualization.
+- **Visualize query** (`visualize_query`): Render a query's results as an inline chart in your AI client.
+
+### Read-only tools
+
+- **Construct query** (`construct_query`): Construct a query against a table or metric. Returns an opaque query handle that can be passed to `execute_query`.
+- **Execute query** (`execute_query`): Execute a previously constructed query and return the results with column metadata, row count, and execution time.
+- **Query tables and metrics** (`query`): Run a query and return results, paging through large result sets with a continuation token. Accepts a query handle from `construct_query`, a fresh query, or a continuation token. Paging returns up to 200 rows per page and 2,000 rows total.
+- **Read resource** (`read_resource`): Read up to five Metabase entities (or lists) per call by `metabase://` URI. List URIs (like a collection's items or a table's fields) return up to 25 items each. Entities available to read include:
+ - collection
+ - dashboard
+ - database
+ - metric
+ - model
+ - question
+ - schema
+ - table
+ - transform
+- **Search tables and metrics** (`search`): Find tables and metrics using keyword or natural language search.
+
+### Write/delete tools
+
+- **Create collection** (`create_collection`): Create a new collection, optionally nested under a parent collection.
+- **Create dashboard** (`create_dashboard`): Create a new dashboard, optionally populated with saved questions.
+- **Create question** (`create_question`): Save a query as a named question.
+- **Execute SQL** (`execute_sql`): Execute a raw SQL query against a database. Requires native-query permission on the target database. An admin can disable this tool instance-wide via the `mcp-execute-sql-enabled` setting (enabled by default).
+- **Update dashboard** (`update_dashboard`): Update a dashboard's metadata (name, description, collection, archived).
+- **Update question** (`update_question`): Update a saved question. Setting `collection_id` moves the question to another collection.
+
+## MCP server settings
+
+_Admin > AI > MCP_
+
+### Enable MCP server
+
+From **Admin > AI**, open the **MCP** tab in the left sidebar, and use the **MCP server** toggle to turn external access to the MCP server on or off.
+
+The MCP server also requires that [AI features](./overview.md) are enabled for your instance. You don't need to configure an AI provider to use the MCP server, but if **AI features** are turned off in **Admin > AI**, the MCP server stays off too.
-You can find your instance's MCP URL in **Admin > AI > MCP**.
+### Show inline charts in these MCP clients
-For Claude Code, for example, you can run the following command.
+These toggles control which browser-based clients can display [inline charts](#using-the-mcp-server) generated by Metabase. Switch on any of the supported clients:
+
+- **Claude** (Claude Desktop and Claude on the web)
+- **Cursor and VS Code**
+- **ChatGPT**
+
+Toggling on a client automatically adds that client's sandbox domains to Metabase's CORS allowlist, which is what lets the client render Metabase's charts in its browser sandbox.
+
+These toggles only control inline charts; they don't gate whether a client can connect. Any MCP client can connect to your MCP server (subject to [authentication](#authentication)), and clients that run outside the browser (like Claude Code on your own machine) don't need a CORS allowlist entry at all.
+
+### Custom inline chart origins
+
+The **Custom inline chart origins** field is for browser-based MCP clients that render [inline charts](#using-the-mcp-server) but aren't in the supported list (like a self-hosted client).
+
+![An inline chart](./images/inline-bar-chart.png)
+
+Adding an origin here puts it on Metabase's CORS allowlist, just like toggling on one of the supported clients. Clients that run outside the browser (like Claude Code on your own machine) don't need an entry here.
+
+Add the client's origin to the field. Separate values with a space, for example:
```
-claude mcp add --transport http metabase https://{your-metabase-url}/api/metabase-mcp
+https://mcp.internal.example.com https://*.staging.example.com
```
-replacing {your-metabase-url} with your Metabase address.
-
-Once you add the MCP server, your client will direct you to authentication page for your Metabase instance.
+The field accepts wildcards (`*`) for subdomains. Changes take effect in about a minute. Might be a good time to get up and pour yourself a glass of water.
## Authentication
@@ -74,17 +145,19 @@ A first-time connection will go something like this:
Results returned by the MCP server are sent to your MCP client, which may forward them to an AI provider depending on how the client is configured. See [AI privacy](./privacy.md).
-### Site URL must match the URL your client uses
+## Authorization logs
-For containerized setups, like when testing locally, you may need to set the `MB_SITE_URL` environment variable to the URL you point to. For example, if you're playing around with a Metabase on localhost:
+To review which clients have connected, go to **Admin > AI > MCP** and open the **Authorizations** tab. The authorization logs are an audit log of MCP and Agent API client registrations and the authorization decisions people have approved or denied.
-```
-MB_SITE_URL: http://localhost:3000
-```
+Each record includes:
-Some explanation: OAuth discovery starts with Metabase returning a `WWW-Authenticate` header whose `resource_metadata` URL is built from your **Site URL** setting in **Admin** > **Settings** > **General** (or via the environment variable).
+- **Client**: the MCP client that registered or requested access (like Claude Code).
+- **User**: the person who approved (authenticated) or denied the request (blank for registration events).
+- **Redirect URI**: the OAuth callback URL the client registered.
+- **Event**: **Registered**, **Approved**, or **Denied**.
+- **Date**: when the event happened.
-If the site URL doesn't match an address your MCP client can reach, like if you're running Metabase in Docker and the site URL got auto-detected from an internal hostname like `metabase-dev:3000`, the client will register but fail the handshake. Your MCP client will typically report a connection failure rather than prompting you to authenticate (for example, Claude Code shows `✗ Failed to connect` rather than `! Needs authentication`).
+Use the event filter to narrow the list to a single event type.
## With the MCP server, your client provides the AI
@@ -96,49 +169,37 @@ You don't need to have an [AI provider](settings.md#choose-ai-provider) configur
## Using the MCP server
-
The MCP server will return results as either text or an inline chart, depending on the question you asked.
If you want the MCP server to return an inline chart, ask it to "show" or "visualize" the data:
![Show me the stuff](./images/mcp-chart.png)
-Currently, the Metabase MCP server supports bar and line charts. You can drill-through through the charts, change time granularity, or explore them in Metabase.
+Inline charts are limited to bar, line, or table charts (which you can toggle between). You can also drill through the charts or change their time granularity. Depending on which client you're using, drilling through will either let you keep exploring the chart right there in your client, or give you a link to continue your exploration in your Metabase.
-If your client is connected to other MCP servers, you can asks questions that combine data from multiple sources. For example, you can ask a question about your customers that combines data from Metabase, your CRM, and your support ticket platform (Though maybe you should put all that data into your Metabase).
+If your client is connected to other MCP servers, you can ask questions that combine data from multiple sources. For example, you can ask a question about your customers that combines data from Metabase, your CRM, and your support ticket platform (Though maybe you should put all that data into your Metabase).
See [Available tools](#available-tools) for the list of functionality supported by the MCP server.
-## Available tools
-
-Some clients (like Claude Desktop) will ask you to approve each tool the first time it's used. The MCP server builds on Metabase's [Agent API](./agent-api.md), and exposes the following tools. If you're building a custom integration and need full control, use the [Agent API](./agent-api.md) directly instead.
-
-#### Find and read content
+## Use the MCP server with agent-driven development
-- **search**: Find tables, metrics, cards, dashboards, and collections using keyword or natural language search.
-- **read_resource**: Read one or more Metabase entities by `metabase://` URI. Covers database / schema / table / collection / card / dashboard / metric / transform navigation in a single tool. Up to 5 URIs per call.
+You can use the MCP server to help you create Metabase content as serialized YAML files that you can import into your Metabase. Point your agent at the MCP server to give it access to your Metabase's database metadata (table names, fields, and sample values) so it can write questions and dashboards that point at real columns.
-#### Query and visualize data
+See [Agent-driven development](./file-based-development.md).
-- **construct_query**: Construct a query against a table or metric. Returns an opaque query handle that can be passed to `execute_query`.
-- **query**: Query a table or metric and return results.
-- **execute_query**: Execute a previously constructed query and return the results with column metadata, row count, and execution time.
-- **execute_sql**: Execute a raw SQL query against a database. Requires native-query permission on the target database. An admin can disable this tool instance-wide via the `mcp-execute-sql-enabled` setting.
-- **visualize_query**: render a chart inline in your AI client (bar or line chart only).
+## Connecting to a local MCP server
-#### Create content
+Some clients don't allow support connecting to MCP servers running on localhost. For example, Claude Desktop doesn't permit local connections, but Claude Code does.
-- **create_question**: Save a query as a named question (card).
-- **update_question**: Update a saved question. Setting `collection_id` moves the card to another collection.
-- **create_dashboard**: Create a new dashboard, optionally populated with saved questions.
-- **update_dashboard**: Update a dashboard's metadata (name, description, collection, archived).
-- **create_collection**: Create a new collection, optionally nested under a parent collection.
+For containerized setups, like when testing locally, you may need to set the `MB_SITE_URL` environment variable to the URL you point to in order to authenticate your client. For example, if you're playing around with a Metabase on localhost, you should set:
-## Use the MCP server with agent-driven development
+```
+MB_SITE_URL: http://localhost:3000
+```
-You can use the MCP server to help you create Metabase content as serialized YAML files that you can import into your Metabase. Point your agent at the MCP server to give it access to your Metabase's database metadata (table names, fields, and sample values) so it can write questions and dashboards that point at real columns.
+Some explanation: OAuth discovery starts with Metabase returning a `WWW-Authenticate` header whose `resource_metadata` URL is built from your **Site URL** setting in **Admin** > **Settings** > **General** (or via the environment variable).
-See [Agent-driven development](./file-based-development.md).
+If the site URL doesn't match an address your MCP client can reach, like if you're running Metabase in Docker and the site URL got auto-detected from an internal hostname like `metabase-dev:3000`, the client will register but fail the handshake. Your MCP client will typically report a connection failure rather than prompting you to authenticate (for example, Claude Code shows `✗ Failed to connect` rather than `! Needs authentication`).
## Further reading