Remote Mcp Server With Auth — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Remote Mcp Server With Auth (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 production ready MCP.
This MCP server uses a clean, modular architecture that makes it easy to extend and maintain:
tools/ and registering themThis architecture allows you to easily add new database operations, external API integrations, or any other MCP tools while keeping the codebase organized and maintainable.
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:
Authentication Flow: Users authenticate via GitHub OAuth → Server validates permissions → Tools become available based on user's GitHub username.
Security Model:
Want to see a basic MCP server before diving into the full database implementation? Check out src/simple-math.ts - a minimal MCP server with a single calculate tool that performs basic math operations (add, subtract, multiply, divide). This example demonstrates the core MCP components: server setup, tool definition with Zod schemas, and dual transport support (/mcp and /sse endpoints). You can run it locally with wrangler dev --config wrangler-simple.jsonc and test at http://localhost:8789/mcp.
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 several 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=developmentMCP Server (Local Development)http://localhost:8792http://localhost:8792/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_name#### Connection String Examples:
postgresql://myuser:mypass@localhost:5432/mydbpostgresql://postgres:[email protected]:5432/postgresThe 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.
Run the server locally:
wrangler devThis makes the server available at http://localhost:8792
Use the MCP Inspector to test your server:
npx @modelcontextprotocol/inspector@latesthttp://localhost:8792/mcp (streamable HTTP transport - newer, more robust)http://localhost:8792/sse (SSE transport - legacy support)listTables 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
wrangler deployCreate a new GitHub OAuth App:
https://mcp-github-oauth.<your-subdomain>.workers.devhttps://mcp-github-oauth.<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_URL
wrangler secret put SENTRY_DSN # optional (more on Sentry setup below)#### Test
Test the remote server using Inspector:
npx @modelcontextprotocol/inspector@latestEnter https://mcp-github-oauth.<your-subdomain>.workers.dev/mcp (preferred) or https://mcp-github-oauth.<your-subdomain>.workers.dev/sse (legacy) and hit connect. Once you go through the authentication flow, you'll see the Tools working:
<img width="640" alt="image" src="https://github.com/user-attachments/assets/7973f392-0a9d-4712-b679-6dd23f824287" />
You 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 and src/index_non_sentry.tsALLOWED_USERNAMES set with GitHub usernameswrangler deploylistTables to understand database structurequeryDatabase to read and analyze dataexecuteDatabase (if you have write access) to make changesOpen 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://mcp-github-oauth.<your-subdomain>.workers.dev/mcp"
]
}
}
}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)When using Claude to connect to your remote MCP server, you may see some error messages. This is because Claude Desktop doesn't yet support remote MCP servers, so it sometimes gets confused. To verify whether the MCP server is connected, hover over the 🔨 icon in the bottom right corner of Claude's interface. You should see your tools available there.
#### Using Cursor and other MCP Clients
To connect Cursor with your MCP server, choose Type: "Command" and in the Command field, combine the command and args fields into one (e.g. npx mcp-remote https://<your-worker-name>.<your-subdomain>.workers.dev/sse).
Note that while Cursor supports HTTP+SSE servers, it doesn't support authentication, so you still need to use mcp-remote (and to use a STDIO server, not an HTTP one).
You can connect your MCP server to other MCP clients like Windsurf by opening the client's configuration file, adding the same JSON that was used for the Claude setup, and restarting the MCP client.
This project includes optional Sentry integration for comprehensive error tracking, performance monitoring, and distributed tracing. There are two versions available:
src/index.ts - Standard version without Sentrysrc/index_sentry.ts - Version with full Sentry integrationTo deploy with Sentry monitoring:
wrangler secret put SENTRY_DSNEnter your Sentry DSN when prompted.
main = "src/index_sentry.ts" wrangler deploy SENTRY_DSN=https://[email protected]/project-id
NODE_ENV=development wrangler dev#### 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:
This project includes comprehensive unit tests covering all major functionality:
npm test # Run all tests
npm run test:ui # Run tests with UIThe test suite covers database security, tool registration, permission handling, and response formatting with proper mocking of external dependencies.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.