You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 98d3a44
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(cloudflare): Stabilize MCP OAuth refresh reuse (#882)
Tighten the Cloudflare MCP OAuth refresh path so we stop logging users
out when we can still safely reuse the upstream Sentry token.
The main behavioral change is to distinguish locally valid cached
tokens, probe-validated cached tokens, definitively invalid upstream
tokens, and indeterminate verification failures. Legacy grants without a
refresh token remain usable while the embedded upstream access token
still works instead of being revoked immediately.
This also expands the MCP OAuth coverage around `/oauth/callback`,
`/oauth/token`, and `/mcp`, and upgrades the Cloudflare worker test
stack to the current `vitest-pool-workers` / Wrangler APIs. That upgrade
makes the previous opaque local startup failure explicit, but this
Ubuntu 20.04 WSL environment still cannot run the worker pool because
newer `workerd` now requires a newer glibc. CI on `ubuntu-latest` is the
intended verification path for these tests.
I did not add a separate workflow because the existing workspace
`test:ci` job already runs `@sentry/mcp-cloudflare`.
---------
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-Error: "No Sentry refresh token available in stored props"
324
-
- Resolution: Client must re-authenticate through full OAuth flow
321
+
1.**Legacy grant missing Sentry refresh token**:
322
+
-Behavior: The refresh exchange immediately stops returning new MCP tokens
323
+
- Resolution: The next `/mcp` request revokes the stale grant and requires a clean re-authentication flow
325
324
326
-
2.**Sentry Refresh Token Invalid**:
327
-
- Error: Sentry OAuth returns 401/400
328
-
- Resolution: Client must re-authenticate with both MCP and Sentry
325
+
2.**Cached Sentry token invalid**:
326
+
- Error: Sentry probe returns 400/401
327
+
- Resolution: Client must re-authenticate with MCP and Sentry
329
328
330
-
3.**Network Failures**:
331
-
- Error: Cannot reach Sentry OAuth endpoint
332
-
- Resolution: Retry with exponential backoff or re-authenticate
329
+
3.**Verification indeterminate**:
330
+
- Error: Network failure, timeout, or upstream 5xx while probing validity
331
+
- Resolution: The current implementation fails closed and requires re-authentication
333
332
334
333
The 2-minute safety window prevents edge cases with clock skew and processing delays between MCP and Sentry.
335
334
@@ -340,7 +339,7 @@ The 2-minute safety window prevents edge cases with clock skew and processing de
340
339
3.**Dual consent**: Users approve both MCP permissions and Sentry access
341
340
4.**Scope enforcement**: Both MCP and Sentry scopes limit access
342
341
5.**Token expiration**: Both MCP and Sentry tokens have expiry times
343
-
6.**Refresh token rotation**: Sentry issues new refresh tokens on each refresh
342
+
6.**Fail-closed verification**: If the worker cannot verify token validity confidently, it requires re-authentication rather than extending access speculatively
344
343
345
344
## Discovery Endpoints
346
345
@@ -376,14 +375,14 @@ The MCP Server then uses the Sentry access token from context to make Sentry API
376
375
### Benefits of the Dual OAuth Approach
377
376
378
377
1.**Security isolation**: MCP clients never see Sentry tokens directly
379
-
2.**Token management**: MCP can refresh Sentry tokens transparently
378
+
2.**Token management**: MCP can re-issue its own tokens while reusing cached Sentry credentials
380
379
3.**Permission layering**: MCP permissions separate from Sentry API scopes
381
380
4.**Client flexibility**: MCP clients don't need to understand Sentry OAuth
382
381
383
382
### Why Not Direct Sentry OAuth?
384
383
385
384
If MCP clients used Sentry OAuth directly:
386
-
- Clients would need to manage Sentry token refresh
385
+
- Clients would need to manage Sentry token lifetime and re-authentication directly
387
386
- No way to add MCP-specific permissions
388
387
- Clients would have raw Sentry API access (security risk)
0 commit comments