Serverless Postgres storage for production deployments. Neon support uses the optionalDocumentation Index
Fetch the complete documentation index at: https://docs.mcp-assistant.in/llms.txt
Use this file to discover all available pages before exploring further.
@neondatabase/serverless peer dependency and the HTTP query API. It is a good fit for serverless applications that need durable MCP session storage without running Redis.
Installation
Configuration
DATABASE_URL is also supported when MCP_TS_STORAGE_TYPE=neon is set. Auto-detection only uses NEON_DATABASE_URL so a generic DATABASE_URL does not unexpectedly change the selected storage backend.
Use a pooled Neon connection string for serverless deployments when your app may create many concurrent function instances. Neon integrations commonly expose pooled URLs through DATABASE_URL; direct/unpooled URLs are better reserved for migrations and long-running administrative work.
Security
Create a dedicated application role instead of using the Neon owner/admin role in production. The role only needs to connect to the database and read/write themcp_sessions table.
sslmode=verify-full. Add channel_binding=require when supported by your runtime and connection path. Do not log or commit Neon connection strings; store them in your deployment environment variables.
Optional RLS configuration
The install migration includes an optional RLS block at the bottom. The base schema does not require RLS. If you want to enforce access through Row Level Security for the dedicated app role, createmcp_service_role, then uncomment and run the RLS block from the migration.
The optional block:
- Revokes public access to
public.mcp_sessions. - Grants read/write access to
mcp_service_role. - Enables Row Level Security on the table.
- Adds a policy that allows the server-side
mcp_service_roleto perform storage operations.
userId in application queries.
Schema
The canonical Neon migration is available atmigrations/neon/20260513010000_install_mcp_sessions.sql.
Run it with an owner/admin role, then connect the application using the least-privilege role from the Security section.
Create the mcp_sessions table in your Neon database:
Usage
Option 1: Automatic Detection (Recommended)
WhenMCP_TS_STORAGE_TYPE=neon and NEON_DATABASE_URL are present in your environment, the global sessions proxy automatically uses the Neon backend.
Option 2: Manual Instantiation
If you want to manage the Neon SQL client yourself or use multiple storage backends:Cleanup
Expired sessions are removed whensessions.cleanupExpired() runs. Schedule that call from your application or platform cron if you want cleanup without database cron support.
If your Neon project has pg_cron enabled, you can also run the optional migration at migrations/neon/20260513020000_add_session_cleanup_cron.sql. Neon requires endpoint-level cron.database_name configuration before pg_cron can be installed and used. After that setup, the migration schedules:
mcp-cleanup-transient-sessions: every 5 minutes, removes inactive expired sessions.mcp-cleanup-dormant-sessions: daily at midnight UTC, removes active sessions untouched for 30+ days.
pg_cron is not enabled for your Neon project, skip the optional migration and use application/platform scheduling instead.
