Skip to content

Databases · MCP integration

Connect PostgreSQL to your AI, with control over every query.

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.

PostgreSQL, in your AI workflow

Illustrative example

Connection in GateRook

stage-db

PostgreSQL

stage / QA
Connector type
PostgreSQL
Name / environment
stage-db / stage
Host / port
postgres.stage.internal / 5432
Database
orders

The route

Your AI requests a tool. GateRook checks the endpoint policy, resolves credentials locally, and calls the configured service.

Understand the request flow

Ask your AI

Check the status and total of order 48213 in PostgreSQL. Read only.

sql_query · arguments
{
  "connection": "stage-db",
  "sql": "SELECT id, status, total FROM public.orders WHERE id = 48213",
  "limit": 10
}
Example result
{
  "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

What you can do with PostgreSQL and AI

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.

Investigate query performance

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.

Separate environments

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

How to connect PostgreSQL

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.
  1. Prepare a database login

    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.

  2. Choose PostgreSQL and configure the connection

    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.

  3. Set TLS, scope and query limits

    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.

  4. Test the connection before saving

    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.

  5. Choose the endpoint and tool modes

    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.

  6. Connect your AI and verify the first call

    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

Configure PostgreSQL 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.

PostgreSQL connection configuration
SettingExampleHow to use it
Connector typePostgreSQLChoose the built-in connector in Connections.
Name / environmentstage-db / stageA recognizable connection name becomes the connection argument in tool calls.
Host / portpostgres.stage.internal / 5432Use a host reachable from the computer running GateRook, including its VPN.
DatabaseordersRequired for PostgreSQL. This is the database to connect to.
User / passwordgateway_reader / Enter in GateRook (write-only)Start with a database account that can only read. Choose Encrypted here or a configured secret store.
SSL modeverify-fullChecks both the certificate authority and host name. Add a PEM CA certificate for a private CA.
Schema allowlistpublicLimit which schemas or databases this connection exposes; environment policies can tighten the scope.

Know what you expose

PostgreSQL tools and access boundaries

The connector determines what is possible. Endpoint modes and connection policies determine what a particular AI client may use.

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

  • sql_query runs reads in a read-only transaction. sql_execute is a separate tool and requires approval for changes; a read-only database login still cannot write after approval.
  • 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

PostgreSQL connection questions

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

Is GateRook a PostgreSQL MCP server or an AI client?

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.

Can the AI change database records?

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.

How do I restrict access to a PostgreSQL schema?

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.

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.

Keep exploring

MySQL

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.

MongoDB

Connect MongoDB to AI through MCP. Find documents, run read-only aggregations and scope collections with GateRook, without putting credentials in prompts.

Redis

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.

Browse all integration guides

Your infrastructure, on your terms

Bring PostgreSQL into the conversation.

Start with one connection. Choose what your AI can do.

Get GateRook

GateRook is in active development. Installers will appear here after a verified release.

macOS

Coming soon. The macOS build is not available yet.

Windows

Coming soon. The Windows build is not available yet.