프로토타입 · 미리 보기: 공식 레지스트리의 모든 서버를 담고 있으며 30분마다 동기화해요. 리뷰와 계정 기능은 다음 단계에서 열려요.
PopNx MCPAI를 쓰는 사람을 위한 MCP 서버 · 쉬운 말로 설명해요

Pg Readonly MCP

제작자: les-k버전 0.1.1i★ –i내 컴퓨터에서 실행
레지스트리 이름io.github.les-k/pg-readonly-mcp

설치

개요

제작자가 쓴 설명(영어 원문)

A read-only Postgres MCP server that parses SQL rather than pattern-matching it.

PopNx MCP의 세 기둥

이 세 가지는 절대 하나의 점수로 합치지 않아요. 의견, 측정, 인기는 서로 다른 것이니까요.

할 수 있는 일

이 서버는 아직 쉬운 말로 된 요약을 쓰지 못했어요. 아래는 레지스트리에서 읽어 온 사실이에요.

  • 연결 방식: 내 컴퓨터에서 실행
  • 전송 방식: stdio
  • 카테고리: 데이터베이스 및 데이터셋
  • 입력해야 할 값: PG_READONLY_MCP_DSN

설치

쓰고 있는 AI 앱을 고른 다음 설정을 복사하세요.

설치하기 전에

  • 기본 점검: 1개 중 1개 통과
  • 내 컴퓨터에서 내 사용자 계정의 권한(파일, 네트워크, 앱)으로 실행돼요.
  • 직접 입력할 값: PG_READONLY_MCP_DSN

비밀로 표시된 값은 내 계정의 열쇠예요. 절대 다른 사람과 공유하거나 채팅에 붙여 넣지 마세요.

필요한 것

  • PyPIPython의 uv 설치(uvx 명령어용)

어떤 앱을 쓰세요?

위에서 앱을 고르세요. 기억해 두었다가 다음부터는 버튼에 “…에 설치”라고 표시해요.

Claude Desktop → Settings → Developer → Edit Config를 열고 claude_desktop_config.json에 이 내용을 붙여 넣으세요

{
  "mcpServers": {
    "pg-readonly": {
      "command": "uvx",
      "args": [
        "pg-readonly-mcp"
      ],
      "env": {
        "PG_READONLY_MCP_DSN": "your-value"
      }
    }
  }
}

터미널에서 이 명령어를 실행하세요

claude mcp add pg-readonly --env PG_READONLY_MCP_DSN=your-value -- uvx pg-readonly-mcp

실행하기 전에 빈 값을 채워 주세요.

Cursor에서 열기

또는 설정을 직접 복사하기

프로젝트의 .cursor/mcp.json 또는 ~/.cursor/mcp.json에 붙여 넣으세요

{
  "mcpServers": {
    "pg-readonly": {
      "command": "uvx",
      "args": [
        "pg-readonly-mcp"
      ],
      "env": {
        "PG_READONLY_MCP_DSN": "your-value"
      }
    }
  }
}

브라우저가 앱을 열지 물어본 다음, 앱이 설정을 보여 주고 확인을 요청해요. 키 값은 비워 두니 직접 입력하세요.

VS Code에서 열기

또는 설정을 직접 복사하기

프로젝트의 .vscode/mcp.json에 붙여 넣으세요

{
  "servers": {
    "pg-readonly": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "pg-readonly-mcp"
      ],
      "env": {
        "PG_READONLY_MCP_DSN": "your-value"
      }
    }
  }
}

브라우저가 앱을 열지 물어본 다음, 앱이 설정을 보여 주고 확인을 요청해요. 키 값은 비워 두니 직접 입력하세요.

이 서버는 내 컴퓨터에서 실행되는데, ChatGPT는 인터넷에 있는 서버에만 연결할 수 있어요. 다른 앱을 고르세요.

선택한 앱은 이 기기의 쿠키에만 저장돼요. 계정은 필요 없어요.

직접 입력할 값

  • PG_READONLY_MCP_DSN 비밀 필수 env
    Postgres connection string for a role that holds only SELECT. The server refuses to start otherwise.

이 설정은 제작자의 레지스트리 정보로 만들었어요. README와 다르면 README를 따르세요.

할 수 있는 일

내 컴퓨터에서 실행돼요. 설치하면 AI 앱에 도구 목록이 나타나요.

기본 점검i

누구나 볼 수 있는 정보를 점검했고, 코드는 읽지 않았어요. 해당하지 않는 항목은 개수에서 뺐어요. · 2026년 11월 7일 점검

  • ✓ 통과

    제작자와 저장소 일치

    레지스트리 이름이 GitHub 계정 les-k 기준으로 확인되었고, 이 계정이 저장소를 소유하고 있어요

  • … 아직 점검 안 함

    계속 관리되고 있음

    아직 GitHub에서 이 저장소를 읽어 오지 않았어요

  • … 아직 점검 안 함

    라이선스 있음

    아직 GitHub에서 이 저장소를 읽어 오지 않았어요

  • – 해당 없음

    엔드포인트 응답

    내 컴퓨터에서 실행되는 서버라 인터넷 엔드포인트가 없어요

  • – 해당 없음

    OAuth로 로그인

    내 컴퓨터에서 실행되며, 대신 로컬 설정을 사용해요

  • … 아직 점검 안 함

    도구 설명에 숨겨진 지시 없음

    내 컴퓨터에서 실행돼요. 도구 목록은 인터넷 엔드포인트가 있는 서버에서만 읽을 수 있어요

데이터베이스 및 데이터셋 카테고리의 다른 서버와 비교i

  • 이 카테고리의 다른 서버 954개 중 0%보다 스타가 많아요
  • 이 카테고리의 다른 서버 954개 중 45%보다 최근에 레지스트리에 공개됐어요
  • 기본 점검 결과가 이 카테고리의 다른 서버 954개 중 100%와 같거나 더 좋아요

레지스트리에서 이 카테고리의 활성 서버 전체와 비교했어요. 스타는 게시자가 저장소를 소유한 경우에만 세요.

자주 묻는 질문

Pg Readonly MCP, 안전한가요?

해당하는 기본 점검 1개 중 1개를 통과했어요. 코드는 읽지 않았어요. 키나 토큰을 넣기 전에 서버가 어떤 권한을 요구하는지 확인하고, 꼭 필요한 권한만 있는 키를 쓰세요.

어떤 키나 코드가 필요한가요?

입력해야 할 값: PG_READONLY_MCP_DSN

내 컴퓨터에서 실행되나요, 클라우드에서 실행되나요?

내 컴퓨터에서 실행돼요. AI 앱이 필요할 때 실행하고, 데이터는 제작자의 서버를 거치지 않아요(서버 자체가 온라인 서비스를 호출하는 경우는 제외).

아직 관리되고 있나요?

GitHub 저장소는 마지막으로 – 변경됐고, 최신 버전(0.1.1)은 35일 전 레지스트리에 올라왔어요.

어떤 앱에서 쓸 수 있나요?

Claude Desktop, Claude Code, Cursor, VS Code처럼 MCP를 지원하는 앱에서 쓸 수 있어요. 내 컴퓨터에 Python (uv)도 있어야 해요.

대신 쓸 수 있는 건 뭐가 있나요?

같은 카테고리에는: Supabase, MongoDB MCP Server, Elasticsearch MCP Server

대안

같은 카테고리에서 다른 제작자가 만든 서버예요. 스타 순으로 정렬했어요.

카드 보는 법:★ GitHub 스타i세 기둥: 리뷰 · 점검 · 사용 정도i업데이트 = 최신 버전을 레지스트리에 공개한 날i

Supabase

제작자: supabase

MCP server for interacting with the Supabase platform

컴퓨터 또는 클라우드★ 2,993Apache-2.0어제 업데이트
설치

MongoDB MCP Server

제작자: mongodb-js

MongoDB Model Context Protocol Server

내 컴퓨터에서 실행★ 1,157Apache-2.0그저께 업데이트
설치

Elasticsearch MCP Server

제작자: cr7258

MCP server for interacting with Elasticsearch

내 컴퓨터에서 실행★ 315Apache-2.014개월 전 업데이트
설치

제작자의 README

README 열기

제작자의 저장소에서 쓰인 그대로 가져왔어요. PopNx MCP가 검토하거나 보증한 내용이 아니에요. HTML, 이미지, 스크립트는 제거했어요. 링크를 누르면 이 사이트를 벗어나요.

pg-readonly-mcp

In plain terms: this lets an AI look at your database and do nothing else.

Not because it was told not to write — the database login it uses is physically

incapable of writing. The official version of this tool had a published flaw

that let a "delete everything" command slip past its safety check; this one is

tested against that exact attack.

A read-only Postgres MCP server that parses SQL rather than pattern-matching it — because the alternative has already failed in public, once, in a way that is worth being specific about.

The bypass this exists to close

Anthropic's reference Postgres MCP server enforced "read-only" by wrapping each query in a read-only transaction. It also accepted semicolon- delimited multi-statement input. That combination is exploitable:

SELECT 1; COMMIT; DROP SCHEMA public CASCADE;

The COMMIT ends the read-only transaction early. Everything after it runs at full session privilege. Datadog Security Labs disclosed this in 2026; the server was deprecated and archived — and the vulnerable package was still pulling 21,000 weekly downloads after that.

A read-only transaction is a property of *how* a query runs. It says nothing about *what the query is*, which is exactly why it was possible to talk your way out of it. This server checks the second thing instead.

Two independent layers

Either one alone would have stopped the disclosed bypass. Both exist because a flaw in one should not be the only thing standing between an agent and a write.

1. The SQL is parsed, not scanned. guard.py uses sqlglot to build a real syntax tree and applies three checks:

  • Exactly one statement. sqlglot.parse splits on statement-terminating semicolons the way a driver would, so the payload above becomes three statements and is refused before any of them reach a connection.
  • The outer statement is a read shape — SELECT, UNION, INTERSECT, EXCEPT, or a CTE built from those. DROP TABLE users is refused here.
  • No write anywhere in the tree, walked in full. This is the check the other two cannot replace: Postgres allows a CTE to carry a data-modifying statement, so WITH x AS (DELETE FROM t RETURNING *) SELECT * FROM x is, at the outer level, a SELECT. A check that only looks at the outer shape misses this completely. Walking every node finds the DELETE regardless of how many levels down it sits.

An unrecognised statement shape — anything sqlglot has no specific rule for — is refused by the same rule as everything else. Unfamiliar is not the same as safe.

2. The connection itself cannot write, independent of what it is asked to run. check_connection_is_readonly refuses to start if the connected role is a superuser, can create databases or roles, can bypass row-level security, or holds any grant beyond SELECT on any table it can see. Not exhaustive — Postgres privilege can also arrive through ownership, PUBLIC grants, or RLS policies this check does not enumerate — but it catches the two ways a misconfiguration most commonly shows up, stated here rather than implied.

What it does not protect against

  • A privileged connection string handed to it anyway. The startup check catches the common shapes of over-privilege; it is not an exhaustive privilege audit, and it says so above rather than implying otherwise.
  • Resource exhaustion within the limits. A query that legally returns 1,000 rows of very wide data, or that is legitimately expensive to plan, still costs what it costs. Row caps and a statement timeout bound the damage; they do not make an expensive read free.
  • What the agent does with the data once it has it. This is a query gate, not a data-loss-prevention tool. Read access to a table is read access to whatever is in it.
  • A parser disagreement. sqlglot and Postgres's own parser are two independent implementations of the same grammar. It is not proven that they agree on every edge case Postgres accepts — a genuine, if narrow, gap in a project whose whole premise is not trusting a single layer. Layer two exists partly because of this: even if a parser differential let something unintended through the guard, the connection underneath still cannot write.

Scanner results

Run against agent-audit 0.19.2 on 18 August 2026: 15 findings, 11 auto-suppressed, 4 actionable — 1 BLOCK, 3 WARN.

The BLOCK finding is the most interesting one, and worth reading in full. server.py:156, confidence 1.0: cur.execute(sql) — flagged as SQL injection via unparameterized execution. That line is real. It is also the single most defended line in this codebase: by the time sql reaches it, validate_readonly() has already parsed it, confirmed it is exactly one statement, confirmed that statement is a read shape, and walked every node in it checking for a write. The scanner has no way to see any of that — it is a single-file pattern match, and the validation happens in a different function, in a different module, several lines earlier. It correctly identifies the *shape* that is dangerous in general and cannot see that the shape has already been checked.

It also could not have been satisfied by doing what it suggests. Parameterized queries protect *values* substituted into a fixed query shape — WHERE id = %s. They do not apply here, because the query's *structure* is the input this tool exists to accept. There is no values-only parameterization scheme for "run whichever read-only SQL the caller asks for." The fix for this class of tool is validating the structure, which is what the rest of this file is for.

The WARN on `query()`'s definition (AGENT-034, "no input validation in the function body") is the same blind spot from a different angle: the function's first line calls validate_readonly(sql) inside a try/except. A call to an imported function is not a pattern the scanner credits as validation.

The two WARNs on hardcoded credentials are in tests/conftest.py: the default admin DSN (postgres:postgres@localhost:5432/postgres, the standard local/CI Postgres default) and the literal password used for roles the test suite creates and drops within the same test. Both are correctly identified as credential-shaped strings; neither is a credential that guards anything — one points at a throwaway local database, the other lives for the duration of a single test.

The remaining 11 findings — all AGENT-041, all in test fixtures that build CREATE SCHEMA / GRANT / DROP ROLE statements from uuid.uuid4()-derived names — were already auto-suppressed by the scanner itself.

A pattern scanner is a smoke detector, not a judge. Publishing what it finds and why is worth more than a clean number would be on its own.

Install

pip install pg-readonly-mcp

From a source checkout: pip install -e .

Configure

Requires a connection string, given either as --dsn or via PG_READONLY_MCP_DSN — the environment variable exists so a password need not appear on a command line or in a client config file that might be committed by accident:

{

"mcpServers": { "pg-readonly-mcp": { "command": "pg-readonly-mcp", "env": { "PG_READONLY_MCP_DSN": "postgresql://readonly_role:...@host:5432/db" } } } }

The role in that connection string needs to hold nothing beyond `SELECT`. The server checks this itself and refuses to start otherwise — see check_connection_is_readonly above.

The tool

One tool, deliberately. A server whose entire value proposition is "we refuse everything except reads" does not need a second surface to also get that right.

ToolWhat it does
queryRuns one SELECT-shaped statement. Parsed and walked before it touches the connection. Capped at --max-rows (default 1000) and --timeout-ms (default 5000)

Tests

37 tests. 25 need no database and run anywhere — they are [`guard.py`](src/pg_readonly_mcp/guard.py)'s whole test suite, pure string in, decision out. The other 12 need a live Postgres and are integration tests by design: the point of check_connection_is_readonly is what it does against real role attributes and real grants, and a mocked connection would pass regardless of what the server actually does against a real one.

pytest -q --cov=pg_readonly_mcp

CI runs against a real `postgres:16` service container and fails the build if the database-backed tests report as skipped there — the same rule sweep-mcp applies to its symlink tests, for the same reason: a test that quietly does nothing is worse than no test.

Among the 12: a live reproduction of the exact Datadog payload, driven through the actual MCP tool call rather than through guard.py directly — and an assertion that the target schema still exists afterward, not just that an exception was raised. Also covered: a write hidden inside a CTE through the same call path, the row cap, the statement timeout, that a cancelled query leaves the connection usable for the next one, and that a role with CREATEDB and zero table grants is refused on the role attribute alone.

Coverage on CI, against a real Postgres: 78%, `guard.py` at 100%. The gap in server.py is the generic psycopg.Error catch-all — nothing in the suite deliberately provokes a database error that isn't a cancellation — and main()'s argparse and transport wiring, which the suite exercises through build_server directly instead; the transport is the part least worth mocking and least likely to be where a real mistake hides.

The first version of this pushed did not pass. Two bugs surfaced only once a real Postgres service container ran the suite for the first time, and neither was visible from the code alone: SET statement_timeout = %s reached Postgres as SET statement_timeout = $1 and failed to parse, because SET is a utility statement and does not accept a bind parameter the way a SELECT does — every real call to the tool would have failed identically. Separately, the test fixtures tried to DROP ROLE a role that still held live grants, which Postgres refuses; DROP OWNED BY has to run first. Both are fixed, and the run since is the one these numbers describe. Left in because a suite that only ever reports success is a suite nobody has watched fail.

Layout

src/pg_readonly_mcp/

guard.py parses and walks the tree. Opens no connection. 135 lines. server.py the MCP tool, the connection check, the timeout and row cap. tests/ test_guard.py 25 tests - no database, run anywhere test_server.py 12 tests - live Postgres required, CI-enforced

guard.py knows nothing about MCP or psycopg. If a query is ever refused for a reason that lives in server.py instead, that is a bug — the judgement belongs one layer down, where it can be tested with a string and nothing else.

Licence

MIT.

Author

Built by Leslie Kadenge. I do independent security reviews of MCP servers; my public survey of thirteen production servers is at les-k.github.io/field-notes.html.

PopNx에게 묻기