feat(host-agent): add mcp-token CLI subcommand

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 15:21:32 +08:00
co-authored by Claude Opus 4.6
parent ce64c4eb47
commit 2d0c740c88
2 changed files with 31 additions and 0 deletions
+16
View File
@@ -146,3 +146,19 @@ def test_duplicate_instance_exits_with_clear_error(
err = capsys.readouterr().err
assert "another Host Agent instance" in err
assert str(lock_path) in err
def test_mcp_token_subcommand_prints_token(tmp_path, capsys, monkeypatch) -> None:
monkeypatch.setenv("HOST_AGENT_IDENTITY_PATH", str(tmp_path / "host_identity.json"))
monkeypatch.setenv("HOST_AGENT_LOCAL_ACCOUNT_PATH", str(tmp_path / "host_local_account.json"))
# Also set control plane URL to satisfy config loading
monkeypatch.setenv("HOST_AGENT_CONTROL_PLANE_URL", "https://cloud.example")
from host_agent.cli import main
main(["mcp-token"])
out = capsys.readouterr().out.strip()
assert len(out) >= 40 # token is ~43 chars
# Subsequent invocation prints the same token (idempotent).
main(["mcp-token"])
out2 = capsys.readouterr().out.strip()
assert out == out2