DataMCPDataMCP
|Tutorial

How to Connect Your PostgreSQL Database to ChatGPT

Step-by-step guide to connecting PostgreSQL to ChatGPT via MCP. Set up in 5 minutes with read-only permissions and a full query audit log.

DataMCP
Founder of DataMCP

You have a PostgreSQL database. You want to ask ChatGPT questions about the data inside it - in plain English, without writing SQL by hand. This is now possible, and the setup takes about 5 minutes.

Here's exactly how to do it.

How ChatGPT connects to external tools

ChatGPT supports a standard called MCP (Model Context Protocol). MCP lets ChatGPT connect to external servers that expose tools - like a database - and call those tools during a conversation.

To connect to your PostgreSQL database, ChatGPT needs to reach an MCP server that:

  • accepts connections from ChatGPT over HTTPS
  • knows how to talk to your database
  • lets you control what ChatGPT can and can't do

That last part matters. You don't want ChatGPT running DROP TABLE or reading tables it has no business touching.

The better approach: DataMCP

DataMCP is a hosted MCP gateway for PostgreSQL. You paste your connection string, set what ChatGPT is allowed to do (read-only, specific tables, no DDL), and get a public HTTPS endpoint to hand to ChatGPT.

Your credentials are encrypted with AES-256-GCM at rest. Every query that runs through ChatGPT is logged. Free plan gets you one connection.

Step-by-step setup

Step 1: Create a DataMCP account

Go to dashboard.datamcp.app and sign up. No credit card required.

Step 2: Add your database

Step 1: Click '+ New Connection' to add your database

Click Add Connection and select PostgreSQL:

Step 2: Select PostgreSQL as your database type

Give your connection a name and click Next:

Step 3: Name your connection, then click Next

Now paste your PostgreSQL connection string:

postgresql://username:password@host:5432/database

Step 4: Paste your connection string, then click Validate Connection

DataMCP connects, reads your schema, and stores the credentials encrypted. It supports every major hosted Postgres provider - Supabase, Neon, AWS RDS, Google Cloud SQL, Azure, Heroku, DigitalOcean.

Step 3: Create an MCP Link

Once your database is added and shows Healthy, click + New MCP Link.

Give the link a name (e.g., "ChatGPT read-only") and choose an access level:

  • Read Only - SELECT queries only, no writes
  • Read & Write - SELECT, INSERT, UPDATE
  • Full Access - all operations including DDL
  • Custom - pick permissions per table (SELECT, INSERT, Update, Delete individually)

Step 3: Name your link, choose access level, click Create Link

If you choose Custom, you get a table-by-table permission grid:

Custom mode: set permissions per table

Choose who gets access - Everyone in your org, or specific members. Then click Create Link.

Step 4: Get your ChatGPT URL

After the link is created, click the ChatGPT tab. You'll see an OAuth URL:

Step 4: Click ChatGPT tab - copy the OAuth URL

Copy that URL.

Step 5: Connect in ChatGPT

Note: ChatGPT Plus or Pro subscription required. The initial setup must be done in ChatGPT in the browser (chatgpt.com) - the desktop and mobile apps do not support adding new MCP servers. Once connected, your database works in the browser, the desktop app, and on mobile.

1. Open Settings

In ChatGPT (browser), click your profile icon in the top-right corner and go to Settings.

2. Enable Developer mode

Go to Apps → Advanced settings and toggle on Developer mode. This is required to add custom MCP servers.

Enable Developer mode - required to add MCP servers

3. Create a new app

Go back to Apps and click Create app.

Click Create app to add your MCP server

4. Fill in the form

In the New App dialog:

  • Name: give it any name (e.g., "My Database")
  • MCP Server URL: paste the URL you copied from DataMCP
  • Authentication: OAuth (already selected by default)
  • Check "I understand and want to continue"
  • Click Create

Fill in name, paste MCP URL, check the box, click Create

5. Authorize on DataMCP

DataMCP's OAuth page will open. Select the database and the MCP Link you created earlier, review what ChatGPT will be able to do, then click Authorize.

Choose your database and permissions, then click Authorize

6. Done

You'll see a confirmation: your database is now connected. From this point it works in the ChatGPT browser, desktop app, and mobile.

Done - your database is now connected to ChatGPT

Step 6: Use it

Open a new chat and start asking questions in plain English:

"What tables do I have in the database?" "How many users signed up last month?" "Show me the top 10 orders by revenue this week."

ChatGPT will translate each question into SQL, run it through DataMCP against your database, and return the result. The query runs within the permission limits you set - if you enabled read-only, ChatGPT can't modify anything even if you ask it to.

ChatGPT can now query your database in plain English

What you can do from here

Once the connection is live, a few things become practical:

Ad-hoc analytics without SQL. Instead of writing a query every time you want a number, you just ask.

Debugging. Ask ChatGPT to look at specific rows, explain relationships between tables, or find anomalies.

Building dashboards. Describe what you want to see, let ChatGPT draft the query, copy it into your BI tool.

Onboarding. New team members can explore the schema by asking questions instead of reading docs.

Is it secure?

DataMCP sits between ChatGPT and your database. ChatGPT never sees your connection string or credentials - it only calls the MCP tools DataMCP exposes. Every query is validated against your permission rules before it runs. Every query that executes gets logged with a timestamp.

The one thing to keep in mind: ChatGPT sends your question to OpenAI's servers, which then call DataMCP. Your actual data (the rows returned) passes through OpenAI's infrastructure. If your database contains sensitive PII or regulated data, make sure that's acceptable under your compliance requirements. For those cases, the DataMCP self-hosted edition (coming soon) keeps everything within your own network.

Quick reference

  1. Create DataMCP account (free) - no credit card
  2. Add your PostgreSQL connection string - schema loads automatically
  3. Create an MCP Link - choose Read Only, Read & Write, Full Access, or Custom per-table permissions
  4. Open the ChatGPT tab on your link - copy the OAuth URL
  5. In ChatGPT browser (Plus/Pro required): enable Developer mode, click Create app, paste the URL, authorize on DataMCP
  6. Ask questions in plain English - works in browser, desktop app, and mobile

The full setup - from empty DataMCP account to asking your first question in ChatGPT - takes about 5 minutes.


DataMCP is free for one database connection. Get started ->

PostgreSQLChatGPTMCP

Ready to connect AI to your database?

Set up DataMCP in 60 seconds. No credit card required.

Get Started Free

Questions? Read the docs or view pricing.