Simplify MCP server with built-in OAuth callback flow#7
Open
peterankennedy-oss wants to merge 6 commits into
Open
Simplify MCP server with built-in OAuth callback flow#7peterankennedy-oss wants to merge 6 commits into
peterankennedy-oss wants to merge 6 commits into
Conversation
Replaced 18 granular WHOOP tools with 7 streamlined tools and added an embedded HTTP callback server so users can complete the OAuth flow directly from Claude without needing to run a separate auth app. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WHOOP's OAuth endpoint requires a `state` parameter with a minimum length. The authorize_whoop handler was calling getAuthorizationUrl() without one, causing an `invalid_state` error on redirect. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Track callback server instance to prevent port conflicts on repeat calls - Close existing server before starting new one - Add error handler for EADDRINUSE with retry - Listen on 0.0.0.0 instead of default (fixes localhost connection issues) - Extend timeout from 5 to 10 minutes - Handle OAuth error responses in callback - Add exchange_code tool as manual fallback when callback fails Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tokens are now saved to whoop-tokens.json after auth and loaded automatically on server startup. If the access token is expired, it auto-refreshes using the saved refresh token. This means users only need to authorize once — subsequent restarts reuse the saved tokens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 'offline' scope to OAuth request so WHOOP returns a refresh token - Fix loadTokens to properly reject expired tokens without refresh tokens instead of silently using them (which caused auth failures in new chats) - Mark isAuthorized=false on refresh failure so user gets a clear re-auth prompt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The MCP server previously only refreshed tokens at startup, so the access token expiring mid-session (~1 hour) required restarting Claude. This adds an axios response interceptor that catches 401 errors, auto-refreshes the token, saves new tokens to disk, and retries the original request transparently. Concurrent requests are queued so only one refresh happens at a time. Also adds WHOOP-MCP-SETUP-GUIDE.md with architecture, auth flow, troubleshooting, and lessons learned. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
authorize_whooptool and verify auth URL is generated🤖 Generated with Claude Code