Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,9 @@ curl -fsSL https://agentkey.app/install.sh | bash -s -- --all-agents
# Only the skill, or only the MCP auth
curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-mcp
curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-skill

# Re-authenticate even if AgentKey is already configured locally
curl -fsSL https://agentkey.app/install.sh | bash -s -- --force-mcp
```

PowerShell equivalents: `-Yes`, `-ListAgents`, `-Only`, `-AllAgents`, `-SkipMcp`, `-SkipSkill`, `-ForceMcp`.
PowerShell equivalents: `-Yes`, `-ListAgents`, `-Only`, `-AllAgents`, `-SkipMcp`, `-SkipSkill`.

**Manual two-step install** (if you'd rather run the two underlying commands yourself, or the one-line installer can't reach your machine):

Expand Down
5 changes: 1 addition & 4 deletions docs/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,9 @@ curl -fsSL https://agentkey.app/install.sh | bash -s -- --all-agents
# 只装 Skill 或只做 MCP 授权
curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-mcp
curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-skill

# 即使本机已经配置过 AgentKey 也强制重新走一次授权
curl -fsSL https://agentkey.app/install.sh | bash -s -- --force-mcp
```

PowerShell 对应参数:`-Yes`、`-ListAgents`、`-Only`、`-AllAgents`、`-SkipMcp`、`-SkipSkill`、`-ForceMcp`
PowerShell 对应参数:`-Yes`、`-ListAgents`、`-Only`、`-AllAgents`、`-SkipMcp`、`-SkipSkill`。

**手动两步安装**(想自己跑两条底层命令,或一键脚本在你的环境里跑不起来):

Expand Down
28 changes: 4 additions & 24 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ param(
[switch]$ListAgents,
[switch]$Remote,
[switch]$Local,
[switch]$ForceMcp,
[switch]$SkipSkill,
[switch]$SkipMcp,
[switch]$NoTelemetry,
Expand Down Expand Up @@ -120,24 +119,6 @@ function Test-RemoteInstall {
return $false
}

# Cheap "is AgentKey already configured?" check across known MCP config files.
function Test-AlreadyAuthed {
$configs = @(
"$env:USERPROFILE\.claude.json",
"$env:USERPROFILE\.cursor\mcp.json",
"$env:APPDATA\Claude\claude_desktop_config.json"
)
foreach ($cfg in $configs) {
if (-not (Test-Path -LiteralPath $cfg)) { continue }
$content = Get-Content -Raw -LiteralPath $cfg -ErrorAction SilentlyContinue
if (-not $content) { continue }
if ($content -match '"agentkey"' -and $content -match '"AGENTKEY_API_KEY"\s*:\s*"ak_[A-Za-z0-9_-]+"') {
return $true
}
}
return $false
}

# ── Help ──────────────────────────────────────────────────────────────────
if ($Help) {
@'
Expand All @@ -158,7 +139,6 @@ Parameters:
SSH, in WinRM, in a container, or via OpenClaw / Claude Code
remote channels.
-Local Force local mode (auto-open browser) and bypass remote heuristics
-ForceMcp Re-run MCP auth even if AgentKey is already configured
-SkipSkill Skip the skill install step (only run MCP auth)
-SkipMcp Skip the MCP auth step (only install the skill)
-NoTelemetry Disable anonymous usage telemetry (writes
Expand Down Expand Up @@ -347,13 +327,13 @@ if (-not $SkipSkill) {
}

# ── 3. MCP authentication ────────────────────────────────────────────────
# Always run auth-login. The CLI itself decides whether the existing token
# can be reused or a fresh device-code flow is needed — the installer no
# longer second-guesses by sniffing config files (which produced false
# positives across the stdio → HTTP schema change).
if ($SkipMcp) {
Write-Step '3. Register the MCP server'
Write-Muted 'Skipped (-SkipMcp)'
} elseif ((Test-AlreadyAuthed) -and -not $ForceMcp) {
Write-Step '3. Register the MCP server'
Write-Ok 'AgentKey is already configured in an MCP client config — skipping auth.'
Write-Muted 'Re-run with -ForceMcp to authenticate again.'
} else {
$isRemote = Test-RemoteInstall
$authArgs = @('--auth-login')
Expand Down
29 changes: 4 additions & 25 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Options:
do NOT auto-open a local browser. Use this when running over
SSH, in Docker, or via OpenClaw / Claude Code remote channels.
--local Force local mode (auto-open browser) and bypass remote heuristics
--force-mcp Re-run MCP auth even if AgentKey is already configured
--skip-skill Skip the skill install step (only run MCP auth)
--skip-mcp Skip the MCP auth step (only install the skill)
--no-telemetry Disable anonymous usage telemetry (writes
Expand Down Expand Up @@ -193,24 +192,6 @@ detect_remote() {
return 1
}

# Cheap "is AgentKey already configured?" check across known MCP config files.
# Greps for an agentkey block + a non-empty AGENTKEY_API_KEY of the expected
# shape. Returns 0 if at least one config has both.
already_authed() {
local cfg
for cfg in "$HOME/.claude.json" \
"$HOME/.cursor/mcp.json" \
"$HOME/Library/Application Support/Claude/claude_desktop_config.json" \
"$HOME/.config/Claude/claude_desktop_config.json"; do
[ -f "$cfg" ] || continue
if grep -q '"agentkey"' "$cfg" 2>/dev/null \
&& grep -qE '"AGENTKEY_API_KEY"[^"]*"ak_[A-Za-z0-9_-]+"' "$cfg" 2>/dev/null; then
return 0
fi
done
return 1
}

install_node() {
local platform="$1"
ui_info "Installing Node.js v$NODE_MIN_MAJOR+ ..."
Expand Down Expand Up @@ -272,7 +253,6 @@ main() {
local PRINT_HELP=false
local LIST_AGENTS=false
local ALL_AGENTS=false
local FORCE_MCP=false
# FORCE_REMOTE / FORCE_LOCAL are read by detect_remote(). Declared as
# plain (non-`local`) so the helpers see them — they're dynamic-scope
# accessible either way in bash, but explicit assignment here keeps
Expand All @@ -295,7 +275,6 @@ main() {
--list-agents) LIST_AGENTS=true; shift ;;
--remote) FORCE_REMOTE=true; shift ;;
--local) FORCE_LOCAL=true; shift ;;
--force-mcp) FORCE_MCP=true; shift ;;
--skip-skill) SKIP_SKILL=true; shift ;;
--skip-mcp) SKIP_MCP=true; shift ;;
--no-telemetry) NO_TELEMETRY=true; shift ;;
Expand Down Expand Up @@ -481,13 +460,13 @@ main() {
fi

# ── 3. MCP authentication ────────────────────────────────────────────
# Always run auth-login. The CLI itself decides whether the existing
# token can be reused or a fresh device-code flow is needed — the
# installer no longer second-guesses by sniffing config files (which
# produced false positives across the stdio → HTTP schema change).
if $SKIP_MCP; then
ui_step "3. Register the MCP server"
ui_muted "Skipped (--skip-mcp)"
elif already_authed && ! $FORCE_MCP; then
ui_step "3. Register the MCP server"
ui_ok "AgentKey is already configured in an MCP client config — skipping auth."
ui_muted "Re-run with --force-mcp to authenticate again."
else
# Decide local-vs-remote and route the MCP CLI flags accordingly.
local IS_REMOTE=false
Expand Down
Loading