mcp-oauth
MCP first OAuth 2.1 authorization server
claude mcp add --transport stdio wille-mcp-oauth-server npx -y mcp-oauth-server@latest \ --env PORT="3000" \ --env ISSUER_URL="http://localhost:3000" \ --env OAUTH_BASE_URL="http://localhost:3000/oauth"
How to use
mcp-oauth-server is an OAuth 2.1 Authorization Server implementation that complies with the MCP Authorization Spec. It provides an OAuthServer instance that you can plug into an MCP workflow via the mcpAuthRouter, enabling dynamic client registration, authorization flows, and access token issuance in the context of MCP clients and resources. The server can run with in-memory storage for development or with a custom OAuthServerModel for production-grade databases, and it is designed to integrate smoothly with the MCP TypeScript SDK to manage authorization flows and consent screens.
To use it, install the server and run it in your Node.js environment. The repository exposes the OAuthServer class and the mcpAuthRouter middleware, which you mount into your Express app. The example in the repository demonstrates an in-memory setup behind an MCP server and includes a consent screen workflow. You can start the demo and then run a separate client to perform the authorization flow, enabling you to test token issuance, consent handling, and resource access within the MCP ecosystem.
How to install
Prerequisites:
- Node.js (recommended LTS) and npm or pnpm installed
- Basic familiarity with npm package installation and running Node.js apps
Step-by-step installation:
-
Ensure Node.js is installed. Verify with: node -v npm -v
-
Install the MCP OAuth server package from npm: npm install mcp-oauth-server@latest --save-exact
or using yarn/pnpm if you prefer
-
Create a small server file to run the OAuth server, for example: // server.js import { OAuthServer } from 'mcp-oauth-server'; const oauthServer = new OAuthServer({ authorizationUrl: new URL('http://localhost:3000/consent'), scopesSupported: ['mcp:tools'], }); // integrate with mcpAuthRouter in your Express app as shown in the README
-
Run the server locally: node server.js
Or use ts-node / your build setup if using TypeScript
-
(Optional) Try the example mentioned in the repository by following the Quick Start in the README to start the demo server and a client to authenticate.
Additional notes
Notes and tips:
- This server is designed to integrate with the MCP SDK and the mcpAuthRouter to expose OAuth endpoints under a base URL you configure.
- You can run with in-memory storage for development or provide your own OAuthServerModel for production persistence.
- If your clients do not follow the resource indicator conventions (RFC 8707) or particular scope requests, the server remains compatible due to its configurable options such as strictResource and default scopes.
- When deploying, ensure your issuerUrl/baseUrl/resourceServerUrl are accessible to MCP clients and any consent UI you host.
- If you encounter issues with token lifetimes or client registration, review the config options documented in the API Reference section of the README to adjust lifetimes, scopes, and resource validation behavior.
Related MCP Servers
context7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
obsidian -tools
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
MiniMax -JS
Official MiniMax Model Context Protocol (MCP) JavaScript implementation that provides seamless integration with MiniMax's powerful AI capabilities including image generation, video generation, text-to-speech, and voice cloning APIs.
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
js
🔐 Plug-and-play auth for Node.js MCP servers.
mcp-bundler
Is the MCP configuration too complicated? You can easily share your own simplified setup!