Skip to content
GitHub (opens in a new tab)

Databases · MCP Firewall integration

Give AI scoped MariaDB access. Approve the changes.

Put MariaDB behind GateRook’s MCP Firewall using the built-in MySQL connector. Follow the Docker walkthrough to select the database, attach it to showcase, run SQL from Codex, approve one update, and inspect its result and audit trail in Activity.

Step-by-step walkthrough

Control AI queries to MariaDB with GateRook’s MCP Firewall

GateRook’s MCP Firewall gives an AI app controlled access to MariaDB without putting the database password in SQL tool calls. Choose the database, expose the connection through an endpoint, and keep changes behind approval. Activity connects each request to its policy decision and execution result.

This walkthrough was performed on November 3, 2026 with GateRook 0.7.0, MariaDB 11.4.5 in Docker Desktop on macOS, and Codex already connected to the showcase development endpoint. It creates a separate mariadb-demo connection and uses four fictional orders to demonstrate discovery, reads, an approved update, and auditing. MariaDB uses GateRook's built-in MySQL connector; the connection test identifies the actual server as MariaDB.

New to GateRook? Set up your endpoint and AI app first.

1. Start an isolated MariaDB server

Keep Docker Desktop and GateRook running. This example assumes an existing development endpoint named showcase and an AI app connected to it. The separate container uses 127.0.0.1:13307, leaving existing database servers on other ports alone. MariaDB 11.4.5 is the exact fixture version used here, not a claim that it is the latest release.

Create a private working directory and independent passwords for the administrator and tutorial user:

Shell commands
mkdir -p ~/gaterook-mariadb-demo
cd ~/gaterook-mariadb-demo
umask 077

python3 - <<'PY'
from pathlib import Path
import secrets

path = Path("mariadb.env")
with path.open("x") as output:
    output.write(
        "MARIADB_ROOT_PASSWORD=" + secrets.token_hex(24) + "\n"
        "MARIADB_DATABASE=gaterook_demo\n"
        "MARIADB_USER=demo_agent\n"
        "MARIADB_PASSWORD=" + secrets.token_hex(24) + "\n"
    )
path.chmod(0o600)
PY

Create init.sql in the same directory:

Shell commands
cat > init.sql <<'SQL'
USE gaterook_demo;

CREATE TABLE orders (
    id INT PRIMARY KEY,
    customer_name VARCHAR(100) NOT NULL,
    status VARCHAR(20) NOT NULL,
    total DECIMAL(10,2) NOT NULL,
    CONSTRAINT orders_status
        CHECK (status IN ('pending', 'paid', 'shipped'))
);

INSERT INTO orders VALUES
    (1001, 'Avery Stone', 'pending', 129.90),
    (1002, 'Morgan Reed', 'paid', 89.00),
    (1003, 'Riley Chen', 'pending', 249.00),
    (1004, 'Jordan Lee', 'shipped', 49.50);

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'demo_agent'@'%';
GRANT SELECT, UPDATE ON gaterook_demo.orders TO 'demo_agent'@'%';
SQL

The official image creates the database and user from the MARIADB_* variables. The initialization script then narrows that user's privileges to SELECT and UPDATE on one table. It does not grant inserts, deletes, or schema changes. These initialization settings apply to an empty data directory; changing the environment file later does not reset an existing database. See the official MariaDB image environment reference.

Start the server:

Shell commands
docker run -d \
  --name gaterook-mariadb-showcase \
  -p 127.0.0.1:13307:3306 \
  --env-file mariadb.env \
  --mount "type=bind,source=$(pwd)/init.sql,target=/docker-entrypoint-initdb.d/01-demo.sql,readonly" \
  --health-cmd='healthcheck.sh --connect --innodb_initialized' \
  --health-interval=2s \
  --health-timeout=3s \
  --health-retries=30 \
  mariadb:11.4.5

docker inspect --format '{{.State.Health.Status}}' \
  gaterook-mariadb-showcase

Wait for healthy. The image's healthcheck script checks connectivity and InnoDB initialization. GateRook will separately test the tutorial user's credentials and privileges. The host port is bound only to loopback. If this container name or port is already occupied, choose another and use it consistently below.

2. Choose the MySQL connector for MariaDB

Open Connections and filter by mariadb-demo before capturing the screen. There should be no match yet. Select Add connection.

Connections filtered to mariadb-demo, keeping unrelated server addresses out of view.
Connections filtered to mariadb-demo, keeping unrelated server addresses out of view.

Choose MySQL, whose description explicitly includes MariaDB, then Continue. There is no separate MariaDB tile in this version. This connector supplies four SQL tools.

MySQL selected in the connector picker; its description includes MariaDB.
MySQL selected in the connector picker; its description includes MariaDB.

3. Enter the server and credentials

Use these values:

FieldValue
Namemariadb-demo
Host127.0.0.1
Port13307
Secret sourceEncrypted here
Userdemo_agent
PasswordThe MARIADB_PASSWORD value from your private mariadb.env
EnvironmentDEV Development

The connection name becomes the connection argument in tool calls and the identifier used in Activity. Choose it before saving: the saved name cannot be edited because calls and policies refer to it.

The mariadb-demo name and local MariaDB address on port 13307.
The mariadb-demo name and local MariaDB address on port 13307.

Enter only the tutorial user's password value, not the MARIADB_ROOT_PASSWORD or the entire environment file. Keep it out of your AI conversation. Encrypted here stores the credential encrypted with GateRook's local master key. The connector uses it to connect; subsequent SQL calls contain a connection name, database, and statement without the password.

Encrypted here selected, demo_agent entered, and the password masked.
Encrypted here selected, demo_agent entered, and the password masked.

4. Configure encryption and the database allowlist

Expand Advanced:

FieldValue in this walkthrough
SSL modeEncrypt, don't verify (require)
CA certificateEmpty for this disposable local fixture
Database allowlistAdd gaterook_demo using the + button
Allow public key retrievalUnchecked
Statement timeoutEmpty: use the environment policy
Pool size2
Connect timeout5000 ms
Functions reads may callEmpty

The test container supports TLS, and the connection succeeds with encryption required. This local fixture does not verify the server certificate or host name. For a remote server, configure a trusted certificate and choose Verify the CA and host name (verify-full); add its private CA certificate when necessary. Do not turn off encryption to work around a remote certificate error.

Public key retrieval is unnecessary for this connection and remains off. MariaDB uses database names as schema names, so the allowlist contains gaterook_demo, not PostgreSQL's public.

Required encryption, the gaterook_demo allowlist, and public key retrieval disabled.
Required encryption, the gaterook_demo allowlist, and public key retrieval disabled.

5. Load and select the database

Select Load databases, then tick gaterook_demo. The form should show 1 databases available · 1 selected. Discovery and selection are separate: select the database you intend agents to use. Reload the list if you change the server, credentials, or connection settings.

Keep DEV Development selected. Its description says that mutations still wait for approval.

gaterook_demo selected and the DEV environment retained.
gaterook_demo selected and the DEV environment retained.

6. Test the connection

Select Continue. GateRook connects with the entered configuration and checks the user's privileges. This run returned Connected · MariaDB 11.4.5 even though the wizard uses the MySQL connector.

The detected permissions were SELECT on one table, UPDATE on gaterook_demo.orders, and no CREATE or ownership for schema changes. The write warning is expected for this demonstration. For an analytics-only connection, grant only the required read access at the database level. Approval does not give a database login privileges it lacks.

A successful MariaDB 11.4.5 connection test and the narrowly scoped SELECT and UPDATE privileges.
A successful MariaDB 11.4.5 connection test and the narrowly scoped SELECT and UPDATE privileges.

7. Add the connection to showcase

Continue to Add to endpoint. Untick default and select only showcase. The connection is not available to an AI app until an endpoint exposes it. Keep the initial modes: three Read only tools and one Approval tool.

Only showcase selected; an unrelated endpoint name is redacted.
Only showcase selected; an unrelated endpoint name is redacted.

Select Save connection. The saved page identifies MariaDB 11, reports Healthy, and shows 1 endpoint with 4 tools on showcase · Codex. The tutorial credential is stored encrypted.

The saved healthy MariaDB connection, attached to one endpoint used by Codex.
The saved healthy MariaDB connection, attached to one endpoint used by Codex.

Scroll to Used by and verify:

ToolModePurpose
sql_list_schemasRead onlyDiscover databases and tables
sql_describe_tableRead onlyInspect columns, keys, and indexes
sql_queryRead onlyRun a validated read
sql_executeApprovalRequest a change for human review

Keep sql_execute in Approval for this walkthrough. Bypass is a separate mode and is not used here; unused tools can be Off.

The three read-only SQL tools and sql_execute in Approval mode on showcase.
The three read-only SQL tools and sql_execute in Approval mode on showcase.

8. Understand how a call reaches MariaDB

The request path is AI app → showcase → mariadb-demo → MariaDB. The AI chooses a tool and supplies arguments. GateRook checks endpoint access, tool mode, policy, and limits; its connector uses the stored credential to contact the database, then returns the allowed result and records the call in Activity.

The connection argument is mariadb-demo. The database argument is the selected gaterook_demo; specifying it also makes the intended database clear when more than one is selected. The four tools were usable from this existing Codex session immediately after saving. If your AI app retains an older tool catalog, refresh its MCP tools or reconnect it.

Database privileges and GateRook policy are separate controls. A read-only database user cannot perform the example UPDATE even if GateRook approves it. Likewise, giving a user UPDATE permission does not bypass the endpoint's Approval mode. Returned data reaches the AI client, so scope the tables and columns it may read as well as the actions it may request.

9. Discover the table and read its rows

Ask your connected AI app:

Through showcase, use mariadb-demo and database gaterook_demo. List the tables, describe orders, show the orders sorted by id, and summarize order count and total by status.

The run used sql_list_schemas with connection: mariadb-demo and database: gaterook_demo, then sql_describe_table with those arguments plus table: orders. Discovery returned one table. Description returned four non-null columns, an integer primary key on id, and one primary index. The initializer defines a status CHECK constraint; this MariaDB description response did not list it, so an empty checks result is not evidence that the table has none.

The first sql_query used:

Tool arguments
{
  "connection": "mariadb-demo",
  "database": "gaterook_demo",
  "sql": "SELECT id, customer_name, status, total FROM orders ORDER BY id",
  "limit": 10
}

It returned four rows without truncation:

idcustomer_namestatustotal
1001Avery Stonepending129.90
1002Morgan Reedpaid89.00
1003Riley Chenpending249.00
1004Jordan Leeshipped49.50

The second read used:

SQL query
SELECT status, COUNT(*) AS order_count, SUM(total) AS total_amount
FROM orders
GROUP BY status
ORDER BY status;
statusorder_counttotal_amount
paid189.00
pending2378.90
shipped149.50

The advertised read limit for this endpoint is 1,000 rows and five seconds; these calls request ten rows. The SQL read tool validates the statement, uses a read-only transaction, and rolls it back after reading. Send one statement per MariaDB call.

Open Activity → Agent calls and enter this filter, then press Enter:

Activity filter
endpoint:showcase connection:mariadb-demo

Open the grouped sql_query event. Request identifies Codex and showcase; Arguments shows the exact SQL, connection, database, and limit.

The grouped MariaDB SELECT recorded in Activity with its client, endpoint, and arguments.
The grouped MariaDB SELECT recorded in Activity with its client, endpoint, and arguments.

Scroll within the detail panel. Policy decision says Allowed, explaining that the read ran immediately. Result includes a three-row summary, response size and hash, and zero masked fields for this fictional dataset. Timing separates resource execution from gateway overhead.

The allowed read decision, three-row summary, result hash, and timing.
The allowed read decision, three-row summary, result hash, and timing.

10. Request a change and review the exact action

Ask the AI to mark order 1001 as shipped only if it is still pending. The sql_execute call uses connection: mariadb-demo, database: gaterook_demo, and this SQL:

SQL query
UPDATE orders
SET status = 'shipped'
WHERE id = 1001 AND status = 'pending';

GateRook returned a pending approval handle: the statement had not executed. The AI shows the approval card once and polls the same handle. It must not submit another UPDATE while waiting.

The operator-supplied Codex approval card: waiting for approval, with the request not yet executed.
The operator-supplied Codex approval card: waiting for approval, with the request not yet executed.

In GateRook's Approvals, inspect the connection, DEV environment, showcase endpoint, exact UPDATE, and both conditions in its WHERE clause. This request matched dev.sql.write-approval. Its impact preview identified orders, estimated 1 row using EXPLAIN, showed a transaction rolled back on error, and a 5 s statement timeout. The estimate is a preview; the execution result establishes the actual count.

A person can add an optional comment and select Approve and run, or select Deny. Opening the chat card does not approve the request. Only the person makes this decision in GateRook; an unanswered request expires at its displayed deadline. The application's protected Approvals screen was not captured; the operator's client-side cards document the pending and completed states.

In this run, the request was submitted at 11:39:22 and approved at 11:40:36 on November 3, 2026 (Europe/Madrid). Polling the original handle returned completed, committed: true, and 1 row updated.

The operator-supplied approval card showing Completed for sql_execute on mariadb-demo.
The operator-supplied approval card showing Completed for sql_execute on mariadb-demo.

11. Verify the saved change

Read the row again through the same endpoint and connection:

SQL query
SELECT id, customer_name, status, total
FROM orders
WHERE id = 1001;

The follow-up sql_query returned:

idcustomer_namestatustotal
1001Avery Stoneshipped129.90

This independent read verifies the database state after the approved write. It is also recorded in Activity.

The verification read recorded in Activity, confirming that order 1001 is shipped.
The verification read recorded in Activity, confirming that order 1001 is shipped.

12. Follow the audit trail

Return to Activity → Agent calls, keep endpoint:showcase connection:mariadb-demo, choose a time range covering the test, and select Refresh. The final view contains six calls: schema discovery, table description, the initial SELECT, the grouped SELECT, the approved UPDATE, and the verification SELECT. Five read events are Allowed; the update is Approved.

Activity filtered to showcase and mariadb-demo, with all six tutorial calls.
Activity filtered to showcase and mariadb-demo, with all six tutorial calls.

Open the sql_execute event. Arguments preserves the exact requested action, while Policy decision explains why it needed approval.

The Approved sql_execute event with the requested SQL, connection, and endpoint.
The Approved sql_execute event with the requested SQL, connection, and endpoint.

The Approval timeline records the request, desktop notification, human decision, and execution. It shows 1 min 14 s waiting and 11 ms executing, with 1 row affected. The Executed action field says that it matches the approved action byte for byte, beside the approved action's SHA-256.

The human approval timeline, one affected row, and byte-for-byte action match.
The human approval timeline, one affected row, and byte-for-byte action match.

The write's Result includes the committed outcome:

Execution result
{
  "committed": true,
  "statements": [{ "type": "UPDATE", "rowsAffected": 1 }],
  "rowsAffected": 1
}
The committed UPDATE result and the separate waiting and execution timings.
The committed UPDATE result and the separate waiting and execution timings.

Use these sections to answer: Which client used this connection? What SQL did it request? Why was it allowed or sent for approval? Who decided? Did the exact approved action run, and how many rows changed?

Result detail depends on the tool. The read events here contain compact text summaries, sizes, and hashes; Activity is not a complete archive of database results. The write event includes structured execution output. Masking depends on configured policies. Zero masked fields in these fictional records does not establish that arbitrary personal data is automatically protected. Setup changes is a separate Activity tab for changes to gateway configuration, rather than database tool calls.

Keep or stop the demo

The connection remains attached only to showcase, with reads enabled and writes requiring approval. Keep the container for further exploration. To pause access without deleting the configuration, turn the connection's On switch off; it affects this connection across endpoints. Turning an endpoint off pauses access through that endpoint. Past calls remain in Activity.

Stop the tutorial server without deleting its data:

Shell commands
docker stop gaterook-mariadb-showcase

Resume it later:

Shell commands
docker start gaterook-mariadb-showcase

Wait for healthy, then use Test connection in GateRook. Keep the local environment file private. For another server, update the address and database selection, use its own limited login and verified TLS configuration, and repeat the test before exposing tools.

Useful access. Explicit control.

What you can do with MariaDB and AI

Connect an existing MariaDB application

Reuse a narrowly scoped MariaDB login and select MySQL in the connection wizard. The server stays on your existing network; GateRook supplies the MCP tools your AI app can discover.

Explain a data discrepancy

Ask the agent to inspect a table definition and run a limited query for a specific record. Compare the result with an API response on the same endpoint without giving the agent either service credential.

Inspect schema during a migration

Compare table definitions, indexes and read results across separately named connections. Keep writes disabled while investigating differences between MySQL and MariaDB environments.

Connection settings

Configure MariaDB in GateRook

These are example values for the connection form. Enter credentials into GateRook’s secret fields, not into an AI prompt. Requirements and alternatives are noted per field.

MariaDB connection configuration
SettingExampleHow to use it
Connector typeMySQLThe built-in MySQL connector supports MariaDB. Test connection detected MariaDB 11.4.5 in this walkthrough.
Name / environmentmariadb-demo / devThe saved connection name is used in tool calls and Activity. DEV retains approval for the demonstrated write.
Host / port127.0.0.1 / 13307The Docker fixture publishes port 3306 only on this computer’s loopback address at port 13307.
Selected databasegaterook_demoUse Load databases, then select gaterook_demo. Pass database in tool calls; it is required when several databases are selected.
User / passworddemo_agent / Encrypted hereEnter the generated MARIADB_PASSWORD in GateRook. This fixture grants SELECT and UPDATE on orders only; use a read-only login when updates are unnecessary.
SSL moderequire (local fixture)This test requires encryption without verifying server identity. For remote servers use verify-full with a trusted certificate and the correct host name.
Database allowlistgaterook_demoAdd the database as a chip in Advanced before loading the database list.
Allow public key retrievalOffNot needed for this tested TLS connection.
Pool / connect timeout2 / 5000 msThe values used in this run. Leave statement timeout empty to use the environment policy; policies may impose stricter limits.
Endpoint / tool modesshowcase / 3 Read only, 1 ApprovalExpose only through showcase. Keep sql_execute in Approval and leave Bypass unused.

Know what you expose

MariaDB tools and access boundaries

The connector defines available operations. GateRook’s MCP Firewall enforces endpoint modes and connection policies before an AI client can use them.

Available tools and access behavior
ToolPurposeAccess behavior
sql_list_schemasDiscover the schemas, databases and tables visible to the connection user.Read only
sql_describe_tableInspect columns, types, indexes and foreign keys before writing a query.Read only
sql_queryRun a read query or EXPLAIN in a read-only transaction, with endpoint limits.Read only
sql_executePropose INSERT, UPDATE or DELETE. You review and approve the exact SQL before execution.Approval

Before you enable access

  • In the demonstrated configuration, sql_query runs validated reads in a read-only transaction and sql_execute waits for human approval. Database privileges remain an independent boundary: approval cannot give a read-only user write access.
  • The endpoint caps rows and execution time. Do not treat a truncated result as the full dataset.
  • Unknown user-defined functions are not automatically trusted as reads: they require approval, and are refused on prod unless allowed by policy.
  • A query result can contain application data. Choose tables, columns and access scope deliberately before exposing them to an AI app.

GateRook stores local connection secrets encrypted and resolves them for connectors. Allowed tool results are returned to your AI client and may be processed by its provider. Scope the data you expose as well as the actions you allow.

Practical answers

MariaDB connection questions

Use Test connection to isolate service access problems. Use Playground and Activity to inspect endpoint permissions and tool calls.

Is GateRook a MariaDB MCP server or an AI client?

GateRook connects to MariaDB and exposes selected database tools through an MCP endpoint. Your AI app is the MCP client. It receives the endpoint configuration, while the database password stays with the GateRook connection.

Can the AI change database records?

In this walkthrough, sql_execute is in Approval mode and the demo login can UPDATE orders. A person approved the exact statement, one row was committed, and a separate SELECT verified it. Keep Approval enabled; Bypass is a separate mode that is not used here.

Why is there no separate MariaDB type in the picker?

MariaDB is handled by the built-in MySQL connector. Choose MySQL and enter the MariaDB server address, database and credentials. GateRook recognizes the server from its version information.

Which MariaDB version was tested here?

This walkthrough used MariaDB 11.4.5 and GateRook 0.7.0 on macOS. The connection test identified MariaDB, and discovery, reads, an approved update, and verification succeeded. Test your actual server and privileges before exposing its tools.

Do I need to expose the database to the public internet?

No. The local GateRook core connects from your computer, so an existing VPN and private network route can be used. The database must be reachable by that computer.

Where can I see what the AI did?

Open Activity → Agent calls and filter by endpoint:showcase connection:mariadb-demo. Open an event to inspect its arguments, policy decision, approval history when applicable, result summary, and timing. The tutorial shows five Allowed reads and one Approved update.

Keep exploring

MySQL

Control MySQL access through GateRook’s MCP Firewall. Configure a scoped login, run read queries, approve an UPDATE and inspect each call in Activity.

PostgreSQL

Put PostgreSQL behind GateRook’s MCP Firewall. Follow the illustrated setup, scope AI queries, approve an UPDATE and inspect its Activity audit trail.

HTTP API

Put HTTP APIs behind GateRook’s MCP Firewall. Protect API keys, restrict destinations and paths, and approve requests that change data.

Browse all integration guides

Your MCP Firewall. Your access rules.

Control AI access to MariaDB.

Start with read-only access. Approve changes. Inspect the audit trail.

Read the getting started guide

Get GateRook

Download GateRook 0.9.2 for your Mac, or get the Windows app from Microsoft Store.

macOS

Version 0.9.2 for Apple Silicon (arm64). This download does not support Intel Macs.

Open the DMG and drag GateRook to Applications.

Windows

Available for free from Microsoft Store. Install GateRook and receive updates through the Store.

macOS release notes and checksums (opens in a new tab)