Skip to content

MCP server connection lost after context compaction — tools unavailable until new session #23556

Closed as not planned

Description

@ramsyman

Description

After context compaction occurs, MCP server tools become completely unavailable for the rest of the session. The only workaround is to start a new session.

This was also reported in NeuralNomadsAI/CodeNomad#344, where the CodeNomad maintainer confirmed this is an OpenCode-level issue.

Steps to Reproduce

  1. Start a session with MCP servers configured
  2. Use MCP tools extensively (large tool outputs, many calls)
  3. Wait for or trigger context compaction (~95% context window)
  4. Attempt to call any MCP tool after compaction

Expected Behavior

MCP server connections are re-established after compaction. Tools remain available throughout the session.

Actual Behavior

All MCP tool calls fail after compaction. The tools are simply gone — no error, no reconnect attempt. A full new session is required to restore MCP functionality.

Impact

Any workflow relying on MCP tools (e.g. database tools, agent registries, custom servers) is silently broken after compaction. This is especially problematic for long-running sessions where compaction is expected.

Environment

  • OpenCode TUI (darwin)
  • MCP servers configured via config
  • Model: claude-sonnet-4-6

Related

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 20, 2026
  2. github-actions commented on Apr 20, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    It may be worth reviewing those issues to see if they overlap with what you're experiencing.

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. rekram1-node commented on Jun 24, 2026

    @rekram1-node
    Contributor

    I don't think this is accurate nor can I reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions