
Pgport
io.github.CloudCorpRecordsPublished by GitHub account CloudCorpRecordsv0.1.0Updated Oct 29, 2026
Read-only SQL queries against a PostgreSQL database.
Overview
Runs single read-only SQL queries against a PostgreSQL database and returns the rows, refusing anything that could modify data.
- What you can do
- Run one read-only SELECT or WITH query against a PostgreSQL database and get the rows back as a JSON array keyed by column name.
- Inspect schema by querying information_schema yourself, since the server holds no schema knowledge.
- Reject non-SELECT statements, multiple statements and write keywords before they reach the database, and execute accepted queries inside an explicit read-only transaction.
- Report guard violations, missing connection details, a missing psql client and database errors as tool errors rather than fabricated rows.
- When to use it
- Useful when an assistant needs to answer questions from a live PostgreSQL database while being structurally unable to change it, for example exploring tables, checking counts or pulling sample rows during analysis.
- Requirements
- Runs locally over stdio via npx or the Docker image. Needs a PostgreSQL connection string, passed as a command argument or through the PGPORT_DATABASE_URL environment variable (plain DATABASE_URL also works). The psql command-line client must be on PATH; without it the server still starts but queries fail.
Installation
In SourceWeft
- Open Pgport in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
pgport
pgport lets an agent — or you, at a terminal — ask a PostgreSQL
database questions without ever being able to change it. It accepts a
connection string, runs a single read-only query, and hands back the
rows. Anything that is not one plain SELECT or WITH ... SELECT
statement is refused before it leaves the process, and the statement
that does run executes inside an explicit read-only transaction.
There is no bundled database driver. Under the hood pgport shells out
to the psql command-line client, so a machine that wants live answers
needs psql on its PATH. Without it — or without a connection
string — the server still starts and lists its tool; only the query
itself reports the problem.
Install
Or run the container image:
The container defaults to the MCP server (see below). Pass CLI arguments to use it as a CLI instead.
CLI
Exit codes: 0 on success, 1 when the query, the connection string,
or psql itself fails (the error says which), 2 for usage errors.
The connection string is a normal PostgreSQL URL:
postgres:// or postgresql://, with host, optional port (default
5432), database name from the path, and optional user and password in
the userinfo. For the mcp command the string can be left off the
command line and supplied through the PGPORT_DATABASE_URL
environment variable instead (plain DATABASE_URL works too).
The read-only guard
A query is accepted only if all of these hold:
- After leading whitespace and comments are stripped, its first
keyword is
SELECTorWITH. - It is a single statement: a semicolon followed by anything other than whitespace ends the conversation.
- None of
INSERT,UPDATE,DELETE,DROP,ALTER,CREATE,TRUNCATE,GRANT,REVOKE,COPY, orVACUUMappears as a whole word outside a string literal. Single-quoted literals are blanked out before scanning, soSELECT 'delete me'is a perfectly good query; a column literally namedupdateis not — the guard would rather refuse an odd name than be talked around.
Accepted queries run as
BEGIN TRANSACTION READ ONLY; <sql>; COMMIT; through
psql -v ON_ERROR_STOP=1 --csv, and the CSV output is parsed into row
objects. Values come back as the strings psql rendered.
MCP server
One bin serves both faces. The mcp subcommand starts a stdio MCP
server:
MCP client configuration:
Tools
The server deliberately knows nothing about your schema at the MCP
layer: ask the database itself, for example
SELECT table_name FROM information_schema.tables, or use the CLI
schemas command, which groups information_schema.columns rows
into a per-table column list.
Development
The core logic lives behind an injectable executor interface, which is what the test suite drives: connection-string parsing, the guard, pass-through querying, error propagation, and schema grouping are all covered with a fake executor.
License
MIT — see LICENSE.
Source: README.md at commit c99b56c
Tools
0Version history
1- v0.1.0LatestOct 29, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts