fix: forward RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE to spawned agent MCP config#583
Merged
Merged
Conversation
…wned agent MCP config PR #581 injected RELAY_API_KEY into the --mcp-config JSON for spawned agents, but RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE were still read via std::env::var inside relaycast_server_config. In "up" mode, the broker process does not have these vars in its own env — they only exist in worker_env passed to child processes. Thread workspaces_json and default_workspace explicitly through: - relaycast_server_config: new params replace std::env::var reads - merge_relaycast_with_project_mcp(_inner): pass-through params added - configure_relaycast_mcp_with_token: new params, callers updated - WorkerRegistry::spawn (PTY + Headless): extract from self.worker_env - Spawner::spawn_wrap_with_token: extract from env_vars Adds 5 new tests (63 total pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codex, OpenCode, and Gemini/Droid paths were reading RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE from std::env::var instead of using the function parameters. This broke workspace forwarding for agents spawned from the broker's 'up' mode where these vars only exist in worker_env. - Codex: use workspaces_json/default_workspace params - OpenCode: add params to ensure_opencode_config signature - Gemini/Droid: add params to gemini_droid_mcp_add_args and configure_gemini_droid_mcp signatures - Update all call sites and test fixtures All 505 tests pass.
…on_with_token Cursor path was missed in the initial fix — ensure_cursor_mcp_config and relaycast_mcp_config_json_with_token now accept and forward workspaces_json/default_workspace params. All CLI paths (Claude, Codex, OpenCode, Gemini, Droid, Cursor) consistently use function parameters instead of std::env::var.
- Add RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE to env var list - Document workspace variable forwarding rule: always use function params, never std::env::var() - Add table of all functions that accept workspace params - Add Cursor to CLI Provider Support Matrix
khaliqgant
added a commit
that referenced
this pull request
Mar 25, 2026
…wned agent MCP config (#583) * fix: forward RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE to spawned agent MCP config PR #581 injected RELAY_API_KEY into the --mcp-config JSON for spawned agents, but RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE were still read via std::env::var inside relaycast_server_config. In "up" mode, the broker process does not have these vars in its own env — they only exist in worker_env passed to child processes. Thread workspaces_json and default_workspace explicitly through: - relaycast_server_config: new params replace std::env::var reads - merge_relaycast_with_project_mcp(_inner): pass-through params added - configure_relaycast_mcp_with_token: new params, callers updated - WorkerRegistry::spawn (PTY + Headless): extract from self.worker_env - Spawner::spawn_wrap_with_token: extract from env_vars Adds 5 new tests (63 total pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: auto-format Rust code with cargo fmt * fix: use function params instead of std::env::var for workspace vars Codex, OpenCode, and Gemini/Droid paths were reading RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE from std::env::var instead of using the function parameters. This broke workspace forwarding for agents spawned from the broker's 'up' mode where these vars only exist in worker_env. - Codex: use workspaces_json/default_workspace params - OpenCode: add params to ensure_opencode_config signature - Gemini/Droid: add params to gemini_droid_mcp_add_args and configure_gemini_droid_mcp signatures - Update all call sites and test fixtures All 505 tests pass. * style: auto-format Rust code with cargo fmt * fix: thread workspace vars through Cursor and relaycast_mcp_config_json_with_token Cursor path was missed in the initial fix — ensure_cursor_mcp_config and relaycast_mcp_config_json_with_token now accept and forward workspaces_json/default_workspace params. All CLI paths (Claude, Codex, OpenCode, Gemini, Droid, Cursor) consistently use function parameters instead of std::env::var. * style: auto-format Rust code with cargo fmt * docs: update mcp-injection rule with workspace var forwarding pattern - Add RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE to env var list - Document workspace variable forwarding rule: always use function params, never std::env::var() - Add table of all functions that accept workspace params - Add Cursor to CLI Provider Support Matrix * fix: suppress clippy::too_many_arguments for workspace-forwarding functions --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.
Summary
RELAY_API_KEYmissing from spawned agent--mcp-configJSON, butRELAY_WORKSPACES_JSONandRELAY_DEFAULT_WORKSPACEwere still read viastd::env::varinsiderelaycast_server_configagent-relay upmode, the broker process does not have these vars in its own env — they only exist inworker_envpassed to child processes--mcp-configJSON was missing workspace context, so relaycast MCP tools couldn't resolve the correct workspaceChanges
Thread
workspaces_jsonanddefault_workspaceas explicit parameters through the MCP config building chain instead of reading fromstd::env::var:src/snippets.rs: New params onrelaycast_server_config,merge_relaycast_with_project_mcp(_inner), andconfigure_relaycast_mcp_with_token; publicconfigure_relaycast_mcpwrapper passesNone, Nonefor backward compatsrc/main.rs: BothWorkerRegistry::spawnpaths (PTY + Headless) now extractRELAY_WORKSPACES_JSON/RELAY_DEFAULT_WORKSPACEfromself.worker_envand pass them throughsrc/spawner.rs:spawn_wrap_with_tokennow extracts the same vars fromenv_varsand passes them throughTests
5 new tests added (63 total, all pass):
relaycast_server_config_includes_workspaces_json_when_providedrelaycast_server_config_includes_default_workspace_when_providedrelaycast_server_config_empty_workspace_vars_omittedmerge_relaycast_injects_workspace_varsconfigure_relaycast_mcp_with_token_passes_workspace_varsTest plan
cargo build— cleancargo test --lib -- snippets— 63 passed, 0 failedworkflows/fix-mcp-spawn.yamlDAG workflow (diagnose → implement → build-check → run-tests → review)🤖 Generated with Claude Code