remote-mcp-server-with-auth

Build authenticated remote MCP servers with GitHub OAuth on Cloudflare Workers.

7|2|Updated May 16, 2026
One-click install
npx skills add https://github.com/reason-machines/mcp-skills --skill remote-mcp-server-with-auth-reason-machines
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: remote-mcp-server-with-auth
Source: https://github.com/reason-machines/mcp-skills/tree/main/skills/remote-mcp-server-with-auth
Command: npx skills add https://github.com/reason-machines/mcp-skills --skill remote-mcp-server-with-auth-reason-machines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Deploying a remote MCP server that requires user authentication, database access, and role-based permissions involves significant boilerplate across OAuth flows, transport protocols, and connection management. This Skill provides a complete template covering GitHub OAuth, dual transport endpoints, PostgreSQL integration, and deployment on Cloudflare Workers. ## Core Features & Use Cases - GitHub OAuth with Role-Based Access: Authenticate users via GitHub and restrict write operations to an allowlist of usernames. - Dual Transport Protocols: Serve MCP over streamable HTTP at /mcp and legacy SSE at /sse from the same Worker. - PostgreSQL Tool Templates: Includes listTables, queryDatabase (read-only), and executeDatabase (write-gated) tools with parameterized queries and SQL injection protection. - Use Case: A team wants to expose a shared PostgreSQL database to Claude Desktop with per-user permissions. They clone the template, configure GitHub OAuth credentials, set the allowed usernames, and deploy to Cloudflare Workers with wrangler. ## Quick Start Set up a remote MCP server with GitHub OAuth and a PostgreSQL database tool, then deploy it to Cloudflare Workers.

Frequently Asked Questions about remote-mcp-server-with-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a remote MCP server with authentication?▼

Use this Cloudflare Workers template with GitHub OAuth built in. Configure GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, and COOKIE_ENCRYPTION_KEY in .dev.vars, create a KV namespace for OAuth state, then run wrangler dev locally or wrangler deploy for production.

How to add a custom tool to an MCP server?▼

Create a new file in src/tools/ defining a Zod input schema and a register function that calls server.tool with a name, description, schema, and handler. Then add the register call to registerAllTools in src/tools/index.ts so the server exposes it.

What is the difference between streamable HTTP and SSE transport in MCP?▼

Streamable HTTP at the /mcp endpoint is the recommended modern transport, while SSE at /sse is the legacy option kept for older clients. Both endpoints in this template create the same MCP server instance with the authenticated username in context.

Can I restrict MCP database write operations to specific users?▼

Yes, the template enforces role-based access through an ALLOWED_USERNAMES set of GitHub usernames. The executeDatabase tool checks meta.username against this allowlist and rejects write queries from unauthorized users, while read-only queries remain available to all authenticated users.

Why is my MCP tool not appearing in Claude Desktop?▼

Verify the tool is registered inside registerAllTools, confirm the Zod schema has no validation errors, and restart Claude Desktop after editing claude_desktop_config.json. Test the endpoint first with the MCP Inspector using npx @modelcontextprotocol/inspector.

How do I prevent SQL injection in MCP database tools?▼

Always use parameterized queries with placeholders like $1 instead of string concatenation. The template also validates query types with regex so the read-only queryDatabase tool only accepts SELECT, SHOW, DESCRIBE, or EXPLAIN statements.