nexql-mcp
OfficialClick on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nexql-mcpShow me the columns of the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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. 54 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.
Related MCP server: PostgreSQL MCP Server
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, audit
npm/ npx shim (per-platform optionalDependencies)
mcpb/ one-click Claude Desktop bundle
docs/ per-client setup, tool referenceLayering 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
npx — recommended, zero install
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.
# Verify
npx -y nexql-mcp@latest --version
# Setup
npx -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 # Cursor
npx -y nexql-mcp@latest init claude-desktop # Claude Desktop
npx -y nexql-mcp@latest init vscode-copilot # VS Code Copilot
npx -y nexql-mcp@latest tui # interactive profile + client wiringClient config (command/args) uses the same pattern — no install step for the client to rely on either:
{
"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.jsonforclaude-code,claude_desktop_config.jsonforclaude-desktop, etc. — see docs/clients/README.md for exact paths per client). Or drivenexql-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-writingclaude 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.
Linux & macOS — downloads the latest release, installs to /usr/local/bin (or ~/.local/bin if sudo is unavailable), then prints setup steps:
curl -fsSL https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.sh | bashPin a version:
NEXQL_MCP_VERSION=v0.2.2 curl -fsSL https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.sh | bashWindows (PowerShell) — installs to %LOCALAPPDATA%\Programs\nexql-mcp and adds it to your user PATH:
irm https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.ps1 | iexPin a version:
$env:NEXQL_MCP_VERSION = "v0.2.2"; irm https://raw.githubusercontent.com/NexQL-OSS/mcp/main/scripts/install.ps1 | iexOr 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 installs CLI tools from PyPI into isolated environments — same prebuilt binary, no Rust toolchain.
Install uv itself (if needed):
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS / Linuxirm https://astral.sh/uv/install.ps1 | iex # WindowsInstall nexql-mcp:
uv tool install nexql-mcp
uv tool update-shell # once, if uv warns the tool bin dir is not on PATHOne-off without installing (uv's equivalent of npx -y):
uvx nexql-mcp postgres://dev@localhost:5432/appdb doctorPin a version:
uv tool install 'nexql-mcp==0.2.2'Upgrade later:
uv tool upgrade nexql-mcpPyPI 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 install nexql-mcpNeeds clang/libclang first (pg_query's bindgen requires it):
sudo apt install clang libclang-dev # Debian/Ubuntu
sudo pacman -S clang # ArchFrom the Releases page:
Platform | Archive |
Linux x64 |
|
Linux arm64 |
|
macOS Intel |
|
macOS Apple Silicon |
|
Windows x64 |
|
Extract and put nexql-mcp (or nexql-mcp.exe) on your PATH.
Prebuilt, published on every release to GHCR:
docker run --rm -i ghcr.io/nexql-oss/mcp:0.5.0 postgres://dev@host.docker.internal:5432/appdb
# or: ghcr.io/nexql-oss/mcp:latestOr build locally from the distroless Dockerfile:
docker build -t nexql-mcp:0.5.0 .
docker run --rm -i nexql-mcp:0.5.0 postgres://dev@host.docker.internal:5432/appdbEach release attaches a platform .mcpb bundle (nexql-mcp-<vendor>.mcpb) — download the one matching
your OS/arch from the Releases page and double-click
to install into Claude Desktop. Built from mcpb/manifest.json via
scripts/package-mcpb.sh.
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.
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
export LIBCLANG_PATH="${LIBCLANG_PATH:-/usr/lib}" # or your llvm lib dir
cargo build --release -p nexql-mcp
./target/release/nexql-mcp postgres://dev@localhost:5432/appdbSet up a connection
Commands below assume
nexql-mcpresolves onPATH. If you're running via npx instead, prefix each one withnpx -y nexql-mcp@latestin place ofnexql-mcp— see Install.
One-off, no config — pass a connection string directly:
nexql-mcp postgres://dev@localhost:5432/appdbSaved profiles — put connections in ~/.config/nexql-mcp/config.toml (override the path with NEXQL_MCP_CONFIG):
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 secrets
sslmode = "verify-full"
access_mode = "read"
schemas = ["public", "billing"]
deny_tables = ["auth.*"]
pii_columns = ["public.users.ssn", "public.users.email"]
max_rows = 200Full 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:
nexql-mcp postgres://dev@localhost:5432/appdb doctor
# or, for a saved profile (note: --profile goes before the subcommand):
nexql-mcp --profile prod doctorGuided 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); alsonpx -y nexql-mcp@latest setup
Wire a client
nexql-mcp postgres://dev@localhost:5432/appdb init cursorSupported init clients: claude | claude-desktop | claude-code | cursor | vscode | vscode-copilot | zed | windsurf | continue | jetbrains | openai-agents.
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— core query/discovery tools (schema search,run_select,explain_query, …)dba— monitoring/admin tools (health checks, index suggestions, locks, …)meta— the smallest initial surface, plusdiscover_toolsfor lazy on-demand activation of the rest (see docs/tools/README.md)full(default) — every active tool
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.
Settings → search NexQL: Mcp: Enabled (
postgresExplorer.mcp.enabled) → check it. Off by default.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
nexql-mcp tuiGuided profile editor: add/edit/delete a connection profile, test-connect it live before saving, then pick any of 7 clients (Claude Desktop, Claude Code, Cursor, VS Code, Copilot Chat, Zed, Windsurf) 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 / 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
cargo check # workspace compile
cargo run -p nexql-mcp -- doctor
cargo test -p nexql-mcp -- init_clients
cargo fmt --all
cargo clippy --workspace --all-targetsRead 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
Phase | Deliverable |
0 | Spike: tokio-postgres + candle MiniLM proof |
1 |
|
2 | MCP stdio transport + ~8 catalog tools |
3 |
|
4 | Full tool surface, resources, prompts, completions |
5 | Local embeddings + RRF fusion |
6 | v1.0 ship: cargo-dist, npm, brew, Docker, MCPB |
7 | Extension cutover — VS Code spawns binary via stdio MCP definition |
8 | Streamable HTTP + bearer token ( |
9 | Write/admin tools + |
10 | Agent ergonomics — |
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 binarypro/src/mcp/NexqlMcpStdioHost.ts— ephemeral profile + binary resolvepro/src/providers/chat/tools/ToolSpec.tspro/src/providers/chat/tools/ToolExecutor.tspro/src/features/dbindex/*
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server for PostgreSQL diagnostics: slow queries, missing indexes, connection pressure.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn open-source MCP server for PostgreSQL schema introspection and guarded read-only queries. It enables MCP clients to discover schemas, tables, columns, indexes, relationships, and safe queryable data from a configured PostgreSQL database.3 npmMIT
- AlicenseAqualityCmaintenanceFull-featured MCP server that exposes 36 tools for interacting with PostgreSQL databases, covering schema introspection, query execution, data exploration, performance monitoring, security auditing, and maintenance.364 npmMIT
- AlicenseAqualityBmaintenanceMCP server for PostgreSQL that enables schema exploration, safe SQL execution, EXPLAIN analysis, health checks, and index recommendations across multiple databases.1074 npmMIT
- FlicenseNot gradedqualityBmaintenanceA read-only PostgreSQL MCP server that translates natural language queries into SQL, enforcing database routing, table/column whitelists, and safety checks. It offers schema inspection and query tools with optional output as SQL or results.-