chore: remove unused check-mcp.sh diagnostic script (#63)

## What

Deletes `skills/agentkey/scripts/check-mcp.sh` (92 lines) and updates
every doc that referenced it. The script has shipped since the initial
public release but is **dead code** — nothing in the skill's runtime
ever invokes it.

## Why it's safe to remove (the receipts)

`check-mcp.sh` was never wired into the skill:

- **Never in SKILL.md, ever.** `git log -S check-mcp -- '*SKILL.md'`
returns no commits across all history — the script has never been
referenced by the skill's decision tree in any version.
- **Superseded by a native check.** The skill verifies MCP health by
calling the MCP `list_tools` endpoint directly (SKILL.md → "Status" /
Step 0.C), not a shell script. Its three status codes (`MCP_OK` /
`MCP_NO_KEY` / `MCP_NOT_CONFIGURED`) are consumed by nothing.
- **Not in any runtime path.** No reference in CI (`scripts-test.yml`),
the bats suite, `dev-smoke.sh`, `install.sh`/`install.ps1`, or
`uninstall.sh`/`uninstall.ps1`. The only mentions were prose:
SECURITY.md, the ClawScan note, the PR template, and directory-tree
comments.

(The companion `@agentkey/cli` is a separately-published npm package; it
*writes* MCP config and has no reason to invoke a diagnostic bundled
inside an already-installed skill.)

## What removing it buys

- **Drops the skill's only `python3` dependency.** `check-mcp.sh`
shelled out to `python3` to parse `~/.claude.json`; on a host without
python3 it silently returned a false `MCP_NO_KEY`. The surviving
`check-update.sh` is pure shell.
- **Shrinks the on-disk read footprint to zero.** Post-removal the skill
reads **no** agent config file and **no** `AGENTKEY_API_KEY` value from
disk — it only talks to the MCP transport. SECURITY.md's "Files the
skill reads or writes" table is updated to match.
- **Removes a security-scanner false-positive surface.** The
credential-read (`*_API_KEY*`) pattern in this script is precisely what
required a dedicated SECURITY.md carve-out *and* a `--clawscan-note`
item explaining "this is not credential exfiltration." Both are now
unnecessary and removed.

## Doc updates (no dangling references left)

- `SECURITY.md` — "two helper scripts" → "one"; removed the check-mcp.sh
bullet and the `*_API_KEY*` scanner note; fixed the file table (the
skill no longer reads `~/.claude.json` / `~/.env.local`;
`~/.claude.json` re-characterized as CLI-written so the
credential-handling reference stays accurate).
- `.github/workflows/release-please.yml` — dropped item (3) from the
ClawScan note.
- `.github/PULL_REQUEST_TEMPLATE.md` — removed the obsolete
"check-mcp.sh still works" checkbox.
- `README.md` / `docs/README_zh.md` / `.claude/CLAUDE.md` —
directory-tree comments.

`grep -rn check-mcp` now returns nothing.

## Verification

-  `bats tests/` — all 10 pass (they cover the untouched
`check-update.sh`).
-  `grep -rn
'check-mcp\|MCP_OK\|MCP_NO_KEY\|MCP_NOT_CONFIGURED\|env.local'` → zero
hits.
-  `release-please.yml` still parses as valid YAML.

## Why `chore:` and not `fix:`

Typed `chore:` deliberately so release-please does **not** cut a version
bump / GitHub Release for an internal cleanup — a release would push a
no-op plugin update to every user. No end-user runtime behavior changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
fullstackjam
2026-06-26 12:14:20 +08:00
committed by GitHub
parent 4d3f87b951
commit e7dbae688a
7 changed files with 10 additions and 104 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ agentkey/
├── .mcp.json # Auto-registers AgentKey MCP when installed as a plugin
├── skills/agentkey/
│ ├── SKILL.md # Decision tree + routing rules (end-user facing)
│ ├── scripts/ # check-mcp / check-update helpers
│ ├── scripts/ # check-update helper
│ └── version.txt # Managed by release-please only — must live inside the skill so it survives `npx skills add`
└── scripts/
└── uninstall.sh # End-user cleanup helper
-1
View File
@@ -27,7 +27,6 @@
**Any change:**
- [ ] No knowledge added to `SKILL.md` (routing logic only)
- [ ] Reference guides follow the standard structure (see `CONTRIBUTING.md`)
- [ ] `check-mcp.sh` still works if `.mcp.json` was touched
---
+1 -1
View File
@@ -89,4 +89,4 @@ jobs:
--slug agentkey \
--version "$VERSION" \
--changelog "$CHANGELOG" \
--clawscan-note "Expected behavior: this is an MCP-adapter skill. (1) SKILL.md routes the agent to the remote AgentKey HTTP MCP endpoint (https://api.agentkey.app/v1/mcp) for real-time data (web search, social, on-chain). (2) scripts/check-update.sh makes a read-only curl to the GitHub Releases API to notify when a newer skill version exists; it never modifies the install. (3) scripts/check-mcp.sh reads local agent config files (e.g. ~/.claude.json) and runs 'claude mcp list' to detect whether the MCP is registered and an API key is present. This is local config inspection and version checking, not credential exfiltration; the API key is user-provided and stays in standard local MCP config."
--clawscan-note "Expected behavior: this is an MCP-adapter skill. (1) SKILL.md routes the agent to the remote AgentKey HTTP MCP endpoint (https://api.agentkey.app/v1/mcp) for real-time data (web search, social, on-chain). (2) scripts/check-update.sh makes a read-only curl to the GitHub Releases API to notify when a newer skill version exists; it never modifies the install. This is version checking, not credential exfiltration; the API key is user-provided and stays in standard local MCP config."
+1 -1
View File
@@ -368,7 +368,7 @@ agentkey/
├── .mcp.json # Used when installed as a plugin
├── skills/agentkey/
│ ├── SKILL.md # Decision tree + routing rules
│ ├── scripts/ # check-mcp / check-update helpers
│ ├── scripts/ # check-update helper
│ └── version.txt # Managed by release-please
└── scripts/
├── install.sh # One-command installer (mac/linux)
+6 -7
View File
@@ -30,24 +30,24 @@ We follow coordinated disclosure. Once a fix is available, we publish a security
### What this skill does on your machine
The skill ships two helper scripts that the agent invokes:
The skill ships one helper script that the agent invokes:
- **`skills/agentkey/scripts/check-update.sh`** — **notify-only**. At most every 60 minutes (12 hours once an upgrade is known), it calls `https://api.github.com/repos/chainbase-labs/agentkey/releases/latest`, compares the tag against a version constant embedded in the script itself (synced at release time by release-please via `extra-files`), and prints `UPGRADE_AVAILABLE <old> <new>` if they differ. The script does **no** filesystem traversal — there is no `dirname`/`..` path resolution, no read of `version.txt`, no dependency on `CLAUDE_PLUGIN_ROOT`. It also honors a snooze file (`~/.config/agentkey/update-snoozed`, escalating 24h/48h/7d backoff) and a disable file (`~/.config/agentkey/update-disabled`); both are read-only from this script's perspective. The script never runs `git`, never writes to anything except its TMPDIR cache, and never executes downloaded code.
When the agent sees `UPGRADE_AVAILABLE` it surfaces an `AskUserQuestion` prompt (Yes / Always / Not now / Never). The actual update — `npx skills update agentkey` — runs only after the user picks "Yes" or "Always", or if the user has previously opted into auto-upgrade via `AGENTKEY_AUTO_UPGRADE=1` or `~/.config/agentkey/auto-upgrade`. The agent invokes that command via its own Bash tool, not via this script.
- **`skills/agentkey/scripts/check-mcp.sh`** — reads `~/.claude.json` and `~/.env.local` to verify the AgentKey MCP server is registered and the API key is present. **Read-only**; no network egress; output is a single status code.
The skill verifies MCP health by calling the MCP `list_tools` endpoint directly (see SKILL.md → "Status"); it does **not** read any agent config file or `AGENTKEY_API_KEY` value from disk.
### Files the skill reads or writes
| Path | Mode | Purpose |
|---|---|---|
| `~/.claude.json` | read | Detect MCP registration; read `AGENTKEY_API_KEY` env value |
| `~/.env.local` | read | Fallback location for `AGENTKEY_API_KEY` |
| `${TMPDIR}/agentkey-update-check` | read/write | Cache for the update check |
| `~/.config/agentkey/auto-upgrade` | written by the agent on user's "Always keep me up to date" choice; read by Step 0 to skip the prompt | Persistent auto-upgrade opt-in |
| `~/.config/agentkey/update-snoozed` | written by the agent on user's "Not now" choice; read by `check-update.sh` to suppress reminders | Snooze state (`<version> <level> <epoch>`) |
| `~/.config/agentkey/update-disabled` | written by the agent on user's "Never ask again" choice; read by `check-update.sh` to exit silently | Permanent disable for update checks |
| `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) / `%APPDATA%/Claude/...` (Windows) | written by the separate `npx -y @agentkey/cli --auth-login` command, **not** by the skill | MCP registration |
| `~/.claude.json` | written by `--auth-login` (`claude mcp add`), **not** by the skill | Claude Code MCP registration + `AGENTKEY_API_KEY` storage |
| `~/.cursor/mcp.json` | written by `--auth-login`, **not** by the skill | MCP registration |
### Network egress from the skill
@@ -71,9 +71,8 @@ The skill ships two helper scripts that the agent invokes:
## Scanner false-positive notes
Automated scanners (VirusTotal, ClawScan) may flag this skill as `Suspicious` due to two intentional patterns. We document them here so reviewers can verify intent:
Automated scanners (VirusTotal, ClawScan) may flag this skill as `Suspicious` due to one intentional pattern. We document it here so reviewers can verify intent:
1. **`check-update.sh` contacts GitHub.** Pattern may match "remote-controlled binary update" heuristics. **Why this is intentional:** the script is notify-only — it issues a single `GET https://api.github.com/repos/chainbase-labs/agentkey/releases/latest`, compares the tag against `skills/agentkey/version.txt`, prints a one-line status, and exits. It never writes anywhere except the cache file at `${TMPDIR}/agentkey-update-check`, never invokes `git`, and never executes downloaded code. Update execution lives entirely in the agent's interactive layer (`AskUserQuestion``npx skills update`), gated by explicit user consent or a previously persisted opt-in flag.
2. **`check-mcp.sh` reads `*API_KEY*` env values.** Pattern matches "credential harvesting" heuristics. **Why this is intentional:** the read is local-only, never transmitted, and exists purely to confirm `AGENTKEY_API_KEY` is configured before the agent attempts an MCP call. The script's only output is a one-word status code (`MCP_OK` / `MCP_NO_KEY` / `MCP_NOT_CONFIGURED`); the key value itself is discarded.
1. **`check-update.sh` contacts GitHub.** Pattern may match "remote-controlled binary update" heuristics. **Why this is intentional:** the script is notify-only — it issues a single `GET https://api.github.com/repos/chainbase-labs/agentkey/releases/latest`, compares the tag against a version constant embedded in the script itself, prints a one-line status, and exits. It never writes anywhere except the cache file at `${TMPDIR}/agentkey-update-check`, never invokes `git`, and never executes downloaded code. Update execution lives entirely in the agent's interactive layer (`AskUserQuestion``npx skills update`), gated by explicit user consent or a previously persisted opt-in flag.
If you operate a scanner and need additional context to triage, please email `support@chainbase.com`.
+1 -1
View File
@@ -368,7 +368,7 @@ agentkey/
├── .mcp.json # 作为插件安装时使用
├── skills/agentkey/
│ ├── SKILL.md # 决策树 & 路由规则
│ ├── scripts/ # check-mcp / check-update 辅助脚本
│ ├── scripts/ # check-update 辅助脚本
│ └── version.txt # 由 release-please 自动维护
└── scripts/
├── install.sh # 一键安装脚本mac/linux
-92
View File
@@ -1,92 +0,0 @@
#!/bin/bash
# AgentKey — Check MCP registration and API key status
#
# Output codes:
# MCP_OK — server registered and API key found
# MCP_NO_KEY — server registered but API key not found anywhere
# MCP_NOT_CONFIGURED — server not registered at all
set -e
# --- Helper: check all known key locations ---
check_key_exists() {
# 1. Check ~/.claude.json MCP env (set by `claude mcp add -e AGENTKEY_API_KEY=...`)
# This is the primary cross-platform storage — works on Mac, Linux, and Windows.
if [ -f "$HOME/.claude.json" ]; then
local key_val
key_val=$(python3 -c "
import json, os
try:
with open(os.path.expanduser('~/.claude.json')) as f:
d = json.load(f)
print(d.get('mcpServers', {}).get('agentkey', {}).get('env', {}).get('AGENTKEY_API_KEY', ''))
except Exception: pass
" 2>/dev/null | tr -d '[:space:]')
[ -n "$key_val" ] && return 0
fi
# 2. Check ~/.env.local (Mac/Linux fallback, written by setup-key.sh)
local env_file="$HOME/.env.local"
if [ -f "$env_file" ]; then
local key_val
key_val=$(grep "^AGENTKEY_API_KEY=" "$env_file" 2>/dev/null | head -1 | cut -d= -f2- | tr -d '"' | tr -d "'" | tr -d '[:space:]')
[ -n "$key_val" ] && return 0
fi
return 1
}
# --- Helper: check a JSON config file for agentkey MCP registration ---
check_json_registered() {
local file="$1"
[ -f "$file" ] || return 1
grep -q "mcpServers" "$file" 2>/dev/null || return 1
grep -q '"agentkey"' "$file" 2>/dev/null || return 1
return 0
}
# --- Helper: find claude CLI ---
find_claude() {
command -v claude 2>/dev/null && return 0
for p in "$HOME/.local/bin/claude" "/usr/local/bin/claude" \
"/opt/homebrew/bin/claude" "$HOME/.npm-global/bin/claude"; do
[ -x "$p" ] && echo "$p" && return 0
done
return 1
}
# ============================================================
# Step 1: Is agentkey registered anywhere?
# ============================================================
REGISTERED=0
# Check ~/.claude.json (user-scope via `claude mcp add --scope user`)
if check_json_registered "$HOME/.claude.json"; then
REGISTERED=1
fi
# Check project .mcp.json as fallback
if [ $REGISTERED -eq 0 ]; then
CLAUDE_BIN=$(find_claude 2>/dev/null || true)
if [ -n "$CLAUDE_BIN" ]; then
MCP_LIST=$("$CLAUDE_BIN" mcp list 2>/dev/null || true)
if echo "$MCP_LIST" | grep -q "agentkey"; then
REGISTERED=1
fi
fi
fi
if [ $REGISTERED -eq 0 ]; then
echo "MCP_NOT_CONFIGURED"
exit 1
fi
# ============================================================
# Step 2: Is the API key present anywhere?
# ============================================================
if check_key_exists; then
echo "MCP_OK"
exit 0
fi
echo "MCP_NO_KEY"
exit 1