Skip to content

fix(mcp): stop Codex MCP install hanging on OAuth callback - #1002

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-codex-mcp-oauth-hang
Draft

fix(mcp): stop Codex MCP install hanging on OAuth callback#1002
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/fix-codex-mcp-oauth-hang

Conversation

@posthog

@posthog posthog Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Users setting up the wizard with Codex installed hit a long hang and a captured error. CodexMCPClient.addServer shells out to codex mcp add --url <url> via a timeout-less spawnSync and only passes --bearer-token-env-var when an API key is present — which is often undefined. With no bearer token, Codex falls into its own interactive OAuth flow against the remote MCP server, can't complete the browser handshake in a non-interactive run, and blocks until its OAuth deadline elapses, surfacing timed out waiting for OAuth callback / deadline has elapsed.

This has been hitting the onboarding flow steadily for weeks across many distinct users. It doesn't crash the wizard (addServer returns success: false), but the user sits through a long hang, the exception is captured as error-tracking noise, and the Codex MCP server silently isn't installed.

Changes

  • Skip the OAuth-triggering path. When no API key is available, don't run codex mcp add at all — that's the only path that falls into interactive browser OAuth. Log how to add it manually and return gracefully.
  • Bound every codex subprocess with a timeout so it can never hang on Codex's OAuth deadline, and treat a timeout/spawn failure (result.error, incl. ETIMEDOUT) as a graceful skip with a diagnostic rather than a captured exception.

Note: this addresses the wizard-side Codex install hang only. The separate OAuthAuthorize "Redirecting…" spinner-without-timeout issue lives in the main webapp, not this repo.

Test plan

  • pnpm test — 1558 passing, including new addServer cases covering the no-api-key skip (no shell-out, no captured exception) and the timeout path (graceful success: false, no captured exception).
  • pnpm lint — 0 errors.

Created with PostHog Desktop from this inbox report.

`codex mcp add --url` falls into Codex's own interactive OAuth flow when no
bearer token is supplied. In the non-interactive wizard run that browser
handshake never completes, so the timeout-less spawnSync blocks until Codex's
OAuth deadline elapses, then surfaces a captured "deadline has elapsed" error.

- Skip the add entirely when no API key is available (that path is the only
  one that triggers OAuth), logging how to add it manually instead.
- Bound every codex subprocess with a timeout so it can never hang, and treat a
  timeout/spawn failure as a graceful skip rather than a captured exception.

Generated-By: PostHog Code
Task-Id: 643a8483-17ac-418e-832a-8be6cd67da2a
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

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.

0 participants