Skip to content

fix(install): always run auth-login, drop stale already_authed check#50

Merged
lxcong merged 1 commit into
mainfrom
fix/install-drop-already-authed
May 15, 2026
Merged

fix(install): always run auth-login, drop stale already_authed check#50
lxcong merged 1 commit into
mainfrom
fix/install-drop-already-authed

Conversation

@lxcong
Copy link
Copy Markdown
Contributor

@lxcong lxcong commented May 15, 2026

Summary

The installer's "is AgentKey already configured?" heuristic went stale after #47 / v1.7.0 switched --auth-login from a stdio MCP block to a remote-HTTP one. The check still greps for \"AGENTKEY_API_KEY\": \"ak_...\" (the old env-shaped field) — but the new config writes \"Authorization\": \"Bearer ak_...\" inside headers instead.

Observed symptom: a user with a residual stdio config from an earlier release sees

✓ AgentKey is already configured in an MCP client config — skipping auth.

…the installer exits successfully, but calling any AgentKey MCP tool errors out because the stdio runtime @agentkey/mcp is no longer used.

The mirror failure also exists: users who have successfully re-authed into the new HTTP shape no longer match the regex and would get re-prompted on every installer run.

Fix

Delete the heuristic. @agentkey/cli --auth-login already knows whether the local token can be reused or a fresh device-code round-trip is needed — let the CLI decide instead of having the installer second-guess from on-disk shape.

Removed

  • `already_authed()` in `scripts/install.sh`
  • `Test-AlreadyAuthed` in `scripts/install.ps1`
  • `--force-mcp` / `-ForceMcp` flags (no longer meaningful — auth always runs unless `--skip-mcp`)
  • `--force-mcp` documentation in README.md / docs/README_zh.md

Net: -57 / +10 lines across the four files.

Test plan

  • On a machine with a stale stdio-shaped `~/.claude.json` from a pre-1.7 install: `curl -fsSL https://agentkey.app/install.sh | bash` now actually re-runs auth-login and the MCP block becomes a working HTTP entry
  • On a fresh machine: install still completes auth in one device-code flow (no behavior change)
  • On a machine already on the new HTTP shape: re-running the installer still works and the CLI either reuses the token or prompts (CLI's call, not the installer's)
  • `--skip-mcp` continues to skip the auth step
  • `bash -n scripts/install.sh` passes (verified)

🤖 Generated with Claude Code

The installer was sniffing config files for "agentkey" + an
"AGENTKEY_API_KEY": "ak_..." env-shaped pair to short-circuit MCP
auth. After --auth-login switched to writing a remote-HTTP MCP block
("Authorization": "Bearer ak_...") in #47 / 1.7.0, the check went
stale in both directions:

  - users still holding a stdio-shaped config from older releases
    matched the regex and were told "AgentKey is already configured
    in an MCP client config — skipping auth", but their MCP block no
    longer works because the stdio runtime is gone — calling the MCP
    tools post-install errors out
  - users who had successfully re-authed into the new HTTP shape no
    longer matched and got asked to re-auth on every installer run

The simplest fix is to delete the heuristic. `@agentkey/cli
--auth-login` is the source of truth for whether a fresh device-code
round-trip is needed; the installer should hand control to the CLI
instead of guessing from on-disk shape.

Removes:
  - already_authed() in install.sh, Test-AlreadyAuthed in install.ps1
  - --force-mcp / -ForceMcp flags (no longer meaningful)
  - "Re-authenticate even if AgentKey is already configured locally"
    documentation in README.md / docs/README_zh.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lxcong lxcong merged commit 658dfda into main May 15, 2026
1 check passed
@lxcong lxcong deleted the fix/install-drop-already-authed branch May 15, 2026 09:19
@lxcong lxcong mentioned this pull request May 15, 2026
lxcong added a commit that referenced this pull request May 15, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.7.1](v1.7.0...v1.7.1)
(2026-05-15)


### Bug Fixes

* **install:** always run auth-login, drop stale already_authed check
([#50](#50))
([658dfda](658dfda))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant