NexQL Postgres MCP

io.github.NexQL-OSS由 GitHub 帳號 NexQL-OSS 發布v0.2.4更新於 Oct 24, 2026

Standalone Postgres MCP server — schema-aware, read-only by default, installable everywhere.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

獨立的 Postgres MCP 伺服器,讓助理以預設唯讀、感知結構描述的方式檢視、查詢與管理所連線的資料庫。

可以做什麼
  • 搜尋與瀏覽結構描述:結構索引、資料表與欄位探索、關聯圖及情境工具
  • 執行與解讀查詢:唯讀 SELECT 執行、查詢計畫與效能檢查
  • 監控與調校:健康檢查、索引建議、鎖定等 DBA 工具
  • 啟用後可寫入與管理:執行 SQL、編輯資料列、套用 DDL,以及用 add_database 接入另一個連線
  • 管理連線:設定檔、doctor 連線測試,以及透過 init 或 TUI 接入用戶端
適用情境
適合讓助理直接操作真實的 Postgres 資料庫,並依實際結構描述而非猜測資料表名稱運作,預設為唯讀。也適用於 DBA 式巡檢,以及在你主動開啟時的受控寫入。
執行需求
以 stdio 在本機執行。需要 Postgres 連線字串,可透過位置參數 URL、DATABASE_URL 密鑰或 config.toml 中的設定檔提供(路徑可用 NEXQL_MCP_CONFIG 覆寫)。npx 方式需要 Node.js;cargo 建置需要 clang/libclang;Linux 預編譯二進位檔需要 glibc 2.35+。
安裝前請注意
有寫入與管理工具(execute_sql、edit_row、apply_ddl),由連線的 access_mode 控管;把設定檔提升為 write 或 admin 就會開放這些工具,非必要請維持唯讀。DATABASE_URL 或設定檔中的連線字串含有資料庫憑證,README 建議改用 password_command 而非明文。新增資料庫時會開啟一次性本機頁面由你輸入密碼,README 提醒不要把密碼貼進對話。除非關閉,否則每天會向 npm registry 進行一次更新檢查。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 NexQL Postgres MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

nexql-mcp

Standalone Postgres MCP server — schema-aware, read-only by default, installable everywhere.

NexQL Pro ships an in-process MCP server locked to VS Code (pro/src/mcp/). This repo extracts that capability into an independent Rust binary any MCP client can spawn: Claude Desktop, Cursor, VS Code Copilot, Zed, etc.

Status: Phases 0–6 + Phase 7 extension cutover (stdio spawn) + Phase 8 HTTP (bearer, sessions, rate limit) + Phase 9 write/admin tools landed. 55 tools across Schema, Query, Context, Perf, Write, and Admin. Full OAuth gateway stays pro-only; session-store LRU eviction cap not yet implemented. See docs/CUTOVER.md.

Why this exists

Competing Postgres MCP servers expose connect → run query → return rows. Models hallucinate table names against schemas that do not exist. NexQL's moat is the offline schema index (TF-IDF, join graph with inferred FKs, value profiles, optional embeddings, RRF fusion) built in pro/src/features/dbindex/. This repo ports that index plus 54 query/schema/DBA/meta tools from Pro into a fast, trivially installable binary.

Architecture

crates/├── nexql-mcp/      CLI, subcommands, wiring (binary)├── nexql-proto/    MCP JSON-RPC types, transports├── nexql-tools/    tool registry, schemas, executors├── nexql-index/    dbindex port (builder, store, lexical, joins, embed)├── nexql-conn/     connection resolution, pool, credentials└── nexql-policy/   access modes, allow/deny, PII, caps, auditnpm/                npx shim (per-platform optionalDependencies)mcpb/               one-click Claude Desktop bundledocs/               per-client setup, tool reference

Layering is one-directional: policy + conn are leaves → index → tools → binary. nexql-tools never depends on nexql-proto.

Scope boundary: nexql-mcp manages objects within a connected database (tables, indexes, columns, …), not the database catalog itself. CREATE DATABASE / DROP DATABASE are rejected in every access mode — permanent, intentional scope, not a gap. See docs/tools/README.md and docs/REFERENCE.md.

Install

Claude Desktop — one download

Get the bundle for your computer from nexql-mcp.astrx.dev/install, double-click it, and paste your database URL. No terminal, Node or PATH setup. The install form also has an "Allow changes to data" switch (off by default) and an optional schema list.

npx — recommended for every other client

bash
npx -y nexql-mcp@latest postgres://dev@localhost:5432/appdb doctor

-y skips the "ok to proceed?" confirmation prompt; @latest always resolves the newest published release instead of whatever npx happens to have cached — always use both together. This is the desired way to run nexql-mcp: no separate install step, nothing added to PATH, works identically whether a human is typing it or an AI agent is running it on your behalf. Requires Node.js (npx ships with it) — nothing else.

bash
# Verifynpx -y nexql-mcp@latest --version
# Setupnpx -y nexql-mcp@latest setup  # initialize connections and db profiles
# Wire your MCP client (or run the guided wizard)npx -y nexql-mcp@latest init cursor          # Cursornpx -y nexql-mcp@latest init claude-desktop  # Claude Desktopnpx -y nexql-mcp@latest init vscode-copilot  # VS Code Copilotnpx -y nexql-mcp@latest tui                  # interactive profile + client wiring

Client config (command/args) uses the same pattern — no install step for the client to rely on either:

json
{  "mcpServers": {    "nexql-mcp": {      "command": "npx",      "args": ["-y", "nexql-mcp@latest", "--profile", "mydb"]    }  }}

If you are an AI coding agent setting this up on a user's behalf: run npx -y nexql-mcp@latest init <client> --apply — non-interactive, no browser needed, writes the merged client config directly (.mcp.json for claude-code, claude_desktop_config.json for claude-desktop, etc. — see docs/clients/README.md for exact paths per client). Or drive nexql-mcp setup's HTTP API directly: POST /api/v1/clients/preview → POST /api/v1/clients/apply (bearer token printed to stderr on startup). Prefer this over hand-writing claude mcp add-style shell commands or hand-parsing/merging the client's JSON config yourself.

Per-client config paths and paste blocks: docs/clients/README.md.

npm install -g nexql-mcp also works if you'd rather have a permanent nexql-mcp on PATH than repeat npx -y nexql-mcp@latest — same shim, same @nexql/mcp-<os>-<arch> prebuilt binaries, no Rust toolchain needed either way.

Linux system requirements: prebuilt GNU/Linux binaries target glibc 2.35+ (Ubuntu 22.04, Debian 12, RHEL 9, and newer). If npx/npm fails with GLIBC_2.39 not found, use one of the fallback methods below (cargo install builds from source; Docker sidesteps glibc entirely). Musl/static Linux builds are not published yet.

Other install methods (fallback)

Reach for one of these only if npx isn't an option — an offline/air-gapped environment, a CI image that wants a pinned binary baked in, no Node.js available, or you simply prefer a permanent install. All ship the same binary as the npm package.

Quick install script (Linux / macOS / Windows) — installs a permanent binary, no Node.js required

Linux & macOS — downloads the latest release, installs to /usr/local/bin (or ~/.local/bin if sudo is unavailable), then prints setup steps:

bash
curl -fsSL https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.sh | bash

Pin a version:

bash
curl -fsSL https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.sh | NEXQL_MCP_VERSION=v0.2.2 bash

Windows (PowerShell) — installs to %LOCALAPPDATA%\Programs\nexql-mcp and adds it to your user PATH:

powershell
irm https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.ps1 | iex

Pin a version:

powershell
$env:NEXQL_MCP_VERSION = "v0.2.2"; irm https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.ps1 | iex

Or download and run the scripts locally: scripts/install.sh · scripts/install.ps1. Once installed, drop the npx -y nexql-mcp@latest prefix and call nexql-mcp directly for every command above.

uv (PyPI)

uv installs CLI tools from PyPI into isolated environments — same prebuilt binary, no Rust toolchain.

Install uv itself (if needed):

bash
curl -LsSf https://astral.sh/uv/install.sh | sh   # macOS / Linux
powershell
irm https://astral.sh/uv/install.ps1 | iex        # Windows

Install nexql-mcp:

bash
uv tool install nexql-mcpuv tool update-shell    # once, if uv warns the tool bin dir is not on PATH

One-off without installing (uv's equivalent of npx -y):

bash
uvx nexql-mcp postgres://dev@localhost:5432/appdb doctor

Pin a version:

bash
uv tool install 'nexql-mcp==0.2.2'

Upgrade later:

bash
uv tool upgrade nexql-mcp

PyPI status: wheels are not published yet. Until the first PyPI release lands, use npx or the quick install script above. Maintainer steps: docs/publish-pypi-uv.md.

cargo (crates.io) — builds from source
bash
cargo install nexql-mcp

Needs clang/libclang first (pg_query's bindgen requires it):

bash
sudo apt install clang libclang-dev   # Debian/Ubuntusudo pacman -S clang                  # Arch
Manual download — grab a release archive by hand

From the Releases page:

PlatformArchive
Linux x64nexql-mcp-<tag>-x86_64-unknown-linux-gnu.tar.gz
Linux arm64nexql-mcp-<tag>-aarch64-unknown-linux-gnu.tar.gz
macOS Intelnexql-mcp-<tag>-x86_64-apple-darwin.tar.gz
macOS Apple Siliconnexql-mcp-<tag>-aarch64-apple-darwin.tar.gz
Windows x64nexql-mcp-<tag>-x86_64-pc-windows-msvc.tar.gz

Extract and put nexql-mcp (or nexql-mcp.exe) on your PATH.

Docker

Prebuilt, published on every release to GHCR:

bash
docker run --rm -i ghcr.io/nexql-oss/mcp:v0.6.0 postgres://[email protected]:5432/appdb# or: ghcr.io/nexql-oss/mcp:latest

Or build locally from the distroless Dockerfile:

bash
docker build -t nexql-mcp:0.6.0 .docker run --rm -i nexql-mcp:0.6.0 postgres://[email protected]:5432/appdb
Claude Desktop (MCPB one-click bundle)

Each release attaches a platform .mcpb bundle (nexql-mcp-<vendor>.mcpb). nexql-mcp.astrx.dev/install picks the right one for your OS; they are also on the Releases page. Double-click to install into Claude Desktop. The install form maps to DATABASE_URL, NEXQL_MCP_ALLOW_WRITES and NEXQL_MCP_SCHEMAS. Built from mcpb/manifest.json via scripts/package-mcpb.sh.

Homebrew

No published tap yet — each release renders a formula (Formula/nexql-mcp.rb, via scripts/render-homebrew-formula.sh) and attaches it as a release asset for a future homebrew-tap repo to pick up. Until that tap exists, use npx or the quick install script above.

MCP Registry

Listed in the official MCP Registry as io.github.NexQL-OSS/nexql-mcp (server.json), published automatically after each release via GitHub OIDC (no stored credentials) — see .github/workflows/publish-mcp-registry.yml.

  • mcp-name: io.github.NexQL-OSS/nexql-mcp
From source
bash
export LIBCLANG_PATH="${LIBCLANG_PATH:-/usr/lib}"   # or your llvm lib dircargo build --release -p nexql-mcp./target/release/nexql-mcp postgres://dev@localhost:5432/appdb

Updates

Once a day nexql-mcp asks the npm registry (registry.npmjs.org/nexql-mcp/latest) for the newest version. The request sends nothing about you or your database, only a nexql-mcp/<version> user agent. When a newer release is out, the chat gets a short notice with the upgrade command for the way you installed it: npx, npm, pnpm, bun, Volta, cargo, uv, pipx, pip, Homebrew, Docker, the install script or the Claude Desktop bundle. The model passes it on and, if it can run commands on your machine, offers to run it for you. nexql-mcp doctor prints the same line.

npx configs need nexql-mcp@latest. With no tag, npx -y nexql-mcp keeps running the copy npx cached first.

Turn the check off with --no-update-check, NEXQL_MCP_NO_UPDATE_CHECK=1, update_check = false in config.toml, or DO_NOT_TRACK=1. It is also off when CI is set, and fails quietly offline.

Set up a connection

Commands below assume nexql-mcp resolves on PATH. If you're running via npx instead, prefix each one with npx -y nexql-mcp@latest in place of nexql-mcp — see Install.

One-off, no config — pass a connection string directly:

bash
nexql-mcp postgres://dev@localhost:5432/appdb

Saved profiles — put connections in ~/.config/nexql-mcp/config.toml (override the path with NEXQL_MCP_CONFIG):

toml
default_profile = "local"
[profiles.local]url = "postgres://dev@localhost:5432/appdb"access_mode = "read"
[profiles.prod]host = "prod.example.com"dbname = "app"user = "readonly_agent"password_command = "op read op://vault/pg/password"   # never store plaintext secretssslmode = "verify-full"access_mode = "read"schemas = ["public", "billing"]deny_tables = ["auth.*"]pii_columns = ["public.users.ssn", "public.users.email"]max_rows = 200

Full field reference: docs/config.example.toml. Then run bare (nexql-mcp) to use default_profile, or nexql-mcp --profile prod.

Test a connection before wiring it into a client:

bash
nexql-mcp postgres://dev@localhost:5432/appdb doctor# or, for a saved profile (note: --profile goes before the subcommand):nexql-mcp --profile prod doctor

Guided setup — an interactive profile editor plus one-keystroke wiring into whichever clients you use:

  • nexql-mcp tui — terminal UI (see Interactive TUI below)
  • nexql-mcp setup — browser UI on loopback (profiles, client wiring, npx/path launch toggle); also npx -y nexql-mcp@latest setup

Add another database from the chat. Ask your assistant, e.g. "also connect billing on db.internal:5432 as billing_reader". It calls add_database with those details, but never a password. nexql-mcp then opens a one-time page on your computer (127.0.0.1, single-use link, expires in 10 minutes). On that page you check the host, database and user, and type the password yourself. nexql-mcp tests the connection, stores the password in your system keychain (or an encrypted file) and adds the database read-only to the running session, with no restart. Your assistant never sees the password, and it can't ask for more than read access. Don't paste passwords into the chat.

If the page can't open (e.g. nexql-mcp runs on another machine), the same thing works from a terminal. When you leave out --password, it asks for the password without showing it:

bash
nexql-mcp profile add billing --host db.internal --dbname billing --user billing_reader --access-mode read

Set NEXQL_MCP_OPEN_BROWSER=0 to stop nexql-mcp opening the page itself; your assistant will show you the link instead.

Wire a client

bash
nexql-mcp postgres://dev@localhost:5432/appdb init cursor

Supported init clients: claude | claude-desktop | claude-code | cursor | vscode | vscode-copilot | zed | windsurf | antigravity | gemini-cli | codex | copilot-cli | cline | lm-studio | kiro | kimi | qwen | goose | opencode | continue | jetbrains | openai-agents. ChatGPT chat can only reach remote servers over HTTPS; see docs/clients/README.md § ChatGPT.

Per-client paste blocks: docs/clients/README.md.

Tool surface / context budget

--tools query|dba|meta|full (env: NEXQL_MCP_TOOLS) restricts which tools are advertised to the client — a context-window budgeting knob, not a security boundary. It's purely advisory: nexql-policy's access_mode (read/write/admin, set via --access-mode or a profile's access_mode) is what actually gates what a call can do. Pick a narrower profile only to reduce how much tool-schema JSON gets loaded into your agent's context window:

  • query (default) — core query/discovery tools (schema search, run_select, explain_query, …)
  • dba — monitoring/admin tools (health checks, index suggestions, locks, …)
  • meta — the smallest initial surface, plus discover_tools for lazy on-demand activation of the rest (see docs/tools/README.md)
  • full — every active tool

Write and admin tools (execute_sql, edit_row, apply_ddl, …) are left out of tools/list unless at least one configured connection's access_mode can run them, whatever --tools says. Restart the client after raising a profile to write or admin.

Exact membership per profile: nexql-tools/src/registry.rs's QUERY_PROFILE/DBA_PROFILE/META_PROFILE/ACTIVE constants.

Use with the NexQL VS Code extension

If you already use ric-v.postgres-explorer (+ NexQL Pro), you don't need any of the above — the extension can spawn this binary itself and reuse your existing saved connections instead of a separate config.toml.

  1. Settings → search NexQL: Mcp: Enabled (postgresExplorer.mcp.enabled) → check it. Off by default.
  2. That's it — it takes effect immediately (no reload needed) and picks up every connection already saved in postgresExplorer.connections. It shows up as an MCP server named NexQL in Copilot Chat / agent-mode tool pickers.

The extension resolves the binary in this order: postgresExplorer.mcp.binaryPath setting → NEXQL_MCP_BIN env var → a copy bundled with the extension → whatever nexql-mcp is on your PATH (i.e. anything installed via npm/cargo/curl above). Set postgresExplorer.mcp.binaryPath explicitly if you want the extension to use a specific install.

Interactive TUI

bash
nexql-mcp tui

Guided profile editor: add/edit/delete a connection profile, test-connect it live before saving, then pick any of 16 clients (Claude Desktop, Claude Code, Cursor, VS Code, Copilot Chat, Zed, Windsurf, Antigravity, Gemini CLI, Codex, Copilot CLI, Cline CLI, LM Studio, Kiro, Kimi Code, Qwen Code) to wire it into at once. Each selected client's real config file is read, merged (existing unrelated servers are preserved), shown as a diff, and only written after you confirm — a timestamped backup is kept alongside it. continue / goose / opencode / jetbrains / openai-agents have no safe on-disk merge target, so those stay copy-paste snippets in the summary screen, same as init.

Keys: n new · e/Enter edit · d delete · t test · w wire into clients · q quit. Bare nexql-mcp (no URL, no flags) launches the TUI automatically when nothing else resolves a connection.

Releases

Pushing a v* tag triggers .github/workflows/release.yml: builds darwin arm64/x64, linux gnu arm64/x64, and windows x64; attaches archives, per-platform .mcpb bundles, a CycloneDX SBOM, and a rendered Homebrew formula to a GitHub release; publishes the npm packages and GHCR image; and publishes the workspace crates to crates.io in dependency order. A follow-up workflow (publish-mcp-registry.yml) then lists the release on the MCP Registry via GitHub OIDC. Linux GNU binaries are built on Ubuntu 22.04 (glibc 2.35). Musl targets remain deferred until a clang-enabled musl builder is validated.

Development

bash
cargo check          # workspace compilecargo run -p nexql-mcp -- doctorcargo test -p nexql-mcp -- init_clientscargo fmt --allcargo clippy --workspace --all-targets

Read CLAUDE.md and docs/REFERENCE.md before implementing.

License

GPL-3.0-only for all crates in this repo, from v0.2.0 onward. If you distribute this program or a derivative — including bundled inside another application — you must release your source under the GPL as well.

Releases up to and including v0.1.6 were published under Apache-2.0. That grant is irrevocable for those versions and is unaffected by this change.

Copyright is held solely by the NexQL-OSS Team, so commercial licenses that lift the GPL obligation are available on request. Premium extensions (provider embeddings, team sync, hosted gateway) live in a separate proprietary crate.

Roadmap

PhaseDeliverable
0Spike: tokio-postgres + candle MiniLM proof
1nexql-conn + nexql-policy + pg_query validator
2MCP stdio transport + ~8 catalog tools
3nexql-index (byte-compatible with TS format)
4Full tool surface, resources, prompts, completions
5Local embeddings + RRF fusion
6v1.0 ship: cargo-dist, npm, brew, Docker, MCPB
7Extension cutover — VS Code spawns binary via stdio MCP definition
8Streamable HTTP + bearer token (--http / NEXQL_MCP_HTTP_TOKEN) — OAuth gateway = pro
9Write/admin tools + validate_write_sql (opt-in --access-mode write|admin)
10Agent ergonomics — orient one-call bootstrap, discover_tools + --tools context-budget profiles, init <client> --apply, save_profile merge semantics, apply_ddl destructive-confirm gate, per-call timeout_ms (docs/roadmap/claude-review-2026-08-23.md)

Full plan: internal design doc (federated-greeting-badger). Cutover details: docs/CUTOVER.md.

Reference implementation

TypeScript sources in the sibling nexql-pro checkout (chat still uses these; MCP HTTP stack removed):

  • pro/src/mcp/McpDefinitionProvider.ts — stdio spawn of this binary
  • pro/src/mcp/NexqlMcpStdioHost.ts — ephemeral profile + binary resolve
  • pro/src/providers/chat/tools/ToolSpec.ts
  • pro/src/providers/chat/tools/ToolExecutor.ts
  • pro/src/features/dbindex/*

來源:README.md,提交 2b142d6

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.4最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分