anomalyco / anomalyco/opencode

server: auth and MCP connections fail after idle period

Open
#43,444 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

After OpenCode remains running and the Mac is idle for several hours, returning to the session results in provider authentication failing and MCP servers not reconnecting. Restarting OpenCode usually takes multiple attempts before authentication works and all MCPs load again.

Recent logs show the provider failure:

Failed to drain Session ... Invalid API key.

At the same time, every remote MCP repeatedly fails to reconnect:

mcp connect failed ... getaddrinfo ENOTFOUND mcp.granola.ai
mcp connect failed ... getaddrinfo ENOTFOUND mcp.apollo.io
mcp connect failed ... getaddrinfo ENOTFOUND mcp.posthog.com
mcp connect failed ... getaddrinfo ENOTFOUND circleback.ai
mcp connect failed ... getaddrinfo ENOTFOUND api.us-west-2.aws.dash0.com
mcp connect failed ... salesforce ... MCP error -32603: fetch failed

This started after a recent OpenCode update and happens consistently after leaving OpenCode idle for a few hours. Once recovery succeeds, opencode mcp list shows all six servers connected.

Plugins

./plugins/agent-arcade.tsx

OpenCode version

1.18.16 (release; issue began after an update)

Steps to reproduce

  1. Start OpenCode with remote MCP servers configured.
  2. Leave OpenCode running and the Mac idle for several hours.
  3. Return to the existing session and send a prompt.
  4. Observe provider authentication failing and MCP connection errors.
  5. Restart OpenCode; multiple restarts may be required before MCPs reconnect.

Expected behavior

The existing provider session remains authenticated, and MCP servers reconnect automatically after the machine resumes or network access returns.

Screenshot and/or share link

Not available. Relevant redacted log excerpts are included above.

Operating System

Darwin 24.6.0, arm64 (macOS)

Terminal

Ghostty (TERM=xterm-256color, COLORTERM=truecolor), shell /bin/zsh

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the idle-and-resume sequence on macOS with the configured remote MCP servers, then compare the provider and MCP log failures with the output of opencode mcp list. Done means an existing provider session remains usable and all remote MCP servers reconnect automatically after the machine resumes or network access returns.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.