Skip to content

Support granular OAuth2 flow with state and verifier persistence #992

Closed as not planned

Description

@andrey-star

Currently, the OAuth2 PKCE implementation in src/mcp/client/auth.py stores the state and code_verifier in memory only, which prevents splitting the OAuth authorization flow across multiple processes.

This is common for apps with servers split between frontend and backend where BE cannot be blocked on a UI action. The UI first requests the server to generate the link, and the server processes the callback separately once the user follows it. The state and code_verifier are persisted between the calls with a short expiration time.

Proposal:

  • Add support for persisting the state and code_verifier values, e.g. through the redirectHandler, and looking them up in the callbackHandler for the final token exchange.
  • Allowing more granular execution of the flow - generateUrl, and exchangeToken should be callable individually.

Activity

  1. changed the title [-]Support Persisting PKCE State and Code Verifier for Multi-Process OAuth Flows[/-] [+]Support granular OAuth2 glow by persisting state and verifier[/+] on Jun 20, 2025
  2. changed the title [-]Support granular OAuth2 glow by persisting state and verifier[/-] [+]Support granular OAuth2 flow by persisting state and verifier[/+] on Jun 20, 2025
  3. changed the title [-]Support granular OAuth2 flow by persisting state and verifier[/-] [+]Support granular OAuth2 flow with state and verifier persistence[/+] on Jun 20, 2025
  4. maxisbey commented on Jul 24, 2026

    @maxisbey
    Contributor

    Thanks for the report. Tracking this in #1743 instead. Closing as part of a general backlog cleanup ahead of the v2 release. If this is still relevant against current main, feel free to reopen.

    AI Disclaimer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues and PRs related to Authentication / OAuthenhancementRequest for a new feature that's not currently supported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions