Skip to content

Commit a16c0b0

Browse files
committed
docs(recovery-system): enhance manual recovery section with detailed user actions and recovery types
1 parent 0317a5b commit a16c0b0

File tree

2 files changed

+49
-15
lines changed

2 files changed

+49
-15
lines changed

development/backend/mcp-server-oauth.mdx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The OAuth implementation includes:
4242
- **OAuth Discovery Service** - Detects OAuth requirement and discovers endpoints using RFC 8414/9728
4343
- **Authorization Endpoint** - Initiates OAuth flow with PKCE, state parameter, and resource parameter
4444
- **Callback Endpoint** - Exchanges authorization code for tokens
45+
- **Re-Authentication Endpoint** - User-initiated token refresh when automatic refresh fails
4546
- **Token Service** - Handles token exchange and refresh operations
4647
- **Client Registration Service** - Implements RFC 7591 Dynamic Client Registration (DCR)
4748
- **Encryption Service** - AES-256-GCM encryption for tokens at rest
@@ -837,16 +838,43 @@ INFO: OAuth token refresh job completed (totalTokens: 3, successCount: 3, failur
837838

838839
### Token Expiration Handling
839840

840-
**During token refresh cron job**:
841+
When automatic token refresh fails (server offline, invalid refresh token, token revoked), the installation enters `requires_reauth` status. Users can recover through self-service re-authentication.
842+
843+
**Automatic Refresh Failure**:
844+
- Token refresh job attempts refresh
845+
- Refresh fails (network error, invalid_grant, server offline)
841846
- Installation status → `requires_reauth`
842-
- User sees "Reconnect" button in frontend
843-
- User must re-authorize to get new tokens
844-
845-
**During satellite token retrieval**:
846-
- Satellite checks `expires_at` timestamp
847-
- If expired and no refresh possible → Return error to MCP client
848-
- MCP client receives authentication error
849-
- User must re-authenticate
847+
- Status message explains why re-auth is needed
848+
849+
**User-Initiated Re-Authentication**:
850+
851+
Users can re-authenticate existing installations without reinstalling:
852+
853+
**Endpoint**: `POST /api/teams/:teamId/mcp/installations/:installationId/reauth`
854+
855+
**Permission**: `mcp.installations.view` (both team_admin and team_user)
856+
857+
**Why Both Roles**: OAuth tokens are per-user credentials, not team-level configuration. Each user authenticates with their own account.
858+
859+
**Flow**:
860+
1. Frontend detects `requires_reauth` status and shows "Re-authenticate" button
861+
2. User clicks button → Backend starts OAuth flow (same as initial authorization)
862+
3. OAuth provider redirects to authorization page
863+
4. User authorizes → Callback exchanges code for new tokens
864+
5. Backend **updates** existing token record (doesn't create new installation)
865+
6. Installation status → `connecting``online`
866+
7. Satellite receives updated tokens via configuration sync
867+
868+
**Key Difference from Initial Authorization**:
869+
- Initial: Creates new installation + new token record
870+
- Re-auth: Updates existing installation + existing token record
871+
872+
**Database Impact**:
873+
- Pending flow created with `installation_id` reference (links to existing installation)
874+
- Callback detects `installation_id` and performs UPDATE instead of INSERT
875+
- Preserves team configuration (env vars, args, headers)
876+
877+
**Security**: Same PKCE flow, state validation, and token encryption as initial authorization
850878

851879
### Token Revocation
852880

development/satellite/recovery-system.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,18 @@ class McpServerWrapper {
347347

348348
## Manual Recovery (Requires User Action)
349349

350-
Some failures cannot auto-recover:
351-
352-
| Status | Reason | User Action |
353-
|--------|--------|-------------|
354-
| `requires_reauth` | OAuth token expired/revoked | Re-authenticate in dashboard |
355-
| `permanently_failed` | 3+ crashes in 5 minutes (stdio) | Check logs, fix issue, manual restart |
350+
Some failures cannot auto-recover and require user intervention:
351+
352+
| Status | Reason | User Action | Recovery Type |
353+
|--------|--------|-------------|---------------|
354+
| `requires_reauth` | OAuth token expired/revoked | Click "Re-authenticate" button in installation details | Self-service (all team members) |
355+
| `permanently_failed` | 3+ crashes in 5 minutes (stdio) | Check logs, fix issue, manual restart | Admin intervention |
356+
357+
**Re-Authentication Details**:
358+
- Available to all team members (OAuth is per-user)
359+
- Preserves installation configuration
360+
- Updates tokens in-place (no reinstall needed)
361+
- See [MCP Server OAuth - Token Expiration Handling](/development/backend/mcp-server-oauth#token-expiration-handling) for technical details
356362

357363
See [Process Management - Auto-Restart System](/development/satellite/process-management#auto-restart-system) for complete stdio restart policy details (3 crashes in 5-minute window, backoff delays).
358364

0 commit comments

Comments
 (0)