fix(http): preserve workspace IDs across MCP sessions - #96
Open
aiforlove wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Share the HTTP server workspace registry across MCP sessions. An explicitly supplied workspace_id opened by one HTTP session can now be adopted by another session, while implicit selected-workspace state remains session-local. The regression smoke covers two descendant worktrees in parallel sessions.
Why
ChatGPT and other MCP clients can keep a workspace_id from an earlier tool call and send it through a later MCP session. Without this change, valid descendant repository or worktree IDs fail with Unknown workspace_id or fall back to a default root.
Root cause
Each Streamable HTTP initialize created a new CodexPro server and WorkspaceManager. The workspace map was therefore session-local, and the old fallback only recognized exact configured roots rather than descendants that had been opened previously.
Impact
Explicit workspace IDs are resolved through a process-lifetime registry and then adopted into the current session. Implicit selection is unchanged and remains isolated per session. The registry is intentionally in-memory; after a process restart, clients must call open_workspace again.
Security
This does not expand allowedRoots, authentication, or path permissions. The registry only records canonical roots already accepted by PathGuard, and explicit IDs still go through the existing validation. No credentials, tokens, local paths, or tunnel configuration are included.
Tests
Related to #91.