GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remote MCP servers disconnected by server-side idle timeout lack automatic reconnection · Issue #15209 · anomalyco/opencode

Remote MCP servers disconnected by server-side idle timeout lack automatic reconnection #15209

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Remote MCP servers disconnected by server-side idle timeout lack automatic reconnection#15209
Copy link
Assignees
rekram1-node
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)

Description

@chenhaodongHD
chenhaodongHD
opened on Feb 26, 2026
Issue body actions

Problem

Remote MCP servers (using SSEClientTransport or StreamableHTTPClientTransport) may have their connections closed by the remote server during idle periods due to server-side timeout policies. Currently, OpenCode:

  1. No keepalive mechanism - There's no heartbeat/ping to keep connections alive during idle periods
  2. No automatic reconnection - When a connection drops, OpenCode doesn't automatically attempt to reconnect
  3. No pre-use connection check - When an agent runs and needs MCP tools, OpenCode doesn't verify if connections are still alive before attempting to use them
  4. Reactive failure handling only - Connection failures are only detected when a tool call fails, at which point the client is marked as "failed" and removed from the active clients pool

Current Behavior

From `packages/opencode/src/mcp/index.ts`:

```typescript
// Tool fetching fails if connection is dead
const toolsResult = await client.listTools().catch((e) => {
log.error("failed to get tools", { clientName, error: e.message })
s.status[clientName] = { status: "failed", error: e.message }
delete s.clients[clientName]
return undefined
})
```

The current flow:

  1. MCP servers connect at startup
  2. Connection sits idle (no keepalive)
  3. Remote server closes connection due to inactivity
  4. User runs an agent that tries to use MCP tool
  5. Tool call fails → client marked as "failed"
  6. User must manually reconnect via `opencode mcp connect ` or restart OpenCode

Expected Behavior

  1. Keepalive mechanism - Periodic ping/heartbeat to keep remote connections alive (configurable interval)
  2. Auto-reconnection - When connection drops, automatically attempt to reconnect with exponential backoff
  3. Pre-use health check - Before an agent session starts, verify all configured MCP servers are connected and attempt reconnection for failed ones
  4. Connection state monitoring - Detect disconnections proactively (e.g., SSE close events) rather than waiting for tool call failures

Suggested Solution

  1. Add a configurable `keepalive` interval for remote MCP servers (e.g., `mcp.keepaliveInterval` in config)
  2. Implement periodic health checks using `client.ping()` or similar mechanism
  3. Listen for transport close/error events to detect disconnections immediately
  4. Add auto-reconnect logic with exponential backoff (configurable max retries)
  5. Before agent execution, check all MCP statuses and attempt to reconnect failed/disconnected servers

Workaround

Currently, users need to:

  • Manually reconnect: `opencode mcp connect `
  • Restart OpenCode to re-establish all MCP connections
  • Use a proxy/load balancer that keeps connections alive

Impact

This affects reliability when using remote MCP servers, especially:

  • Cloud-hosted MCP services with aggressive idle timeouts
  • MCP servers behind corporate firewalls/proxies
  • Long-running OpenCode sessions with sporadic MCP usage
Reacted by Vladislav Afonin

Activity

  1. github-actions commented on Feb 26, 2026

    @github-actions
    github-actionsBot
    on Feb 26, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request, or Question
    • Based on the content, this appears to be a Feature Request — if so, the title should start with [FEATURE]: and include the required verification checkbox
    • The description reads as an AI-generated wall of text. Please summarize the request concisely in your own words

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions
    added
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Feb 26, 2026
  3. github-actions
    assigned
    rekram1-node
    on Feb 26, 2026
  4. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 26, 2026
  5. github-actions commented on Feb 26, 2026

    @github-actions
    github-actionsBot
    on Feb 26, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  6. github-actions
    removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Feb 26, 2026
  7. github-actions
    closed this as not plannedon Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.