Writing ·
MCP DB Wizard now generates MCP servers for PostgreSQL
MCP DB Wizard for Postgres is available now, for PostgreSQL 16, 17 and 18. It is the same generator as the Oracle product, pointed at a different catalog: you choose the tables, views, functions, procedures, sequences and your own curated, tested SQL statements an agent may use, and it generates an MCP server that exposes exactly those as typed tools. Nothing you did not select has a tool, a method or a class, and every call binds its values. There is no “run SQL” tool to misuse.
docker pull ghcr.io/srmadscience/mcpdbwizard-postgres:2.0.43
The console, the authenticating proxy, accounts and tokens, the access grid, the audit trail and Context Pinning all work as they do on Oracle. One licence covers both products. What follows is the part that is not the same, because Postgres is not Oracle with different keywords.
Where the shapes differ
Packages are schemas. An Oracle config lists PACKAGE.PROCEDURE; a Postgres config lists
schema.routine. There is no package state to worry about, and tool names carry the schema
(sales_orders_get_by_pk for sales.orders), because a Postgres database routinely holds several
schemas with tables of the same name.
Overloads are first-class. Postgres resolves a function by its argument types, so
app.price(numeric) and app.price(numeric, text) are different routines. Each gets its own tool,
and the tool’s description names the signature so an agent can tell them apart.
More objects become tools. Views, materialized views, foreign tables and partitioned tables are
handled like tables (a partition is reached through its parent). An expression index such as
upper(name) or date_trunc('day', created) gets its own lookup tool, with the arguments typed by
the expression and the query written so that the index actually serves it.
Result sets come two ways. A function returning refcursor or SETOF becomes one tool that
returns rows, capped at 10,000 by default as on Oracle.
How the types cross
Oracle’s type system is records, collections and object types. Postgres has its own, and each needed a decision about how it crosses JSON:
| Postgres | Over MCP |
|---|---|
| composite type | JSON object, keyed by attribute name |
| array, or a domain over one | JSON array (a lower bound other than 1 is kept) |
timestamp / timestamptz | string at full microsecond precision; timestamptz keeps its offset |
interval, ranges, multiranges, inet, money | string, in Postgres’s own text form ([1,5)) |
json, jsonb | JSON text: a string holding the document |
PostGIS geometry, geography | EWKT: SRID=4326;POINT(1 2) |
pgvector vector, halfvec | array of numbers |
pgvector sparsevec | {length, indices, values}, indices from 0 |
A type that has no agreed JSON form yet (the geometric types, tsvector, hstore, citext) is
not guessed at: a routine using one is left out when the server is generated, and the generation log
says why. Composites and arrays bind directly, so unlike Oracle the generator never creates shadow
types in your database and needs no CREATE TYPE grant.
Where the runtime differs
Pooling is always on. On Postgres, one failed statement aborts the transaction, and every later statement on that connection fails with SQLSTATE 25P02 until it is rolled back. An unpooled server sharing one connection would be one error away from refusing everything, so a generated Postgres server is always pooled and each tool call is its own transaction, committed when it succeeds and rolled back when it fails.
Context Pinning uses a custom setting instead of SYS_CONTEXT. A pinned URL parameter such as
CUSTOMER_ID is set for the length of each call with set_config('mcp.customer_id', ..., true).
Being transaction-local, it reverts by itself when the call’s transaction ends, so no value can reach
the next caller of a pooled connection. Your SQL reads it with
current_setting('mcp.customer_id', true). Nothing needs installing in the database.
Sessions name themselves in pg_stat_activity.application_name, which is where Oracle’s
DBMS_APPLICATION_INFO module goes. A running server reports its DAO factory’s class name, so you
can tell its connections apart from everything else using the same login.
Errors name the SQLSTATE ((SQLSTATE 23505)) where Oracle’s name ORA-00001, and a statement
timeout surfaces as 57014.
Names keep their case. Nothing is upper-cased on the way in; Postgres’s own folding of unquoted names is the only folding that happens.
Why 16 and later? Describing a SQL statement’s result columns at generation time relies on
pg_prepared_statements.result_types, which arrived in 16. The generator PREPAREs each of your SQL
statements when it builds the server, so a broken statement fails the build, not its first call.
Try it
Pull the image, point it at a database you are happy for an agent to read, select a handful of objects, and look at the tools it generates before you connect anything to them:
docker pull ghcr.io/srmadscience/mcpdbwizard-postgres:2.0.43
Quickstart: Postgres takes you from that to a working server. The full
reference is MCP DB Wizard for Postgres, and
Sessions and pooling on Postgres covers sizing the pool
against max_connections.