Discuss your project

Guide

PostgreSQL MCP: the schema behind the answers

A PostgreSQL MCP connection gives your assistant read-only SQL access to the tables your business runs on. What it exposes, and which definition breaks first.

By · Updated · 4 min read

The Postgres connection I set up gives an assistant read-only SQL against the tables your business actually runs on. The database behind it is PostgreSQL, and most people reach it by searching for a Postgres MCP server. The tables are not neutral. The schema is a record of every decision someone once made about what the business is.

I am Benoit Pecqueur. I connect business systems to AI assistants for owners in Phoenix and Scottsdale. A PostgreSQL database is often the closest thing a business has to a written model of itself, and nobody may have read it that way.

The PostgreSQL schema is the business model

Whatever the company sells, the truth about it lives in the tables. Customers, orders, invoices, inventory. Every column is a decision: does a customer have one email or many, does an order have one status or a history, is a payment a row of its own.

Most owners have never read the schema. The person who wrote it may have left the company. So the first thing an assistant connected to PostgreSQL will learn is the business the way an archeologist would, from the structure rather than the story.

That is the value. A chat without the database answers from memory. A chat with the database answers from the structure that produces the numbers.

What a read-only connection sees

The PostgreSQL connection I set up is read-only and lets the assistant run SELECT queries within a defined scope. It sees:

  • The tables in the database I configure
  • Schema and column types for any table it is asked about
  • Read-only results of SELECT queries, including joins, filters, grouping and aggregation

What it does not expose: writes. No inserts, no updates, no schema changes. A question is allowed. A change is not.

The question that one query ends

The cross question PostgreSQL answers better than any dashboard: which number is right when 3 people each hold a version.

A real case. Sales says active customers means anyone with an order in the last 12 months. Finance counts anyone with a nonzero balance. Support counts anyone with a ticket open. 3 answers to the question how many customers the business has. The database can settle it, but only after someone writes down what an active customer is. The schema holds the data. The definition is still a human decision.

Which definition breaks first

Revenue per customer. Or more precisely, which rows count.

A view can hide a definition nobody remembers writing. Picture a revenue view that excludes one product category, written by someone who left 4 years ago. Reports built on the view would be wrong, quietly, and everyone would get used to the wrong number.

The same trap shows up in joins. A customer table joined to an orders table on email duplicates rows the moment one customer has 2 emails. The total looks inflated until someone counts distinct customers and gets a different number from the same query.

None of this is a PostgreSQL problem. It is the reason I do not connect a database and hand over a prompt. I connect the database and settle the definitions first.

Where a PostgreSQL connection does not fit

3 cases.

A production database with no read replica. Querying the live transactional database with an assistant is a bad idea. A runaway join can slow the system customers are using right now. I connect a replica, a daily snapshot, or nothing.

A database with no column documentation. If every column is named x1, x2, flag, the assistant cannot learn the business from the schema, because the schema is silent. The connection will produce confident nonsense.

A number that changes definition every week. If the meaning of the number shifts with each report, the database cannot save you. Someone has to write the definition down first.

How I would run the first query

One query, one owner, one number, published weekly.

  1. Grant a read-only role with access to a named set of tables. Nothing else.
  2. Read the schema with the owner for one hour. Find the views. Ask who wrote each one and what it hides.
  3. Pick one number that currently comes from a spreadsheet. One that 3 people disagree about is ideal.
  4. Write the definition as SQL. One query that produces the number, with the source tables named.
  5. Run the query weekly and publish the result. For a month, compare it against the spreadsheet version. When they disagree, the query wins only after someone reads the difference.

If the query and the spreadsheet disagree, the spreadsheet usually encodes a correction someone made by hand years ago. Finding that correction is the entire point.

A read-only role is the boundary that matters most. I wrote the boundaries I set before any connection in connect business tools to AI, and the scope rules live in read-only AI access. If your data lives in a system with no schema at all, MongoDB MCP covers what changes when the structure is not written down.

Questions owners ask

No. The connection I set up is read-only SQL. The assistant can query, join, filter and aggregate. It cannot insert, update, delete or alter the schema.

Because each report encodes its own definition, often in a view nobody remembers writing. The database holds one set of rows. The disagreement is between definitions, not between facts.

I would not. A read replica or a daily snapshot gives the same answers without putting the live system at risk from a runaway query.

By the question it has to answer. The role gets the minimum set of tables for that question, and nothing else. Scope is decided before the connection exists.

Then the schema is silent and the assistant cannot learn from it. The first release becomes naming and documenting the columns the question needs, before any query is written.

Start with the process that costs you the most time

Tell me which process you want to improve. A name, an email, and a short description of the process are enough to start a useful conversation.

Discuss your project