[PR #6974] [MERGED] fix(mcp): restore ctx.query from cookie in OAuth flow #32601

Closed
opened 2026-04-17 23:22:25 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6974
Author: @bytaesu
Created: 12/24/2025
Status: Merged
Merged: 1/8/2026
Merged by: @bytaesu

Base: canaryHead: 2025-12-24/fix/mcp-oauth-cookie-persistence


📝 Commits (6)

  • df36b70 fix(mcp): restore ctx.query from cookie in OAuth flow
  • 07636d8 test: add test case for OAuth cookie persistence
  • 3c1c928 use safeJSONParse util
  • 7c91e15 fix: imports order
  • c3e567b Merge branch 'canary' into 2025-12-24/fix/mcp-oauth-cookie-persistence
  • 3eb9487 Merge branch 'canary' into 2025-12-24/fix/mcp-oauth-cookie-persistence

📊 Changes

2 files changed (+107 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/plugins/mcp/index.ts (+7 -0)
📝 packages/better-auth/src/plugins/mcp/mcp.test.ts (+100 -0)

📄 Description

Closes https://github.com/better-auth/better-auth/issues/6958


Summary by cubic

Fixes MCP OAuth login redirects so unauthenticated users who log in are sent back to the client/consent flow, not /api/auth/error.

  • Bug Fixes
    • Restore ctx.query from the persisted oidc_login_prompt cookie during OAuth to continue with the original authorization params.
    • Add a test that asserts cookie persistence and a valid redirect (consent or callback with code) without invalid_client or error.

Written for commit 3eb948786a. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6974 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 12/24/2025 **Status:** ✅ Merged **Merged:** 1/8/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `2025-12-24/fix/mcp-oauth-cookie-persistence` --- ### 📝 Commits (6) - [`df36b70`](https://github.com/better-auth/better-auth/commit/df36b703edc32d3f164feceeeca34d517a6afe53) fix(mcp): restore ctx.query from cookie in OAuth flow - [`07636d8`](https://github.com/better-auth/better-auth/commit/07636d8e67ce50b2ef70dde96d3d1f1cf2d889ab) test: add test case for OAuth cookie persistence - [`3c1c928`](https://github.com/better-auth/better-auth/commit/3c1c92853f08322c9d031ff6fa1839b4fb20fe62) use safeJSONParse util - [`7c91e15`](https://github.com/better-auth/better-auth/commit/7c91e15ffd991ad133f2b8e6f60fcd1fb7103bec) fix: imports order - [`c3e567b`](https://github.com/better-auth/better-auth/commit/c3e567b98a1b1262d003b13e3b08f8c54314c3f6) Merge branch 'canary' into 2025-12-24/fix/mcp-oauth-cookie-persistence - [`3eb9487`](https://github.com/better-auth/better-auth/commit/3eb948786a32ea3d63bf05127903fc0c72bc9606) Merge branch 'canary' into 2025-12-24/fix/mcp-oauth-cookie-persistence ### 📊 Changes **2 files changed** (+107 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/mcp/index.ts` (+7 -0) 📝 `packages/better-auth/src/plugins/mcp/mcp.test.ts` (+100 -0) </details> ### 📄 Description Closes https://github.com/better-auth/better-auth/issues/6958 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes MCP OAuth login redirects so unauthenticated users who log in are sent back to the client/consent flow, not /api/auth/error. - **Bug Fixes** - Restore ctx.query from the persisted oidc_login_prompt cookie during OAuth to continue with the original authorization params. - Add a test that asserts cookie persistence and a valid redirect (consent or callback with code) without invalid_client or error. <sup>Written for commit 3eb948786a32ea3d63bf05127903fc0c72bc9606. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:22:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#32601