[PR #4435] feat: add session-scoped MCP support with same-turn tool refresh #10973

Closed
opened 2026-02-16 18:15:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4435

State: closed
Merged: No


Add Session-Scoped MCP Support + Same-Turn Tool Refresh

Summary

Adds session-scoped MCP loading and event-driven tool refresh to enable:

  1. Same-turn usage - MCPs loaded mid-turn are immediately available without requiring the user to type "continue"
  2. Agent-driven loading - Agent can decide when to load MCPs based on user requests, not explicit mentions
  3. Session isolation - Subagents load temporary MCPs that auto-dispose without polluting parent context

Implementation

MCP state is now split between instance-scoped (shared, persistent) and session-scoped (isolated, ephemeral). When a session-scoped MCP loads, it publishes an event that triggers tool refresh mid-turn, allowing immediate use. Session disposal automatically cleans up associated MCPs.

The API surface adds addSessionScoped() and disposeSession() to the MCP module, with a new REST endpoint for session-scoped loading. Event-driven tool refresh replaces the previous turn-boundary limitation.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4435 **State:** closed **Merged:** No --- # Add Session-Scoped MCP Support + Same-Turn Tool Refresh ## Summary Adds session-scoped MCP loading and event-driven tool refresh to enable: 1. **Same-turn usage** - MCPs loaded mid-turn are immediately available without requiring the user to type "continue" 2. **Agent-driven loading** - Agent can decide when to load MCPs based on user requests, not explicit mentions 3. **Session isolation** - Subagents load temporary MCPs that auto-dispose without polluting parent context ## Implementation MCP state is now split between instance-scoped (shared, persistent) and session-scoped (isolated, ephemeral). When a session-scoped MCP loads, it publishes an event that triggers tool refresh mid-turn, allowing immediate use. Session disposal automatically cleans up associated MCPs. The API surface adds `addSessionScoped()` and `disposeSession()` to the MCP module, with a new REST endpoint for session-scoped loading. Event-driven tool refresh replaces the previous turn-boundary limitation.
yindo added the pull-request label 2026-02-16 18:15:44 -05:00
yindo closed this issue 2026-02-16 18:15:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10973