You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Expose session context to MCP servers via environment variables #15117
MCP servers spawned by OpenCode have no way to identify which session invoked a tool call. While #9292 and PR #9289 address this for the bash tool and prompt shell, MCP servers are spawned via StdioClientTransport in mcp/index.ts and do not receive session context.
This creates a gap for multi-session orchestration systems where:
Multiple OpenCode sessions run concurrently
A shared MCP server handles tool calls from all sessions
The MCP server needs to route responses or state back to the correct session
Without session identification, the MCP server cannot correlate tool calls to their originating session.
Use Case
An orchestration system manages multiple concurrent OpenCode sessions, each working on a different task. When a session calls an MCP tool (e.g., send_notification or log_progress), the MCP server needs to know which session made the call to route the output to the correct destination.
Currently, the only workaround is requiring the LLM to pass an identifier as a tool parameter, which is error-prone and adds cognitive load to the agent.
Proposed Solution
Expose session context to MCP servers, similar to PR #9289:
OPENCODE_SESSION_ID: The unique session identifier (e.g., ses_xyz123)
OPENCODE_SESSION_TITLE: The human-readable session title
Additional context
This would enable building robust multi-session orchestration systems on top of OpenCode where MCP servers can maintain session affinity for routing, logging, and state management.
Activity
github-actions commentedon Feb 25, 2026
This issue might be a duplicate of existing issues. Please check:
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.