Skip to content

docs: add COOP header troubleshooting for OAuth popup flows in MCP clients #671

@saif-at-scalekit

Description

@saif-at-scalekit

Problem

When developers integrate MCP servers using Scalekit OAuth (bring-your-own-auth), certain MCP clients (including Amazon Q) use a popup-based OAuth flow. If the app's login page sets Cross-Origin-Opener-Policy: same-origin, the browser severs the opener reference from the popup as soon as the login page loads. The MCP client sees popup.closed === true immediately and reports an error — even though the OAuth flow itself succeeds.

This is standard browser COOP enforcement and is not a Scalekit bug, but it produces a confusing failure with no actionable error message for developers.

Root cause (confirmed)

Cross-Origin-Opener-Policy: same-origin

When a cross-origin window (e.g., quick.aws.com) opens a popup that navigates to a page with COOP: same-origin, the browser severs the opener's reference to the popup. The MCP client's popup reference becomes closed === true immediately, before the OAuth flow completes.

Fix (app-side): Remove or change COOP to unsafe-none on the login/redirect endpoint used in the OAuth callback path.

What the docs should cover

Add a troubleshooting section to the MCP OAuth documentation covering:

  1. Symptom: OAuth popup closes immediately or "window closed too soon" error appears in the MCP client, even though the auth flow appears to complete.
  2. Diagnosis: Check Cross-Origin-Opener-Policy header on the app's login page via curl -sI <login-url> | grep -i cross-origin.
  3. Fix: Set Cross-Origin-Opener-Policy: unsafe-none on the login/redirect endpoint, or scope the COOP header only to non-OAuth paths.
  4. Note: This is a browser security policy enforced by the customer's app, not a Scalekit configuration issue.

Suggested doc location

  • src/content/docs/agentkit/ — MCP server OAuth integration guide (troubleshooting section)
  • Possibly a dedicated troubleshooting page for MCP auth

Additional context

The same issue surfaced alongside a separate email claim regression (a platform-side configuration that caused email to disappear from access tokens). The two are unrelated but both blocked the same integration. The email claim issue was resolved by support; the COOP issue required the customer to update their app's HTTP headers.

Source

Resolved support conversation — Slack thread about OAuth connection failure in Amazon Q when connecting to an MCP server using Scalekit auth. 25-message thread with 2+ day resolution time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions