You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ai/mcp.md
+32-14Lines changed: 32 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ summary: Connect MCP-compatible AI clients to Metabase to search, explore, and q
9
9
10
10
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.
11
11
12
-
# Enable MCP server
12
+
##Enable MCP server
13
13
14
14
_Admin > AI > MCP_
15
15
@@ -23,7 +23,7 @@ Under **Supported MCP clients**, switch on any clients you want to allow:
23
23
24
24
-**Claude** (Claude Desktop and Claude on the web)
25
25
-**Cursor and VS Code**
26
-
-**ChatGPT**
26
+
-**ChatGPT**, including **Codex**
27
27
28
28
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.
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.
41
41
42
-
## Connect an MCP client
42
+
## Connect a client to your Metabase MCP server
43
43
44
-
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/mcp`. For example:
44
+
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:
In the terminal, for example, you can run the following command.
50
+
You can find your instance's MCP URL in **Admin > AI > MCP**.
51
+
52
+
For Claude Code, for example, you can run the following command.
51
53
52
54
```
53
-
claude mcp add --transport http metabase https://{your-metabase-url}/api/mcp
55
+
claude mcp add --transport http metabase https://{your-metabase-url}/api/metabase-mcp
54
56
```
55
57
56
-
Replacing {your-metabase-url} with your Metabase address. Once added, Claude Code will handle the OAuth flow for you:
58
+
replacing {your-metabase-url} with your Metabase address.
57
59
58
-
For Claude Desktop, you can create a [custom connector](https://support.claude.com/en/articles/11175166-get-started-with-custom-connectors-using-remote-mcp) by just giving it that URL to your Metabase's mcp endpoint.
60
+
Once you add the MCP server, your client will direct you to authentication page for your Metabase instance.
59
61
60
62
## Authentication
61
63
@@ -92,35 +94,51 @@ For example, if you ask your AI client to use your Metabase's MCP server "what's
92
94
93
95
You don't need to have an [AI provider](settings.md#choose-ai-provider) configured in Metabase to use your Metabase's MCP server. If you _do_ have an AI provider configured in Metabase to power Metabot, that provider will _not_ be used for MCP server requests. MCP calls by your local client have no effect on token usage for your Metabase's AI connection.
94
96
97
+
## Using the MCP server
98
+
99
+
100
+
The MCP server will return results as either text or an inline chart, depending on the question you asked.
101
+
102
+
If you want the MCP server to return an inline chart, ask it to "show" or "visualize" the data:
103
+
104
+

105
+
106
+
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.
107
+
108
+
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).
109
+
110
+
See [Available tools](#available-tools) for the list of functionality supported by the MCP server.
111
+
95
112
## Available tools
96
113
97
114
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.
98
115
99
-
###Discovery and reading
116
+
#### Find and read content
100
117
101
118
-**search**: Find tables, metrics, cards, dashboards, and collections using keyword or natural language search.
102
119
-**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.
103
120
104
-
### Query construction and execution
121
+
####Query and visualize data
105
122
106
123
-**construct_query**: Construct a query against a table or metric. Returns an opaque query handle that can be passed to `execute_query`.
107
124
-**query**: Query a table or metric and return results.
108
125
-**execute_query**: Execute a previously constructed query and return the results with column metadata, row count, and execution time.
109
126
-**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.
127
+
-**visualize_query**: render a chart inline in your AI client (bar or line chart only).
110
128
111
-
###Writing
129
+
#### Create content
112
130
113
131
-**create_question**: Save a query as a named question (card).
114
132
-**update_question**: Update a saved question. Setting `collection_id` moves the card to another collection.
115
133
-**create_dashboard**: Create a new dashboard, optionally populated with saved questions.
116
134
-**update_dashboard**: Update a dashboard's metadata (name, description, collection, archived).
117
135
-**create_collection**: Create a new collection, optionally nested under a parent collection.
118
136
119
-
## Use the MCP server with file-based development
137
+
## Use the MCP server with agent-driven development
120
138
121
139
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.
122
140
123
-
See [File-based development](./file-based-development.md).
141
+
See [Agent-driven development](./file-based-development.md).
0 commit comments