Skip to content

MCP Tools ​

Generated from the tool definitions the server sends to clients, so it always matches what an assistant sees. For setup and the safety rules, see With AI Assistants (MCP).

check_sql ​

read-only, idempotent

Check SQL syntax without a server, and summarize each statement: its kind, the tables it reads, writes or defines, the functions it calls, and whether run_sql would ask for confirmation.

ParameterTypeDescription
sqlstringrequiredSQL: one or more statements

describe_schema ​

read-only, idempotent

The tables, views and foreign tables in a database, with row estimates and sizes.

ParameterTypeDescription
targetstringrequiredInstance name, a connection name the server was given (list_instances shows them), or a connection string. Never put a password in a tool argument: it would be visible in the conversation; use a connection name, or PGPASSWORD or ~/.pgpass on the server
databasestringoptionalDatabase (default: postgres for an instance)
schemastringoptionalOnly this schema

describe_table ​

read-only, idempotent

One table or view in full: columns (type, nullability, default, identity, generated, primary key), indexes, and constraints with foreign key targets.

ParameterTypeDescription
targetstringrequiredInstance name, a connection name the server was given (list_instances shows them), or a connection string. Never put a password in a tool argument: it would be visible in the conversation; use a connection name, or PGPASSWORD or ~/.pgpass on the server
tablestringrequiredTable or view, optionally schema-qualified (sales.orders)
databasestringoptionalDatabase (default: postgres for an instance)
schemastringoptionalSchema where an unqualified name is looked up

doctor ​

read-only, idempotent

Check that PostgreSQL can run on this machine: platform, user, Maven reachable, cache writable, folder usable, port free.

ParameterTypeDescription
portintegerdefault 5432Port to check is free (default 5432)

explain_query ​

The query plan, as JSON (EXPLAIN FORMAT JSON). With analyze, the statement really runs, inside a transaction that is always rolled back, so its changes never persist (sequences still advance); actual times and row counts are included.

ParameterTypeDescription
targetstringrequiredInstance name, a connection name the server was given (list_instances shows them), or a connection string. Never put a password in a tool argument: it would be visible in the conversation; use a connection name, or PGPASSWORD or ~/.pgpass on the server
sqlstringrequiredOne statement
analyzebooleandefault falseRun it and include actual times and rows (rolled back afterwards)
databasestringoptionalDatabase (default: postgres for an instance)
schemastringoptionalSchema for unqualified names

format_sql ​

read-only, idempotent

Format SQL with the PostgreSQL parser, keeping comments. No server needed.

ParameterTypeDescription
sqlstringrequiredSQL: one or more statements; comments are kept

get_connection_string ​

read-only, idempotent

The connection string of a running instance.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it
formatstringdefault npgsqlnpgsql (default), uri, libpq, jdbc or env
databasestringoptionalDatabase (default: postgres)
schemastringoptionalSchema for unqualified names (sets the search path)

get_logs ​

read-only, idempotent

The last lines of an instance's server log: startup messages, errors, slow statements.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it
linesintegerdefault 50Lines from the end (default 50, at most 1000)

install_version ​

idempotent

Download, verify and extract a PostgreSQL version ahead of time, so a later start_instance is fast.

ParameterTypeDescription
versionstringrequiredExact (17.6.0), major (17), minor (17.6) or latest

kill_instance ​

destructive, asks first

Force-kill an instance's server processes, as a last resort when stop_instance does not work. Asks for confirmation.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it
confirmbooleandefault falseSet to true, after the user agreed, when the client cannot ask the user itself

list_extensions ​

read-only, idempotent

The extensions CREATE EXTENSION can use in a PostgreSQL version: name, default version, what it requires, description.

ParameterTypeDescription
versionstringrequiredExact (17.6.0), major (17), minor (17.6) or latest

list_instances ​

read-only, idempotent

Every pgembed instance on this machine (name, version, port, state, uptime, data size), and the names of the other servers this MCP server was given (connections), usable as a target.

list_versions ​

read-only, idempotent

PostgreSQL versions published for this machine: the newest of each major, or every version of one major.

ParameterTypeDescription
majorstringoptionalA major, for example 17, to list all of its versions

remove_instance ​

destructive, asks first

Delete an instance and all of its data, stopping it first if it runs. Asks for confirmation.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it
confirmbooleandefault falseSet to true, after the user agreed, when the client cannot ask the user itself

restart_instance ​

Stop an instance and start it again with the same version, port and settings.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it

run_sql ​

Run SQL against an instance (by name) or any server (by connection string). Each statement returns its rows (at most max_rows; the result says when it was truncated) or its affected rows. json/jsonb values come back as JSON. Statements that change the schema or existing rows ask for confirmation first. With read_only, anything that writes is refused and the SQL runs in a read-only transaction. Errors include the position, detail and hint, to correct the SQL. To page through a large result, use ORDER BY with a keyset (WHERE id > last) or LIMIT/OFFSET.

ParameterTypeDescription
targetstringrequiredInstance name, a connection name the server was given (list_instances shows them), or a connection string. Never put a password in a tool argument: it would be visible in the conversation; use a connection name, or PGPASSWORD or ~/.pgpass on the server
sqlstringrequiredSQL: one or more statements
databasestringoptionalDatabase (default: postgres for an instance)
schemastringoptionalSchema for unqualified names (sets the search path)
max_rowsintegerdefault 100Rows returned per statement (default 100, at most 10000)
read_onlybooleandefault falseRefuse anything that writes, and run in a read-only transaction
confirmbooleandefault falseSet to true, after the user agreed to the changes, when the client cannot ask the user itself

start_instance ​

idempotent

Start a named PostgreSQL instance in the background, creating it on first use (give a version then). If it is already running, attaches to it. It keeps running after this conversation, and keeps its port. Returns the connection string.

ParameterTypeDescription
namestringrequiredInstance name: letters, digits, '.', '_' and '-'
versionstringoptionalVersion for a new instance: exact (17.6.0), major (17), minor (17.6) or latest. Not needed to restart an existing one
portintegeroptionalPort; default 5432 when free, else any free port, remembered for later starts

stop_instance ​

idempotent

Stop a running instance cleanly. Its data is kept; start_instance starts it again.

ParameterTypeDescription
namestringrequiredInstance name, as list_instances shows it

Released under the MIT License.