mcp-oauth-password
Verified Safeby arnaldo-delisio
Overview
Provides a self-hosted, password-based OAuth 2.1 authentication server for Model Context Protocol (MCP) applications.
Installation
npx ts-node example/server.tsEnvironment Variables
- SERVER_URL
- DATABASE_URL
- OAUTH_CLIENT_ID
- OAUTH_CLIENT_SECRET
- OAUTH_PASSWORD_HASH
- SESSION_SECRET
- API_KEY
- NODE_ENV
Security Notes
The server implements OAuth 2.1 with Proof Key for Code Exchange (PKCE), bcrypt password hashing (10 rounds), and secure session cookies (httpOnly, secure, sameSite=Lax). Session and authorization codes are stored persistently in PostgreSQL. Redirect URI validation and automatic rate limiting on login, token, and authorize endpoints help mitigate common attacks. Audit logging tracks authentication events for monitoring. The 'secure' cookie flag is correctly enforced based on the NODE_ENV. For its intended use in personal/self-hosted environments, these features provide strong security. However, as noted in the README, features like token expiration with refresh tokens and multi-user support (beyond a single configured password) are still on the roadmap for full enterprise-grade production readiness (v1.0.0). The example provides default credentials for demonstration, but the core library design encourages using environment variables for sensitive data.
Similar Servers
example-remote-server
A reference server demonstrating all Model Context Protocol (MCP) features and OAuth 2.0 authentication patterns.
mcp-tools
Provides a TypeScript library to simplify building Model Context Protocol (MCP) clients and servers, enabling AI applications to securely access private user data through OAuth-based authentication flows.
oauth-mcp-proxy
OAuth 2.1 authentication library for Go MCP servers, supporting both mark3labs and official SDKs for token validation and caching.
mcp-server-playground
A playground and reference implementation for a Model Context Protocol (MCP) server, featuring streamable HTTP transport, OAuth proxy for third-party authorization servers like Auth0, and stateful session management.