SF ShipGlows
Menu Open navigation menu Close navigation menu

Remote MCP OAuth

Remote agents still need a local OAuth callback path.

When Codex runs on a server, MCP OAuth can fail for a simple reason: the browser callback points to local `127.0.0.1`, but the login process that needs that callback is running somewhere else.

The Short Version

The provider redirects your browser to localhost. The agent is not local.

Hosted MCP providers such as Vercel or Supabase can use OAuth to authorize Codex. In a remote setup, Codex starts the OAuth flow on the server while your browser opens on your laptop. That split is where `connection refused` and `connection reset` usually come from.

ShipGlows Pattern

Create a temporary SSH tunnel for the fresh callback port.

ShipGlows reads the callback port from the current OAuth attempt, opens an SSH `-L` route for that port, lets the browser finish the authorization, then closes the tunnel.

Why It Breaks

`127.0.0.1` means different machines depending on where you stand.

OAuth localhost callbacks are normal for command-line tools. They become confusing only when the command-line tool is remote and the browser is local.

The problem is not OAuth itself. The problem is routing: the local browser needs a path back to the callback listener running on the remote server.

The remote process starts OAuth

`codex mcp login vercel` or `codex mcp login supabase` runs on the server because that is where the remote Codex session and its MCP configuration live.

The local browser receives the redirect

The provider opens an authorization URL in your browser. That URL eventually redirects to `http://127.0.0.1:PORT/callback`.

The port belongs to the current attempt

The callback port is not stable. A later login attempt can use a different port, so reusing an old SSH tunnel is the wrong model.

The fix is routing, not OAuth reimplementation

ShipGlows does not replace the provider flow. It only creates the missing route from the local browser back to the remote callback listener for the duration of the login.

Mental Model

Three moving parts explain the whole flow.

1. Remote Codex starts the login

The MCP provider and OAuth state belong to the Codex session on the server, so the login command must run there.

2. The local browser completes authorization

The operator still approves access in the browser, using the provider's official OAuth page.

3. The SSH tunnel connects the callback

The tunnel exists only so the local `127.0.0.1:PORT/callback` request can reach the remote listener for that one login attempt.

Then ShipGlows closes the route

Once Codex verifies the OAuth status, the callback tunnel is no longer useful. It should not become a permanent app tunnel.

Flow

The tunnel exists only between callback discovery and login completion.

Local browser

The browser receives the provider callback on localhost after the operator approves access.

Temporary SSH route

ShipGlows opens a short-lived path between that localhost callback and the matching port on the remote server.

Remote Codex login

The remote Codex process receives the callback and completes the MCP provider login.

Cleanup

After Codex verifies the OAuth status, ShipGlows closes the callback route instead of keeping a permanent tunnel.

Operator Setup

The menu should know the server, user, and optional SSH key.

The important operator detail is not the OAuth URL itself. It is the saved SSH target. If you change servers, the local ShipGlows menu needs the new host, SSH user, and optionally the key path if your key has a custom name.

Use the guided local menu

Run `urls`, then choose the server configuration entry. The same saved connection is used by app tunnels and by `shipglows-mcp-login`.

Leave the key blank when SSH already knows

If `~/.ssh/config` or your SSH agent already selects the right key, ShipGlows does not need a key path. If the key has a special file name and SSH cannot infer it, enter the path in the menu.

Do not type stale callback ports

The callback port is extracted from the current Codex login output. Manual port reuse is fragile because each OAuth attempt can produce a new callback port.

Keep provider authorization explicit

The browser approval still happens on the provider's official page. The operator chooses the account and organization there.

Security Boundary

The tunnel is a route for the callback, not a token store.

ShipGlows should not read, persist, or transform OAuth tokens. The token exchange stays between Codex and the provider. ShipGlows's job is to make the network path match the remote execution model.

Temporary by default

The OAuth tunnel should close after the login attempt. Development app tunnels and MCP login tunnels are separate concerns.

No token logging

OAuth authorization URLs are shown only because the operator needs to open them. Persisted OAuth credentials remain Codex/provider responsibility.

ShipGlows Local Setup

Use the local tool when Codex runs remotely.

The operational command is `shipglows-mcp-login vercel`, `shipglows-mcp-login supabase`, or `shipglows-mcp-login all`. If the SSH target changed, configure the new server through the local menu first.