Skip to content

feat: implement automatic OAuth flow with dynamic client registration#26

Open
mvaled wants to merge 1 commit intonicobailon:mainfrom
mvaled:main
Open

feat: implement automatic OAuth flow with dynamic client registration#26
mvaled wants to merge 1 commit intonicobailon:mainfrom
mvaled:main

Conversation

@mvaled
Copy link
Copy Markdown

@mvaled mvaled commented Mar 23, 2026

Disclaimer: This was fully vibed with pi and kimi-k2.5. I don't have yet the time to devote a full revision. I have successfully registered Notion's and Sentry's MCPs with this. In particular Sentry provide tokens with refresh of 15 minutes, which makes this auto-refresh a nice addition.


Add full OAuth 2.0 authorization code flow with PKCE:

  • New oauth-flow.ts: Complete OAuth implementation

    • Discovery via .well-known/oauth-authorization-server
    • Dynamic client registration at /register endpoint
    • PKCE code verifier/challenge generation
    • Local HTTP callback server with random port
    • Automatic browser opening for authorization
    • Token exchange and storage
  • Enhanced oauth-handler.ts:

    • Automatic token refresh when expired
    • Uses refresh_token to get new access_token
    • Stores authorization metadata (server, clientId)
  • Updated types.ts:

    • Added scopes, clientId, authorizationServer fields
  • Updated commands.ts:

    • /mcp-auth now runs full OAuth flow instead of showing instructions
    • Step-by-step progress notifications
  • Updated server-manager.ts:

    • Async token loading with automatic refresh

Fixes: OAuth servers like Notion that require dynamic client registration now work automatically without manual setup.

Add full OAuth 2.0 authorization code flow with PKCE:

- New oauth-flow.ts: Complete OAuth implementation
  - Discovery via .well-known/oauth-authorization-server
  - Dynamic client registration at /register endpoint
  - PKCE code verifier/challenge generation
  - Local HTTP callback server with random port
  - Automatic browser opening for authorization
  - Token exchange and storage

- Enhanced oauth-handler.ts:
  - Automatic token refresh when expired
  - Uses refresh_token to get new access_token
  - Stores authorization metadata (server, clientId)

- Updated types.ts:
  - Added scopes, clientId, authorizationServer fields

- Updated commands.ts:
  - /mcp-auth now runs full OAuth flow instead of showing instructions
  - Step-by-step progress notifications

- Updated server-manager.ts:
  - Async token loading with automatic refresh

Fixes: OAuth servers like Notion that require dynamic client registration
now work automatically without manual setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant