refactor(mcp-server): migrate worker-URL env to AGENTKEYS_WORKER_{MEMORY,AUDIT}_URL#202
refactor(mcp-server): migrate worker-URL env to AGENTKEYS_WORKER_{MEMORY,AUDIT}_URL#202hanwencheng wants to merge 1 commit into
Conversation
|
Review verdict: rebase & salvage — the core rename is still valid, but the branch is stale. The premise still holds on Two staleness issues to fix before this can merge:
The reviewer note is still accurate: Recommended action: rebase, drop the runbook hunk, add the daemon rename, keep the accept-both fallback → mergeable. Keep this PR open. |
…_WORKER_{MEMORY,AUDIT}_URL
Salvage of PR #202, rebased onto current main:
- MCP server config.rs: clap env -> canonical AGENTKEYS_WORKER_{MEMORY,AUDIT}_URL
with accept-both fallback in from_cli (legacy bare names honored only when the
canonical var/flag is unset) for zero-downtime over un-redeployed mcp.env hosts.
- setup-mcp-host.sh + README: emit the canonical names.
- daemon main.rs: fold in the same memory-url rename (now matches its already-
canonical --config-url) with the legacy fallback at consumption.
- arch.md §5: add the AGENTKEYS_WORKER_<svc>_URL canonical-names row.
- Dropped the stale docs/plan/issue-107-mcp-demo-runbook.md hunk (file deleted by #207).
cargo check -p agentkeys-mcp-server -p agentkeys-daemon: clean. bash -n: ok.
5a684e5 to
bb1353b
Compare
|
Salvage pushed — this is now MERGEABLE (was CONFLICTING/DIRTY). Rebased onto current
Verification: Ready for review/merge. |
What & why
Terminology-drift follow-up (arch.md §5 "Canonical names"). The MCP server (
agentkeys-mcp-server) read its worker base-URLs from the bare env namesAGENTKEYS_MEMORY_URL/AGENTKEYS_AUDIT_URL, diverging from the canonicalAGENTKEYS_WORKER_<svc>_URLfamily thatscripts/operator-workstation.envalready defines (audit/cred/email/memory) and that the daemon's W3 work + the dev guide use. This renames the MCP server's family to the canonical spelling — memory and audit together, since they share the same drift.AGENTKEYS_BROKER_URLis intentionally untouched — the broker is not a worker, so the bare name is already canonical.Zero-downtime (accept-both fallback)
A deployed remote MCP host still carries the old bare names in
/etc/agentkeys/mcp.env(written by an oldersetup-mcp-host.sh) until its next redeploy. To avoid breaking it between the binary upgrade and that redeploy,config.rs::from_clinow accepts both: it reads the canonicalAGENTKEYS_WORKER_*var (clapenv, or the--memory-url/--audit-urlflag) first, then falls back to the legacy bare name viastd::env::var(...).ok()only when unset. The fallback drops out naturally once the nextsetup-mcp-host.shrun rewritesmcp.envwith the canonical names.(The daemon could hard-rename because nothing external sets its old name; the MCP server cannot, hence the fallback.)
Files
crates/agentkeys-mcp-server/src/config.rs— clapenvattrs (memory_url/audit_url) + thefrom_cliaccept-both fallback.crates/agentkeys-mcp-server/README.md— Docker-eflags.scripts/setup-mcp-host.sh— bothmcp.envheredocs (xiaozhi + self-hosted modes).docs/plan/issue-107-mcp-demo-runbook.md— the http-backend switch line + the §B.5 broker-URLs callout (with a short note that the binary accepts the legacy names during the upgrade window).docs/arch.md— new §5 canonical-names row marking the bare names retired-in-code-with-fallback for the MCP server.Verification
cargo check -p agentkeys-mcp-server→ exit 0, 0 warnings.bash -n scripts/setup-mcp-host.sh→ OK.bash scripts/lint-wiki.sh→ clean (no wiki page touched).envattrs remain and every residual bare-name reference is a deliberate fallback/legacy mention.Reviewer notes
AGENTKEYS_WORKER_MEMORY_URL", but onmain(crates/agentkeys-daemon/src/main.rs--memory-url) it still reads the bareAGENTKEYS_MEMORY_URL. Left as-is (out of scope); the new arch.md row records this honestly and flags the daemon hard-rename as a separate follow-up.Cargo.lockwas deliberately excluded.cargo checkmaterialized a pre-existing manifest/lockfile drift (agentkeys-daemon's dep list gainedagentkeys-provisioner); noCargo.tomlwas touched in this PR, so the unrelated lockfile delta was kept out of this focused diff. Worth a separatecargo update -p/lockfile-sync commit onmain.