PostgreSQL MCP

v1.0.0Databasesstable

Template for a remote MCP server with GitHub OAuth - following best practices for building MCP servers so you can take this as a starting point for any MCP server you want to build!

postgresql-mcp-server-with-github-oauthmcpai-integration
Share:
293
Stars
0
Downloads
0
Weekly
0/5

What is PostgreSQL MCP?

PostgreSQL MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to template for a remote mcp server with github oauth - following best practices for building mcp servers so you can take this as a starting point for any mcp server you want to build!

Template for a remote MCP server with GitHub OAuth - following best practices for building MCP servers so you can take this as a starting point for any MCP server you want to build!

This server falls under the Databases and Developer Tools categories on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Template for a remote MCP server with GitHub OAuth - followi

Use Cases

Build remote MCP servers with GitHub OAuth authentication.
Use a production-ready template for any MCP server implementation.
Deploy secure MCP servers following industry best practices.
coleam00

Maintainer

LicenseMIT License
Languagetypescript
Versionv1.0.0
UpdatedMay 18, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx postgresql-mcp-server-with-github-oauth

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use PostgreSQL MCP

This project is a production-ready template for building remote MCP servers with GitHub OAuth authentication, backed by a PostgreSQL database and deployed on Cloudflare Workers. It demonstrates best practices for secure MCP server construction: OAuth 2.0 login flow, encrypted session cookies, role-based database access, and deployment to the Cloudflare edge network. Developers can use it as a starting point for any MCP server that needs authenticated multi-user access, or use it directly to expose a PostgreSQL database to AI clients with read/write access control.

Prerequisites

  • Node.js 18+ and npm installed
  • A Cloudflare account with Workers enabled (free tier works for development)
  • A PostgreSQL database with connection string (local, Supabase, Neon, etc.)
  • A GitHub account to create an OAuth App for authentication
  • Wrangler CLI (Cloudflare's deployment tool) — installed via npm
1

Clone the repository and install dependencies

Clone the template repository and install all npm dependencies including the Wrangler CLI.

git clone https://github.com/coleam00/remote-mcp-server-with-auth
cd remote-mcp-server-with-auth
npm install -g wrangler
npm install
2

Create a GitHub OAuth App

Go to https://github.com/settings/developers and create a new OAuth App. Set the Homepage URL to http://localhost:8792 for development and the Authorization callback URL to http://localhost:8792/callback.

3

Configure local environment variables

Create a .dev.vars file in the project root with your GitHub OAuth credentials, a generated encryption key, and your PostgreSQL connection string.

# .dev.vars
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
COOKIE_ENCRYPTION_KEY=$(openssl rand -hex 32)
DATABASE_URL=postgresql://username:password@host:5432/database_name
4

Run locally for development

Start the Cloudflare Worker in local development mode. The MCP server will be available at http://localhost:8792.

wrangler dev
5

Deploy to Cloudflare Workers

Create the KV namespace for OAuth state, update wrangler.jsonc with the KV ID, then deploy and set production secrets.

wrangler kv namespace create "OAUTH_KV"
# Update wrangler.jsonc with the returned KV namespace ID
wrangler deploy
wrangler secret put GITHUB_CLIENT_ID
wrangler secret put GITHUB_CLIENT_SECRET
wrangler secret put COOKIE_ENCRYPTION_KEY
wrangler secret put DATABASE_URL
6

Connect your MCP client to the deployed server

Point your MCP client at the deployed Cloudflare Worker URL. Users will be prompted to authenticate with GitHub before accessing the database tools.

{
  "mcpServers": {
    "postgres-remote": {
      "url": "https://your-worker.workers.dev/mcp"
    }
  }
}

PostgreSQL MCP Examples

Client configuration

Connect to the deployed remote MCP server using its Cloudflare Workers URL. Authentication is handled via GitHub OAuth in the browser.

{
  "mcpServers": {
    "postgres-remote": {
      "url": "https://your-worker.workers.dev/mcp"
    }
  }
}

Prompts to try

Once connected and authenticated, use these prompts to interact with your PostgreSQL database through Claude.

- "List all tables in my database and describe their schemas"
- "Run a SELECT query to find all users who signed up in the last 7 days"
- "Show me the column types and constraints for the orders table"
- "Query the products table and return the top 5 items by price"

Troubleshooting PostgreSQL MCP

GitHub OAuth callback returns an error or redirects to the wrong URL

Ensure the Authorization callback URL in your GitHub OAuth App settings exactly matches your server URL plus /callback (e.g., http://localhost:8792/callback for dev, https://your-worker.workers.dev/callback for production). Both Homepage URL and Callback URL must be updated when switching between dev and prod.

DATABASE_URL connection fails in production

Cloudflare Workers run at the edge and may need a connection-pooling proxy like PgBouncer or a managed service like Supabase/Neon that supports HTTP-based connections. Direct TCP connections to a local Postgres server will not work from Workers.

Wrangler dev fails with KV namespace errors

The KV namespace for OAuth state must be created before running `wrangler dev`. Run `wrangler kv namespace create OAUTH_KV` and copy the resulting ID into the `kv_namespaces` section of wrangler.jsonc.

Frequently Asked Questions about PostgreSQL MCP

What is PostgreSQL MCP?

PostgreSQL MCP is a Model Context Protocol (MCP) server that template for a remote mcp server with github oauth - following best practices for building mcp servers so you can take this as a starting point for any mcp server you want to build! It connects AI assistants to external tools and data sources through a standardized interface.

How do I install PostgreSQL MCP?

Follow the installation instructions on the PostgreSQL MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with PostgreSQL MCP?

PostgreSQL MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is PostgreSQL MCP free to use?

Yes, PostgreSQL MCP is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Databases MCP Servers

Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "postgresql-mcp-server-with-github-oauth": { "command": "npx", "args": ["-y", "postgresql-mcp-server-with-github-oauth"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use PostgreSQL MCP?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides