To let people ask questions in plain language over your app’s database or your warehouse, set guardrails in both your database and Metabase. Connect Metabase with a read-only database user, so that your database refuses any INSERT, UPDATE or DELETE in a generated query. Metabot, the AI assistant in Metabase, and Metabase’s MCP server then run each query as the person who signed in, with that person’s permissions. You can open the query behind each chart that Metabot or an MCP client shows, and check it before you rely on the number. For calculations, Metabot prefers the metrics your data team defined.
Metabot, the MCP server and the permissions that decide who can query each database come with every Metabase plan, including the free open-source edition. Per-group AI controls, verified content, AI usage auditing and impersonation, which makes your database check each query, are part of the Pro and Enterprise plans. Pro costs $575 a month with 10 users included, and Enterprise starts at $20,000 a year (checked on November 12, 2026). To turn on Metabot or connect Claude, Cursor or Codex, see Natural language questions in open-source Metabase. To build an assistant into your own app, see Let your AI assistant answer questions from company data.
How do I keep text-to-SQL read-only on Postgres?
When you run a query from the SQL editor, Metabase sends it to your database “exactly as it is written”. The MCP server’s execute_sql tool does the same with the SQL an agent writes, which it runs “verbatim against the database”. So the privileges of the database user in Metabase’s connection decide whether a generated query can change data. Metabase’s docs recommend “a dedicated metabase database user with read-only access”, and on PostgreSQL you can set one up like this:
-- Follows "Database users, roles, and privileges". Tested on PostgreSQL 16 and 17.
-- Run as an admin on the database that Metabase will query (here: app).
CREATE ROLE analytics;
GRANT CONNECT ON DATABASE app TO analytics;
GRANT USAGE ON SCHEMA public TO analytics;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO analytics;
-- The user you enter in Metabase's connection form.
CREATE USER metabase WITH PASSWORD 'replace-with-a-strong-password';
GRANT analytics TO metabase;
-- Tables that app_owner (the role your migrations use) creates later are readable too.
-- Run this statement as app_owner or as a superuser.
ALTER DEFAULT PRIVILEGES FOR ROLE app_owner IN SCHEMA public
GRANT SELECT ON TABLES TO analytics;
With this user, INSERT, UPDATE, DELETE and TRUNCATE fail with permission denied for table, and DROP and ALTER fail because the user doesn’t own the tables. A string that puts a DELETE after a SELECT fails the same way, because PostgreSQL checks the privileges of each statement. Functions need one more step. PostgreSQL lets everyone run a new function by default, and a SECURITY DEFINER function runs with the privileges of its owner. If such a function writes data, run REVOKE EXECUTE ON FUNCTION delete_account(bigint) FROM PUBLIC; as its owner, with your function’s name. Then grant EXECUTE again to the role your app uses. The block above grants SELECT on every table in the public schema. If some tables hold secrets, such as password hashes or API keys, grant SELECT table by table and skip the default privileges. Hiding a table or a column in Metabase keeps it out of Metabot’s search. But Metabase’s docs say that “neither setting is a permission”, so keep secrets out with database grants and data permissions.
How do I see and check the SQL behind an AI answer?
In the SQL editor, Metabot writes the SQL for your prompt, “but it won’t run the query”, so you can read the code before you run it. When you ask Metabot for a chart, it first points you to an existing question that answers it, if there is one. Otherwise, it builds a new question with the query builder, where you can open the editor and see each step. People with SQL access can also click View SQL to see “the native query that Metabase will run”.
An admin can turn on inline charts for Claude Desktop (in Chat), Claude on the web, ChatGPT, Cursor and VS Code under Show inline charts in these MCP clients. In those clients, an MCP answer can come back as a chart, and “every chart has an Explore in Metabase button that opens the question in Metabase”. The execute_query and execute_sql tools also return a query_handle for the query that ran. With that handle, question_write “saves exactly the query that tool validated”, so an agent can save its answer as a question for a person to review.
On Pro and Enterprise, AI usage auditing in Monitor lists each Metabot conversation. Its detail page shows “every SQL or query builder (MBQL) query Metabot wrote during the conversation” with the tables it used, and Visit opens a query so you can run it yourself. MCP calls appear in MCP analytics instead, on its Tool calls tab.
Does the AI see only the data each person can see?
Yes. Metabot “inherits the permissions of the person it’s chatting with”, so it “can only see what that person has permissions to see and do”. MCP clients sign in to Metabase with OAuth, and on the MCP server “every tool runs as you, scoped to your permissions”. A client’s scopes can narrow what it may do, but “a scope never grants more than your Metabase permissions allow”.
So you set the guardrail once, as permissions for each group, and it holds in the SQL editor, in Metabot and in every MCP client. On every plan, collection permissions decide which questions and dashboards a group can open. The Create queries permission decides whether a group can query a database, and whether it can write SQL there. On Pro and Enterprise, the View data permission can also block a database, a schema or a table. Row and column security then filters a table by user attributes, such as a customer ID. Metabase’s docs recommend one dedicated metabase database user, and each question still runs with the data permissions of the person who asked it.
Should the AI write raw SQL or use the query builder?
The MCP server lets an agent do both. The execute_query tool needs the agent:query:run scope, is marked read-only, and runs queries in Metabase’s query language, which covers “counts, sums, grouping, filtering, joins”. The execute_sql tool needs the agent:sql:run scope and runs raw SQL for “the rest (window functions, CTEs, engine-specific functions)”. Metabot works the same two ways, since it builds charts with the query builder and can also write SQL.
For a group that shouldn’t send raw SQL, set its Create queries permission on that database to Query builder only. The MCP docs say the agent:sql:run scope “won’t let a client run SQL against a database you can’t write native queries on”, while execute_query still answers that group’s questions. On Pro and Enterprise, a group with Row and column security or Blocked on any table loses native queries on that whole database. That’s because Metabase “can’t parse SQL queries” to see which tables they use.
On Pro and Enterprise, two more controls narrow this for each group. In AI feature access, uncheck SQL generation, and Metabot “will try to answer SQL-shaped prompts with a query builder result”. In MCP tools access, click Switch to group-level permissions. All Users then loses its tools, and each group gets only the tools you check. Check the tools the group needs and leave execute_sql in the Raw SQL row unchecked. A person gets a tool if any of their groups allows it, so leave it unchecked in each group they belong to. Metabase then leaves execute_sql out of their tool list and refuses it if a client calls it anyway. That also stops the group from saving SQL questions with question_write.
How many rows can an AI answer return?
The MCP tools that return rows, execute_query, execute_sql and run_saved_question, take a row_limit that is 100 by default and 2,000 at most for each call. For execute_query, that number is the page size and “not a bound on the result”, so put a limit in the query to cap the answer. The agent fetches the next page of a cut-off result with a cursor.
For each query Metabot runs, Metabase sends “part of the result” to your AI provider, “like the column names and a limited number of rows”.
How does the AI use the same definitions as your dashboards?
Define each number people ask about once, as a metric, because Metabase’s docs say to “build a metric if you want Metabot to reuse a calculation”. When more than one source could answer a question, Metabot “picks the most curated one”, with metrics first for calculations. When it looks at a table, it “is instructed to use” the table’s measures and segments “instead of writing its own calculation”, and it “gets the glossary with every message”. Your data team defines measures, segments and the glossary in Data Studio, where you curate the semantic layer and transforms, and creates metrics from New metric or Browse > Metrics.
On Pro and Enterprise, admins can verify questions, models, metrics and dashboards, and Metabase removes the verification when anyone changes a verified item’s query. With Verified or curated content turned on in Admin > AI, Metabot “only uses content that’s verified, in an official collection, or published to the Library”.
Can Metabot run on a model you host yourself?
Yes. Metabot sends your prompts, table and field names and a sample of field values to the AI provider you connect. By default, it also sends query results, and the error message of any query that fails. That provider can be a vLLM or Ollama server that you run, and connecting your own provider “doesn’t require a paid Metabase plan”. In Admin > AI, add a vLLM or Ollama provider and enter your server’s address, which ends in /v1. Set MB_LLM_ALLOWED_NETWORKS=allow-private so that Metabase can reach a server on your private network, or allow-all for a server on the same machine. Metabot needs a context window of at least 16,384 tokens, and it calls tools, so start vLLM with --enable-auto-tool-choice and a --tool-call-parser that matches your model.
To stop Metabot from reading query results, turn off Allow Metabot to read query results on the Internal tab of Admin > AI, or set MB_METABOT_QUERY_EXECUTION_ENABLED=false. Metabot then “can still build queries and charts for you, but it can’t read their results”. MCP clients bring their own model, so the MCP server doesn’t use your Metabase AI provider. Its results go to the client, which may send them on to its own AI provider.
How do I make the database check every query?
Use impersonation, which is part of the Pro and Enterprise plans. You create a role in your database for each team or customer, and give each person a user attribute whose value is their role. Then you block the All Users group on that database and set their group’s View data permission to Impersonated. Metabase passes that value to a SET ROLE or USE ROLE command “before Metabase executes the query”, so your database’s own privileges and row-level security decide what each query returns. Impersonation “sets permissions for questions written in both the SQL editor and the query builder”. Impersonation works on ClickHouse 24.4 and later, MySQL, PostgreSQL, Redshift, Snowflake, SQL Server and Starburst/Trino. On Redshift, SQL Server and Starburst/Trino, Metabase switches to a database user instead of a role, so each person’s attribute holds a user name. The impersonation docs also list the connection settings that Redshift, MySQL, Snowflake and SQL Server need.
On PostgreSQL, this example from Metabase’s impersonation docs creates a role that only sees Vermont rows in a people table. The last two lines add what a read-only connection user like metabase needs:
-- From "Impersonation access", plus the last two lines. Tested on PostgreSQL 16 and 17.
-- Run as the owner of the people table (with CREATEROLE) or as a superuser.
CREATE ROLE vermont_sales_team;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO vermont_sales_team;
CREATE POLICY vermont ON people FOR SELECT TO vermont_sales_team USING (state = 'VT');
ALTER TABLE people ENABLE ROW LEVEL SECURITY;
-- Let the connection user switch to the role, and keep reading every row itself.
GRANT vermont_sales_team TO metabase;
CREATE POLICY metabase_reads_all ON people FOR SELECT TO metabase USING (true);
For the read-only metabase user, PostgreSQL allows SET ROLE only to a role it has been granted, and once row-level security is on, it can only read the rows that a policy allows. Without the last two lines, SET ROLE fails with permission denied to set role, and the metabase user sees an empty people table. In Metabase, give each person in the group a db_role attribute (any key works) set to vermont_sales_team. If they should write SQL, set the group’s Create queries permission to Query builder and native.
Once any group has impersonated access to a database, Metabase checks every native query on that database before it runs, whoever runs it. For people who aren’t admins, it runs only a single SELECT statement, which may use WITH or UNION. It rejects CREATE, ALTER and DROP, role switches such as SET ROLE, and functions such as pg_sleep, set_config and dblink. No one, admins included, can send several statements separated by semicolons. If Metabase can’t apply impersonation for someone, for example because their attribute is empty, “it shows an error instead of running their query with the connection’s full access”. Admins don’t see impersonation’s restrictions, so check your setup with a test user in the impersonated group.
Which guardrails come with each plan?
Plans below were checked on November 12, 2026.
- Every plan, including the free open-source edition, includes Metabot, the MCP server and your own AI provider or a model you host. It also includes the query builder, the SQL editor, collection and Create queries permissions, measures, segments and the glossary.
- Pro and Enterprise add per-group AI access controls, per-group MCP tool access, token limits, system prompts, and AI usage auditing with MCP analytics. They also add content verification, official collections, the Library, download limits, and View data permissions with row and column security and impersonation.
Next steps
- Set up a read-only database user
- Set data permissions for each group
- See every MCP server tool and the scope it needs
- Choose the AI features and MCP tools each group can use
- Review Metabot conversations and the queries it wrote
- Check what Metabase sends to AI providers and MCP clients
- Connect vLLM, Ollama or another AI provider
- Set up impersonation
- Natural language questions in open-source Metabase
- Let your AI assistant answer questions from company data
- Compare Metabase plans