mcp-server-neon
- Type
- MCP server
- Scanned
- Oct 29, 2026
- Version
- cd24cc172f7e
- Files read
- 207
This project is the official remote MCP server for managing Neon Postgres projects, branches, and databases via the Neon Management API and serverless SQL driver. The primary risks are that destructive SQL and infrastructure operations can be triggered through prompt injection in write mode, and that OAuth tokens returned to clients carry full upstream Neon API privileges regardless of consent-screen scope restrictions.
What it can reach
- Network
- Connects to the Neon Management API (console.neon.tech), Neon OAuth (oauth2.neon.tech), user Neon Postgres databases, neon.com documentation/search endpoints, feedback.neon.tech, Upstash Redis (KV_URL), and Segment/Sentry telemetry endpoints.
- Secrets
- Reads Neon API keys, OAuth client credentials, Redis and Postgres token-store URLs from environment variables, and retrieves database connection strings and Neon Auth/Realtime secrets on behalf of authenticated users.
- Other
- Can create, modify, and delete Neon projects, branches, compute endpoints, databases, roles, functions, storage buckets, and execute arbitrary SQL queries on user databases.
Findings
-
MediumDownstream OAuth clients receive raw upstream Neon tokens with full account privileges
During OAuth login, the server always requests full read/write/delete scopes (
urn:neoncloud:projects:*andurn:neoncloud:orgs:*) from Neon's upstream OAuth provider and returns the resulting upstreamaccess_tokendirectly to the MCP client. Even when a user restricts a client on the consent page to read-only mode, a single project, specific tool categories, or a pinned Postgres role, those restrictions are only enforced when calling through this MCP server—the bearer token itself can be used directly againsthttps://console.neon.tech/api/v2with full account access. Additionally,/api/revokeonly deletes the token from the local database without revoking it upstream.Fix: Issue an opaque MCP-server-minted token to downstream OAuth clients and keep the upstream Neon OAuth access and refresh tokens server-side in the token store, or request narrowed upstream scopes and forward revocation requests to the upstream OAuth server.
-
MediumQuery tuning tools silently ignore the
role_nameparameter and run as database ownerBoth
prepare_query_tuningandcomplete_query_tuningadvertise an optionalrole_nameinput parameter in their schemas to execute SQL under a specific Postgres role, but the handlers omitparams.role_namewhen callinghandleQueryTuningandhandleCompleteTuning. On connections that do not have a grant-level role pin (?roleName=), SQL statements in these tools silently run as the privileged database owner instead of the requested role.Fix: Pass
roleName: params.role_nameintohandleQueryTuningandhandleCompleteTuning, and forward it tohandleExplainSqlStatement,handleDescribeTableSchema, andhandleRunSqlTransaction. -
Low
describe_branchcreates and drops a function inpubliceven in read-only modemcp/tools/handlers/describe-branch.ts:68
Although
describe_branch(also reachable via thefetchtool) is markedreadOnlySafe: trueand exposed in read-only mode, it runsCREATE OR REPLACE FUNCTION public.show_db_tree()andDROP FUNCTION IF EXISTS public.show_db_tree()outside of aREAD ONLYtransaction. Calling this tool performs DDL writes in the target database and will overwrite and delete any existing user function namedpublic.show_db_tree.Fix: Replace the temporary PL/pgSQL function in
DESCRIBE_DATABASE_STATEMENTSwith a pureSELECTquery usingUNION ALLandWITH RECURSIVEinside areadOnly: truetransaction. -
LowOAuth protected resource metadata trusts
X-Forwarded-HostandHostheaderslib/oauth/protected-resource-metadata.ts:40
resolveRequestOriginconstructs the OAuthauthorization_serversorigin andWWW-Authenticateresource_metadataURL from the incomingx-forwarded-hostorhostheader rather thanSERVER_HOST. In self-hosted deployments where a reverse proxy does not strip or validate these headers, an attacker can spoof the host header to direct MCP clients to an attacker-controlled authorization server.Fix: Derive the origin from the trusted
SERVER_HOSTconfiguration value (or an explicit allowlist of hosts) rather than unvalidated request headers. -
LowSegment analytics and Sentry PII collection are enabled by default with hardcoded keys
The configuration defaults to hardcoded production keys for Segment (
track.neon.tech) and Sentry, andmcp/sentry/instrument.tsenablessendDefaultPii: true. Anyone self-hosting this server will send user account details, tool invocation events, IP addresses, and error traces to Neon's telemetry endpoints unlessNEON_MCP_DISABLE_ANALYTICS=1is set andSENTRY_DSNis overridden.Fix: Default
ANALYTICS_WRITE_KEYandSENTRY_DSNto empty strings so telemetry is opt-in via environment variables on self-hosted deployments.