Business Intelligence

Trino MCP Server: Give the Agent Its Own Catalog

On a real Trino 484, two read-only MCP tools wrote to PostgreSQL. What stopped every write and still let admins write: the agent's own catalog with a SELECT-only login.

Javier BonillaCo-founder & CTO

A read-only Trino MCP tool can still write to your database. On Trino 484, two statements got past read-only tools and wrote to PostgreSQL: EXPLAIN ANALYZE runs the statement it explains, and CALL <catalog>.system.execute hands SQL to the database without Trino reading it. What stopped every write was a catalog just for the agent: a Trino rule lets the agent use that catalog and no other, and the PostgreSQL login behind it can only SELECT.

Two Trino statements that write while looking like reads

A read-only guard in an MCP server reads the SQL text. Statements that start like reads, such as SELECT, SHOW and EXPLAIN, pass. Trino has two that pass that check and write anyway.

The first is EXPLAIN ANALYZE. Plain EXPLAIN only plans a query. EXPLAIN ANALYZE does exactly what Trino's docs say: "Execute the statement and show the distributed execution plan of the statement along with the cost of each operation." Put an INSERT after it and the INSERT runs. You get a query plan back, and the table gets a new row.

The second is the PostgreSQL connector's system.execute procedure. It sends any SQL you give it to PostgreSQL, including statements that "insert, update, or delete data". And Trino's PostgreSQL connector docs are blunt about who checks it: "The query text is not parsed by Trino, only passed through, and therefore only subject to any security or access control of the underlying data source."

We ran both on Trino 484 against a PostgreSQL 18.6 catalog, as a Trino user called agent, with Trino's default access control. The orders table went back to 6 rows before each statement:

  • CALL postgresql.system.execute(query => 'DELETE FROM orders WHERE id = 2') succeeded. PostgreSQL then had 5 rows.
  • EXPLAIN ANALYZE INSERT INTO postgresql.public.orders ... returned a plan that starts "Trino version: 484". PostgreSQL then had 7 rows.
  • A plain DELETE succeeded too, down to 5 rows. Default access control stopped none of these.

Results from our test on Trino 484 as user agent. SELECT count(*) returns 6. CALL postgresql.system.execute with a DELETE succeeds, and PostgreSQL then has 5 rows. EXPLAIN ANALYZE INSERT returns a query plan, and PostgreSQL then has 7 rows. A DELETE inside system.query fails with a syntax error, and the table stays at 6 rows.

The third passthrough you'll read about, the system.query table function, couldn't write here: PostgreSQL rejected a DELETE inside it with syntax error at or near "FROM", and the table stayed at 6 rows.

What each Trino MCP server sent

We found no MCP server from the Trino project itself, only community ones. We ran the two written in Go on the same Trino 484 stack and sent the three writes from above through each tool:

Tool EXPLAIN ANALYZE system.execute DELETE
tuannvm execute_query, default Refused Refused Refused
tuannvm execute_query, writes on Ran, 7 rows Ran, 5 rows Ran, 5 rows
txn2 trino_query Ran, 7 rows Refused Refused
txn2 trino_execute, read-only default Ran, 7 rows Ran, 5 rows Refused

How we ran it: on November 19, 2026, our own script called each tool over MCP: tuannvm/mcp-trino at commit 3e0be00 and txn2/mcp-trino 0.1.0 at commit 8039bd9, where "writes on" means TRINO_ALLOW_WRITE_QUERIES=true. Every call ran as Trino user agent with default access control, on Trino 484, PostgreSQL 18.6 and Java 25. The two Python servers, trino-mcp 0.2.7 and Dataring's mcp-server-trino, ran only against a mock Trino coordinator, never on this stack: there, trino-mcp's execute_query_read_only refused EXPLAIN ANALYZE INSERT and a CALL, and Dataring's execute_sql sent all 12 statements we gave it.

txn2's trino_query is the tool its own error calls read-only: "trino_query is read-only". It refused the CALL and the DELETE by name, then let the INSERT through behind EXPLAIN ANALYZE. Its trino_execute tool, in the read-only mode that's on by default, refused the DELETE with "modification statements are not allowed in read-only mode" and then ran the same DELETE through system.execute.

tuannvm's default refused all three, with "security restriction: only SELECT, SHOW, DESCRIBE, and EXPLAIN queries are allowed". If you run a community server, run tuannvm/mcp-trino on its default and leave TRINO_ALLOW_WRITE_QUERIES off. It's one switch, and it opens all three writes at once.

Starburst has its own MCP servers, and we didn't test them. Starburst Galaxy's MCP server docs say "Only read-only SQL statements are supported (SELECT, SHOW, EXPLAIN)", and it runs as the user's default role. Starburst Enterprise turns its server on with starburst.mcp.enabled=true, and its query tool takes read-only SQL only. If you run either, ask Starburst one question: does its EXPLAIN check refuse EXPLAIN ANALYZE INSERT?

Why the catalog's login is the real lock

A tool label is a guess about SQL text. The database login is what PostgreSQL actually checks. We saw the same on plain Postgres in our text-to-SQL agent test, and with Athena's MCP servers.

With the usual catalog file, connection-user names one PostgreSQL login, and every Trino user's query on that catalog runs as it. Trino can also take the login from extra credentials a client sets when it connects (user-credential-name), but a plain catalog file doesn't. system.execute then runs whatever that one login may run, for whoever calls it.

Trino's own access control did hold in our test. With access-control.name=read-only, the agent's writes and both passthroughs failed with Access Denied errors, such as "Access Denied: Cannot execute procedure postgresql.system.execute". But that setting covers the whole cluster, so your admins can't write either.

File-based access control held too. Our rules.json made the agent read-only on the postgresql catalog and gave admin everything. The agent's writes and both passthroughs failed, while admin still inserted (7 rows) and deleted (5 rows). The passthroughs failed because there were no function rules, and Trino's docs say "If function rules are not present, only functions in system.builtin can be executed."

Then we added one rule that grants EXECUTE on system.execute and system.query to every user, the kind of rule someone adds for a migration and forgets. The agent's plain DELETE and INSERT were still denied. Its CALL postgresql.system.execute DELETE went through, down to 5 rows. Trino's rules said the agent was read-only on that catalog, but PostgreSQL never saw those rules.

So we gave the agent a catalog of its own. Two halves, and you need both: a catalog whose login can only SELECT, and a Trino rule that bars the agent from every other catalog. Here's the catalog file, etc/catalog/pg_agent.properties, for Trino 484 (PostgreSQL connector):

connector.name=postgresql
connection-url=jdbc:postgresql://127.0.0.1:55432/shop
connection-user=agent_ro
connection-password=<agent_ro's password>

The grants for that login, in PostgreSQL 18.6:

REVOKE ALL ON DATABASE shop FROM PUBLIC;
GRANT CONNECT ON DATABASE shop TO agent_ro;
GRANT USAGE ON SCHEMA public TO agent_ro;
GRANT SELECT ON public.orders TO agent_ro;

And the rules.json for Trino 484's file-based access control. To show the login holds on its own, we granted the agent both passthroughs on its catalog on purpose:

{
  "catalogs": [
    { "user": "admin", "catalog": ".*", "allow": "all" },
    { "user": "agent", "catalog": "pg_agent", "allow": "all" }
  ],
  "functions": [
    { "user": "agent", "catalog": "pg_agent", "schema": "system", "function": "query", "privileges": ["EXECUTE"] },
    { "user": "admin", "privileges": ["EXECUTE"] }
  ],
  "procedures": [
    { "user": "agent", "catalog": "pg_agent", "schema": "system", "procedure": "execute", "privileges": ["EXECUTE"] },
    { "user": "admin", "privileges": ["EXECUTE"] }
  ]
}

Two Trino catalog files side by side. postgresql.properties connects to PostgreSQL as the owner login, and only admin may use it. pg_agent.properties connects as agent_ro, which PostgreSQL allows SELECT only, and it's the one catalog the agent may use.

The agent could read: SELECT count(*) on pg_agent returned 6. Every write failed in PostgreSQL, even with both passthroughs granted. PostgreSQL turned down the system.execute DELETE and the plain DELETE with "permission denied for table orders", and the EXPLAIN ANALYZE INSERT with "permission denied for schema public". When the agent tried the owner catalog, it got "Access Denied: Cannot access catalog postgresql". The table stayed at 6 rows. Admin, through the owner catalog, still deleted a row, down to 5.

Got a data lake behind Trino too? We didn't test Hive, Iceberg or Delta Lake, but each connector takes a read-only setting per catalog: hive.security=read-only, iceberg.security=READ_ONLY and delta.security=READ_ONLY. In Hive's read-only mode, reads work and "none of the operations that write data or metadata, such as CREATE, INSERT or DELETE, are allowed". We'd set them up the same way: a second catalog over the same data for the agent, read-only at the connector, and a rule that limits the agent to it.

Connecting Trino through Querio

Trino is one of Querio's integrations. Credentials go in a browser form, never in tool arguments or an agent conversation.

Claude, ChatGPT and other agents reach your data through Querio's MCP server, which is on every plan, Free included. Each teammate signs in with their own Querio account, and the agent searches your team's context, describes tables, runs SQL, gets metrics by name and runs saved queries as that Querio user.

Approving an agent doesn't grant any workspace or datasource permissions. It gets the Querio access its person already has, datasource access included, and nothing more.

Magic happens when
people and agents work together