Est.

Guide

Neon MCP Server: Setup, Read-Only Mode and a Least-Privilege Role

Connect Neon's hosted MCP server to your AI coding tool, scope it to one project, read-only and logged in as a role that can see only what it should, and know when agents need a governed data layer instead.

By the Agentic Infrastructure Review editors · Updated

The Neon MCP server is how an AI agent gets into your Neon account. It is the Model Context Protocol server Neon hosts, and once it is connected, Claude Code, Cursor, Codex or another MCP client can create branches, inspect your schema, run SQL and diagnose slow queries for you. Connecting it takes one command. Limiting what the agent can reach takes a little more thought, and Neon gives you more controls for that than most providers do.

The commands, URL parameters and tool names below follow Neon's own documentation as of November 2026. The server changes often, so check there before you rely on a specific flag.

What the Neon MCP server is

  • Hosted, not installed. The server runs at https://mcp.neon.tech/mcp over Streamable HTTP. The old local package, @neondatabase/mcp-server-neon, is deprecated, and the old SSE endpoint (https://mcp.neon.tech/sse) is retired and returns 410 Gone.
  • It signs in with OAuth. The first time your client calls it, a browser window opens where you authorize access to Neon. An API key is only needed for CI and other headless agents.
  • It acts on your account. By default, every project you can reach is in scope, and SQL runs as the database owner. Neon warns that the server grants broad database management capabilities.
  • It is large. With every category on, it exposes well over a hundred tools, from SQL and branching to Neon Auth, Functions and object storage.

If your database is on Supabase, see our Supabase MCP server guide. For Postgres hosted anywhere else, see the Postgres MCP server guide.

How to connect it to your AI tool

Neon's quickest route is its CLI, which asks which agents to set up and how to authenticate, then writes the config for you:

npx neon@latest mcp

Neon also offers a plugin that bundles the MCP server with its agent skills (npx neon@latest plugins --agent <agent>). If you want only the MCP server, configure it directly in your client.

Claude Code

claude mcp add --transport http neon https://mcp.neon.tech/mcp

Start a new claude session, or run /mcp, to sign in.

Cursor

Add this to .cursor/mcp.json in the project, or to ~/.cursor/mcp.json for every project:

{
  "mcpServers": {
    "Neon": {
      "url": "https://mcp.neon.tech/mcp"
    }
  }
}

Neon's Cursor page also has a one-click install button for the same config. Cursor prompts you to sign in the first time it uses a Neon tool.

Codex

npx add-mcp https://mcp.neon.tech/mcp -a codex

This adds a neon entry to .codex/config.toml (add -g for ~/.codex/config.toml). Restart Codex. If it doesn't prompt you to sign in, run codex mcp login neon.

VS Code

Add this to .vscode/mcp.json, then restart VS Code or enable the server in settings and click Authorize when the OAuth window opens:

{
  "servers": {
    "neon": {
      "type": "http",
      "url": "https://mcp.neon.tech/mcp"
    }
  }
}

MCP servers in VS Code need the GitHub Copilot and GitHub Copilot Chat extensions. Use the agent in Copilot Chat's Agent mode.

Scope it before you connect it

The URLs above give the agent every project you can reach, write access, and SQL as the database owner. Narrow it with URL parameters before you point it at anything real:

Parameter What it does Example
readonly=true Disables write tools; SQL runs in a READ ONLY transaction ?readonly=true
projectId=<id> Limits the server to one project and hides project management tools ?projectId=<your-project-id>
category=<name> Enables only the tool categories you list (repeatable) ?category=querying&category=schema
roleName=<role> Makes every SQL tool log in as that Postgres role instead of the owner ?roleName=agent_reader
secrets=<mode> Chooses which secrets tool results may show: setup (default), all or none ?secrets=none

You can combine them. For an agent that should read schema and data in one project and nothing else, this is a sensible starting point:

https://mcp.neon.tech/mcp?projectId=<your-project-id>&readonly=true&category=querying&category=schema&roleName=agent_reader

With OAuth, these parameters are fixed when you authorize. You can also pick read-only scope, a Postgres role and the secrets mode on the authorization page itself. To see which tools a URL would expose without signing in, Neon publishes a check endpoint:

curl "https://mcp.neon.tech/api/list-tools?readonly=true&category=querying"

Filtering categories also saves context. Every tool the server exposes adds its name, description and schemas to your agent's context, so an agent that only writes SQL has no use for the Neon Auth or storage tools.

Give it a role that can only read what it should

Read-only mode stops writes. It does not decide what the agent can read: by default SQL runs as the database owner, which can see everything. roleName is the setting that closes that gap, because the role's grants then decide what the agent sees.

Create a role for the agent with SQL, and grant it only what it needs:

CREATE ROLE agent_reader LOGIN PASSWORD 'change-me';
GRANT USAGE ON SCHEMA public TO agent_reader;
GRANT SELECT ON public.orders, public.products TO agent_reader;

Three details matter here:

  1. Create the role in SQL, not the console. Neon's docs note that roles created in the Neon Console or API, and roles created with the CLI or MCP server without an access level, are members of neon_superuser, which can read all data. Pinning one of those roles doesn't limit anything.
  2. The role must exist on every branch you query. A role that can't log in fails the call rather than falling back to the owner.
  3. It applies to SQL only. Combine it with readonly=true and category to limit the management tools too.

The same least-privilege thinking applies to any Postgres MCP server. Our Postgres MCP server guide walks through a fuller read-only role, including default privileges and a statement timeout.

What the agent can do once connected

Tools are grouped into categories, all on by default:

  • SQL (querying): run_sql, run_sql_transaction, explain_sql_statement, schema changes tested on a temporary branch, and inspect_database, which runs the same read-only diagnostics as neon inspect db (table and index sizes, unused indexes, slow and stalled queries, cache hit rate, bloat and more).
  • Schema (schema): inspect tables and columns, and compare schemas between branches.
  • Branches, compute endpoints and snapshots: create, reset and delete branches; start, suspend and restart compute; create and restore snapshots.
  • Projects (projects): list, create, describe and delete projects. Hidden when you set projectId.
  • Docs (docs): search the Neon docs and API reference from inside your assistant.
  • Neon Auth, Data API, Functions, object storage, Realtime and observability: each its own category. Filter them out with category unless the task needs them.

run_sql returns up to 100 rows per statement unless the agent sets max_rows (up to 10,000). In read-only mode, run_sql_transaction, get_connection_string and the general-purpose call_api are not available.

What read-only mode does and does not protect

Neon's read-only mode is enforced on the server: SQL runs inside a READ ONLY transaction, so Postgres rejects a write even if the agent tries one. That holds whichever client or gateway sends the request, which matters for setups where you never see individual tool calls, such as MCP gateways or clients that let the model write code that calls many tools at once.

It does not protect you from what the agent reads. If the connection can see a table of customer messages, a message containing instructions can steer the agent, a risk we cover in Prompt Injection via Untrusted Database Results. Neon's own guidance is blunt:

  • Use MCP for development and testing only. Never connect MCP agents to production databases.
  • Avoid production or personal data. Use anonymized data.
  • Review and authorize every action the model requests before it runs.
  • Restrict access to trusted users and audit it regularly.
  • Combine the controls: read-only mode, one project, a limited role, only the categories you need, and secrets=none if the agent needs write access.

Neon branches make the first two easier than on most platforms: point the agent at a development branch rather than your main one, so its experiments never touch the data your app serves.

Using it in CI or another headless environment

Where a browser sign-in isn't possible, pass a Neon API key as a header, with the same access-control parameters on the URL:

{
  "mcpServers": {
    "Neon": {
      "type": "http",
      "url": "https://mcp.neon.tech/mcp?projectId=<your-project-id>&readonly=true",
      "headers": {
        "Authorization": "Bearer <NEON_API_KEY>"
      }
    }
  }
}

npx neon@latest mcp -y --agent <agent> --api-key <key> writes this for you and mints a separate key for the MCP server. Keep keys in your CI secret store, never in the repository. If your project uses IP Allow, add the hosted server's addresses listed in Neon's docs to the allowlist.

Where the Neon MCP server stops being the right tool

The Neon MCP server is built for development: designing schemas, testing migrations on branches, tuning queries. Using it so an agent can answer "what was our MRR last month?" runs into the same three problems as any MCP server on a live database:

  1. It queries the database itself. Neon advises against connecting it to production at all, and an analytical scan on your main branch competes with your app. See Production Database Access Risks for AI Agents.
  2. Each agent writes its own SQL. Two agents can define "active user" differently and both return confident numbers. A read-only role does nothing about that. See AI Agents That Compute Their Own Metrics Are Governance Failures.
  3. Access stops at the table. The agent sees whatever its role sees. It can't be limited to a list of approved metrics.

For recurring metrics, board numbers and agents that run without a person watching, put a governed layer between the database and the agent: metrics defined once and pre-calculated, the data copied away from the instance your app uses, and agents given MCP access to that layer rather than the raw schema. MCP Servers as the Access Control Boundary for Agent Data explains the design.

A practical split: give developers the Neon MCP server, scoped, read-only and on a development branch, for building the product. Give analytics agents a governed layer for answering questions about the business.

Frequently asked questions

What is the Neon MCP server?
It is Neon's official Model Context Protocol server. It lets an AI client such as Claude Code, Cursor, Codex or VS Code manage your Neon projects and branches, inspect schemas, run SQL, run database diagnostics and search the Neon docs on your behalf.
What is the Neon MCP server URL?
The hosted server is https://mcp.neon.tech/mcp and uses Streamable HTTP. The older SSE endpoint, https://mcp.neon.tech/sse, is retired and returns 410 Gone, so change any config that still points at it.
Do I still install @neondatabase/mcp-server-neon?
No. The local stdio package is deprecated. Use the hosted server. If your client only supports local stdio servers, Neon's docs show how to bridge to the hosted URL with mcp-remote.
Do I need a Neon API key?
Not for interactive use. The hosted server signs you in with OAuth the first time your client calls it. An API key passed as an Authorization Bearer header is for CI and other headless agents.
How do I make the Neon MCP server read-only?
Add readonly=true to the server URL, for example https://mcp.neon.tech/mcp?readonly=true, or choose the read-only scope when you authorize with OAuth. SQL then runs in a READ ONLY transaction and write tools are disabled. To limit what the agent can read as well, add roleName=<role> so SQL runs as a Postgres role with narrow grants.
Can I connect the Neon MCP server to my production database?
Neon recommends its MCP server for development and testing only, and says never to connect MCP agents to production databases or expose production or personal data. Use a development branch or anonymized data instead, and give analytics agents a governed copy of the data rather than the live database.
Is the Neon MCP server free?
Neon's docs don't put a price on the MCP server itself, but tools that create projects, branches or compute act on resources your Neon plan bills for. Check neon.com/pricing for current plans.

Sources

Further reading