Skip to content

Commit 7a2796e

Browse files
committed
docs: update OAuth configuration details and usage instructions in multiple files for clarity
1 parent 1a7749d commit 7a2796e

File tree

5 files changed

+184
-245
lines changed

5 files changed

+184
-245
lines changed

.cursorrules

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ The following environment variables are supported (see `src/config.ts`):
105105

106106
### OAuth Configuration (Optional)
107107

108-
- `ENABLE_AUTH` - Enable OAuth authentication (default: false)
108+
- `ENABLE_AUTH` - Enable OAuth 2.1 authentication (default: false)
109+
- `OAUTH_ISSUER` - OAuth issuer URL (required if auth enabled)
109110
- `OAUTH_CLIENT_ID` - OAuth client ID (required if auth enabled)
110111
- `OAUTH_CLIENT_SECRET` - OAuth client secret (required if auth enabled)
111-
- `OAUTH_AUTH_ENDPOINT` - OAuth authorization endpoint (required if auth enabled)
112-
- `OAUTH_TOKEN_ENDPOINT` - OAuth token endpoint (required if auth enabled)
113-
- `OAUTH_SCOPE` - OAuth scope (default: "read")
114-
- `OAUTH_REDIRECT_URI` - OAuth redirect URI (required if auth enabled)
112+
- `OAUTH_AUDIENCE` - Expected audience in JWT tokens (optional but recommended)
113+
- `OAUTH_SCOPE` - OAuth scope (default: "openid profile email")
114+
- `OAUTH_REDIRECT_URI` - OAuth redirect URI (optional, defaults to BASE_URL/callback)
115115

116116
## Coding Guidelines
117117

@@ -135,19 +135,38 @@ The following environment variables are supported (see `src/config.ts`):
135135

136136
## OAuth Implementation
137137

138-
### Modular Authentication
138+
### Simple Binary Configuration
139139

140-
The template includes optional OAuth 2.1 authentication that can be easily enabled or completely removed:
140+
The template includes optional OAuth 2.1 authentication with a simple on/off approach:
141141

142+
- **Default**: No authentication required - server runs immediately with `ENABLE_AUTH=false`
143+
- **Enable When Needed**: Set `ENABLE_AUTH=true` and provide OAuth configuration
142144
- **Modular Design**: All OAuth code is in `src/auth/` directory
143-
- **Conditional Loading**: OAuth middleware only applies when `ENABLE_AUTH=true`
144145
- **Zero Impact When Disabled**: No performance overhead when authentication is disabled
145146
- **Easy Removal**: Delete `src/auth/` directory and remove auth import from `src/index.ts`
146147

147-
### Authentication Patterns
148+
### Use Cases
148149

149-
1. **External OAuth (Recommended)**: Use Pomerium or similar OAuth proxy
150-
2. **Built-in OAuth Server**: Use the provided OAuth implementation in `src/auth/`
150+
**Authentication Disabled** (`ENABLE_AUTH=false` or omitted):
151+
- Public MCP servers
152+
- Gateway-protected deployments (Pomerium, nginx with auth, etc.)
153+
- Development and testing
154+
- Internal corporate networks with perimeter security
155+
156+
**Authentication Enabled** (`ENABLE_AUTH=true`):
157+
- Direct OAuth 2.1 with token validation
158+
- Self-contained secure deployment
159+
- Production servers without gateway infrastructure
160+
161+
### Quick Setup
162+
163+
To enable authentication, add to your `.env`:
164+
```bash
165+
ENABLE_AUTH=true
166+
OAUTH_ISSUER=https://your-provider.com
167+
OAUTH_CLIENT_ID=your-client-id
168+
OAUTH_CLIENT_SECRET=your-client-secret
169+
```
151170

152171
### Removing OAuth
153172

.env.example

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,58 @@ LOG_LEVEL=info
99
# Defaults to http://localhost:PORT if not set (where PORT is the configured port)
1010
# BASE_URL=http://localhost:3000
1111

12-
# Authentication Configuration (Optional)
13-
# Set ENABLE_AUTH=true to enable authentication
14-
ENABLE_AUTH=false
15-
16-
# Authentication mode: "resource_server", "full", or "none" (default)
17-
AUTH_MODE=resource_server
18-
1912
# ============================================================================
20-
# Resource Server Mode Configuration
21-
# ============================================================================
22-
# MCP server acts as a resource server and validates tokens from external OAuth providers
23-
# Commonly used with gateways that handle OAuth flows for enterprise deployments
24-
# Can also work with direct OAuth flows where clients get tokens themselves
25-
26-
# OAuth issuer URL for token validation (required for resource_server mode)
27-
# Examples:
28-
# Auth0: https://your-domain.auth0.com
29-
# Okta: https://your-domain.okta.com
30-
# Google: https://accounts.google.com
31-
OAUTH_ISSUER=https://your-domain.auth0.com
32-
33-
# Expected audience in JWT tokens (optional)
34-
# If set, tokens must have this audience claim
35-
OAUTH_AUDIENCE=your-api-identifier
36-
37-
# ============================================================================
38-
# Full Mode Configuration (OAuth Proxy + Resource Server)
13+
# Authentication Configuration (Optional)
3914
# ============================================================================
40-
# MCP server acts as both OAuth client (proxy to external IdP) AND resource server
41-
# Provides OAuth endpoints while delegating authentication to external providers
42-
# Production-ready but consider using resource_server mode with a gateway for enterprise deployments
43-
44-
# OAuth client credentials (required for full mode)
45-
OAUTH_CLIENT_ID=your-client-id
46-
OAUTH_CLIENT_SECRET=your-client-secret
15+
# Default: No authentication required - server runs immediately
16+
# Enable when you need OAuth 2.1 authentication with token validation
17+
# ENABLE_AUTH=false
4718

48-
# OAuth provider endpoints (required for full mode)
49-
OAUTH_AUTH_ENDPOINT=https://your-domain.auth0.com/authorize
50-
OAUTH_TOKEN_ENDPOINT=https://your-domain.auth0.com/oauth/token
19+
# When ENABLE_AUTH=true, configure your OAuth provider:
20+
# ENABLE_AUTH=true
21+
# OAUTH_ISSUER=https://your-provider.com
22+
# OAUTH_CLIENT_ID=your-client-id
23+
# OAUTH_CLIENT_SECRET=your-client-secret
5124

52-
# OAuth configuration
53-
OAUTH_SCOPE=read
54-
# OAUTH_REDIRECT_URI=http://localhost:3000/callback # Optional, defaults to BASE_URL/callback
25+
# Additional OAuth settings (optional)
26+
# OAUTH_AUDIENCE=your-api-identifier # For token audience validation
27+
# OAUTH_SCOPE=openid profile email # Default scope
28+
# OAUTH_REDIRECT_URI=http://localhost:3000/callback # Defaults to BASE_URL/callback
5529

5630
# ============================================================================
57-
# Example Configurations
31+
# Common OAuth Provider Examples
5832
# ============================================================================
5933

60-
# Example: Auth0 Resource Server Mode
34+
# Auth0 Example:
6135
# ENABLE_AUTH=true
62-
# AUTH_MODE=resource_server
6336
# OAUTH_ISSUER=https://your-domain.auth0.com
37+
# OAUTH_CLIENT_ID=your-auth0-client-id
38+
# OAUTH_CLIENT_SECRET=your-auth0-client-secret
6439
# OAUTH_AUDIENCE=your-api-identifier
6540

66-
# Example: Auth0 Full Mode
41+
# Okta Example:
6742
# ENABLE_AUTH=true
68-
# AUTH_MODE=full
69-
# OAUTH_CLIENT_ID=your-auth0-client-id
70-
# OAUTH_CLIENT_SECRET=your-auth0-client-secret
71-
# OAUTH_AUTH_ENDPOINT=https://your-domain.auth0.com/authorize
72-
# OAUTH_TOKEN_ENDPOINT=https://your-domain.auth0.com/oauth/token
73-
# OAUTH_SCOPE=read
74-
# OAUTH_REDIRECT_URI=http://localhost:3000/callback # Optional, defaults to BASE_URL/callback
43+
# OAUTH_ISSUER=https://your-domain.okta.com
44+
# OAUTH_CLIENT_ID=your-okta-client-id
45+
# OAUTH_CLIENT_SECRET=your-okta-client-secret
7546

76-
# Example: No Authentication Mode (Default)
77-
# Note: Consider enabling auth even for local development for security best practices
78-
# ENABLE_AUTH=false
79-
# AUTH_MODE=none
47+
# Google Example:
48+
# ENABLE_AUTH=true
49+
# OAUTH_ISSUER=https://accounts.google.com
50+
# OAUTH_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
51+
# OAUTH_CLIENT_SECRET=your-google-client-secret
52+
53+
# ============================================================================
54+
# Use Cases
55+
# ============================================================================
56+
#
57+
# Auth Disabled (ENABLE_AUTH=false or omitted):
58+
# - Public MCP servers
59+
# - Gateway-protected deployments (Pomerium, nginx with auth, etc.)
60+
# - Development and testing
61+
# - Internal corporate networks with perimeter security
62+
#
63+
# Auth Enabled (ENABLE_AUTH=true):
64+
# - Direct OAuth 2.1 with token validation
65+
# - Self-contained secure deployment
66+
# - Production servers without gateway infrastructure

.github/copilot-instructions.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ See `src/config.ts` for all supported environment variables:
7474
- `SERVER_VERSION` - Server version
7575
- `LOG_LEVEL` - Logging level (error/warn/info/debug)
7676

77+
### OAuth Configuration (Optional)
78+
79+
- `ENABLE_AUTH` - Enable OAuth 2.1 authentication (default: false)
80+
- `OAUTH_ISSUER` - OAuth issuer URL (required if auth enabled)
81+
- `OAUTH_CLIENT_ID` - OAuth client ID (required if auth enabled)
82+
- `OAUTH_CLIENT_SECRET` - OAuth client secret (required if auth enabled)
83+
- `OAUTH_AUDIENCE` - Expected audience in JWT tokens (optional but recommended)
84+
- `OAUTH_SCOPE` - OAuth scope (default: "openid profile email")
85+
- `OAUTH_REDIRECT_URI` - OAuth redirect URI (optional, defaults to BASE_URL/callback)
86+
7787
## Common Patterns
7888

7989
### Adding a New MCP Tool
@@ -134,9 +144,30 @@ const port = config.PORT;
134144
const serverName = config.SERVER_NAME;
135145
```
136146

147+
## Authentication
148+
149+
### Simple Binary Configuration
150+
151+
The template includes optional OAuth 2.1 authentication:
152+
153+
- **Default**: No authentication required (`ENABLE_AUTH=false`)
154+
- **Enable when needed**: Set `ENABLE_AUTH=true` and provide OAuth config
155+
- **Use cases**: Public servers (auth disabled) or secure deployments (auth enabled)
156+
157+
### Quick Setup
158+
159+
To enable authentication, add to `.env`:
160+
```bash
161+
ENABLE_AUTH=true
162+
OAUTH_ISSUER=https://your-provider.com
163+
OAUTH_CLIENT_ID=your-client-id
164+
OAUTH_CLIENT_SECRET=your-client-secret
165+
```
166+
137167
## Important Notes
138168

139169
- **File extensions**: Use `.js` in import statements (TypeScript compilation requirement)
140170
- **OpenTelemetry ready**: Logger automatically correlates with OTel traces when configured
141171
- **Production ready**: Includes graceful shutdown, error handling, and structured logging
142-
- **Template usage**: This is a template - customize for your specific MCP server needs
172+
- **Template usage**: This is a template - customize for your specific MCP server needs
173+
- **Authentication**: Server starts immediately with no auth setup required, add OAuth when needed

CLAUDE.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ The following environment variables are supported (see `src/config.ts`):
9393

9494
### OAuth Configuration (Optional)
9595

96-
- `ENABLE_AUTH` - Enable OAuth authentication (default: false)
96+
- `ENABLE_AUTH` - Enable OAuth 2.1 authentication (default: false)
97+
- `OAUTH_ISSUER` - OAuth issuer URL (required if auth enabled)
9798
- `OAUTH_CLIENT_ID` - OAuth client ID (required if auth enabled)
9899
- `OAUTH_CLIENT_SECRET` - OAuth client secret (required if auth enabled)
99-
- `OAUTH_AUTH_ENDPOINT` - OAuth authorization endpoint (required if auth enabled)
100-
- `OAUTH_TOKEN_ENDPOINT` - OAuth token endpoint (required if auth enabled)
101-
- `OAUTH_SCOPE` - OAuth scope (default: "read")
102-
- `OAUTH_REDIRECT_URI` - OAuth redirect URI (required if auth enabled)
100+
- `OAUTH_AUDIENCE` - Expected audience in JWT tokens (optional but recommended)
101+
- `OAUTH_SCOPE` - OAuth scope (default: "openid profile email")
102+
- `OAUTH_REDIRECT_URI` - OAuth redirect URI (optional, defaults to BASE_URL/callback)
103103

104104
## Logging Best Practices
105105

@@ -124,19 +124,28 @@ When adding new tools to the MCP server:
124124

125125
## OAuth Implementation
126126

127-
### Modular Authentication
127+
### Simple Binary Configuration
128128

129-
The template includes optional OAuth 2.1 authentication that can be easily enabled or completely removed:
129+
The template includes optional OAuth 2.1 authentication with a simple on/off approach:
130130

131+
- **Default**: No authentication required - server runs immediately
132+
- **Enable When Needed**: Set `ENABLE_AUTH=true` and provide OAuth config
131133
- **Modular Design**: All OAuth code is in `src/auth/` directory
132-
- **Conditional Loading**: OAuth middleware only applies when `ENABLE_AUTH=true`
133134
- **Zero Impact When Disabled**: No performance overhead when authentication is disabled
134135
- **Easy Removal**: Delete `src/auth/` directory and remove auth import from `src/index.ts`
135136

136-
### Authentication Patterns
137+
### Use Cases
137138

138-
1. **External OAuth (Recommended)**: Use Pomerium or similar OAuth proxy
139-
2. **Built-in OAuth Server**: Use the provided OAuth implementation in `src/auth/`
139+
**Authentication Disabled** (`ENABLE_AUTH=false` or omitted):
140+
- Public MCP servers
141+
- Gateway-protected deployments (Pomerium, nginx with auth, etc.)
142+
- Development and testing
143+
- Internal corporate networks with perimeter security
144+
145+
**Authentication Enabled** (`ENABLE_AUTH=true`):
146+
- Direct OAuth 2.1 with token validation
147+
- Self-contained secure deployment
148+
- Production servers without gateway infrastructure
140149

141150
### Removing OAuth
142151

0 commit comments

Comments
 (0)