@@ -90,7 +90,7 @@ npm run dev:integrated
9090npx -y @modelcontextprotocol/inspector
9191
9292# 4. Connect and test:
93- # - Connect to http://localhost:3232
93+ # - Connect to http://localhost:3232/mcp
9494# - Navigate to the Auth tab
9595# - Complete the OAuth flow
9696# - All auth endpoints will be served from :3232
@@ -108,7 +108,7 @@ npm run dev:with-separate-auth
108108npx -y @modelcontextprotocol/inspector
109109
110110# 4. Connect and test:
111- # - Connect to http://localhost:3232
111+ # - Connect to http://localhost:3232/mcp
112112# - Navigate to the Auth tab
113113# - The auth flow will redirect to :3001 for authentication
114114# - After auth, tokens from :3001 will be used on :3232
@@ -117,26 +117,84 @@ npx -y @modelcontextprotocol/inspector
117117### Architecture Diagrams
118118
119119#### Integrated Mode
120- ```
121- ┌──────────┐ ┌───────────────────┐
122- │ MCP │◀────▶│ MCP Server │
123- │ Inspector│ │ (port 3232) │
124- └──────────┘ │ │
125- │ - OAuth Server │
126- │ - Resource Server │
127- └───────────────────┘
120+ ``` mermaid
121+ graph TD
122+ Client["MCP Client<br/>(Inspector)"]
123+ MCP["MCP Server<br/>(port 3232)<br/>• OAuth Server<br/>• Resource Server"]
124+
125+ Client <-->|"OAuth flow & MCP resources"| MCP
128126```
129127
130128#### Separate Mode
129+ ``` mermaid
130+ graph TD
131+ Client["MCP Client<br/>(Inspector)"]
132+ MCP["MCP Server<br/>(port 3232)<br/>Resource Server"]
133+ Auth["Auth Server<br/>(port 3001)<br/>OAuth Server"]
134+
135+ Client <-->|"1. Discover metadata"| MCP
136+ Client <-->|"2. OAuth flow<br/>(register, authorize, token)"| Auth
137+ Client <-->|"3. Use tokens for MCP resources"| MCP
138+ MCP <-->|"Token validation<br/>(introspect)"| Auth
139+ ```
140+
141+ ## OAuth Flow Analysis
142+
143+ ### OAuth 2.0 + PKCE Flow Sequence
144+
145+ The server implements a complete OAuth 2.0 authorization code flow with PKCE. Here's how each step maps to data storage and expiry:
146+
147+ ** 1. Client Registration** (app setup - happens once)
148+ ```
149+ App → Auth Server: "I want to use OAuth, here's my info"
150+ Auth Server → App: "OK, your client_id is XYZ, client_secret is ABC"
151+ ```
152+ - ** Storage** : Client credentials for future OAuth flows
153+ - ** Expiry** : 30 days (long-lived app credentials)
154+
155+ ** 2. Authorization Request** (starts each OAuth flow)
156+ ```
157+ User → App: "I want to connect to MCP server"
158+ App → Auth Server: "User wants access, here's my PKCE challenge"
159+ Auth Server: Stores pending authorization, shows auth page
131160```
132- ┌──────────┐ ┌───────────────────┐ ┌─────────────────┐
133- │ MCP │◀────▶│ MCP Server │◀────▶│ Auth Server │
134- │ Inspector│ │ (port 3232) │ │ (port 3001) │
135- └──────────┘ │ │ │ │
136- │ │ - Resource Server │ │ - OAuth Server │
137- └───────────▶│ │ │ │
138- └───────────────────┘ └─────────────────┘
161+ - ** Storage** : ` PENDING_AUTHORIZATION ` - temporary state during flow
162+ - ** Expiry** : 10 minutes (short-lived temporary state)
163+
164+ ** 3. Authorization Code Exchange** (completes OAuth flow)
165+ ```
166+ User → Auth Server: "I approve this app"
167+ Auth Server → App: "Here's your authorization code"
168+ App → Auth Server: "Exchange code + PKCE verifier for tokens"
169+ Auth Server → App: "Here are your access/refresh tokens"
170+ ```
171+ - ** Storage** : ` TOKEN_EXCHANGE ` - prevents replay attacks
172+ - ** Expiry** : 10 minutes (single-use, consumed immediately)
173+
174+ ** 4. Token Storage** (long-term user session)
175+ ```
176+ Auth Server: Issues access_token + refresh_token
177+ Server: Stores user installation with tokens
139178```
179+ - ** Storage** : ` UPSTREAM_INSTALLATION ` - the actual user session
180+ - ** Expiry** : 7 days (balances security vs usability)
181+
182+ ** 5. Token Refresh** (extends user session)
183+ ```
184+ App → Auth Server: "My access token expired, here's my refresh token"
185+ Auth Server → App: "Here's a new access token"
186+ ```
187+ - ** Storage** : ` REFRESH_TOKEN ` - mapping for token rotation
188+ - ** Expiry** : 7 days (matches installation lifetime)
189+
190+ ### Data Lifecycle Hierarchy
191+
192+ ** Timeline (shortest to longest expiry):**
193+ 1 . ** OAuth flow state** (10 minutes) - very temporary
194+ 2 . ** User sessions** (7 days) - medium-term
195+ 3 . ** Client credentials** (30 days) - long-term
196+
197+ This creates a logical hierarchy where each layer outlives the layers it supports.
140198
141199## Installation
142200
0 commit comments