Securely Authenticate MCP Services with OAuth
Webrix MCP-S Gateway adds centralized OAuth authentication in front of your MCP servers via Auth.js.
Why it matters
Establish a secure, self-hosted gateway for MCP authentication, unifying enterprise access to various MCP modules and services through OAuth.
Outcomes
What it gets done
Implement OAuth authentication with over 80 providers.
Provide a unified enterprise interface for managing MCP modules.
Support STDIO and StreamableHTTP connections for MCP servers.
Enable server selection via request parameters for targeted access.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-webrix-mcp-gateway | bash Overview
Webrix MCP Gateway MCP Server
A self-hosted OAuth gateway for MCP servers: centralized Auth.js-based login, connection routing, and support for STDIO/StreamableHTTP clients. Use it when running multiple MCP servers that need centralized OAuth authentication instead of per-server security.
What it does
Webrix MCP-S Gateway is a self-hosted, open-source gateway and integration layer that sits in front of your MCP servers, adding secure OAuth authentication via Auth.js before requests reach them. Instead of exposing each MCP server directly, you register them in a single mcp.json config, and the gateway handles authentication, connection routing, and supports both STDIO and StreamableHTTP connection types for clients like Claude, Cursor, Windsurf, VS Code, and Cline.
When to use - and when NOT to
Use this when you're running multiple MCP servers and want centralized OAuth authentication in front of them - for example, requiring a Google, Okta, Azure AD, or GitHub login before an AI client can use your internal tools. GitHub OAuth in particular is useful for MCP servers that touch repositories (like Octocode), where scopes such as repo (full access), public_repo, read:user, or user:email control exactly what the server can reach. It's built for self-hosted, enterprise-oriented deployments where security and access control matter. It is not useful for a single local MCP server with no authentication requirement, and it requires Node.js 22+ (the node:sqlite module used for its database needs that version or higher - a common troubleshooting case is exactly this Node version mismatch, fixed by upgrading via nvm install 22 && nvm use 22).
Capabilities
- Self-hosted gateway deployable within your own infrastructure.
- OAuth authentication with any Auth.js-supported provider (80+ providers, including Google, Okta, Azure AD, and GitHub).
- Full TypeScript implementation.
- Support for both STDIO and StreamableHTTP MCP connection types, including per-server routing via a
?server_name=query parameter. - Configurable via
mcp.json(registered MCP servers) and environment variables (auth provider, secrets, token expiration, database path).
How to install
Create an mcp.json listing your MCP servers, then run:
npx @mcp-s/secure-mcp-gateway
Or clone and run locally:
git clone https://github.com/mcp-s-ai/secure-mcp-gateway.git && cd secure-mcp-gateway
npm install && npm run start
Set AUTH_SECRET and AUTH_PROVIDER plus the provider's client ID/secret (e.g. AUTH_GOOGLE_ID, AUTH_GOOGLE_SECRET for Google). Connect an MCP client either via STDIO (command: npx, args ["-y", "@mcp-s/mcp"], BASE_URL env var) or StreamableHTTP (url: http://localhost:3000/mcp). Requires Node.js 22+. For production, the project suggests running it under a process manager like PM2 (pm2 start "npx @mcp-s/secure-mcp-gateway" --name mcp-gateway), containerized via Docker/Kubernetes, or on a platform like Heroku, Railway, or Render.
Who it's for
Teams running multiple MCP servers who need a centralized OAuth login layer in front of them - enforcing authentication once at the gateway instead of per-server, before connecting AI clients like Claude, Cursor, or VS Code. A fully managed hosted version is also available from the maintainer (webrix.ai) with additional enterprise features like pre-built connectors and role-based access control, for teams that don't want to self-host.
Source README
Webrix MCP-S Gateway
A secure, open-source OAuth gateway for MCP authentication
Gateway + integration layer for the Model Context Protocol (MCP)
MCP-S Gateway
mcp-gateway is a secure gateway and integration layer for the Model Context Protocol (MCP). It provides a unified, enterprise-ready interface for connecting, managing, and extending MCP modules and services, with a focus on security and seamless integration.
Quick Start
1. Configure your MCP servers - Create mcp.json file in your project:
{
"mcpServers": {
"your-server": {
"command": "npx",
"args": ["-y", "@your-mcp-server"],
"env": {
"API_KEY": "your-api-key"
}
},
"octocode": {
"command": "npx",
"args": ["octocode-mcp"]
}
}
}
2. Use the .env.example file as a base, and override as needed:
3. Start with npx (Recommended):
# Default (uses ./mcp.json and ./.env)
npx @mcp-s/secure-mcp-gateway
# Custom configuration paths
npx @mcp-s/secure-mcp-gateway --mcp-config ./custom/mcp.json --envfile ./custom/.env
Or clone:
git clone https://github.com/mcp-s-ai/secure-mcp-gateway.git && cd secure-mcp-gateway
npm install && npm run start
4. Add to your MCP configuration:
stdio:
{
"mcpServers": {
"mcp-gateway": {
"command": "npx",
"args": ["-y", "@mcp-s/mcp"],
"env": {
"BASE_URL": "http://localhost:3000"
}
}
}
}
Streamable HTTP Configuration:
{
"mcpServers": {
"mcp-gateway": {
"url": "http://localhost:3000/mcp"
}
}
}
Features
- Self-Hosted Gateway: Deploy within your own infrastructure for maximum control
- OAuth Authentication: Secure authentication with any OAuth provider via Auth.js
- TypeScript Support: Fully typed for robust development
Supports all MCP Connection Types:
STDIO: Standard input/output MCP servers
StreamableHTTP: HTTP-based streaming connections via
http://localhost:3000/mcp(orhttps://<your-domain>/mcpfor hosted deployments)Server Selection: You can connect to a specific MCP server by adding the
?server_name=XXXquery parameter, whereXXXis the name of the server from yourmcp.jsonconfiguration. For example:http://localhost:3000/mcp?server_name=your-serverConnect with your preferred AI client:
Client Link Claude
claude.ai Cursor
cursor.com Windsurf
codeium.com/windsurf VSCode
code.visualstudio.com
Clinecline.tools Highlight AI
highlightai.com
Augment Codeaugmentcode.com
Deploy
Deploy the mcp-s gateway using npx:
- Set up your environment variables (see Advanced Configuration)
- Create your
mcp.jsonconfiguration file - Run
npx @mcp-s/secure-mcp-gateway
For production deployments, consider using:
- Process managers like PM2:
pm2 start "npx @mcp-s/secure-mcp-gateway" --name mcp-gateway - Container orchestration (Docker, Kubernetes)
- Cloud platforms (Heroku, Railway, Render)
Authentication Setup
mcp-gateway leverages the power of Auth.js, which supports 80+ OAuth providers out of the box. This makes Auth.js the perfect companion for an open-source project like mcp-gateway. Both libraries share the same commitment to flexibility, security, and developer experience. By integrating with Auth.js, we avoid reinventing authentication wheels and instead provide you with battle-tested, production-ready OAuth flows that work seamlessly across providers.
Simply set the AUTH_PROVIDER environment variable and provide the required credentials for your chosen provider - mcp-gateway handles the rest.
Google OAuth Setup
Documentation: Auth.js Google Provider
AUTH_SECRET=your-random-secret
AUTH_PROVIDER=google
AUTH_GOOGLE_ID=your-google-client-id
AUTH_GOOGLE_SECRET=your-google-client-secret
Okta OAuth Setup
Documentation: Auth.js Okta Provider
AUTH_SECRET=your-random-secret
AUTH_PROVIDER=okta
AUTH_OKTA_ID=your-okta-client-id
AUTH_OKTA_SECRET=your-okta-client-secret
AUTH_OKTA_ISSUER=https://your-okta-domain.okta.com/oauth2/default
Azure AD OAuth Setup
Documentation: Auth.js Azure AD Provider
AUTH_SECRET=your-random-secret
AUTH_PROVIDER=azure-ad
AUTH_AZURE_AD_ID=your-azure-client-id
AUTH_AZURE_AD_SECRET=your-azure-client-secret
AUTH_AZURE_AD_TENANT_ID=your-tenant-id-or-common
GitHub OAuth Setup
Documentation: Auth.js GitHub Provider
GitHub OAuth is particularly useful for MCP servers that interact with GitHub repositories, such as Octocode. When using GitHub OAuth, you can specify scopes to control what permissions your MCP servers have access to.
AUTH_SECRET=your-random-secret
AUTH_PROVIDER=github
AUTH_GITHUB_ID=your-github-client-id
AUTH_GITHUB_SECRET=your-github-client-secret
AUTH_GITHUB_SCOPES=repo
Common GitHub Scopes:
repo- Full access to repositories (public and private)public_repo- Access to public repositories onlyread:user- Read access to user profile informationuser:email- Access to user email addresses
For Octocode and similar MCP servers that need repository access, the repo scope is typically required.
For other providers, see the Auth.js Providers documentation.
Advanced Configuration
Command Line Options
| Option | Description | Default Value | Example |
|---|---|---|---|
--mcp-config |
Path to MCP servers configuration file | ./mcp.json |
--mcp-config ./config/servers.json |
--envfile |
Path to environment variables file | ./.env |
--envfile ./config/production.env |
Environment Variables
| Environment Variable | Description | Default Value | Required |
|---|---|---|---|
PORT |
Server port | 3000 |
No |
BASE_URL |
Base URL for the gateway | http://localhost:3000 |
No |
AUTH_SECRET |
Secret for signing/encrypting tokens (generate with openssl rand -base64 33) |
- | Yes |
AUTH_PROVIDER |
OAuth provider name | google |
No |
TOKEN_EXPIRATION_TIME |
Token expiration time in milliseconds | 86400000 (24h) |
No |
DB_PATH |
SQLite database file path | ./mcp.sqlite |
No |
AUTH_[Provider]_ID |
OAuth client ID for your provider | - | Yes |
AUTH_[Provider]_SECRET |
OAuth client secret for your provider | - | Yes |
AUTH_[Provider]_* |
Additional provider-specific variables (see Auth.js documentation) | - | Varies |
Troubleshooting
StreamableHTTP with Cursor: Tools not appearing after login
Issue: When using StreamableHTTP configuration in Cursor, tools don't appear even after successful authentication.
Solution: Make sure you have only one Cursor window open. Multiple Cursor windows can interfere with the MCP connection establishment.
- Close all Cursor windows
- Open a single Cursor window
- Retry the authentication process
Node.js SQLite module error
Issue: You see the following error:
Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:sqlite
Solution: This error occurs when using an older version of Node.js. The node:sqlite module requires Node.js version 22 or higher.
Fix:
- Update Node.js to version 22 or later
- Verify your version:
node --version - Restart the gateway:
npm run start
Installation options:
- Using nvm:
nvm install 22 && nvm use 22 - Download from nodejs.org
Hosted Solution
Visit webrix.ai for our fully managed hosting solution with advanced features:
- Zero Configuration: Get started in seconds without any setup
- Enterprise-grade Security: Advanced SSO authentication for all MCP interactions
- 20+ Pre-built Connectors: Fast plug-and-play integration with hundreds of tools
- Roles & Permissions: Granular access control with custom role definitions
- Monitoring & Analytics: Real-time insights into your MCP usage
- High Availability: 99.9% uptime SLA with global CDN
- Premium Support: Direct access to our engineering team
- Custom Integrations: Build and deploy custom MCP connectors
Community
Have questions? Need help getting started? Want to share your MCP setup?
Join our Slack community where developers are actively helping each other with MCP gatway implementations, troubleshooting, and sharing best practices.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.

