ต้นแบบ · รุ่นทดลอง: มีทุก server ในทะเบียนทางการ อัปเดตทุก 30 นาที รีวิวและบัญชีผู้ใช้จะมาในขั้นถัดไป
PopNx MCPที่รวม MCP สำหรับคนใช้ AI · อธิบายเป็นภาษาคน

Postgres (read-only transactions)

โดย Poudel0รุ่น 0.1.3i★ –iรันบนเครื่อง
ชื่อใน registryio.github.Poudel0/postgres-mcp-safe

ติดตั้ง

ภาพรวม

คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)

Drop-in replacement for @modelcontextprotocol/server-postgres that is actually read-only.

สามเสาของ PopNx MCP

สามเรื่องนี้ไม่รวมเป็นคะแนนเดียว เพราะความเห็น การวัด และความนิยม เป็นคนละเรื่องกัน

ใช้ทำอะไรได้

ตัวนี้ยังไม่ได้เรียบเรียงเป็นภาษาไทย ด้านล่างคือข้อเท็จจริงที่เราอ่านจาก registry

  • การเชื่อมต่อ: รันบนเครื่อง
  • ช่องทาง (transport): stdio
  • หมวด: ฐานข้อมูลและชุดข้อมูล

ติดตั้ง

เลือกโปรแกรม AI ที่คุณใช้ แล้วคัดลอกค่าตั้งไปวาง

ก่อนติดตั้ง

ต้องเตรียมก่อน

  • npmติดตั้ง Node.js (มีคำสั่ง npx) ในเครื่อง

คุณใช้แอปไหน

เลือกแอปด้านบน เราจำไว้ให้ ครั้งหน้าปุ่มจะขึ้นว่า “ติดตั้งลง …”

เปิด Claude Desktop → Settings → Developer → Edit Config แล้ววางค่านี้ในไฟล์ claude_desktop_config.json

{
  "mcpServers": {
    "postgres-safe": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-safe"
      ]
    }
  }
}

พิมพ์คำสั่งนี้ใน Terminal

claude mcp add postgres-safe -- npx -y postgres-mcp-safe

ตัวนี้ต้องใส่ค่าในคำสั่งเปิดเอง ให้คัดลอกค่าตั้งแล้วเติมค่า

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .cursor/mcp.json ของโปรเจกต์ หรือ ~/.cursor/mcp.json

{
  "mcpServers": {
    "postgres-safe": {
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-safe"
      ]
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

ตัวนี้ต้องใส่ค่าในคำสั่งเปิดเอง ให้คัดลอกค่าตั้งแล้วเติมค่า

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .vscode/mcp.json ของโปรเจกต์

{
  "servers": {
    "postgres-safe": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "postgres-mcp-safe"
      ]
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

ตัวนี้รันในเครื่องคุณ แต่ ChatGPT ต่อได้เฉพาะ server บนอินเทอร์เน็ต ลองเลือกแอปอื่น

ตัวเลือกเก็บในคุกกี้บนเครื่องนี้ ไม่ต้องมีบัญชี

ค่าตั้งนี้สร้างจากข้อมูลใน registry ของผู้ทำ ถ้าไม่ตรงกับ README ให้เชื่อ README

ทำอะไรได้บ้าง

รันในเครื่องคุณ รายการเครื่องมือจะขึ้นในแอป AI หลังติดตั้ง

ผลตรวจเบื้องต้นi

เราตรวจจากข้อมูลที่ใครก็เปิดดูได้ ยังไม่ได้อ่านโค้ด ข้อที่ไม่เกี่ยวกับตัวนี้ไม่นับในตัวหาร · ตรวจเมื่อ 6 พ.ย. 2569

  • ✓ ผ่าน

    ตัวตนผู้ทำตรงกับ repo

    ชื่อใน registry ยืนยันด้วยบัญชี GitHub Poudel0 ซึ่งเป็นเจ้าของ repo

  • … ยังไม่ตรวจ

    ยังมีคนดูแล

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • … ยังไม่ตรวจ

    มีสัญญาอนุญาต (license)

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • – ไม่เกี่ยว

    endpoint ตอบ

    ตัวนี้รันบนเครื่องคุณ ไม่มี endpoint บนอินเทอร์เน็ต

  • – ไม่เกี่ยว

    ล็อกอินแบบ OAuth

    ตัวนี้รันบนเครื่อง ใช้ค่าที่ตั้งในเครื่องแทน

  • … ยังไม่ตรวจ

    คำอธิบายเครื่องมือไม่มีคำสั่งแอบแฝง

    รันในเครื่องคุณ เราอ่านรายการเครื่องมือได้เฉพาะตัวที่มี endpoint บนอินเทอร์เน็ต

เทียบกับตัวอื่นในหมวด ฐานข้อมูลและชุดข้อมูลi

  • ดาวมากกว่า 0% ของอีก 953 ตัวในหมวดนี้
  • ส่งรุ่นใหม่เข้า registry ล่าสุดกว่า 92% ของอีก 953 ตัวในหมวดนี้
  • ผลตรวจเบื้องต้นดีกว่าหรือเท่ากับ 100% ของอีก 953 ตัวในหมวดนี้

เทียบกับทุก server ที่ยังใช้งานในหมวดนี้ทั้งทะเบียน ดาวนับเฉพาะเมื่อผู้ลงทะเบียนเป็นเจ้าของ repo

คำถามที่พบบ่อย

Postgres (read-only transactions) ปลอดภัยไหม?

จากการตรวจเบื้องต้นของเรา ผ่าน 1 จาก 1 ข้อที่ตรวจได้ เรายังไม่ได้อ่านโค้ด ก่อนใส่กุญแจหรือ token ให้ดูว่า server ขอสิทธิ์อะไร และเลือกกุญแจที่ทำได้เท่าที่จำเป็น

ต้องใช้กุญแจหรือรหัสอะไรบ้าง?

registry ไม่ได้ระบุว่าต้องใช้กุญแจ แต่บางตัวจะขอให้ล็อกอินตอนใช้ครั้งแรก

ตัวนี้รันบนเครื่องหรือบนคลาวด์?

รันบนเครื่องของคุณ โปรแกรม AI จะเปิด server ขึ้นมาเองเมื่อใช้ ข้อมูลไม่ต้องผ่านเซิร์ฟเวอร์ของผู้ทำ (ยกเว้นตัวที่ไปเรียกบริการออนไลน์ต่อ)

ยังมีคนดูแลอยู่ไหม?

repo บน GitHub มีการแก้โค้ดล่าสุด – และส่งรุ่นล่าสุด (0.1.3) เข้า registry 3 วันที่ผ่านมา

ใช้กับโปรแกรมไหนได้บ้าง?

โปรแกรมที่รองรับ MCP เช่น Claude Desktop, Claude Code, Cursor และ VS Code ตัวนี้ต้องมี Node.js, Docker ในเครื่องด้วย

มีตัวไหนใช้แทนได้บ้าง?

ในหมวดเดียวกันมี Supabase, MongoDB MCP Server, Elasticsearch MCP Server

ตัวที่ใช้แทนได้

server หมวดเดียวกันจากผู้ทำคนอื่น เรียงตามดาว

อ่านการ์ด:★ ดาว GitHubiสามเสา: รีวิว · ผลตรวจ · การใช้งานiอัปเดต = วันที่ส่งรุ่นล่าสุดเข้า registryi

Supabase

โดย supabase

server ทางการของ Supabase ให้ AI สร้างตาราง ถามข้อมูล และดูการตั้งค่าโปรเจกต์ในฐานข้อมูล Supabase ของคุณ

บนเครื่องหรือคลาวด์★ 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.0อัปเดต 14 เดือนที่ผ่านมา
ติดตั้ง

README จากผู้ทำ

เปิดอ่าน README

ส่วนนี้คัดจาก repo ของผู้ทำตามต้นฉบับ PopNx MCP ไม่ได้ตรวจหรือรับรองเนื้อหา ตัด HTML รูปภาพ และสคริปต์ออกแล้ว ลิงก์จะพาออกนอกเว็บ

postgres-mcp-safe

A drop-in replacement for the deprecated @modelcontextprotocol/server-postgres, but actually read-only.

Lets AI tools (Claude, Cursor, Zed, ...) query a Postgres database, read its schema and explain queries. Swap the package name in your MCP config and keep everything else.

Migrating from server-postgres

 {

"mcpServers": { "postgres": { "command": "npx",

  • "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
  • "args": ["-y", "postgres-mcp-safe", "postgresql://localhost/mydb"] } }

}

Docker: docker run -i --rm ghcr.io/poudel0/postgres-mcp-safe postgresql://host.docker.internal:5432/mydb. Binaries for Linux, macOS and Windows are on the releases page.

One catch: if your URL logs in as a superuser (like Docker's default postgres user), every call is refused until you either create a read-only role (recommended) or add --allow-superuser before the URL. A superuser can get around a read-only transaction, so we won't pretend otherwise.

The old server's query tool and postgres://.../ /schema resources work the same. See Differences for the small, deliberate changes.

Why

The old server's "read-only" mode can be broken with COMMIT; DROP TABLE ... (Datadog Security Labs, 2025-08-21). A fix was merged upstream but never published, and the package is deprecated with no official successor.

Flags

Flags go before the URL.

FlagDefault
--timeout30sTime limit per call.
--max-rows1000Rows returned per call. Extra rows are cut off with a note.
--max-bytes262144JSON bytes returned per call, and the max size of a single row.
--allow-explain-analyzeoffLets explain run EXPLAIN ANALYZE, which executes the query.
--allow-superuseroffAllows a superuser role, or a member of one. Read-only is then not guaranteed.

Each call opens a fresh connection (that's part of the safety model). Against a remote database over TLS that costs a few round trips: about 0.5 s per call at 50 ms latency. On Postgres 17+ you can save one round trip by adding sslnegotiation=direct to the URL.

Limits can't be turned off; 0 is an error. The URL can also be a keyword DSN (host=db dbname=app), and the standard PG* environment variables (PGPASSWORD, ...) are read as libpq would.

Tools

ToolInput
querysqlOne read-only statement. Returns a JSON array of rows.
list_tablesschema?Tables and views with schema and type.
describe_tabletable, schema? (public)Columns, constraints and indexes.
explainsql, analyze?Query plan. analyze needs --allow-explain-analyze.

How read-only is enforced

Postgres enforces it, not a SQL parser. Every call:

  1. Opens a fresh connection (no session state survives a call) and starts a READ ONLY transaction.
  2. Sends your SQL as a single protocol-level *Parse* message. Postgres rejects more than one statement there, so COMMIT; ... fails before anything runs.
  3. Runs it only if Postgres says it returns rows. COMMIT, SET, DO, COPY, CALL, PREPARE and friends are rejected without running.
  4. Applies statement_timeout, a client deadline, and row and byte caps.
  5. Closes the connection, which ends the transaction.

The bypass suite runs every known payload against a real database and checks a canary table after each one:

PayloadResult
COMMIT; DROP SCHEMA public CASCADE;Rejected: multiple statements
COMMIT / SET TRANSACTION READ WRITE / DO $$...$$ / CALL p()Rejected: returns no rows
COPY (SELECT 1) TO PROGRAM '...' (as superuser)Rejected: returns no rows
DELETE ... RETURNING * / WITH d AS (DELETE ...) SELECT ...Read-only transaction error
SELECT nextval('s')Read-only transaction error
SELECT set_config('transaction_read_only','off',true)Error
SELECT pg_sleep(600), even after set_config('statement_timeout','0')Cancelled at --timeout
SELECT pg_advisory_lock(1)Released when the call ends
SELECT generate_series(1,10000000) / repeat('x', 10000000)Capped / rejected, memory stays bounded
explain with ANALYZE SELECT ...Syntax error: can't smuggle ANALYZE

Found a bypass? Open an issue. It becomes a test row before the fix.

Use a read-only role too

This server makes each call read-only at the transaction level. Some things are out of a transaction's reach, and only the database role stops them:

  • dblink_exec(...) opens a *separate* session that isn't read-only.
  • pg_terminate_backend(...) kills other connections.
  • A superuser can read server files (pg_read_file, pg_ls_dir): read-only stops writes, not reads.
  • A superuser can write server files with lo_export, even inside a read-only transaction.

So connect as a role that can only read:

CREATE ROLE mcp_ro LOGIN PASSWORD '...';

GRANT pg_read_all_data TO mcp_ro; -- PG 14+; or GRANT SELECT on what it needs ALTER ROLE mcp_ro SET default_transaction_read_only = on;

Because of the last two, the server refuses superuser roles (and members of them) unless you pass --allow-superuser.

Differences from server-postgres

  1. Errors in a tool call come back as a tool result with isError: true and the Postgres message and SQLSTATE, so the model can fix its SQL. The old server sent a JSON-RPC error.
  2. resources/read only shows columns of the public table, in column order. The old one mixed in columns from same-named tables in other schemas.
  3. Percent-encoded table names in resource URIs are decoded (the old server never matched them).
  4. Values are what Postgres prints, typed where it's clear: booleans, numbers (including bigint and numeric) and json are JSON values; everything else is a string such as "2026-01-02 03:04:05+00", "\\x0102" or "{x,y}". NaN is "NaN" (the old server gave null).
  5. Statements that return no rows (SET, DO, COPY, ...) are rejected. The old server ran them and returned [].

Development

docker run -d --name pg-mcp-test -e POSTGRES_PASSWORD=postgres -p 127.0.0.1:5434:5432 postgres:17-alpine

export DATABASE_URL='postgresql://postgres:postgres@127.0.0.1:5434/postgres?sslmode=disable' make test # all tests, including the bypass suite make golden # re-record the old server's output (needs npx)

DATABASE_URL must be a superuser: the fixture resets the public schema and creates the mcp_ro role. Use a throwaway database.

ถาม PopNx