Beta · active development · Postgres & SQLite

Turn Postgres into MCP tools, a REST API & OpenAPI — from one Rust engine

Point pgvis at your Postgres database. It introspects the schema once and serves it three ways from a single pipeline: typed Model Context Protocol tools for LLM agents, a PostgREST-compatible REST API, and an OpenAPI 3.0 document. One parser, one planner, one SQL builder — behavior stays consistent by design.

License Apache-2.0
Language Rust · Edition 2024
Protocol MCP · REST · OpenAPI
Your Postgres database
pgvis engine parse → plan → SQL
MCP REST OpenAPI
Features

One pipeline. Three surfaces. Zero glue.

MCP for AI agents

Every table and function becomes a typed Model Context Protocol tool — list_*, create_*, update_*, delete_*, call_* — with discovery resources like pgvis://schemas. No glue code. Works with Claude Desktop and any MCP client.

PostgREST-compatible

Same query DSL, the same Prefer header semantics, the same PGRST* error codes. A flat routing mode lets existing PostgREST clients keep working unchanged.

OpenAPI 3.0

Generated from the same introspected schema as REST and MCP — always in sync by construction. Print it with pgvis openapi, or fetch it from the API root with Accept: application/openapi+json.

Rust & embeddable

pgvis-core is I/O-free and depends on no driver. Backends implement a single Backend trait. Add a database API to any Rust app with the pgvis-lib Builder.

Safe by construction

Parameterized SQL only. JWT verification with symmetric or asymmetric algorithms, role switching, and Row-Level Security via Postgres. Statement timeouts and a server-side row cap.

Backend-agnostic

Postgres today; a SQLite backend crate is in progress and on the roadmap. Dialect capability flags drive feature gating — no core rewrite needed for a new backend.

Get started

Up and running in three commands

REST API
# build the CLI
cargo build --release --bin pgvis

# point it at your database
export PGVIS_DSN="postgres://user@localhost/mydb"
./target/release/pgvis serve --bind 0.0.0.0:3000

# query
curl "http://localhost:3000/api/public/users?select=id,name&active=eq.true"
MCP for Claude Desktop
// claude_desktop_config.json
{
  "mcpServers": {
    "pgvis": {
      "command": "pgvis",
      "args": [
        "--dsn", "postgres://localhost/mydb",
        "mcp"
      ]
    }
  }
}
Embed in Rust
use pgvis_lib::Builder;

// REST + MCP-over-HTTP router for axum::serve
let router = Builder::new("postgres://localhost/mydb")
    .schemas(vec!["public"])
    .with_mcp_http()
    .build()
    .await?;
Why pgvis

How it differs from PostgREST

I/O-free, backend-agnostic core

pgvis-core does no I/O. Backends implement a single Backend trait — Postgres today, SQLite in progress — without touching the engine.

First-class MCP surface

MCP is not a bolt-on. Tables and functions lower into typed MCP tools through the same plan → SQL path REST uses, so the two surfaces can never disagree.

A library, not just a server

The CLI is one consumer of pgvis-lib. Embed the same stack in any Rust app with the Builder facade.

Schema-in-URL routing

Routes default to /{prefix}/{schema}/{table} with a flat PostgREST-compatible mode available via routing config for drop-in replacement.

Open source. Apache-2.0.

Contributions welcome — issues, PRs, and design feedback all land on GitHub.