feat(cli): add agent-relay mcp-args subcommand#759
Conversation
|
Preview deployed!
This preview will be cleaned up when the PR is merged or closed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 099f01d492
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cmd.workspaces_json.as_deref(), | ||
| cmd.default_workspace.as_deref(), |
There was a problem hiding this comment.
Fall back to workspace env vars when flags are omitted
mcp-args currently forwards cmd.workspaces_json/cmd.default_workspace directly, so when those flags are omitted the call uses None even if RELAY_WORKSPACES_JSON and RELAY_DEFAULT_WORKSPACE are set in the environment. That diverges from the existing internal MCP wiring path (WorkerRegistry::build_mcp_args), which forwards those env values, and causes external env-driven callers to lose multi-workspace context in the generated MCP args. Add the same env fallback behavior here to preserve parity.
Useful? React with 👍 / 👎.
Match WorkerRegistry::build_mcp_args in the broker: when callers drive the subcommand via env (cloud's SandboxedStepExecutor exports these from orchestrator-managed secrets), RELAY_AGENT_TOKEN / RELAY_WORKSPACES_JSON / RELAY_DEFAULT_WORKSPACE must feed through even if not repeated on the CLI. Without this the authority delegation silently dropped per-worker identity in env-driven callers. Adds a test that sets the env vars, passes None for the equivalent flags, and asserts each sentinel value lands in the generated claude mcp config JSON. Addresses PR #759 Codex P2 review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
099f01d to
f2f43a2
Compare
|
Addressed review feedback + fixed the failing E2E. Codex P2 — env fallback for
Added E2E Integration Test failure — rebased onto current main The PR was branched from Local |
* feat(cli): add --register flag to mcp-args subcommand Composes RelaycastHttpClient::register_agent_token with configure_relaycast_mcp_with_token so external consumers (cloud's SandboxedStepExecutor) can mint an at_live_* token and build MCP args in a single exec, without reimplementing relaycast registration. Output JSON gains an optional agentToken field, populated only when --register is used. --register + --agent-token are mutually exclusive. Follow-up to #759. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(mcp-args): address PR #760 review findings - Validate local inputs (cwd + --existing-args JSON) BEFORE the --register call. A POST to /v1/agents/spawn rotates the agent's token on the relaycast backend, so we must not fire it when the request is going to fail locally anyway. (Codex P2) Adds register_does_not_hit_network_when_local_validation_fails: invalid --existing-args + --register asserts the mock spawn endpoint receives zero hits. - Serialize RELAY_* env-var tests behind a module-level Mutex and introduce an EnvGuard RAII helper that snapshots + restores env on drop. Previously register_without_api_key_returns_clear_error, register_without_base_url_returns_clear_error, register_happy_path_embeds_minted_token, and env_vars_fill_in_when_cli_flags_omitted mutated process-global env without serialization; under parallel #[tokio::test] execution they raced, and none of them restored prior values on panic. (Codex P2) - Correct the .trajectories/index.json entry so `path` points at the canonical /Users/khaliqgant/Projects/AgentWorkforce/relay location instead of the worktree directory, matching all other 522 entries. (Devin) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: MCP Register Flag Bot <agent@agent-relay.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Expose configure_relaycast_mcp_with_token as a CLI subcommand so external consumers (cloud SandboxedStepExecutor, debugging tools) can get identical MCP wiring without reimplementing it. Delegates to the existing Rust function — zero duplication. Includes parity test asserting subcommand output matches the broker internal build_mcp_args for the same inputs. Unblocks deletion of the TypeScript MCP branching AgentWorkforce/cloud#226 added. Generated by workflows/add-mcp-args-subcommand.ts (claude plan → codex implement → cargo-test-fix-rerun → claude review).