Skip to content

PostgreSQL MCP and API

PostgreSQL exposes database schemas and SQL queries through a locally running MCP server. An agent can inspect database schemas and run SQL queries for data work. Add your DATABASE_URI when you install the PostgreSQL MCP server in Longwave.

Add to Longwave

Install elsewhere

Install PostgreSQL

Choose a harness. These instructions start the same local MCP server shown on this page.

Claude Code

Run this in your terminal. It adds a user-scoped server; use --scope project instead if it should apply only to the current project.

terminal
claude mcp add --scope user --transport stdio --env DATABASE_URI=YOUR_DATABASE_URI postgres -- uvx --with 'mcp<2' postgres-mcp

Replace each YOUR_… value with the required secret before running the command.

access
Your key

Use PostgreSQL on Longwave

  1. Download Longwave or open app.longwave.run.
  2. Add your DATABASE_URI when you install the PostgreSQL MCP server in Longwave.
  3. Ask for the result in any thread, for example: “Inspect a table before writing a query”. The agent picks the PostgreSQL function and calls it.

Use cases

Questions people ask

Which PostgreSQL diagnostics does the listed MCP server expose?

The server includes schema inspection, query plans and database health tools. It also provides SQL execution tools. PostgreSQL documentation

Can the PostgreSQL server run in a restricted mode?

The listed server supports a restricted access mode. Its documentation describes the SQL and diagnostic operations available in that mode. PostgreSQL documentation

How do I add the PostgreSQL MCP server to Claude Code?

Run claude mcp add postgres -- uvx --with mcp<2 postgres-mcp in a terminal. Add your DATABASE_URI when you install the PostgreSQL MCP server in Longwave.

Who publishes the PostgreSQL MCP server?

Crystal DBA publishes the PostgreSQL MCP server that Longwave installs. Source code

Use PostgreSQL in Longwave

Call PostgreSQL from any agent thread, on your machine or in the cloud.

Add to Longwave