Trace relationships in a database
Use schema discovery and table descriptions to inspect primary keys, foreign keys and indexes. The agent can explain a relationship using the actual schema instead of guessing table names from your prompt.
Databases · MCP integration
Give your AI app a controlled path to PostgreSQL through MCP. Explore tables, inspect indexes and foreign keys, run limited SELECT queries, and review proposed changes in GateRook. Credentials belong to the connection, while the endpoint decides which tools the agent can use.
Connection in GateRook
stage-db
PostgreSQL
stage / QAThe route
Your AI requests a tool. GateRook checks the endpoint policy, resolves credentials locally, and calls the configured service.
Understand the request flowAsk your AI
Check the status and total of order 48213 in PostgreSQL. Read only.
{
"connection": "stage-db",
"sql": "SELECT id, status, total FROM public.orders WHERE id = 48213",
"limit": 10
}{
"columns": [
"id",
"status",
"total"
],
"rows": [
[
48213,
"pending",
"149.00"
]
],
"rowCount": 1,
"truncated": false
}Sample configuration and output, not a live connection. Replace example values with your environment. Tool names here are connector names; the endpoint may expose a connection-specific name.
Put context to work
Use schema discovery and table descriptions to inspect primary keys, foreign keys and indexes. The agent can explain a relationship using the actual schema instead of guessing table names from your prompt.
Ask for EXPLAIN of a specific SELECT and compare it with the available indexes. Start with a bounded query and a statement timeout; database work still consumes resources even when it only reads.
Keep a stage connection and a production read connection on separate endpoints or with distinct modes. The visible environment and per-connection permissions make the intended target clear in each call.
From service to MCP
GateRook must be running on a computer that can reach your service. Open Connections, choose Add connection, and select PostgreSQL. Give the connection a name and environment.
New to GateRook? Start with the full setup guide.Create or select a PostgreSQL user with read access to the intended tables. Keep the database reachable from your desktop. A read-only login adds a database-level boundary alongside the endpoint policy.
Open Connections, choose Add connection, then PostgreSQL. Set the name, environment, host, port and database. Enter credentials in the connection form, separately from anything you paste into an AI conversation.
Keep verify-full for a server with TLS, add its private CA when needed, and restrict the schema allowlist. Advanced settings include statement timeout, pool size and connection timeout. Policies may impose stricter limits.
Continue to Test and review connectivity and the privileges reported for the login. Finish Add to endpoint to save the connection. Leave mutation tools Off unless you intend to review proposed changes.
Add the tested connection to an endpoint. In Tools & policies, enable only the tools needed for the task. Start with Read only where supported; use Approval for any selected mutation and leave other tools Off. A connection alone does not grant an AI client access.
In Clients, choose your AI app and endpoint, review the connection details, and connect. Try this guide’s example in Playground before asking your AI. Open Activity to inspect the tool, target, decision and returned result. The getting started guide covers this shared flow.
Connection settings
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.
| Setting | Example | How to use it |
|---|---|---|
Connector type | PostgreSQL | Choose the built-in connector in Connections. |
Name / environment | stage-db / stage | A recognizable connection name becomes the connection argument in tool calls. |
Host / port | postgres.stage.internal / 5432 | Use a host reachable from the computer running GateRook, including its VPN. |
Database | orders | Required for PostgreSQL. This is the database to connect to. |
User / password | gateway_reader / Enter in GateRook (write-only) | Start with a database account that can only read. Choose Encrypted here or a configured secret store. |
SSL mode | verify-full | Checks both the certificate authority and host name. Add a PEM CA certificate for a private CA. |
Schema allowlist | public | Limit which schemas or databases this connection exposes; environment policies can tighten the scope. |
Know what you expose
The connector determines what is possible. Endpoint modes and connection policies determine what a particular AI client may use.
| Tool | Purpose | Access behavior |
|---|---|---|
sql_list_schemas | Discover the schemas, databases and tables visible to the connection user. | Read only |
sql_describe_table | Inspect columns, types, indexes and foreign keys before writing a query. | Read only |
sql_query | Run a read query or EXPLAIN in a read-only transaction, with endpoint limits. | Read only |
sql_execute | Propose INSERT, UPDATE or DELETE. You review and approve the exact SQL before execution. | Approval |
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
Use Test connection to isolate service access problems. Use Playground and Activity to inspect endpoint permissions and tool calls.
GateRook connects to PostgreSQL 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.
Only when you expose sql_execute in Approval mode, the policy permits the statement, the database user has permission, and you approve the exact action. There is no mode for unattended writes.
Set the connection Schema allowlist, keep the database role privileges narrow, and apply the environment policy. The default schema is public unless changed in Advanced settings.
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.
Keep exploring
Connect MySQL to an MCP-compatible AI app with GateRook. Explore schemas, run read-only SQL, review changes and keep database credentials out of prompts.
Connect MongoDB to AI through MCP. Find documents, run read-only aggregations and scope collections with GateRook, without putting credentials in prompts.
Connect Redis to an AI app through MCP. Scan allowed keys, inspect values and TTLs, and troubleshoot cache data with the read-only GateRook connector.
Your infrastructure, on your terms
Start with one connection. Choose what your AI can do.