Remote Postgres Mcp Server — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Remote Postgres Mcp Server (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This is a Model Context Protocol (MCP) server that enables you to chat with your PostgreSQL database, deployable as a remote MCP server with GitHub OAuth through Cloudflare. This is a production-ish ready MCP.
scale
This MCP server supports both modern and legacy transport protocols:
For new implementations, use the /mcp endpoint as it provides better performance and reliability.
The MCP server provides three main tools for database interaction:
Other tools include:
Authentication Flow: Users authenticate via GitHub OAuth → Server validates permissions → Tools become available based on user's GitHub username.
Security Model:
You can use the command below to get the remote MCP Server template that this project was built on created on your local machine if you want to build from scratch:
npm create cloudflare@latest -- my-mcp-server --template=cloudflare/ai/demos/remote-mcp-github-oauthOtherwise:
Install Wrangler globally to manage your Cloudflare Workers:
npm install -g wranglerLog in to your Cloudflare account:
wrangler loginThis will open a browser window where you can authenticate with your Cloudflare account.
Clone the repo directly & install dependencies: npm install.
Before running the MCP server, you need to configure a few environment variables for authentication and database access.
cp .dev.vars.example .dev.vars.dev.vars: # GitHub OAuth (for authentication)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
COOKIE_ENCRYPTION_KEY=your_random_encryption_key
# Database Connection
DATABASE_URL=postgresql://username:password@localhost:5432/database_name
# Optional: Sentry monitoring
SENTRY_DSN=https://[email protected]/project-id
NODE_ENV=developmenthttp://localhost:8788 (port can be changed in the wrangler.jsonc file)http://localhost:8788/callbackGITHUB_CLIENT_ID in .dev.varsGITHUB_CLIENT_SECRET in .dev.varsGenerate a secure random encryption key for cookie encryption:
openssl rand -hex 32Copy the output and paste it as COOKIE_ENCRYPTION_KEY in .dev.vars.
.dev.vars with your connection string: DATABASE_URL=postgresql://username:password@host:5432/database_nameThe MCP server works with any PostgreSQL database schema. It will automatically discover:
public schemaTesting the Connection: Once you have your database set up, you can test it by asking the MCP server "What tables are available in the database?" and then querying those tables to explore your data.
Add your github username in this configuration in the src/index.ts file
// Add GitHub usernames for database write access
const ALLOWED_USERNAMES = new Set([
'yourusername', // Replace with your GitHub username
]);Add the server to cladue desktop
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8788/sse"
]
}
}
}Run the server locally:
wrangler devThis makes the server available at http://localhost:8788
Use the MCP Inspector to test your server:
npx @modelcontextprotocol/inspector@latesthttp://localhost:8788/mcp (streamable HTTP transport - newer, more robust- might not work with some clients)http://localhost:8788/sse (SSE transport - legacy support)add to add two number togethergetCurrentUserInfo to get the user's information from githublistTables to see your database structurequeryDatabase to run SELECT queriesexecuteDatabase (if you have write access) for INSERT/UPDATE/DELETE operations#### Set up a KV namespace
wrangler kv namespace create "OAUTH_KV"
wrangler.jsonc file with the KV ID (replace <Add-KV-ID>)#### Deploy Deploy the MCP server to make it available on your workers.dev domain
Create a new GitHub OAuth App:
https://db-mcp-server.<your-subdomain>.workers.devhttps://db-mcp-server.<your-subdomain>.workers.dev/callbackwrangler secret put GITHUB_CLIENT_ID
wrangler secret put GITHUB_CLIENT_SECRET
wrangler secret put COOKIE_ENCRYPTION_KEY # use: openssl rand -hex 32
wrangler secret put DATABASE_URLwrangler deployYou now have a remote MCP server deployed!
#### 1. listTables (All Users) Purpose: Discover database schema and structure Access: All authenticated GitHub users Usage: Always run this first to understand your database structure
Example output:
- Tables: users, products, orders
- Columns: id (integer), name (varchar), created_at (timestamp)
- Constraints and relationships#### 2. queryDatabase (All Users) Purpose: Execute read-only SQL queries Access: All authenticated GitHub users Restrictions: Only SELECT statements and read operations allowed
-- Examples of allowed queries:
SELECT * FROM users WHERE created_at > '2024-01-01';
SELECT COUNT(*) FROM products;
SELECT u.name, o.total FROM users u JOIN orders o ON u.id = o.user_id;#### 3. executeDatabase (Privileged Users Only) Purpose: Execute write operations (INSERT, UPDATE, DELETE, DDL) Access: Restricted to specific GitHub usernames Capabilities: Full database write access including schema modifications
-- Examples of allowed operations:
INSERT INTO users (name, email) VALUES ('New User', '[email protected]');
UPDATE products SET price = 29.99 WHERE id = 1;
DELETE FROM orders WHERE status = 'cancelled';
CREATE TABLE new_table (id SERIAL PRIMARY KEY, data TEXT);Database write access is controlled by GitHub username in the ALLOWED_USERNAMES configuration:
// Add GitHub usernames for database write access
const ALLOWED_USERNAMES = new Set([
'yourusername', // Replace with your GitHub username
'teammate1', // Add team members who need write access
'database-admin' // Add other trusted users
]);To update access permissions:
src/index.ts fileALLOWED_USERNAMES set with GitHub usernameswrangler deployOpen Claude Desktop and navigate to Settings -> Developer -> Edit Config. This opens the configuration file that controls which MCP servers Claude can access.
Replace the content with the following configuration. Once you restart Claude Desktop, a browser window will open showing your OAuth login page. Complete the authentication flow to grant Claude access to your MCP server. After you grant access, the tools will become available for you to use.
{
"mcpServers": {
"math": {
"command": "npx",
"args": [
"mcp-remote",
"https://db-mcp-server.<your-subdomain>.workers.dev/sse"
]
}
}
}Once the Tools (under 🔨) show up in the interface, you can ask Claude to interact with your database. Example commands:
listTables toolqueryDatabase toolexecuteDatabase tool (if you have write access)#### OAuth Provider The OAuth Provider library serves as a complete OAuth 2.1 server implementation for Cloudflare Workers. It handles the complexities of the OAuth flow, including token issuance, validation, and management. In this project, it plays the dual role of:
#### Durable MCP Durable MCP extends the base MCP functionality with Cloudflare's Durable Objects, providing:
this.props#### MCP Remote The MCP Remote library enables your server to expose tools that can be invoked by MCP clients like the Inspector. It:
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.