Skip to content
Back to search

agentkey

MarketplaceWorks with Claude CodeGitHub

One-stop live data marketplace for your agent: web search, web scraping, social media, finance, crypto, e-commerce, business data, weather/maps, and travel

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/chainbase-labs/agentkey with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/chainbase-labs/agentkey'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/chainbase-labs-agentkey/badge.svg)](/listings/chainbase-labs-agentkey)

HTML

<a href="/listings/chainbase-labs-agentkey"><img src="/api/listings/chainbase-labs-agentkey/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

One command. A browser tab opens for login, then you're done. The installer auto-detects every agent on your machine ([40+ supported](https://github.com/vercel-labs/skills#available-agents). Common examples include Claude Code, Codex, Gemini CLI, and Cursor CLI, etc.) and configures each one.

**macOS / Linux**

curl -fsSL https://agentkey.app/install.sh | bash

**Windows** (PowerShell)

irm https://agentkey.app/install.ps1 | iex

Restart your agent, then ask it something that needs the internet. A running DeepSeek Harness profile watches the home patch through HMR; stopped profiles load it on their next start.

> *"What has Musk been tweeting about lately?"*

That's it. No API key to copy, no JSON to edit.

<sub>Need to target specific agents or run in CI? → See the "Advanced install options" item in the [FAQ](#faq).</sub>

---

DeepSeek Harness (DSH)

The one-line installers above detect `${DSH_HOME:-~/.dsh}` or the `dsh` command automatically. They install the AgentKey skill globally at `~/.agents/skills/agentkey`, authenticate with AgentKey, and add one managed Loader block to DSH's home-level patch:

${DSH_HOME:-~/.dsh}/cordis.patch.yml

This is a **CLI-managed DSH MCP integration**, not a native installable DSH plugin. The home layer uses Loader id `agentkey`, module `@deepseek-ai/dsh-mcp-client`, and MCP `serverName: agentkey`; it is composed over current and future profiles. Tool allow/deny policy still controls whether a preset, session, or subagent can see the tools.

DSH 0.1.0-rc.7 does not provide an OAuth `authProvider` to its MCP SDK client. A header-free server entry cannot complete 401/RFC 9728 discovery or open a browser. DSH must use the device-code command below so the CLI writes a local Bearer key.

For a DSH-only manual install, run exactly these two steps:

npx -y skills add chainbase-labs/agentkey -g -a universal -s agentkey -y
npx -y @agentkey/cli --auth-login --only dsh

The CLI stores the real API key only in the single local home patch; no key belongs in Git. Re-running the command rotates the key and replaces the managed block. No existing profile is required. During migration it removes only top-level, column-1 AgentKey managed blocks from per-profile patches and renames a legacy `.agent-presets/agentkey` directory to a timestamped backup; the CLI prints that backup path. If it structurally detects an older unmarked AgentKey Loader row, it stops without changing any patch and asks you to remove that top-level `insert` child manually. Symlinked profile patches are inspected read-only: a clean symlink profile is allowed, while either legacy AgentKey form stops installation and reports the path for manual removal.

Only currently running profile processes observe the home-file change immediately through HMR. Stopped and future profiles load it when they start. If an old preset was already active in a session, close that session or restart DSH once after migration.

How to confirm DSH installation

1. Open **DSH → Settings → Plugins → Plugin list**, search for configured id `agentkey`, and expand the `mcp-client` row. DSH 0.1 currently renders: - Loader path: `include:agentkey` (the stable configured entry id is `agentkey`) - module title: `@deepseek-ai/dsh-mcp-client` (the card shortens it to `mcp-client`) - Cordis status: `Mounted` (the underlying fiber phase is `active`)

`Mounted`/`active` proves only that Cordis loaded the row. Because `failOnStartupError: false`, it does **not** prove that MCP authenticated or connected.

2. In the intended preset/session, confirm the three core tools are visible: - `mcp__agentkey__find_tools` - `mcp__agentkey__describe_tool` - `mcp__agentkey__execute_tool`

`list_tools` is deprecated and is not a readiness requirement. If a core tool is hidden only in one context, inspect that preset/session/subagent's tool policy.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 18 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "agentkey",
  3. "description": "One-stop live data marketplace for your agent: web search, web scraping, social media, finance, crypto, e-commerce, business data, weather/maps, and travel",
  4. "owner": {
  5. "name": "Chainbase Labs",
  6. "url": "https://agentkey.app"
  7. },
  8. "plugins": [
  9. {
  10. "name": "agentkey",
  11. "description": "AgentKey — one-stop live data marketplace for your agent: web search, web scraping, social media, finance, crypto, e-commerce, business data, weather/maps, and travel through a single MCP server. No API keys to manage, auto failover across providers, free to start.",
  12. "source": "./",
  13. "category": "data",
  14. "homepage": "https://github.com/chainbase-labs/agentkey",
  15. "tags": ["agentkey", "web-search", "scraping", "social-media", "finance", "crypto", "blockchain", "e-commerce", "business-data", "weather", "maps", "travel", "real-time-data"]
  16. }
  17. ]
  18. }
README.md · README · 531 lines · 11 findings marked

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. <p align="center">
  2. <img width="256" alt="AgentKey" src="https://github.com/user-attachments/assets/4c7c78a9-e5d8-45ce-9372-d5bffe8f61c5" />
  3. </p>
  4. <p align="center">
  5. <strong>One command. Full internet access for your AI agent.</strong>
  6. <br>
  7. Browse Twitter, search LinkedIn, scrape social media, read any webpage. Zero config. Just install and go.
  8. </p>
  9. <p align="center">
  10. <a href="#install">Install</a> ·
  11. <a href="#what-your-agent-can-now-do">Platforms</a> ·
  12. <a href="#faq">FAQ</a> ·
  13. <a href="docs/README_zh.md">中文</a>
  14. </p>
  15. <p align="center">
  16. <a href="https://agentkey.app"><img src="https://img.shields.io/badge/Website-agentkey.app-blue?style=for-the-badge" alt="Website" /></a>
  17. <a href="https://console.agentkey.app"><img src="https://img.shields.io/badge/Console-console.agentkey.app-7c3aed?style=for-the-badge" alt="Console" /></a>
  18. </p>
  19. <p align="center">
  20. <a href="https://www.producthunt.com/products/agentkey?embed=true&amp;utm_source=badge-top-post-badge&amp;utm_medium=badge&amp;utm_campaign=badge-agentkey" target="_blank" rel="noopener noreferrer"><img alt="AgentKey - One-stop live data marketplace for your agent | Product Hunt" width="250" height="54" src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=1192591&amp;theme=light&amp;period=daily&amp;t=1784013858323"></a>
  21. </p>
  22. ---
  23. **Install AgentKey. Give your AI superpowers.**
  24. AgentKey is the master key for the agent ecosystem. When using Claude, Manus, or other agents, you often need external data: social media, e-commerce, on-chain data, various APIs. That means hunting down API keys, managing subscriptions, or hitting dead ends.
  25. With AgentKey installed, your agent gains all these data capabilities automatically. No per-provider registrations, no juggling separate API bills. One subscription and go.
  26. > ⭐ Star this repo to get notified whenever we add new platform support or release updates.
  27. ---
  28. ## Use Cases
  29. | You ask your agent to... | Without AgentKey | With AgentKey |
  30. | ------------------------------------------------------ | ----------------------------- | ---------------------------------------------- |
  31. | 🐦 What has Musk been saying on Twitter lately? | Can't access, tweets blocked | Pulls all relevant tweets and summarizes them |
  32. | 📕 What do people think of this product on Instagram? | Blocked, login required | Scrapes real posts, organizes by sentiment |
  33. | 📺 What does this YouTube / Bilibili video cover? | Can't read, no subtitles | Reads the video/transcript, extracts key points |
  34. | 📖 Find Reddit threads about this pain point | 403 blocked | Finds relevant threads and extracts solutions |
  35. | 👔 Check this competitor / candidate's LinkedIn | 403, access issues | Opens the page, summarizes key info |
  36. | 🎵 What's trending on Douyin / TikTok right now? | Can't scrape the hot list | Pulls trending topics and tags |
  37. | 🌐 What does this webpage say? | Returns a wall of raw HTML | Extracts the content, explains it clearly |
  38. | 📦 What does this GitHub repo do? | Have to click through yourself | Reads README & Issues, one-line summary |
  39. | 🧾 What has this wallet / fund been buying lately? | Click through a block explorer | Summarizes recent transactions and positions |
  40. Before AgentKey: 10 tasks → 10 API keys → 10 separate bills.
  41. Your agent is half-capable at best, constantly needing human help to find data, juggling credentials, drowning in complexity.
  42. Now: one AgentKey handles everything. **AgentKey unifies all the external access your AI needs to do real work.**
  43. ---
  44. ## New here? Start on the web
  45. Before touching the terminal, you can get a feel for AgentKey directly in your browser — the website and console explain things more visually than this README can.
  46. - 🌐 **[agentkey.app](https://agentkey.app)** — Product overview, supported platforms, live demos, pricing details
  47. - 🎛️ **[console.agentkey.app](https://console.agentkey.app)** — Sign up, manage your subscription, manage your API key, track usage
  48. The one-line install below is what plugs AgentKey into your AI agent. If you only want to look around first, the two links above are the friendlier starting point.
  49. ---
  50. ## Install
  51. One command. A browser tab opens for login, then you're done. The installer auto-detects every agent on your machine ([40+ supported](https://github.com/vercel-labs/skills#available-agents). Common examples include Claude Code, Codex, Gemini CLI, and Cursor CLI, etc.) and configures each one.
  52. **macOS / Linux**
  53. ```bash
  54. curl -fsSL https://agentkey.app/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 78 on GitHub
  55. ```
  56. **Windows** (PowerShell)
  57. ```powershell
  58. irm https://agentkey.app/install.ps1 | iex
  59. ```
  60. Restart your agent, then ask it something that needs the internet. A running DeepSeek Harness profile watches the home patch through HMR; stopped profiles load it on their next start.
  61. > *"What has Musk been tweeting about lately?"*
  62. That's it. No API key to copy, no JSON to edit.
  63. <sub>Need to target specific agents or run in CI? → See the "Advanced install options" item in the [FAQ](#faq).</sub>
  64. ---
  65. ### DeepSeek Harness (DSH)
  66. The one-line installers above detect `${DSH_HOME:-~/.dsh}` or the `dsh` command automatically. They install the AgentKey skill globally at `~/.agents/skills/agentkey`, authenticate with AgentKey, and add one managed Loader block to DSH's home-level patch:
  67. ```text
  68. ${DSH_HOME:-~/.dsh}/cordis.patch.yml
  69. ```
  70. This is a **CLI-managed DSH MCP integration**, not a native installable DSH plugin. The home layer uses Loader id `agentkey`, module `@deepseek-ai/dsh-mcp-client`, and MCP `serverName: agentkey`; it is composed over current and future profiles. Tool allow/deny policy still controls whether a preset, session, or subagent can see the tools.
  71. DSH 0.1.0-rc.7 does not provide an OAuth `authProvider` to its MCP SDK client. A header-free server entry cannot complete 401/RFC 9728 discovery or open a browser. DSH must use the device-code command below so the CLI writes a local Bearer key.
  72. For a DSH-only manual install, run exactly these two steps:
  73. ```bash
  74. npx -y skills add chainbase-labs/agentkey -g -a universal -s agentkey -y
  75. npx -y @agentkey/cli --auth-login --only dsh
  76. ```
  77. The CLI stores the real API key only in the single local home patch; no key belongs in Git. Re-running the command rotates the key and replaces the managed block. No existing profile is required. During migration it removes only top-level, column-1 AgentKey managed blocks from per-profile patches and renames a legacy `.agent-presets/agentkey` directory to a timestamped backup; the CLI prints that backup path. If it structurally detects an older unmarked AgentKey Loader row, it stops without changing any patch and asks you to remove that top-level `insert` child manually. Symlinked profile patches are inspected read-only: a clean symlink profile is allowed, while either legacy AgentKey form stops installation and reports the path for manual removal.
  78. Only currently running profile processes observe the home-file change immediately through HMR. Stopped and future profiles load it when they start. If an old preset was already active in a session, close that session or restart DSH once after migration.
  79. #### How to confirm DSH installation
  80. 1. Open **DSH → Settings → Plugins → Plugin list**, search for configured id `agentkey`, and expand the `mcp-client` row. DSH 0.1 currently renders:
  81. - Loader path: `include:agentkey` (the stable configured entry id is `agentkey`)
  82. - module title: `@deepseek-ai/dsh-mcp-client` (the card shortens it to `mcp-client`)
  83. - Cordis status: `Mounted` (the underlying fiber phase is `active`)
  84. `Mounted`/`active` proves only that Cordis loaded the row. Because `failOnStartupError: false`, it does **not** prove that MCP authenticated or connected.
  85. 2. In the intended preset/session, confirm the three core tools are visible:
  86. - `mcp__agentkey__find_tools`
  87. - `mcp__agentkey__describe_tool`
  88. - `mcp__agentkey__execute_tool`
  89. `list_tools` is deprecated and is not a readiness requirement. If a core tool is hidden only in one context, inspect that preset/session/subagent's tool policy.
  90. 3. Ask: **“Please use AgentKey to search for today's latest AI news.”** Success requires an actual `find_tools` → `describe_tool` → `execute_tool` call, not merely a Mounted card.
  91. Troubleshooting:
  92. - **No `agentkey` row:** the home patch was not written or `DSH_HOME` points elsewhere. Re-run the DSH-only CLI command and inspect its reported path.
  93. - **Row exists but is not Mounted/active:** inspect the Loader error and verify `@deepseek-ai/dsh-mcp-client` exists in the DSH installation.
  94. - **Mounted but tools are missing:** inspect MCP connection logs, the local Authorization key, and the active tool policy. In `tools/list`, each tool's root `inputSchema.additionalProperties` must be absent or `true`, never `false`.
  95. - **401:** the local key is missing or invalid; rerun auth-login to rotate it.
  96. - **`serverName already in use`:** rerun the current CLI so it archives the legacy preset, then close sessions that still hold the old preset or restart DSH once.
  97. ---
  98. ## What your agent can now do
  99. AgentKey maintains cloud-side integrations across the open web — no extra accounts, no extra keys.
  100. | Capability | What it covers |
  101. | :--- | :--- |
  102. | **Web search** | Search engines, news, and real-time discovery across the open web |
  103. | **Web scraping** | Clean article extraction, structured data, and metadata from any URL |
  104. | **On-chain / Crypto** | Token prices, market data, on-chain activity, and project metadata |
  105. | **Social & content** | Public posts, videos, and discussions across major social and content platforms |
  106. | **Finance** | Stock & FX quotes, technical indicators, company financials, and earnings |
  107. | **E-commerce** | Product listings, prices, reviews, and best-sellers across major marketplaces |
  108. | **Business** | Company, funding, investor, and people data for market and competitive research |
  109. Underlying providers are routed automatically and grow over time — your agent can call `find_tools` to see what's currently available.
  110. **Planned:** Maps & Weather
  111. ---
  112. ## FAQ
  113. <details>
  114. <summary><b>Is it safe?</b></summary>
  115. Yes. AgentKey is a master key — one platform that unlocks external capabilities for your agent. By design, we have no access to your local files, your credentials, or your agent's conversations. The only data AgentKey collects is anonymous usage telemetry — which agent you installed into, your skill version, and upgrade outcomes — never your queries or responses. See "How do I opt out of telemetry?" below.
  116. </details>
  117. <details>
  118. <summary><b>How is this different from Claude / ChatGPT's built-in web access?</b></summary>
  119. Native web access in Claude and ChatGPT has limited platform coverage. It often can't reach Twitter, on-chain data, etc. AgentKey fills those gaps.
  120. </details>
  121. <details>
  122. <summary><b>How does pricing work? What if I use up my plan's credits?</b></summary>
  123. AgentKey is subscription-based. Each plan includes a monthly credit allowance; usage beyond that is billed pay-as-you-go as overage. You can upgrade your plan or manage billing anytime at [console.agentkey.app](https://console.agentkey.app). See [agentkey.app](https://agentkey.app) for current plans and pricing.
  124. </details>
  125. <details>
  126. <summary><b>How do I update?</b></summary>
  127. There are two pieces and they update differently:
  128. - **MCP server**: the real server is hosted at `https://api.agentkey.app/v1/mcp`, so it's always up to date — no local upgrade step. The `@agentkey/cli` package (run as `npx -y @agentkey/cli --auth-login`) only writes the remote-HTTP MCP config into each AI client and never has to be re-run unless you want to rotate your key.
  129. - **Skill files** (`SKILL.md` + helpers): how this updates depends on your client.
  130. ### Claude Code
  131. Updates are automatic. On the first call of a session the skill runs a silent version check; if a new release is available it prompts you to upgrade and (with your consent) runs `npx skills update -g agentkey`.
  132. ### Claude Desktop, Cursor, and other clients without an inline Bash tool
  133. The skill cannot run the inline check itself, but starting in v1.4.0 the **MCP server publishes the latest skill version via a dedicated metadata tool (`agentkey_skill_meta`)**. Your agent calls it once per session, compares against this skill's own version, and prompts you to upgrade with the exact command for your client. See [protocol/skill-meta-v1.md](./protocol/skill-meta-v1.md) for the protocol details.
  134. **One-time bootstrap on Desktop:** if you're stuck on a pre-1.4.0 skill in Claude Desktop, the metadata tool exists but your skill rule doesn't know how to read it. Bring yourself current once with:
  135. ```bash
  136. # Replace <UUID1>/<UUID2> with the actual session folder under skills-plugin
  137. # (usually there's just one; pick the one that contains skills/agentkey/SKILL.md)
  138. DESKTOP_BASE="$HOME/Library/Application Support/Claude/local-agent-mode-sessions/skills-plugin"
  139. LATEST_REPO_ZIP=$(mktemp -d)/agentkey.tar.gz
  140. curl -fsSL https://github.com/chainbase-labs/agentkey/archive/refs/heads/main.tar.gz -o "$LATEST_REPO_ZIP"
  141. tar -xzf "$LATEST_REPO_ZIP" -C "$(dirname "$LATEST_REPO_ZIP")"
  142. find "$DESKTOP_BASE" -type d -path "*/skills/agentkey" 2>/dev/null | while read -r dst; do
  143. cp -R "$(dirname "$LATEST_REPO_ZIP")"/agentkey-main/skills/agentkey/. "$dst/"
  144. done
  145. # Then fully quit and restart Claude Desktop.
  146. ```
  147. After this one bootstrap, future versions will be discovered automatically via the metadata tool.
  148. ### Force manual update (any client)
  149. ```bash
  150. # Refresh the skill content
  151. npx skills update agentkey
  152. # Pin a specific version
  153. npx skills add chainbase-labs/agentkey@v1.0.0
  154. ```
  155. Note: `npx skills update` writes to `~/.agents/skills/agentkey` and `~/.claude/skills/agentkey`, which is where Claude Code reads from. **Claude Desktop reads from its own sandbox path** and is not touched by `npx skills update` — use the Desktop bootstrap command above for Desktop.
  156. Re-run `npx -y @agentkey/cli --auth-login` only when you want to rotate your API key.
  157. </details>
  158. <details>
  159. <summary><b>How do I uninstall?</b></summary>
  160. One command, cleans every agent and config file.
  161. **macOS / Linux**
  162. ```bash
  163. curl -fsSL https://agentkey.app/uninstall.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 247 on GitHub
  164. ```
  165. **Windows** (PowerShell)
  166. ```powershell
  167. irm https://agentkey.app/uninstall.ps1 | iex
  168. ```
  169. Removes the skill from every agent, strips the `agentkey` MCP entry + API key from all MCP client configs, and clears caches/logs. Pass `--keep-marketplace` (bash) / `-KeepMarketplace` (PowerShell) to retain the Claude Code plugin marketplace entry.
  170. **Prefer manual two-step?**
  171. ```bash
  172. # 1. Remove the skill from every agent
  173. npx skills remove chainbase-labs/agentkey
  174. # 2. Delete the "agentkey" entry under mcpServers in each MCP client config:
  175. # - Claude Code: ~/.claude.json
  176. # - Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
  177. # %APPDATA%\Claude\claude_desktop_config.json (Windows)
  178. # - Cursor: ~/.cursor/mcp.json
  179. ```
  180. The one-command uninstaller additionally cleans npm/npx caches, legacy shell rc entries, CLAUDE.md sections, and MCP stdio logs — use that if you want a fully clean slate.
  181. </details>
  182. <details>
  183. <summary><b>How do I opt out of telemetry?</b></summary>
  184. AgentKey sends anonymous usage telemetry (which agent you use, skill version, upgrade outcomes — never queries or responses). Three ways to opt out, any of them works:
  185. ```bash
  186. # Persistent opt-out (recommended)
  187. touch ~/.config/agentkey/telemetry-disabled
  188. # One-shot env override (CI / single session)
  189. AGENTKEY_TELEMETRY=0 <your command>
  190. # At install time
  191. curl -fsSL https://agentkey.app/install.sh | bash -s -- --no-telemetry
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 287 on GitHub
  192. ```
  193. To re-enable, delete `~/.config/agentkey/telemetry-disabled`.
  194. </details>
  195. <details>
  196. <summary><b>Something's not working — how do I check?</b></summary>
  197. Inside your agent, try `/agentkey status` — it diagnoses your MCP config, version, and connectivity.
  198. Available slash commands:
  199. | Command | What it does |
  200. |---------|--------------|
  201. | `/agentkey` | Auto-triggered during data queries — you usually don't call it manually |
  202. | `/agentkey setup` | First-time setup: configure API key + verify MCP connectivity |
  203. | `/agentkey status` | Diagnose current config (MCP, version, connectivity test) |
  204. Still stuck? See the "Where do I get help" item below.
  205. </details>
  206. <details>
  207. <summary><b>Advanced install options (CI / specific agents / manual two-step)</b></summary>
  208. The installer auto-detects which AI agents you have on this machine (by probing well-known config dirs and binaries from the [vercel-labs/skills supported-agents list](https://github.com/vercel-labs/skills)) and pre-selects them — no multi-select prompt. Override with the flags below.
  209. **Installer flags:**
  210. ```bash
  211. # Non-interactive (CI / unattended): install to every detected agent, no prompts
  212. curl -fsSL https://agentkey.app/install.sh | bash -s -- --yes
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 320 on GitHub
  213. # See which agents the installer would auto-select on this host (and exit)
  214. curl -fsSL https://agentkey.app/install.sh | bash -s -- --list-agents
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 323 on GitHub
  215. # Only install the skill for specific agents (overrides auto-detection)
  216. curl -fsSL https://agentkey.app/install.sh | bash -s -- --only claude-code,cursor
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 326 on GitHub
  217. # Skip our agent detection; let `skills` CLI install for every agent it finds
  218. curl -fsSL https://agentkey.app/install.sh | bash -s -- --all-agents
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 329 on GitHub
  219. # Only the skill, or only the MCP auth
  220. curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-mcp
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 332 on GitHub
  221. curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-skill
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 333 on GitHub
  222. ```
  223. PowerShell equivalents: `-Yes`, `-ListAgents`, `-Only`, `-AllAgents`, `-SkipMcp`, `-SkipSkill`.
  224. **Manual two-step install** (if you'd rather run the two underlying commands yourself, or the one-line installer can't reach your machine):
  225. ```bash
  226. # 1. Install the skill into every detected agent
  227. npx skills add chainbase-labs/agentkey
  228. # 2. Authenticate and register the MCP server
  229. npx -y @agentkey/cli --auth-login
  230. ```
  231. **Headless / SSH / Docker?** The auth step always tries to open a browser **and** prints the URL — so on a machine without a usable display, just copy the printed URL to any device with a browser to finish auth. Prefer typing the key manually? `npx -y @agentkey/cli --setup` opens an interactive wizard instead.
  232. </details>
  233. <details>
  234. <summary><b>My agent isn't on the auto-configured list — how do I set it up manually?</b></summary>
  235. The CLI supports the clients shown in its current **Supported agents** list, and the one-line installer targets the supported clients it detects — including **DeepSeek Harness**. If your client is not detected or supported for automatic configuration, the skill can still be installed globally, but you must paste this MCP snippet into that client's own config (path varies per client):
  236. ```json
  237. {
  238. "mcpServers": {
  239. "agentkey": {
  240. "type": "http",
  241. "url": "https://api.agentkey.app/v1/mcp",
  242. "headers": { "Authorization": "Bearer ak_..." }
  243. }
  244. }
  245. }
  246. ```
  247. Then restart the agent. The skill's first-run activation will also walk you through this.
  248. </details>
  249. <details>
  250. <summary><b>Can I self-host or develop against this?</b></summary>
  251. **Install from a local checkout:**
  252. ```bash
  253. git clone https://github.com/chainbase-labs/agentkey.git
  254. cd agentkey
  255. # 1. Install your working tree into every detected agent
  256. npx skills add .
  257. # 2. Register the MCP server (if you haven't already)
  258. npx -y @agentkey/cli --auth-login
  259. ```
  260. `npx skills add .` accepts a local path (or a `file://` URL) — run it again after each edit to `skills/agentkey/SKILL.md`. The MCP step only needs to run once per machine.
  261. **Iterating on the MCP server itself?** The server lives at `AgentKey-Server/` (Go) and exposes the MCP endpoint at `/v1/mcp`. Run a local server (`make run`) and point your MCP config at `http://localhost:8081/v1/mcp` to test changes end-to-end.
  262. **Claude Code plugin mode** — install straight from the marketplace. The plugin bundles a header-free remote HTTP entry and uses Claude Code's native MCP OAuth flow, so there is **no API key to paste and no second `@agentkey/cli` step**:
  263. ```bash
  264. # Public install
  265. claude plugin marketplace add chainbase-labs/agentkey
  266. claude plugin install agentkey@agentkey
  267. # …or from a local checkout, for development
  268. claude plugin marketplace add /absolute/path/to/agentkey
  269. claude plugin install agentkey@agentkey
  270. ```
  271. After installation, run `/reload-plugins`, open `/mcp`, select the AgentKey entry, and choose **Authenticate** to complete browser sign-in. From a terminal, `claude mcp login plugin:agentkey:agentkey` starts the same OAuth flow. The plugin's `.mcp.json` intentionally has no `Authorization` header: adding one makes Claude Code treat the server as header-authenticated and suppresses OAuth fallback after a 401. Reload a local checkout with `claude plugin update agentkey` after edits. Day-to-day Skill iteration is still fastest via the Skills CLI path; the plugin path is the OAuth-based option for Claude Code users.
  272. **Codex plugin mode** — install from the marketplace bundled in this repo. Auth is OAuth (browser sign-in on install), so there's **no API key to paste and no second `@agentkey/cli` step**:
  273. ```bash
  274. # Public install
  275. codex plugin marketplace add chainbase-labs/agentkey
  276. # then run /plugins inside Codex and install AgentKey,
  277. # or: codex plugin install agentkey@agentkey
  278. ```
  279. The plugin manifest lives in `.codex-plugin/plugin.json`; it bundles the same skill plus a remote-HTTP MCP entry (`.codex-plugin/mcp.json`) that authenticates against `https://api.agentkey.app/v1/mcp` via MCP OAuth (RFC 9728 discovery). Sign in with your AgentKey account when Codex prompts you.
  280. **Kimi Code plugin mode** — install the repo directly from Kimi Code. The manifest bundles the skill and an inline remote-HTTP MCP entry at the client-attributed `https://api.agentkey.app/kimi/v1/mcp` route, so there is **no API key to paste and no second `@agentkey/cli` step**:
  281. ```text
  282. # Public install
  283. /plugins install https://github.com/chainbase-labs/agentkey
  284. # Or install a local checkout for development
  285. /plugins install /absolute/path/to/agentkey
  286. ```
  287. Kimi shows `Run /new or /reload to apply plugin changes.` after installation. Run `/reload`; when Kimi reports that the plugin MCP server needs OAuth, run `/mcp-config login plugin-agentkey:agentkey` and approve the browser authorization. You can then ask your original AgentKey question.
  288. Kimi copies local plugins into its managed plugin directory. Re-run `/plugins install /absolute/path/to/agentkey` after editing the checkout, then run `/reload` again.
  289. If you previously worked around an older AgentKey plugin by adding a user-global `agentkey` entry through `/mcp-config`, remove that old entry once with `/mcp-config remove agentkey` before reloading. The plugin now owns its namespaced MCP entry; keeping both would create duplicate tools and authentication attempts.
  290. **Cursor plugin mode** — install AgentKey from the Cursor Marketplace after the listing is published. The Cursor-native manifest at `.cursor-plugin/plugin.json` bundles the same Skill and an inline remote-HTTP MCP entry, so there is **no API key to paste and no second `@agentkey/cli` step**. When Cursor prompts for MCP authentication, approve the AgentKey browser sign-in.
  291. For maintainers, push the plugin to a public Git repository and submit the repository URL at [cursor.com/marketplace/publish](https://cursor.com/marketplace/publish). Before submitting, test the plugin in the current Cursor release and confirm that both the `agentkey` Skill and MCP server load successfully after OAuth. The manifest follows the [Cursor plugin reference](https://cursor.com/docs/reference/plugins); keep its component paths relative to the plugin root.
  292. **Gemini CLI extension mode** — install the repository as an extension. The root `gemini-extension.json` bundles the existing AgentKey skill and the remote Streamable HTTP MCP server, so there is **no API key to paste and no second `@agentkey/cli` step**:
  293. ```bash
  294. # Public install
  295. gemini extensions install https://github.com/chainbase-labs/agentkey
  296. # Or link a local checkout for development
  297. gemini extensions link /absolute/path/to/agentkey
  298. ```
  299. Restart Gemini CLI after installing or linking. On the first connection, the extension's `oauth.enabled` setting asks Gemini to start its native browser authorization automatically. Complete that flow, then run `/mcp reload` and `/mcp list` to confirm that `agentkey` is connected. If Gemini only reports that authentication is required, or the browser flow was closed, run `/mcp auth agentkey` to start it manually. Gemini stores and refreshes the OAuth tokens, so this is normally a one-time sign-in. Do not add a second user-level MCP entry or run `@agentkey/cli --auth-login` in extension mode.
  300. If Gemini reports that `~/.agents/skills/agentkey` overrides the copy bundled by the extension, that is a separate Skill-precedence warning rather than an OAuth failure. A previously installed user Skill has higher priority and can safely remain when it is the same version—especially if other agents use that shared directory. Remove it with `gemini skills uninstall agentkey --scope user` only when it is no longer needed elsewhere, then run `/skills reload`.
  301. **Antigravity 2.0 / Antigravity CLI plugin mode** — both runtimes use the root `plugin.json`, `mcp_config.json`, and existing `skills/` directory. The MCP entry uses Antigravity's `serverUrl` schema and automatic OAuth discovery through dynamic client registration, so there is **no API key to paste, no OAuth client secret to configure, and no second `@agentkey/cli` step**.
  302. For Antigravity 2.0, place the repository at workspace scope or global scope, then restart Antigravity:
  303. ```bash
  304. # Workspace scope
  305. git clone https://github.com/chainbase-labs/agentkey.git /path/to/workspace/.agents/plugins/agentkey
  306. # Or global scope
  307. git clone https://github.com/chainbase-labs/agentkey.git ~/.gemini/config/plugins/agentkey
  308. ```
  309. For Antigravity CLI, install a local checkout and verify it is registered:
  310. ```bash
  311. agy plugin install /absolute/path/to/agentkey
  312. agy plugin list
  313. ```
  314. After Antigravity discovers the plugin, authenticate its bundled MCP entry rather than adding a duplicate:
  315. - **Antigravity 2.0:** open **Settings → Customizations → Installed MCP Servers**, click **Authenticate** next to AgentKey, complete the browser flow, copy the authorization code back into the settings panel, and submit it. The server reconnects automatically; click **Refresh** if the status does not update.
  316. - **Antigravity CLI:** open `/mcp`, select `agentkey`, choose **Authenticate**, and follow the browser/code prompts. Reload the server in the same panel and confirm the AgentKey tools are listed; inspect its connection logs there if it remains disconnected.
  317. Keep `mcp_config.json` free of static headers, access tokens, and OAuth client credentials. AgentKey publishes protected-resource and authorization-server metadata, including a dynamic registration endpoint, for both Antigravity runtimes to discover.
  318. **Repo layout:**
  319. ```
  320. agentkey/
  321. ├── .claude-plugin/plugin.json # Claude Code plugin manifest
  322. ├── .codex-plugin/
  323. │ ├── plugin.json # Codex plugin manifest
  324. │ └── mcp.json # Codex MCP entry (OAuth, no user_config)
  325. ├── .cursor-plugin/
  326. │ └── plugin.json # Cursor manifest with Skill + inline MCP OAuth
  327. ├── .kimi-plugin/
  328. │ └── plugin.json # Kimi manifest with inline MCP OAuth entry
  329. ├── .agents/plugins/marketplace.json # Codex marketplace (this repo is its own marketplace)
  330. ├── .mcp.json # Claude plugin MCP entry (OAuth discovery, no headers)
  331. ├── gemini-extension.json # Gemini CLI extension manifest (MCP OAuth + skills)
  332. ├── plugin.json # Antigravity desktop/CLI plugin manifest
  333. ├── mcp_config.json # Antigravity remote MCP entry (serverUrl + OAuth)
  334. ├── skills/agentkey/
  335. │ ├── SKILL.md # Decision tree + routing rules
  336. │ ├── scripts/ # check-update helper
  337. │ └── version.txt # Managed by release-please
  338. └── scripts/
  339. ├── build-release-assets.sh # Build Skill + Gemini GitHub Release assets
  340. ├── install.sh # One-command installer (mac/linux)
  341. ├── install.ps1 # Windows PowerShell installer
  342. ├── uninstall.sh # One-command uninstaller (mac/linux)
  343. └── uninstall.ps1 # Windows PowerShell uninstaller
  344. ```
  345. **Release a new version (maintainers):** releases are cut automatically by [release-please](https://github.com/googleapis/release-please). Merging a PR with a `feat:` or `fix:` title opens a Release PR that bumps `skills/agentkey/version.txt`, all four versioned plugin manifests, `gemini-extension.json`, and `CHANGELOG.md`. The Antigravity schema has no `version` field, so its root `plugin.json` is not part of version syncing. Merging the Release PR creates the tag + GitHub Release, preserves the `agentkey.skill` asset, and uploads platform-named Gemini extension archives whose roots contain `gemini-extension.json`.
  346. </details>
  347. <details>
  348. <summary><b>What stage is the product at?</b></summary>
  349. Early access. There are rough edges and we appreciate your patience. Feature requests and bug reports are welcome via [GitHub Issues](https://github.com/chainbase-labs/agentkey/issues) or Telegram (see below).
  350. </details>
  351. <details>
  352. <summary><b>Where do I get help / report bugs / follow updates?</b></summary>
  353. - **Telegram:** [t.me/AgentKey_Official](https://t.me/AgentKey_Official) — general questions, support, feature requests
  354. - **Bug reports:** [GitHub Issues](https://github.com/chainbase-labs/agentkey/issues)
  355. - **Release announcements:** ⭐ star this repo to get notified
  356. </details>
  357. ---
  358. ## Star History
  359. [![Star History Chart](https://api.star-history.com/chart?repos=chainbase-labs/agentkey&type=date&legend=top-left&sealed_token=ZnduG_kCABo_uyUn3A-CRWKj9wC9AMGIDCpvu5PSfSvwKtE9Ab_5PEJNjQoQafwEYOlWr4Ioq_n7wC8vNwlwRMQ-BIz0VmBMNZq0aY-KYlH9S2i_29q9fw)](https://www.star-history.com/?repos=chainbase-labs%2Fagentkey&type=date&legend=top-left)
scripts/install.ps1 · Bundled script · 441 lines · 4 findings marked
  1. #Requires -Version 5.1
  2. <#
  3. .SYNOPSIS
  4. AgentKey installer for Windows
  5. .DESCRIPTION
  6. Usage:
  7. irm https://agentkey.app/install.ps1 | iex
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 7 on GitHub
  8. & ([scriptblock]::Create((irm https://agentkey.app/install.ps1))) -Yes
  9. & ([scriptblock]::Create((irm https://agentkey.app/install.ps1))) -Only "claude-code,cursor"
  10. & ([scriptblock]::Create((irm https://agentkey.app/install.ps1))) -NoTelemetry
  11. Behavior mirrors install.sh: checks Node >= 18 (installs via winget/scoop/choco),
  12. auto-detects which AI agents are installed and runs `npx skills add` for them,
  13. then `npx @agentkey/cli --auth-login` for device auth. The auth step always
  14. tries to open a local browser AND prints the URL so headless / SSH users can
  15. copy it elsewhere. MCP config is written automatically for Claude Code /
  16. Claude Desktop / Cursor.
  17. #>
  18. [CmdletBinding()]
  19. param(
  20. [switch]$Yes,
  21. [switch]$Interactive,
  22. [string]$Only,
  23. [switch]$AllAgents,
  24. [switch]$ListAgents,
  25. [switch]$SkipSkill,
  26. [switch]$SkipMcp,
  27. [switch]$NoTelemetry,
  28. [switch]$Help
  29. )
  30. $ErrorActionPreference = 'Stop'
  31. $SkillRepo = 'chainbase-labs/agentkey'
  32. $CliPackage = '@agentkey/cli'
  33. $NodeMinMajor = 18
  34. # ── Agent markers (mirror of install.sh) ──────────────────────────────────
  35. # Subset of vercel-labs/skills' 45 supported agent IDs that have reliable
  36. # Windows-side markers. Sync source:
  37. # https://github.com/vercel-labs/skills (Supported Agents table).
  38. #
  39. # IMPORTANT: ids here MUST match the `--only` ids accepted by both
  40. # `npx skills add -a` and `npx -y @agentkey/cli --auth-login --only`.
  41. # `claude-desktop` and `dsh` are exceptions. Neither is passed to
  42. # `skills add -a`; DSH reads the global skill installed for `universal`.
  43. $DshHome = if ([string]::IsNullOrWhiteSpace($env:DSH_HOME)) { Join-Path ([Environment]::GetFolderPath('UserProfile')) '.dsh' } else { $env:DSH_HOME }
  44. if ($DshHome -eq '~') {
  45. $DshHome = [Environment]::GetFolderPath('UserProfile')
  46. } elseif ($DshHome -match '^~[\\/]') {
  47. $DshHome = Join-Path ([Environment]::GetFolderPath('UserProfile')) $DshHome.Substring(2)
  48. }
  49. $DshHome = [System.IO.Path]::GetFullPath($DshHome)
  50. $AgentMarkers = @(
  51. @{ Id = 'claude-code'; Markers = @("path:$env:USERPROFILE\.claude.json", 'cmd:claude') }
  52. @{ Id = 'claude-desktop'; Markers = @("path:$env:LOCALAPPDATA\AnthropicClaude", "path:$env:APPDATA\Claude\claude_desktop_config.json", "path:$env:APPDATA\Claude") }
  53. @{ Id = 'cursor'; Markers = @("path:$env:USERPROFILE\.cursor", 'cmd:cursor', "path:$env:LOCALAPPDATA\Programs\cursor") }
  54. @{ Id = 'codex'; Markers = @("path:$env:USERPROFILE\.codex", 'cmd:codex') }
  55. @{ Id = 'dsh'; Markers = @("path:$DshHome", 'cmd:dsh') }
  56. @{ Id = 'gemini-cli'; Markers = @("path:$env:USERPROFILE\.gemini", 'cmd:gemini') }
  57. @{ Id = 'opencode'; Markers = @("path:$env:APPDATA\opencode", "path:$env:USERPROFILE\.opencode", 'cmd:opencode') }
  58. @{ Id = 'openclaw'; Markers = @("path:$env:USERPROFILE\.openclaw", 'cmd:openclaw') }
  59. @{ Id = 'qwen-code'; Markers = @("path:$env:USERPROFILE\.qwen", 'cmd:qwen') }
  60. @{ Id = 'iflow-cli'; Markers = @("path:$env:USERPROFILE\.iflow", 'cmd:iflow') }
  61. @{ Id = 'windsurf'; Markers = @("path:$env:USERPROFILE\.codeium\windsurf", "path:$env:USERPROFILE\.windsurf", 'cmd:windsurf') }
  62. @{ Id = 'warp'; Markers = @("path:$env:USERPROFILE\.warp") }
  63. @{ Id = 'amp'; Markers = @("path:$env:APPDATA\amp", 'cmd:amp') }
  64. @{ Id = 'crush'; Markers = @("path:$env:APPDATA\crush", 'cmd:crush') }
  65. @{ Id = 'goose'; Markers = @("path:$env:APPDATA\goose", 'cmd:goose') }
  66. @{ Id = 'droid'; Markers = @('cmd:droid') }
  67. @{ Id = 'kode'; Markers = @('cmd:kode') }
  68. @{ Id = 'kilo'; Markers = @('cmd:kilo') }
  69. @{ Id = 'kimi-cli'; Markers = @("path:$env:USERPROFILE\.kimi", 'cmd:kimi') }
  70. @{ Id = 'kiro-cli'; Markers = @("path:$env:USERPROFILE\.kiro", 'cmd:kiro') }
  71. )
  72. # Agent ids excluded from per-agent `skills add -a`: Claude Desktop has no
  73. # skill path, while DSH consumes the global `universal` copy.
  74. $SkillsAgentExclusions = @('claude-desktop', 'dsh')
  75. # Agent ids whose MCP registration the installer can drive automatically.
  76. # Mirror of MCP_AUTO_AGENTS in install.sh and AGENT_REGISTRY in
  77. # AgentKey-Server/cli/src/lib/mcp-clients.ts. Keep these three in sync.
  78. $McpAutoAgents = @(
  79. 'claude-code', 'claude-desktop', 'cursor', 'codex', 'gemini-cli',
  80. 'opencode', 'qwen-code', 'iflow-cli', 'kimi-cli', 'kiro-cli',
  81. 'windsurf', 'warp', 'amp', 'crush', 'droid', 'openclaw', 'dsh'
  82. )
  83. # ── UI helpers ────────────────────────────────────────────────────────────
  84. function Write-Banner {
  85. Write-Host ''
  86. Write-Host ' █████ ██████ ███████ ███ ██ ████████ ██ ██ ███████ ██ ██' -ForegroundColor Cyan
  87. Write-Host ' ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ' -ForegroundColor Cyan
  88. Write-Host ' ███████ ██ ███ █████ ██ ██ ██ ██ █████ █████ ████ ' -ForegroundColor Cyan
  89. Write-Host ' ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ' -ForegroundColor Cyan
  90. Write-Host ' ██ ██ ██████ ███████ ██ ████ ██ ██ ██ ███████ ██ ' -ForegroundColor Cyan
  91. Write-Host ''
  92. Write-Host ' One command. Full internet access for your AI agent.' -ForegroundColor White
  93. Write-Host ' https://agentkey.app' -ForegroundColor DarkGray
  94. Write-Host ''
  95. }
  96. function Write-Step ($text) { Write-Host ''; Write-Host " $text" -ForegroundColor White }
  97. function Write-Info ($text) { Write-Host " › $text" -ForegroundColor Gray }
  98. function Write-Ok ($text) { Write-Host " ✓ $text" -ForegroundColor Green }
  99. function Write-Warn2($text) { Write-Host " ! $text" -ForegroundColor Yellow }
  100. function Write-Err ($text) { Write-Host " ✗ $text" -ForegroundColor Red }
  101. function Write-Muted($text) { Write-Host " $text" -ForegroundColor DarkGray }
  102. function Die ($text) { Write-Err $text; exit 1 }
  103. # ── Helpers: agent detection ──────────────────────────────────────────────
  104. function Test-AgentMarker {
  105. param([string]$Marker)
  106. if ($Marker.StartsWith('cmd:')) {
  107. return [bool](Get-Command $Marker.Substring(4) -ErrorAction SilentlyContinue)
  108. }
  109. if ($Marker.StartsWith('path:')) {
  110. return Test-Path -LiteralPath $Marker.Substring(5)
  111. }
  112. return $false
  113. }
  114. function Get-DetectedAgents {
  115. $hits = New-Object System.Collections.Generic.List[string]
  116. foreach ($entry in $AgentMarkers) {
  117. foreach ($m in $entry.Markers) {
  118. if (Test-AgentMarker $m) { $hits.Add($entry.Id) | Out-Null; break }
  119. }
  120. }
  121. return @($hits | Sort-Object -Unique)
  122. }
  123. # ── Help ──────────────────────────────────────────────────────────────────
  124. if ($Help) {
  125. @'
  126. AgentKey installer for Windows
  127. Usage:
  128. irm https://agentkey.app/install.ps1 | iex
  129. & ([scriptblock]::Create((irm https://agentkey.app/install.ps1))) -Yes
  130. Parameters:
  131. -Yes Non-interactive: install skill to every detected agent, no prompts
  132. -Interactive Force interactive mode (fails if console input is redirected)
  133. -Only <a,b,c> Only install skill for these agents (e.g. "claude-code,cursor")
  134. -AllAgents Skip auto-detection; let 'skills' CLI install for every detected agent
  135. -ListAgents Print the agents we'd auto-select on this machine and exit
  136. -SkipSkill Skip the skill install step (only run MCP auth)
  137. -SkipMcp Skip the MCP auth step (only install the skill)
  138. -NoTelemetry Disable anonymous usage telemetry (writes
  139. %USERPROFILE%\.config\agentkey\telemetry-disabled so
  140. the skill stays opted-out across runs)
  141. -Help Show this help
  142. Behavior:
  143. The installer auto-detects which AI agents are on this machine and
  144. pre-selects them for skill installation. The auth step always tries
  145. to open a browser and also prints the URL — so SSH / WinRM / Docker
  146. / OpenClaw users can copy the URL to any device with a browser.
  147. '@
  148. exit 0
  149. }
  150. if ($ListAgents) {
  151. $detected = Get-DetectedAgents
  152. if ($detected.Count -gt 0) { $detected -join "`n" | Write-Output }
  153. else { Write-Host 'no agents detected on this host' -ForegroundColor Yellow }
  154. exit 0
  155. }
  156. Write-Banner
  157. # ── 1. Preflight ──────────────────────────────────────────────────────────
  158. Write-Step '1. Preflight'
  159. # Platform guard
  160. if (-not $IsWindows -and $PSVersionTable.PSVersion.Major -ge 6) {
  161. Die 'This script targets Windows. On macOS/Linux use install.sh instead.'
  162. }
  163. Write-Ok 'Platform: windows'
  164. # Resolve interactive mode. PowerShell's `iex` runs in the current session, so
  165. # Read-Host works natively even under `irm | iex`. The only thing we need to
  166. # guard is truly redirected input (scheduled tasks, CI with redirected stdin).
  167. $InputRedirected = $false
  168. try { $InputRedirected = [Console]::IsInputRedirected } catch { $InputRedirected = $false }
  169. $Mode = $null
  170. if ($Yes) { $Mode = 'noninteractive' }
  171. elseif ($Interactive) {
  172. if ($InputRedirected) { Die '-Interactive requested but console input is redirected.' }
  173. $Mode = 'interactive'
  174. }
  175. elseif ($InputRedirected) {
  176. $Mode = 'noninteractive'
  177. Write-Warn2 'No interactive console detected — falling back to -Yes'
  178. }
  179. else {
  180. $Mode = 'interactive'
  181. }
  182. Write-Ok "Mode: $Mode"
  183. # Resolve telemetry intent: -NoTelemetry overrides everything; existing
  184. # %USERPROFILE%\.config\agentkey\telemetry-disabled file means already-opted-out.
  185. $TelemetryOptOutFile = Join-Path $env:USERPROFILE '.config\agentkey\telemetry-disabled'
  186. if ($NoTelemetry) {
  187. New-Item -ItemType Directory -Path (Split-Path $TelemetryOptOutFile) -Force | Out-Null
  188. New-Item -ItemType File -Path $TelemetryOptOutFile -Force | Out-Null
  189. Write-Ok 'Telemetry: disabled (-NoTelemetry)'
  190. } elseif (Test-Path -LiteralPath $TelemetryOptOutFile) {
  191. Write-Ok "Telemetry: disabled ($TelemetryOptOutFile exists)"
  192. } else {
  193. Write-Info 'Telemetry: anonymous usage stats enabled (re-run with -NoTelemetry to opt out)'
  194. }
  195. # Node check
  196. function Get-NodeMajor {
  197. try {
  198. $v = (& node --version) 2>$null
  199. if ($v -match '^v(\d+)\.') { return [int]$Matches[1] }
  200. } catch {}
  201. return 0
  202. }
  203. function Install-Node {
  204. Write-Info "Installing Node.js LTS ..."
  205. if (Get-Command winget -ErrorAction SilentlyContinue) {
  206. winget install -e --id OpenJS.NodeJS.LTS --silent --accept-source-agreements --accept-package-agreements | Out-Null
  207. } elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
  208. scoop install nodejs-lts | Out-Null
  209. } elseif (Get-Command choco -ErrorAction SilentlyContinue) {
  210. choco install nodejs-lts -y | Out-Null
  211. } else {
  212. Die 'No package manager found (winget/scoop/choco). Install Node.js LTS manually: https://nodejs.org/'
  213. }
  214. # Refresh PATH so this session sees the newly installed node
  215. $env:Path = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + ';' +
  216. [System.Environment]::GetEnvironmentVariable('Path', 'User')
  217. Write-Ok 'Node.js installed'
  218. }
  219. $nodeMajor = Get-NodeMajor
  220. if ($nodeMajor -ge $NodeMinMajor) {
  221. Write-Ok "Node.js: v$nodeMajor.x"
  222. } else {
  223. if ($nodeMajor -gt 0) { Write-Warn2 "Node.js v$nodeMajor found but v$NodeMinMajor+ is required" }
  224. if ($Mode -eq 'interactive') {
  225. Write-Host ''
  226. Write-Host " Node.js v$NodeMinMajor+ is required but not found." -ForegroundColor White
  227. $reply = Read-Host ' Install it now? [Y/n]'
  228. if ($reply -match '^(n|no)$') { Die 'Node.js required. Aborting.' }
  229. }
  230. Install-Node
  231. }
  232. if (-not (Get-Command npx -ErrorAction SilentlyContinue)) {
  233. Die 'npx not found after Node install — please reopen your terminal or reinstall Node.js.'
  234. }
  235. # Resolve target agent list — shared between the skill step and the MCP step.
  236. # $AllTargets — every detected agent, including local exceptions
  237. # $SkillTargets — $AllTargets minus ids excluded from `skills add -a`
  238. # $McpTargets — $AllTargets filtered to ids the MCP CLI knows how to write
  239. $AllTargets = @()
  240. if ($Only) {
  241. $AllTargets = @($Only -split ',' | Where-Object { $_ -ne '' })
  242. Write-Info "Targeting agents from -Only: $($AllTargets -join ', ')"
  243. } elseif ($AllAgents) {
  244. Write-Info "Installing for every agent the 'skills' CLI detects (-AllAgents)"
  245. } else {
  246. $AllTargets = @(Get-DetectedAgents)
  247. if ($AllTargets.Count -gt 0) {
  248. Write-Ok "Detected agents on this host: $($AllTargets -join ', ')"
  249. Write-Muted '(override with -Only <ids>, or use -AllAgents)'
  250. } else {
  251. Write-Info "No agents auto-detected — letting 'skills' CLI scan."
  252. }
  253. }
  254. $SkillTargets = @($AllTargets | Where-Object { $_ -notin $SkillsAgentExclusions })
  255. $McpTargets = @($AllTargets | Where-Object { $_ -in $McpAutoAgents })
  256. $DshSelected = $AllTargets -contains 'dsh'
  257. $DshConfigured = $false
  258. # ── 2. Install the AgentKey skill ─────────────────────────────────────────
  259. if ($SkipSkill) {
  260. Write-Step '2. Install the AgentKey skill'
  261. Write-Muted 'Skipped (-SkipSkill)'
  262. } elseif ($AllTargets.Count -gt 0 -and $SkillTargets.Count -eq 0 -and -not $DshSelected) {
  263. # DSH never enters this branch: `-Only dsh` must still run the global
  264. # `skills add -g -a universal` path, without passing dsh to `-a`.
  265. Write-Step '2. Install the AgentKey skill'
  266. Write-Muted "Skipped — selected targets ($($AllTargets -join ',')) are MCP-only (no skill install path)."
  267. } else {
  268. Write-Step '2. Install the AgentKey skill'
  269. $skillsArgs = @('-y', 'skills', 'add', $SkillRepo, '-g')
  270. if ($SkillTargets.Count -gt 0) {
  271. $skillsArgs += '-a'
  272. $skillsArgs += $SkillTargets
  273. } elseif ($DshSelected) {
  274. $skillsArgs += @('-a', 'universal', '-s', 'agentkey')
  275. }
  276. # Always pass -y in noninteractive mode AND when we already resolved
  277. # an explicit target list — there's nothing left to ask the user.
  278. if ($Mode -eq 'noninteractive' -or $AllTargets.Count -gt 0) {
  279. $skillsArgs += '-y'
  280. }
  281. & npx @skillsArgs
  282. if ($LASTEXITCODE -ne 0) { Die "Failed to install skill via 'skills' CLI" }
  283. # The skills CLI sometimes prints "Installation failed" and still
  284. # exits 0 (e.g. network error during git clone). Verify the skill
  285. # actually landed on disk before declaring success. Paths must mirror
  286. # the `path:` markers in $AgentMarkers: most agents live under
  287. # %USERPROFILE%\.<agent>, but amp / crush / goose / opencode live
  288. # under %APPDATA%\<agent>.
  289. $userHome = [Environment]::GetFolderPath('UserProfile')
  290. $candidatePaths = @(
  291. (Join-Path $userHome '.agents\skills\agentkey'),
  292. (Join-Path $userHome '.claude\skills\agentkey'),
  293. (Join-Path $userHome '.cursor\skills\agentkey'),
  294. (Join-Path $userHome '.codex\skills\agentkey'),
  295. (Join-Path $userHome '.gemini\skills\agentkey'),
  296. (Join-Path $userHome '.opencode\skills\agentkey'),
  297. (Join-Path $userHome '.openclaw\skills\agentkey'),
  298. (Join-Path $userHome '.qwen\skills\agentkey'),
  299. (Join-Path $userHome '.iflow\skills\agentkey'),
  300. (Join-Path $userHome '.windsurf\skills\agentkey'),
  301. (Join-Path $userHome '.warp\skills\agentkey'),
  302. (Join-Path $userHome '.kimi\skills\agentkey'),
  303. (Join-Path $userHome '.kiro\skills\agentkey'),
  304. # APPDATA-rooted agents (parity with install.sh's $HOME/.config/<agent>)
  305. (Join-Path $env:APPDATA 'amp\skills\agentkey'),
  306. (Join-Path $env:APPDATA 'crush\skills\agentkey'),
  307. (Join-Path $env:APPDATA 'goose\skills\agentkey'),
  308. (Join-Path $env:APPDATA 'opencode\skills\agentkey')
  309. )
  310. $agentkeyFound = $false
  311. foreach ($abs in $candidatePaths) {
  312. if (Test-Path (Join-Path $abs 'SKILL.md')) {
  313. $agentkeyFound = $true
  314. break
  315. }
  316. }
  317. if (-not $agentkeyFound) {
  318. Die "Skill install reported success but no agentkey SKILL.md was created — likely a network or git clone failure. Retry: npx -y skills add $SkillRepo -g -a universal -s agentkey -y"
  319. }
  320. Write-Ok 'Skill installed'
  321. }
  322. # ── 3. MCP authentication ────────────────────────────────────────────────
  323. # Always run auth-login. The CLI itself decides whether the existing token
  324. # can be reused or a fresh device-code flow is needed — the installer no
  325. # longer second-guesses by sniffing config files (which produced false
  326. # positives across the stdio → HTTP schema change).
  327. if ($SkipMcp) {
  328. Write-Step '3. Register the MCP server'
  329. Write-Muted 'Skipped (-SkipMcp)'
  330. } elseif ($AllTargets.Count -gt 0 -and $McpTargets.Count -eq 0) {
  331. # User selected ONLY MCP-incompatible agents (goose / kode / kilo via
  332. # -Only). Running auth-login without --only would silently register MCP
  333. # in every detected agent, overriding the user's explicit scope. Skip
  334. # rather than over-register. See PR #41 B1.
  335. Write-Step '3. Register the MCP server'
  336. Write-Muted "Skipped — selected agents ($($AllTargets -join ',')) need manual MCP setup (see SKILL.md Fallback section)."
  337. } else {
  338. # Pin MCP registration to the same agent list the skill step targeted.
  339. # When McpTargets is empty (auto-detect found nothing), let
  340. # `@agentkey/cli` do its own detection — same fallback we use for skill
  341. # install. Older CLI versions silently ignore --only, so this is
  342. # forward-compatible.
  343. $authArgs = @('--auth-login')
  344. if ($McpTargets.Count -gt 0) {
  345. $authArgs += '--only'
  346. $authArgs += ($McpTargets -join ',')
  347. }
  348. Write-Step '3. Register the MCP server'
  349. Write-Info 'Opening your browser for AgentKey device authentication ...'
  350. if ($McpTargets.Count -gt 0) {
  351. Write-Muted "Will register MCP in: $($McpTargets -join ', ')"
  352. } else {
  353. Write-Muted "If a browser doesn't open (SSH / WinRM / Docker / headless), the auth URL is also printed below — open it on any device to finish."
  354. }
  355. Write-Host ''
  356. # Telemetry context for install_completed. Opt-out is honored at the
  357. # SOURCE: when AGENTKEY_TELEMETRY=0, no other context env vars are
  358. # exported — hostname-derived fingerprint, agent lists, and installer
  359. # flags are never computed nor passed to the child `npx @agentkey/cli`
  360. # process. The server treats AGENTKEY_TELEMETRY=0 as a hard skip.
  361. if ($NoTelemetry -or (Test-Path -LiteralPath $TelemetryOptOutFile)) {
  362. $env:AGENTKEY_TELEMETRY = '0'
  363. } else {
  364. $env:AGENTKEY_TELEMETRY = '1'
  365. $_hn = [System.Net.Dns]::GetHostName()
  366. $_user = $env:USERNAME
  367. $_input = "$_hn|windows|$_user"
  368. $_bytes = [System.Text.Encoding]::UTF8.GetBytes($_input)
  369. $_sha = [System.Security.Cryptography.SHA256]::Create()
  370. $_hash = ($_sha.ComputeHash($_bytes) | ForEach-Object { $_.ToString('x2') }) -join ''
  371. $DeviceFingerprint = $_hash.Substring(0, 16)
  372. $DetectedAgents = Get-DetectedAgents
  373. $env:AGENTKEY_INSTALL_SOURCE = 'one_liner'
  374. $env:AGENTKEY_DETECTED_AGENTS = ($DetectedAgents -join ',')
  375. $env:AGENTKEY_SELECTED_AGENTS = ($AllTargets -join ',')
  376. $env:AGENTKEY_INSTALLER_FLAGS = ($PSBoundParameters.Keys | ForEach-Object { "-$_" }) -join ','
  377. $env:AGENTKEY_DEVICE_FINGERPRINT = $DeviceFingerprint
  378. }
  379. & npx -y $CliPackage @authArgs
  380. if ($LASTEXITCODE -ne 0) {
  381. Write-Err 'MCP auth failed.'
  382. Write-Muted "Retry manually: npx -y $CliPackage $($authArgs -join ' ')"
  383. exit 1
  384. }
  385. $DshConfigured = $McpTargets -contains 'dsh'
  386. Write-Ok 'MCP server registered'
  387. }
  388. # ── 4. Summary ───────────────────────────────────────────────────────────
  389. Write-Step '✨ Installation complete'
  390. Write-Host ''
  391. Write-Host ' Next steps' -ForegroundColor White
  392. if ($DshConfigured) {
  393. Write-Muted '1. Running DSH profiles hot-apply the home patch; start stopped DSH profiles and restart other clients.'
  394. } else {
  395. Write-Muted '1. Restart your agent (Claude Code / Cursor / etc.)'
  396. }
  397. Write-Muted '2. Ask it something that needs the internet:'
  398. Write-Host ' "What has Musk been tweeting about lately?"' -ForegroundColor Cyan
  399. Write-Host ''
  400. Write-Host ' Docs https://agentkey.app/docs' -ForegroundColor White
  401. Write-Host ' Uninstall irm https://agentkey.app/uninstall.ps1 | iex' -ForegroundColor White
  402. Write-Host ''
scripts/install.sh · Bundled script · 496 lines · 11 findings marked
  1. #!/usr/bin/env bash
  2. # AgentKey installer for macOS and Linux
  3. # Usage: curl -fsSL https://agentkey.app/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 3 on GitHub
  4. # curl -fsSL https://agentkey.app/install.sh | bash -s -- --yes
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 4 on GitHub
  5. # curl -fsSL https://agentkey.app/install.sh | bash -s -- --interactive
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 5 on GitHub
  6. # curl -fsSL https://agentkey.app/install.sh | bash -s -- --only claude-code,cursor
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 6 on GitHub
  7. # curl -fsSL https://agentkey.app/install.sh | bash -s -- --skip-mcp
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 7 on GitHub
  8. set -euo pipefail
  9. # ── Constants ─────────────────────────────────────────────────────────────
  10. SKILL_REPO="chainbase-labs/agentkey"
  11. CLI_PACKAGE="@agentkey/cli"
  12. NODE_MIN_MAJOR=18
  13. DSH_DETECT_HOME="${DSH_HOME:-}"; [[ -n "$DSH_DETECT_HOME" && "$DSH_DETECT_HOME" == *[![:space:]]* ]] || DSH_DETECT_HOME="$HOME/.dsh"
  14. case "$DSH_DETECT_HOME" in "~"|"~/"*) DSH_DETECT_HOME="$HOME${DSH_DETECT_HOME#"~"}" ;; /*) ;; *) DSH_DETECT_HOME="$PWD/$DSH_DETECT_HOME" ;; esac
  15. # ── Agent markers ─────────────────────────────────────────────────────────
  16. # `claude-desktop` and `dsh` are exceptions. Neither may be passed to
  17. # `skills add -a`; DSH reads the global skill installed for `universal`.
  18. #
  19. # Format: <agent-id>|<marker>[,<marker>...]
  20. # marker types: cmd:foo — `command -v foo`
  21. # path:/abs/or/~path — file or dir exists (~ expands to $HOME)
  22. AGENT_MARKERS=(
  23. "claude-code|path:~/.claude.json,cmd:claude"
  24. "claude-desktop|path:/Applications/Claude.app,path:~/Applications/Claude.app,path:~/Library/Application Support/Claude/claude_desktop_config.json,path:~/Library/Application Support/Claude,path:~/.config/Claude/claude_desktop_config.json,path:~/.config/Claude"
  25. "cursor|path:~/.cursor,cmd:cursor"
  26. "codex|path:~/.codex,cmd:codex"
  27. "dsh|path:$DSH_DETECT_HOME,cmd:dsh"
  28. "gemini-cli|path:~/.gemini,cmd:gemini"
  29. "opencode|path:~/.config/opencode,path:~/.opencode,cmd:opencode"
  30. "openclaw|path:~/.openclaw,cmd:openclaw"
  31. "qwen-code|path:~/.qwen,cmd:qwen"
  32. "iflow-cli|path:~/.iflow,cmd:iflow"
  33. "windsurf|path:~/.codeium/windsurf,path:~/.windsurf,cmd:windsurf"
  34. "warp|path:~/.warp,path:~/Library/Application Support/dev.warp.Warp-Stable"
  35. "amp|path:~/.config/amp,cmd:amp"
  36. "crush|path:~/.config/crush,cmd:crush"
  37. "goose|path:~/.config/goose,cmd:goose"
  38. "droid|cmd:droid"
  39. "kode|cmd:kode"
  40. "kilo|cmd:kilo"
  41. "kimi-cli|path:~/.kimi,cmd:kimi"
  42. "kiro-cli|path:~/.kiro,cmd:kiro"
  43. )
  44. SKILLS_AGENT_EXCLUSIONS=(claude-desktop dsh)
  45. MCP_AUTO_AGENTS=(
  46. claude-code claude-desktop cursor codex gemini-cli opencode
  47. qwen-code iflow-cli kimi-cli kiro-cli windsurf warp
  48. amp crush droid openclaw dsh
  49. )
  50. # ── Colors (only if stdout is a TTY) ─────────────────────────────────────
  51. if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
  52. BOLD=$'\033[1m'
  53. ACCENT=$'\033[38;2;0;200;180m' # AgentKey teal
  54. INFO=$'\033[38;2;136;146;176m'
  55. SUCCESS=$'\033[38;2;0;220;150m'
  56. WARN=$'\033[38;2;255;176;32m'
  57. ERROR=$'\033[38;2;230;57;70m'
  58. MUTED=$'\033[38;2;110;118;132m'
  59. NC=$'\033[0m'
  60. else
  61. BOLD=''; ACCENT=''; INFO=''; SUCCESS=''; WARN=''; ERROR=''; MUTED=''; NC=''
  62. fi
  63. # ── UI helpers ────────────────────────────────────────────────────────────
  64. ui_banner() {
  65. printf "\n"
  66. printf "${ACCENT} █████ ██████ ███████ ███ ██ ████████ ██ ██ ███████ ██ ██${NC}\n"
  67. printf "${ACCENT} ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ${NC}\n"
  68. printf "${ACCENT} ███████ ██ ███ █████ ██ ██ ██ ██ █████ █████ ████ ${NC}\n"
  69. printf "${ACCENT} ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ${NC}\n"
  70. printf "${ACCENT} ██ ██ ██████ ███████ ██ ████ ██ ██ ██ ███████ ██ ${NC}\n"
  71. printf "\n"
  72. printf " ${BOLD}One command. Full internet access for your AI agent.${NC}\n"
  73. printf " ${MUTED}https://agentkey.app${NC}\n\n"
  74. }
  75. ui_info() { printf " ${INFO}›${NC} %s\n" "$*"; }
  76. ui_ok() { printf " ${SUCCESS}✓${NC} %s\n" "$*"; }
  77. ui_warn() { printf " ${WARN}!${NC} %s\n" "$*"; }
  78. ui_error() { printf " ${ERROR}✗${NC} %s\n" "$*" >&2; }
  79. ui_step() { printf "\n ${BOLD}%s${NC}\n" "$*"; }
  80. ui_muted() { printf " ${MUTED}%s${NC}\n" "$*"; }
  81. die() { ui_error "$*"; exit 1; }
  82. print_help() {
  83. cat <<EOF
  84. AgentKey installer for macOS and Linux
  85. Usage:
  86. curl -fsSL https://agentkey.app/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 97 on GitHub
  87. curl -fsSL https://agentkey.app/install.sh | bash -s -- [OPTIONS]
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 98 on GitHub
  88. Options:
  89. --yes, -y Non-interactive: install skill to every detected agent, no prompts
  90. --interactive Force interactive mode (fails if no TTY/terminal is reachable)
  91. --only <a,b,c> Only install skill for these agents (comma-separated, e.g. claude-code,cursor)
  92. --all-agents Skip auto-detection; let 'skills' CLI install for every detected agent
  93. --list-agents Print the agents we'd auto-select on this machine and exit
  94. --skip-skill Skip the skill install step (only run MCP auth)
  95. --skip-mcp Skip the MCP auth step (only install the skill)
  96. --no-telemetry Disable anonymous usage telemetry (writes
  97. ~/.config/agentkey/telemetry-disabled so the skill
  98. stays opted-out across runs)
  99. -h, --help Show this help
  100. Behavior:
  101. Interactive mode is the default when a terminal is reachable; otherwise it
  102. falls back to --yes. The installer auto-detects which AI agents are on this
  103. machine and pre-selects them for skill installation. The auth step always
  104. attempts to open a browser and also prints the URL — so SSH / Docker /
  105. OpenClaw users can copy the URL to any device with a browser.
  106. EOF
  107. }
  108. # ── Helpers: agent detection ──────────────────────────────────────────────
  109. _expand_path() {
  110. local p="$1"
  111. case "$p" in
  112. "~"|"~/"*) printf '%s\n' "$HOME${p#"~"}" ;;
  113. *) printf '%s\n' "$p" ;;
  114. esac
  115. }
  116. _probe_marker() {
  117. local m="$1"
  118. case "$m" in
  119. cmd:*) command -v "${m#cmd:}" >/dev/null 2>&1 ;;
  120. path:*) [ -e "$(_expand_path "${m#path:}")" ] ;;
  121. *) return 1 ;;
  122. esac
  123. }
  124. detect_agents() {
  125. local entry id markers marker hits=()
  126. for entry in "${AGENT_MARKERS[@]}"; do
  127. id="${entry%%|*}"
  128. markers="${entry#*|}"
  129. IFS=',' read -ra marker_list <<<"$markers"
  130. for marker in "${marker_list[@]}"; do
  131. if _probe_marker "$marker"; then
  132. hits+=("$id")
  133. break
  134. fi
  135. done
  136. done
  137. if [ ${#hits[@]} -gt 0 ]; then
  138. printf '%s\n' "${hits[@]}" | sort -u | paste -sd, -
  139. fi
  140. }
  141. _in_list() {
  142. local needle="$1"; shift
  143. local item
  144. for item in "$@"; do
  145. [ "$item" = "$needle" ] && return 0
  146. done
  147. return 1
  148. }
  149. _filter_csv() {
  150. local csv="$1"; shift
  151. [ -z "$csv" ] && return 0
  152. local id
  153. local -a ids=() out=()
  154. IFS=',' read -ra ids <<<"$csv"
  155. for id in "${ids[@]}"; do
  156. if _in_list "$id" "$@"; then
  157. out+=("$id")
  158. fi
  159. done
  160. if [ ${#out[@]} -gt 0 ]; then
  161. printf '%s\n' "${out[@]}" | paste -sd, -
  162. fi
  163. }
  164. install_node() {
  165. local platform="$1"
  166. ui_info "Installing Node.js v$NODE_MIN_MAJOR+ ..."
  167. if [ "$platform" = "macos" ]; then
  168. if command -v brew >/dev/null 2>&1; then
  169. brew install node >/dev/null 2>&1 || die "brew install node failed"
  170. else
  171. die "Homebrew not found. Install Node.js v$NODE_MIN_MAJOR+ manually: https://nodejs.org/"
  172. fi
  173. else
  174. if command -v apt-get >/dev/null 2>&1; then
  175. curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - >/dev/null 2>&1 \
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 195 on GitHub
  176. && sudo apt-get install -y nodejs >/dev/null 2>&1 || die "apt install nodejs failed"
  177. elif command -v dnf >/dev/null 2>&1; then
  178. curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo -E bash - >/dev/null 2>&1 \
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 198 on GitHub
  179. && sudo dnf install -y nodejs >/dev/null 2>&1 || die "dnf install nodejs failed"
  180. elif command -v yum >/dev/null 2>&1; then
  181. curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo -E bash - >/dev/null 2>&1 \
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 201 on GitHub
  182. && sudo yum install -y nodejs >/dev/null 2>&1 || die "yum install nodejs failed"
  183. elif command -v apk >/dev/null 2>&1; then
  184. sudo apk add --no-cache nodejs npm >/dev/null 2>&1 || die "apk add nodejs failed"
  185. else
  186. die "No supported package manager found. Install Node.js v$NODE_MIN_MAJOR+ manually: https://nodejs.org/"
  187. fi
  188. fi
  189. ui_ok "Node.js installed"
  190. }
  191. compute_device_fingerprint() {
  192. local platform="$1"
  193. local hn user input hash
  194. hn="$(hostname 2>/dev/null || echo "")"
  195. user="${USER:-$(id -un 2>/dev/null || echo "")}"
  196. input="$hn|$platform|$user"
  197. if command -v sha256sum >/dev/null 2>&1; then
  198. hash="$(printf '%s' "$input" | sha256sum | cut -c1-16)"
  199. elif command -v shasum >/dev/null 2>&1; then
  200. hash="$(printf '%s' "$input" | shasum -a 256 | cut -c1-16)"
  201. else
  202. hash="rnd$(printf '%04x%04x%04x' "$RANDOM" "$RANDOM" "$RANDOM")"
  203. fi
  204. printf '%s' "$hash"
  205. }
  206. main() {
  207. local MODE=""
  208. local ONLY_AGENTS=""
  209. local SKIP_MCP=false
  210. local SKIP_SKILL=false
  211. local PRINT_HELP=false
  212. local LIST_AGENTS=false
  213. local ALL_AGENTS=false
  214. local NO_TELEMETRY=false
  215. local _orig_args=("$@")
  216. while [ $# -gt 0 ]; do
  217. case "$1" in
  218. -y|--yes) MODE=noninteractive; shift ;;
  219. --interactive) MODE=interactive; shift ;;
  220. --only) ONLY_AGENTS="${2:-}"; shift 2 ;;
  221. --only=*) ONLY_AGENTS="${1#*=}"; shift ;;
  222. --all-agents) ALL_AGENTS=true; shift ;;
  223. --list-agents) LIST_AGENTS=true; shift ;;
  224. --skip-skill) SKIP_SKILL=true; shift ;;
  225. --skip-mcp) SKIP_MCP=true; shift ;;
  226. --no-telemetry) NO_TELEMETRY=true; shift ;;
  227. -h|--help) PRINT_HELP=true; shift ;;
  228. *) ui_warn "Unknown argument: $1"; shift ;;
  229. esac
  230. done
  231. if $PRINT_HELP; then print_help; exit 0; fi
  232. if $LIST_AGENTS; then
  233. local detected
  234. detected="$(detect_agents)"
  235. if [ -n "$detected" ]; then
  236. printf '%s\n' "$detected" | tr ',' '\n'
  237. else
  238. printf 'no agents detected on this host\n' >&2
  239. fi
  240. exit 0
  241. fi
  242. ui_banner
  243. # ── 1. Preflight ──────────────────────────────────────────────────────
  244. ui_step "1. Preflight"
  245. local OS PLATFORM
  246. OS="$(uname -s)"
  247. case "$OS" in
  248. Darwin) PLATFORM="macos" ;;
  249. Linux) PLATFORM="linux" ;;
  250. *) die "Unsupported OS: $OS (macOS/Linux only; use install.ps1 on Windows)" ;;
  251. esac
  252. ui_ok "Platform: $PLATFORM"
  253. local TTY_AVAILABLE=false
  254. if ( : < /dev/tty ) >/dev/null 2>&1; then
  255. TTY_AVAILABLE=true
  256. fi
  257. if [ -z "$MODE" ]; then
  258. if $TTY_AVAILABLE; then
  259. MODE=interactive
  260. else
  261. MODE=noninteractive
  262. ui_warn "No terminal detected (CI/non-TTY shell) — falling back to --yes"
  263. fi
  264. elif [ "$MODE" = interactive ] && ! $TTY_AVAILABLE; then
  265. die "--interactive requested but no TTY is reachable"
  266. fi
  267. ui_ok "Mode: $MODE"
  268. local TELEMETRY_OPT_OUT_FILE="$HOME/.config/agentkey/telemetry-disabled"
  269. if $NO_TELEMETRY; then
  270. mkdir -p "$(dirname "$TELEMETRY_OPT_OUT_FILE")" 2>/dev/null || true
  271. touch "$TELEMETRY_OPT_OUT_FILE" 2>/dev/null || true
  272. ui_ok "Telemetry: disabled (--no-telemetry)"
  273. elif [ -f "$TELEMETRY_OPT_OUT_FILE" ]; then
  274. ui_ok "Telemetry: disabled (~/.config/agentkey/telemetry-disabled exists)"
  275. else
  276. ui_info "Telemetry: anonymous usage stats enabled (re-run with --no-telemetry to opt out)"
  277. fi
  278. local NODE_OK=false NODE_VERSION NODE_MAJOR
  279. if command -v node >/dev/null 2>&1; then
  280. NODE_VERSION="$(node --version 2>/dev/null | sed 's/^v//')"
  281. NODE_MAJOR="${NODE_VERSION%%.*}"
  282. if [ -n "$NODE_MAJOR" ] && [ "$NODE_MAJOR" -ge "$NODE_MIN_MAJOR" ] 2>/dev/null; then
  283. NODE_OK=true
  284. ui_ok "Node.js: v$NODE_VERSION"
  285. else
  286. ui_warn "Node.js v$NODE_VERSION found but v$NODE_MIN_MAJOR+ is required"
  287. fi
  288. fi
  289. if ! $NODE_OK; then
  290. if [ "$MODE" = interactive ]; then
  291. printf "\n ${BOLD}Node.js v%s+ is required but not found.${NC}\n" "$NODE_MIN_MAJOR"
  292. printf " Install it now? [Y/n] "
  293. local REPLY=""
  294. read -r REPLY < /dev/tty || REPLY=""
  295. case "$REPLY" in
  296. n|N|no|No) die "Node.js required. Aborting." ;;
  297. esac
  298. fi
  299. install_node "$PLATFORM"
  300. fi
  301. command -v npx >/dev/null 2>&1 || die "npx not found after Node install — please reinstall Node.js"
  302. # ── Resolve target agent list ─────────────────────────────────────────
  303. local ALL_TARGETS=""
  304. if [ -n "$ONLY_AGENTS" ]; then
  305. ALL_TARGETS="$ONLY_AGENTS"
  306. ui_info "Targeting agents from --only: $ALL_TARGETS"
  307. elif $ALL_AGENTS; then
  308. ui_info "Installing for every agent the 'skills' CLI detects (--all-agents)"
  309. else
  310. ALL_TARGETS="$(detect_agents)"
  311. if [ -n "$ALL_TARGETS" ]; then
  312. ui_ok "Detected agents on this host: $ALL_TARGETS"
  313. ui_muted "(override with --only <ids>, or use --all-agents)"
  314. else
  315. ui_info "No agents auto-detected — letting 'skills' CLI scan."
  316. fi
  317. fi
  318. local SKILL_TARGETS=""
  319. local MCP_TARGETS=""
  320. local DSH_SELECTED=false
  321. local DSH_MCP_CONFIGURED=false
  322. if [ -n "$ALL_TARGETS" ]; then
  323. local _id
  324. local -a _id_list=() _kept=()
  325. IFS=',' read -ra _id_list <<<"$ALL_TARGETS"
  326. for _id in "${_id_list[@]}"; do
  327. [ "$_id" = dsh ] && DSH_SELECTED=true
  328. if ! _in_list "$_id" "${SKILLS_AGENT_EXCLUSIONS[@]}"; then
  329. _kept+=("$_id")
  330. fi
  331. done
  332. if [ ${#_kept[@]} -gt 0 ]; then
  333. SKILL_TARGETS="$(printf '%s\n' "${_kept[@]}" | paste -sd, -)"
  334. fi
  335. MCP_TARGETS="$(_filter_csv "$ALL_TARGETS" "${MCP_AUTO_AGENTS[@]}")"
  336. fi
  337. # ── 2. Install the AgentKey skill ─────────────────────────────────────
  338. if $SKIP_SKILL; then
  339. ui_step "2. Install the AgentKey skill"
  340. ui_muted "Skipped (--skip-skill)"
  341. elif [ -n "$ALL_TARGETS" ] && [ -z "$SKILL_TARGETS" ] && ! $DSH_SELECTED; then
  342. ui_step "2. Install the AgentKey skill"
  343. ui_muted "Skipped — selected targets ($ALL_TARGETS) are MCP-only (no skill install path)."
  344. else
  345. ui_step "2. Install the AgentKey skill"
  346. local SKILLS_ARGS=(-y skills add "$SKILL_REPO" -g)
  347. if [ -n "$SKILL_TARGETS" ]; then
  348. local AGENT_LIST=()
  349. IFS=',' read -ra AGENT_LIST <<<"$SKILL_TARGETS"
  350. SKILLS_ARGS+=(-a "${AGENT_LIST[@]}")
  351. elif $DSH_SELECTED; then
  352. SKILLS_ARGS+=(-a universal -s agentkey)
  353. fi
  354. if [ "$MODE" = noninteractive ] || [ -n "$ALL_TARGETS" ]; then
  355. SKILLS_ARGS+=(-y)
  356. fi
  357. local npx_stdin="/dev/null"
  358. if [ "$MODE" = interactive ] && $TTY_AVAILABLE; then
  359. npx_stdin="/dev/tty"
  360. fi
  361. if ! npx "${SKILLS_ARGS[@]}" < "$npx_stdin"; then
  362. die "Failed to install skill via 'skills' CLI"
  363. fi
  364. local _agentkey_found=false _dir
  365. for _dir in \
  366. "$HOME/.agents/skills/agentkey" \
  367. "$HOME/.claude/skills/agentkey" \
  368. "$HOME/.cursor/skills/agentkey" \
  369. "$HOME/.codex/skills/agentkey" \
  370. "$HOME/.gemini/skills/agentkey" \
  371. "$HOME/.opencode/skills/agentkey" \
  372. "$HOME/.openclaw/skills/agentkey" \
  373. "$HOME/.qwen/skills/agentkey" \
  374. "$HOME/.iflow/skills/agentkey" \
  375. "$HOME/.windsurf/skills/agentkey" \
  376. "$HOME/.warp/skills/agentkey" \
  377. "$HOME/.config/amp/skills/agentkey" \
  378. "$HOME/.config/crush/skills/agentkey" \
  379. "$HOME/.config/goose/skills/agentkey" \
  380. "$HOME/.config/opencode/skills/agentkey" \
  381. "$HOME/.kimi/skills/agentkey" \
  382. "$HOME/.kiro/skills/agentkey"; do
  383. [ -f "$_dir/SKILL.md" ] && { _agentkey_found=true; break; }
  384. done
  385. if ! $_agentkey_found; then
  386. die "Skill install reported success but no agentkey SKILL.md was created — likely a network or git clone failure. Retry: npx -y skills add $SKILL_REPO -g -a universal -s agentkey -y"
  387. fi
  388. ui_ok "Skill installed"
  389. fi
  390. # ── 3. MCP authentication ────────────────────────────────────────────
  391. if $SKIP_MCP; then
  392. ui_step "3. Register the MCP server"
  393. ui_muted "Skipped (--skip-mcp)"
  394. elif [ -n "$ALL_TARGETS" ] && [ -z "$MCP_TARGETS" ]; then
  395. ui_step "3. Register the MCP server"
  396. ui_muted "Skipped — selected agents ($ALL_TARGETS) need manual MCP setup (see SKILL.md Fallback section)."
  397. else
  398. local AUTH_ARGS=(--auth-login)
  399. if [ -n "$MCP_TARGETS" ]; then
  400. AUTH_ARGS+=(--only "$MCP_TARGETS")
  401. fi
  402. ui_step "3. Register the MCP server"
  403. ui_info "Opening your browser for AgentKey device authentication ..."
  404. if [ -n "$MCP_TARGETS" ]; then
  405. ui_muted "Will register MCP in: $MCP_TARGETS"
  406. else
  407. ui_muted "If a browser doesn't open (SSH / Docker / headless), the auth URL is also printed below — open it on any device to finish."
  408. fi
  409. echo
  410. if $NO_TELEMETRY || [ -f "$TELEMETRY_OPT_OUT_FILE" ]; then
  411. export AGENTKEY_TELEMETRY=0
  412. else
  413. export AGENTKEY_TELEMETRY=1
  414. local _flags=""
  415. for _f in "${_orig_args[@]:-}"; do
  416. _flags="${_flags:+$_flags,}$_f"
  417. done
  418. export AGENTKEY_INSTALL_SOURCE="one_liner"
  419. export AGENTKEY_DETECTED_AGENTS="$(detect_agents)"
  420. export AGENTKEY_SELECTED_AGENTS="${ALL_TARGETS:-}"
  421. export AGENTKEY_INSTALLER_FLAGS="$_flags"
  422. export AGENTKEY_DEVICE_FINGERPRINT="$(compute_device_fingerprint "$PLATFORM")"
  423. fi
  424. if ! npx -y "$CLI_PACKAGE" "${AUTH_ARGS[@]}"; then
  425. ui_error "MCP auth failed."
  426. ui_muted "Retry manually: npx -y $CLI_PACKAGE ${AUTH_ARGS[*]}"
  427. exit 1
  428. fi
  429. case ",$MCP_TARGETS," in *,dsh,*) DSH_MCP_CONFIGURED=true ;; esac
  430. ui_ok "MCP server registered"
  431. fi
  432. # ── 4. Summary ───────────────────────────────────────────────────────
  433. ui_step "✨ Installation complete"
  434. local APPLY_HINT="Restart your agent (Claude Code / Cursor / etc.)"
  435. if $DSH_MCP_CONFIGURED; then
  436. APPLY_HINT="Running DSH profiles hot-apply the home patch; start stopped DSH profiles and restart other clients"
  437. fi
  438. cat <<EOF
  439. ${BOLD}Next steps${NC}
  440. ${MUTED}1.${NC} $APPLY_HINT
  441. ${MUTED}2.${NC} Ask it something that needs the internet:
  442. ${ACCENT}"What has Musk been tweeting about lately?"${NC}
  443. ${BOLD}Docs${NC} https://agentkey.app/docs
  444. ${BOLD}Uninstall${NC} curl -fsSL https://agentkey.app/uninstall.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 491 on GitHub
  445. EOF
  446. }
  447. main "$@"
scripts/uninstall.ps1 · Bundled script · 500 lines · 2 findings marked
  1. #Requires -Version 5.1
  2. <#
  3. .SYNOPSIS
  4. AgentKey uninstaller for Windows
  5. .DESCRIPTION
  6. Usage:
  7. irm https://agentkey.app/uninstall.ps1 | iex
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 7 on GitHub
  8. & ([scriptblock]::Create((irm https://agentkey.app/uninstall.ps1))) -KeepMarketplace
  9. & ([scriptblock]::Create((irm https://agentkey.app/uninstall.ps1))) -ForceInRepo
  10. Cleans up everything install.ps1 (and the legacy two-command flow) ever wrote:
  11. 1. Skill files in every agent (via `skills remove`)
  12. 2. MCP server entries (Claude Code / Claude Desktop / Cursor)
  13. 3. Plugin + marketplace caches
  14. 4. CLAUDE.md sections + npm/npx caches (legacy)
  15. #>
  16. [CmdletBinding()]
  17. param(
  18. [switch]$KeepMarketplace,
  19. [switch]$ForceInRepo,
  20. [switch]$SkipSkillRemove,
  21. [switch]$Help
  22. )
  23. $ErrorActionPreference = 'Continue'
  24. if ($Help) {
  25. @'
  26. AgentKey uninstaller (Windows)
  27. Usage:
  28. irm https://agentkey.app/uninstall.ps1 | iex
  29. Parameters:
  30. -KeepMarketplace Keep the Claude Code plugin marketplace registration
  31. -ForceInRepo Allow running inside the AgentKey-Skill source repo
  32. -SkipSkillRemove Skip 'npx skills remove' (only clean configs/caches)
  33. -Help Show this help
  34. '@
  35. exit 0
  36. }
  37. # ── UI helpers ────────────────────────────────────────────────────────────
  38. function Write-Step ($t) { Write-Host ''; Write-Host " $t" -ForegroundColor White }
  39. function Write-Info ($t) { Write-Host " › $t" -ForegroundColor Gray }
  40. function Write-Ok ($t) { Write-Host " ✓ $t" -ForegroundColor Green }
  41. function Write-Warn2($t) { Write-Host " ! $t" -ForegroundColor Yellow }
  42. function Write-Skip ($t) { Write-Host " - $t" -ForegroundColor DarkGray }
  43. function Write-Err ($t) { Write-Host " ✗ $t" -ForegroundColor Red }
  44. # ── Safety rail ──────────────────────────────────────────────────────────
  45. if ((Test-Path '.claude-plugin/plugin.json') -and -not $ForceInRepo) {
  46. $content = Get-Content '.claude-plugin/plugin.json' -Raw -ErrorAction SilentlyContinue
  47. if ($content -match '"name"\s*:\s*"agentkey"') {
  48. Write-Host ''
  49. Write-Host ' AgentKey — Uninstall' -ForegroundColor White
  50. Write-Host ''
  51. Write-Err 'Refusing to run inside the AgentKey-Skill source repo.'
  52. Write-Host " Running here would wipe this repo's own .mcp.json and CLAUDE.md." -ForegroundColor DarkGray
  53. Write-Host ' Re-run with -ForceInRepo if you really mean it.' -ForegroundColor DarkGray
  54. Write-Host ''
  55. exit 2
  56. }
  57. }
  58. Write-Host ''
  59. Write-Host ' AgentKey — Uninstall' -ForegroundColor White
  60. Write-Host ' https://agentkey.app' -ForegroundColor DarkGray
  61. # ── 1. Skill removal via skills CLI ──────────────────────────────────────
  62. Write-Step '1. Skill files'
  63. if ($SkipSkillRemove) {
  64. Write-Skip 'Skipped (-SkipSkillRemove)'
  65. } elseif (-not (Get-Command npx -ErrorAction SilentlyContinue)) {
  66. Write-Warn2 "npx not found — skipping 'skills remove'"
  67. Write-Host ' Manual: npx skills remove agentkey -g' -ForegroundColor DarkGray
  68. } else {
  69. # `skills remove` takes the **skill name** (`agentkey`), not the repo path.
  70. # The CLI also exits 0 when nothing matches, so we inspect stdout instead.
  71. Write-Info 'Running: npx -y skills remove agentkey -g -y'
  72. $removeOutput = (& npx -y skills remove agentkey -g -y 2>&1) -join "`n"
  73. if ($removeOutput -match 'Successfully removed') {
  74. Write-Ok 'Skill removed from detected agents'
  75. } elseif ($removeOutput -match 'No matching skills found') {
  76. Write-Skip "Not registered with 'skills' CLI (already removed or installed via plugin marketplace)"
  77. } else {
  78. Write-Warn2 "'skills remove' produced unexpected output — some agents may still have skill files"
  79. Write-Host ' Check manually: npx skills list -g' -ForegroundColor DarkGray
  80. }
  81. }
  82. # ── 2. MCP config cleanup ────────────────────────────────────────────────
  83. Write-Step '2. MCP server entries'
  84. $home2 = [Environment]::GetFolderPath('UserProfile')
  85. # All known JSON MCP config paths across the 16 auto-supported agents. The
  86. # scrub logic is schema-agnostic — it walks the JSON tree and drops any
  87. # dict key whose name exactly matches our server name (current + legacy),
  88. # so the same scrubber handles every dialect: mcpServers, mcp,
  89. # amp.mcpServers, projects.X.mcpServers, etc. Keep this list aligned with
  90. # AGENT_REGISTRY in AgentKey-Server/cli/src/lib/mcp-clients.ts.
  91. $mcpJsonConfigs = @(
  92. (Join-Path $home2 '.claude.json'), # Claude Code
  93. (Join-Path $home2 '.cursor\mcp.json'), # Cursor
  94. (Join-Path $env:APPDATA 'Claude\claude_desktop_config.json'), # Claude Desktop
  95. (Join-Path $home2 '.gemini\settings.json'), # Gemini CLI
  96. (Join-Path $home2 '.qwen\settings.json'), # Qwen Code
  97. (Join-Path $home2 '.iflow\settings.json'), # iFlow CLI
  98. (Join-Path $home2 '.kimi\mcp.json'), # Kimi CLI
  99. (Join-Path $home2 '.kiro\settings\mcp.json'), # Kiro CLI
  100. (Join-Path $home2 '.codeium\windsurf\mcp_config.json'), # Windsurf
  101. (Join-Path $home2 '.warp\.mcp.json'), # Warp
  102. (Join-Path $env:APPDATA 'opencode\opencode.json'), # OpenCode (mcp.<name>)
  103. (Join-Path $env:APPDATA 'amp\settings.json'), # Amp (amp.mcpServers.<name>)
  104. (Join-Path $env:APPDATA 'crush\crush.json') # Crush (mcp.<name>)
  105. )
  106. # TOML config — handled separately (no built-in TOML parser pre-PS7.4).
  107. $mcpTomlConfigs = @(
  108. (Join-Path $home2 '.codex\config.toml') # Codex CLI
  109. )
  110. $ServerNames = @('agentkey', 'agentkey.app agentkey')
  111. # Schema-agnostic recursive scrub: drop any dict key whose lowercased name
  112. # is in $ServerNames. Covers mcpServers / mcp / amp.mcpServers / projects.*
  113. # in one pass. Exact match (not substring) so we don't nuke unrelated user
  114. # keys like "my-agentkey-helper".
  115. function Scrub-Mcp($node) {
  116. $removed = 0
  117. if ($node -is [System.Management.Automation.PSCustomObject]) {
  118. $keys = @($node.PSObject.Properties.Name)
  119. foreach ($k in $keys) {
  120. if ($ServerNames -contains $k.ToLower()) {
  121. $node.PSObject.Properties.Remove($k)
  122. $removed++
  123. } else {
  124. $removed += Scrub-Mcp $node.$k
  125. }
  126. }
  127. } elseif ($node -is [System.Collections.IList]) {
  128. foreach ($item in $node) {
  129. $removed += Scrub-Mcp $item
  130. }
  131. }
  132. return $removed
  133. }
  134. function Clean-McpJsonConfig($path) {
  135. if (-not (Test-Path $path)) {
  136. Write-Skip "$([System.IO.Path]::GetFileName($path)) not found"
  137. return
  138. }
  139. try {
  140. $raw = Get-Content $path -Raw
  141. $obj = $raw | ConvertFrom-Json
  142. } catch {
  143. Write-Warn2 "Could not parse $path — skipping"
  144. return
  145. }
  146. $removed = Scrub-Mcp $obj
  147. if ($removed -gt 0) {
  148. ($obj | ConvertTo-Json -Depth 100) | Set-Content -Path $path -Encoding UTF8
  149. Write-Ok "Removed $removed entry/entries from $path"
  150. } else {
  151. Write-Skip "No agentkey entry in $path"
  152. }
  153. }
  154. foreach ($cfg in $mcpJsonConfigs) { Clean-McpJsonConfig $cfg }
  155. # Codex TOML — line-scan to splice out our [mcp_servers.agentkey] block
  156. # (bare + legacy quoted name). Done in pure PowerShell — no TOML lib needed
  157. # because we only ever delete, never re-emit unrelated tables.
  158. function Clean-McpTomlConfig($path) {
  159. if (-not (Test-Path $path)) {
  160. Write-Skip "$([System.IO.Path]::GetFileName($path)) not found"
  161. return
  162. }
  163. $lines = Get-Content $path
  164. $headerPattern = '^\s*\[\s*mcp_servers\s*\.\s*(agentkey|"agentkey\.app AgentKey")\s*\]\s*$'
  165. $anyHeader = '^\s*\[[^\]]+\]\s*$'
  166. if (-not ($lines -match $headerPattern)) {
  167. Write-Skip "No agentkey block in $path"
  168. return
  169. }
  170. $out = New-Object System.Collections.Generic.List[string]
  171. $skip = $false
  172. foreach ($line in $lines) {
  173. if ($line -match $headerPattern) { $skip = $true; continue }
  174. if ($skip -and $line -match $anyHeader) { $skip = $false }
  175. if (-not $skip) { $out.Add($line) }
  176. }
  177. Set-Content -Path $path -Value $out -Encoding UTF8
  178. Write-Ok "Removed agentkey block from $path"
  179. }
  180. foreach ($cfg in $mcpTomlConfigs) { Clean-McpTomlConfig $cfg }
  181. # DSH stores the MCP loader in the home patch; old installs used profiles.
  182. $DshHome = if ([string]::IsNullOrWhiteSpace($env:DSH_HOME)) { Join-Path $home2 '.dsh' } else { $env:DSH_HOME }
  183. if ($DshHome -eq '~') { $DshHome = $home2 }
  184. elseif ($DshHome -match '^~[\\/]') { $DshHome = Join-Path $home2 $DshHome.Substring(2) }
  185. $DshHome = [System.IO.Path]::GetFullPath($DshHome)
  186. $utf8NoBom = New-Object System.Text.UTF8Encoding($false)
  187. $managedPattern = '(?ms)^# agentkey:start(?:[ \t][^\r\n]*)?(?:\r?\n|$).*?^# agentkey:end(?:[ \t][^\r\n]*)?(?:\r?\n|$)'
  188. $profilesDir = Join-Path $DshHome 'profiles'
  189. $dshCleaned = $false
  190. $dshPatches = New-Object System.Collections.Generic.List[string]
  191. $homePatch = Join-Path $DshHome 'cordis.patch.yml'; if (Test-Path $homePatch) { [void]$dshPatches.Add($homePatch) }
  192. if (Test-Path $profilesDir) {
  193. foreach ($profile in Get-ChildItem $profilesDir -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ne 'node_modules' }) {
  194. $patch = Join-Path $profile.FullName 'cordis.patch.yml'
  195. if (Test-Path $patch) { [void]$dshPatches.Add($patch) }
  196. }
  197. }
  198. foreach ($patch in $dshPatches) {
  199. $raw = [System.IO.File]::ReadAllText($patch)
  200. $markerDepth = 0
  201. $malformedMarkers = $false
  202. foreach ($line in ($raw -split '\r?\n')) {
  203. if ($line -match '^# agentkey:start(?:[ \t]|$)') {
  204. if ($markerDepth -ne 0) { $malformedMarkers = $true }; $markerDepth++
  205. } elseif ($line -match '^# agentkey:end(?:[ \t]|$)') {
  206. if ($markerDepth -ne 1) { $malformedMarkers = $true }; if ($markerDepth -gt 0) { $markerDepth-- }
  207. }
  208. }
  209. if ($markerDepth -ne 0) { $malformedMarkers = $true }
  210. if ($malformedMarkers) {
  211. Write-Warn2 "Malformed AgentKey markers in $patch — left unchanged"
  212. continue
  213. }
  214. $updated = [regex]::Replace($raw, $managedPattern, '')
  215. if ($updated -ne $raw) {
  216. $meaningful = @($updated -split '\r?\n' | Where-Object { $_ -match '^\s*[^#\s]' })
  217. if ($meaningful.Count -eq 0) {
  218. $eol = if ($raw.Contains("`r`n")) { "`r`n" } else { "`n" }
  219. $prefix = $updated.TrimEnd()
  220. $updated = if ($prefix) { $prefix + $eol + $eol + '[]' + $eol } else { '[]' + $eol }
  221. }
  222. [System.IO.File]::WriteAllText($patch, $updated, $utf8NoBom)
  223. $dshCleaned = $true
  224. Write-Ok "Removed AgentKey DSH block from $patch"
  225. } elseif ($raw -match '(?m)^# agentkey:start(?:[ \t]|$)') {
  226. Write-Warn2 "Malformed AgentKey markers in $patch — left unchanged"
  227. } else {
  228. Write-Skip "No AgentKey DSH block in $patch"
  229. }
  230. }
  231. $legacyDshPreset = Join-Path $DshHome '.agent-presets\agentkey'
  232. if (Test-Path $legacyDshPreset) {
  233. $presetBackup = "$legacyDshPreset.backup-$([DateTime]::UtcNow.ToString('yyyyMMddTHHmmssZ'))"; while (Test-Path $presetBackup) { $presetBackup += '-1' }
  234. Move-Item $legacyDshPreset $presetBackup; Write-Ok "Archived legacy DSH preset at $presetBackup" }
  235. $dshSettings = Join-Path $DshHome 'settings.yaml'
  236. if (Test-Path $dshSettings) {
  237. $lines = [System.IO.File]::ReadAllLines($dshSettings)
  238. $out = New-Object System.Collections.Generic.List[string]
  239. $inPresets = $false
  240. $removedDefault = $false
  241. foreach ($line in $lines) {
  242. if ($line -match '^\s*agent-presets\.default:\s*["'']?agentkey["'']?\s*(?:#.*)?$') {
  243. $removedDefault = $true
  244. continue
  245. }
  246. if ($line -match '^[^\s#][^:]*:\s*') {
  247. $inPresets = $line -match '^agent-presets:\s*(?:#.*)?$'
  248. }
  249. if ($inPresets -and $line -match '^\s+default:\s*["'']?agentkey["'']?\s*(?:#.*)?$') {
  250. $removedDefault = $true
  251. continue
  252. }
  253. [void]$out.Add($line)
  254. }
  255. if ($removedDefault) {
  256. [System.IO.File]::WriteAllLines($dshSettings, $out, $utf8NoBom)
  257. Write-Ok "Removed legacy agent-presets default from $dshSettings"
  258. }
  259. }
  260. # ── 2b. CLI-registered agents (droid / openclaw) ─────────────────────────
  261. # These two have no documented file-edit path; we registered them via their
  262. # CLIs so we have to unregister the same way. Best-effort — silently skip
  263. # if the CLI isn't on PATH or the entry was never created.
  264. Write-Step '2b. CLI-registered agents (droid / openclaw)'
  265. if (Get-Command droid -ErrorAction SilentlyContinue) {
  266. & droid mcp remove agentkey 2>$null | Out-Null
  267. if ($LASTEXITCODE -eq 0) { Write-Ok 'Removed agentkey from droid (`droid mcp remove`)' }
  268. else { Write-Skip 'No agentkey entry in droid (or already removed)' }
  269. } else {
  270. Write-Skip 'droid CLI not on PATH'
  271. }
  272. if (Get-Command openclaw -ErrorAction SilentlyContinue) {
  273. & openclaw mcp unset agentkey 2>$null | Out-Null
  274. if ($LASTEXITCODE -eq 0) { Write-Ok 'Removed agentkey from openclaw (`openclaw mcp unset`)' }
  275. else { Write-Skip 'No agentkey entry in openclaw (or already removed)' }
  276. } else {
  277. Write-Skip 'openclaw CLI not on PATH'
  278. }
  279. # ── 3. Claude Code plugin registrations (legacy) ─────────────────────────
  280. Write-Step '3. Claude Code plugin registrations (legacy)'
  281. if (-not (Get-Command claude -ErrorAction SilentlyContinue)) {
  282. Write-Skip 'Claude Code CLI not on PATH — nothing to do here'
  283. } else {
  284. $pluginList = & claude plugin list 2>$null
  285. $markets = @()
  286. if ($pluginList) {
  287. $markets = $pluginList | Select-String -Pattern 'agentkey@[a-zA-Z0-9_-]+' -AllMatches |
  288. ForEach-Object { $_.Matches.Value } | Sort-Object -Unique
  289. }
  290. if ($markets.Count -eq 0) {
  291. Write-Skip 'No agentkey plugin registered'
  292. } else {
  293. foreach ($entry in $markets) {
  294. $name = $entry.Split('@')[0]
  295. Write-Info "Uninstalling $entry ..."
  296. & claude plugin uninstall $name --scope user 2>$null
  297. if ($LASTEXITCODE -eq 0) { Write-Ok "Removed $entry" }
  298. else { Write-Warn2 "Could not remove $entry" }
  299. }
  300. }
  301. $mcpList = & claude mcp list 2>$null
  302. if ($mcpList -and ($mcpList -match '^agentkey')) {
  303. Write-Info "Removing MCP server 'agentkey' via claude CLI ..."
  304. & claude mcp remove agentkey 2>$null
  305. if ($LASTEXITCODE -eq 0) { Write-Ok 'MCP server removed' }
  306. else { Write-Warn2 'Could not remove MCP server via claude CLI' }
  307. } else {
  308. Write-Skip "No 'agentkey' MCP via claude CLI"
  309. }
  310. if ($KeepMarketplace) {
  311. Write-Skip 'Marketplace removal skipped (-KeepMarketplace)'
  312. } else {
  313. $mktList = & claude plugin marketplace list 2>$null
  314. $agentkeyMkts = @()
  315. if ($mktList) {
  316. $joined = $mktList -join "`n"
  317. if ($joined -match '(AgentKey-Skill|chainbase-labs/AgentKey-Skill|agentkey-skill|chainbase-labs/agentkey)') {
  318. $agentkeyMkts = $mktList | Select-String -Pattern '^\s*❯\s+([a-zA-Z0-9_-]+)' |
  319. ForEach-Object { $_.Matches[0].Groups[1].Value }
  320. }
  321. }
  322. if ($agentkeyMkts.Count -eq 0) {
  323. Write-Skip 'No AgentKey marketplace entry'
  324. } else {
  325. foreach ($mkt in $agentkeyMkts) {
  326. Write-Info "Removing marketplace '$mkt' ..."
  327. & claude plugin marketplace remove $mkt 2>$null
  328. if ($LASTEXITCODE -eq 0) { Write-Ok "Removed marketplace '$mkt'" }
  329. else { Write-Warn2 "Could not remove marketplace '$mkt'" }
  330. }
  331. }
  332. }
  333. }
  334. # ── 4. Plugin + marketplace caches ────────────────────────────────────────
  335. Write-Step '4. Plugin / marketplace caches'
  336. $cacheHits = @()
  337. $pluginCache = Join-Path $home2 '.claude\plugins\cache'
  338. if (Test-Path $pluginCache) {
  339. $cacheHits += Get-ChildItem -Path $pluginCache -Directory -Filter 'agentkey*' -ErrorAction SilentlyContinue
  340. }
  341. $mktCache = Join-Path $home2 '.claude\plugins\marketplaces'
  342. if (Test-Path $mktCache) {
  343. $cacheHits += Get-ChildItem -Path $mktCache -Directory -Filter '*agentkey*' -ErrorAction SilentlyContinue
  344. }
  345. if ($cacheHits.Count -eq 0) {
  346. Write-Skip 'No cache found'
  347. } else {
  348. foreach ($d in $cacheHits) {
  349. Remove-Item -Recurse -Force $d.FullName -ErrorAction SilentlyContinue
  350. Write-Ok "Removed $($d.FullName)"
  351. }
  352. }
  353. # ── 5. CLAUDE.md cleanup (legacy) ─────────────────────────────────────────
  354. Write-Step '5. CLAUDE.md sections (legacy)'
  355. $mdChanged = $false
  356. $candidates = @(
  357. (Join-Path $home2 '.claude\CLAUDE.md'),
  358. '.claude\CLAUDE.md',
  359. 'CLAUDE.md'
  360. )
  361. foreach ($md in $candidates) {
  362. if (-not (Test-Path $md)) { continue }
  363. $c = Get-Content $md -Raw
  364. if ($c -notmatch '(AgentKey|agentkey|AGENTKEY)') { continue }
  365. $c2 = [regex]::Replace($c, '\n# AgentKey\n.*?(?=\n# |\z)', '', 'Singleline')
  366. $c2 = [regex]::Replace($c2, '\n[^\n]*(\.agentkey|agentkey.*activation\.md|agentkey.*SKILL\.md)[^\n]*', '', 'IgnoreCase')
  367. if ($c2 -ne $c) {
  368. Set-Content -Path $md -Value $c2 -Encoding UTF8
  369. Write-Ok "Removed AgentKey section from $md"
  370. $mdChanged = $true
  371. }
  372. }
  373. if (-not $mdChanged) { Write-Skip 'No removable AgentKey section in CLAUDE.md' }
  374. # ── 6. npm / npx caches ───────────────────────────────────────────────────
  375. Write-Step '6. npm / npx caches'
  376. if (Get-Command npm -ErrorAction SilentlyContinue) {
  377. $globalList = & npm list -g --depth=0 2>$null
  378. $removedAny = $false
  379. # Sweep both the current package name and the legacy v0.x name so users
  380. # who installed before the @agentkey/mcp → @agentkey/cli rename get a
  381. # clean uninstall.
  382. foreach ($pkg in @('@agentkey/cli', '@agentkey/mcp')) {
  383. if ($globalList -and ($globalList -match [regex]::Escape($pkg))) {
  384. Write-Info "Uninstalling global $pkg ..."
  385. & npm uninstall -g $pkg 2>$null | Out-Null
  386. if ($LASTEXITCODE -eq 0) { Write-Ok "Removed $pkg"; $removedAny = $true }
  387. else { Write-Warn2 "Could not remove $pkg" }
  388. }
  389. }
  390. if (-not $removedAny) {
  391. Write-Skip 'No global @agentkey/cli or @agentkey/mcp installed'
  392. }
  393. } else {
  394. Write-Skip 'npm not on PATH'
  395. }
  396. $npxCache = Join-Path $home2 '.npm\_npx'
  397. if (Test-Path $npxCache) {
  398. $hits = Get-ChildItem -Path $npxCache -Directory -Recurse -Depth 2 -ErrorAction SilentlyContinue |
  399. Where-Object { $_.Name -match 'agentkey' }
  400. if ($hits) {
  401. $hits | ForEach-Object { Remove-Item -Recurse -Force $_.FullName -ErrorAction SilentlyContinue }
  402. Write-Ok 'Cleared agentkey entries from npx cache'
  403. } else {
  404. Write-Skip 'No agentkey entries in npx cache'
  405. }
  406. } else {
  407. Write-Skip 'No npx cache directory'
  408. }
  409. # ── 7. Residual plugin registries ─────────────────────────────────────────
  410. Write-Step '7. Residual plugin registries'
  411. $regs = @(
  412. (Join-Path $home2 '.claude\plugins\installed_plugins.json'),
  413. (Join-Path $home2 '.claude\plugins\known_marketplaces.json'),
  414. (Join-Path $home2 '.claude\mcp-needs-auth-cache.json')
  415. )
  416. function Scrub-Agentkey($node) {
  417. $removed = 0
  418. if ($node -is [System.Management.Automation.PSCustomObject]) {
  419. $keys = @($node.PSObject.Properties.Name)
  420. foreach ($k in $keys) {
  421. if ($k -match 'agentkey') {
  422. $node.PSObject.Properties.Remove($k)
  423. $removed++
  424. } else {
  425. $removed += Scrub-Agentkey $node.$k
  426. }
  427. }
  428. } elseif ($node -is [System.Collections.IList]) {
  429. # Rebuild list without agentkey items
  430. $kept = New-Object System.Collections.ArrayList
  431. foreach ($item in $node) {
  432. $s = ($item | ConvertTo-Json -Depth 10 -Compress).ToLower()
  433. if ($s -match 'agentkey') {
  434. $removed++
  435. } else {
  436. $removed += Scrub-Agentkey $item
  437. [void]$kept.Add($item)
  438. }
  439. }
  440. return @{ removed = $removed; list = $kept }
  441. }
  442. return $removed
  443. }
  444. foreach ($reg in $regs) {
  445. if (-not (Test-Path $reg)) { continue }
  446. try {
  447. $obj = Get-Content $reg -Raw | ConvertFrom-Json
  448. } catch { continue }
  449. $res = Scrub-Agentkey $obj
  450. $n = if ($res -is [hashtable]) { $res.removed } else { $res }
  451. if ($n -gt 0) {
  452. ($obj | ConvertTo-Json -Depth 100) | Set-Content -Path $reg -Encoding UTF8
  453. Write-Ok "Cleaned $n entry/entries from $reg"
  454. }
  455. }
  456. # ── Done ──────────────────────────────────────────────────────────────────
  457. Write-Host ''
  458. Write-Host ' ✓ Uninstall complete.' -ForegroundColor Green -NoNewline
  459. if ($dshCleaned) { Write-Host ' Running DSH profiles watch removal; close legacy sessions or restart once if needed.' -ForegroundColor White }
  460. else { Write-Host ' Restart your agent to apply changes.' -ForegroundColor White }
  461. Write-Host ''
scripts/uninstall.sh · Bundled script · 500 lines · 4 findings marked
  1. #!/usr/bin/env bash
  2. #
  3. # AgentKey uninstaller for macOS and Linux
  4. # Usage: curl -fsSL https://agentkey.app/uninstall.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 4 on GitHub
  5. # curl -fsSL https://agentkey.app/uninstall.sh | bash -s -- --keep-marketplace
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 5 on GitHub
  6. # curl -fsSL https://agentkey.app/uninstall.sh | bash -s -- --force-in-repo
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 6 on GitHub
  7. #
  8. # Cleans up everything install.sh (and the legacy two-command flow) ever wrote:
  9. # 1. Skill files in every agent (via `skills remove` — fans across 40+ agents)
  10. # 2. MCP server entries (Claude Code / Claude Desktop / Cursor configs)
  11. # 3. Claude Code plugin + marketplace registrations (legacy plugin install path)
  12. # 4. Plugin / marketplace / npx caches
  13. # 5. Shell RC exports + CLAUDE.md sections (legacy)
  14. # 6. MCP stdio log
  15. set -euo pipefail
  16. KEEP_MARKETPLACE=false
  17. FORCE_IN_REPO=false
  18. SKIP_SKILL_REMOVE=false
  19. for arg in "$@"; do
  20. case "$arg" in
  21. --keep-marketplace) KEEP_MARKETPLACE=true ;;
  22. --force-in-repo) FORCE_IN_REPO=true ;;
  23. --skip-skill-remove) SKIP_SKILL_REMOVE=true ;;
  24. -h|--help)
  25. cat <<EOF
  26. AgentKey uninstaller (macOS / Linux)
  27. Usage:
  28. curl -fsSL https://agentkey.app/uninstall.sh | bash [-s -- OPTIONS]
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 31 on GitHub
  29. Options:
  30. --keep-marketplace Keep the Claude Code plugin marketplace registration
  31. --force-in-repo Allow running inside the AgentKey-Skill source repo
  32. --skip-skill-remove Skip 'npx skills remove' (only clean configs/caches)
  33. -h, --help Show this help
  34. EOF
  35. exit 0 ;;
  36. esac
  37. done
  38. # ── Colors ────────────────────────────────────────────────────────────────
  39. # Use $'...' so variables hold real ESC bytes (works in both printf and heredoc).
  40. if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
  41. BOLD=$'\033[1m'; SUCCESS=$'\033[38;2;0;220;150m'; INFO=$'\033[38;2;136;146;176m'
  42. WARN=$'\033[38;2;255;176;32m'; ERROR=$'\033[38;2;230;57;70m'
  43. MUTED=$'\033[38;2;110;118;132m'; NC=$'\033[0m'
  44. else
  45. BOLD=''; SUCCESS=''; INFO=''; WARN=''; ERROR=''; MUTED=''; NC=''
  46. fi
  47. info() { printf " ${INFO}›${NC} %s\n" "$*"; }
  48. ok() { printf " ${SUCCESS}✓${NC} %s\n" "$*"; }
  49. warn() { printf " ${WARN}!${NC} %s\n" "$*"; }
  50. skipped() { printf " ${MUTED}-${NC} %s\n" "$*"; }
  51. step() { printf "\n ${BOLD}%s${NC}\n" "$*"; }
  52. # ── Safety rail ──────────────────────────────────────────────────────────
  53. if [ -f ".claude-plugin/plugin.json" ] \
  54. && grep -q '"name"[[:space:]]*:[[:space:]]*"agentkey"' .claude-plugin/plugin.json 2>/dev/null \
  55. && ! $FORCE_IN_REPO; then
  56. printf "\n ${BOLD}AgentKey — Uninstall${NC}\n\n"
  57. printf " ${ERROR}Refusing to run inside the AgentKey-Skill source repo.${NC}\n"
  58. printf " Running here would wipe this repo's own .mcp.json and CLAUDE.md.\n"
  59. printf " Re-run with ${BOLD}--force-in-repo${NC} if you really mean it.\n\n"
  60. exit 2
  61. fi
  62. printf "\n ${BOLD}AgentKey — Uninstall${NC}\n"
  63. printf " ${MUTED}https://agentkey.app${NC}\n"
  64. # ── 1. Remove the skill via skills CLI ────────────────────────────────────
  65. step "1. Skill files"
  66. if $SKIP_SKILL_REMOVE; then
  67. skipped "Skipped (--skip-skill-remove)"
  68. elif ! command -v npx >/dev/null 2>&1; then
  69. warn "npx not found — skipping 'skills remove' (manual: npx skills remove agentkey -g)"
  70. else
  71. # `skills remove` takes the **skill name** (`agentkey`), not the repo path.
  72. # The CLI also exits 0 when nothing matches, so we inspect stdout instead.
  73. info "Running: npx -y skills remove agentkey -g -y"
  74. REMOVE_OUTPUT="$(npx -y skills remove agentkey -g -y 2>&1 || true)"
  75. if printf '%s\n' "$REMOVE_OUTPUT" | grep -q "Successfully removed"; then
  76. ok "Skill removed from detected agents"
  77. elif printf '%s\n' "$REMOVE_OUTPUT" | grep -q "No matching skills found"; then
  78. skipped "Not registered with 'skills' CLI (already removed or installed via plugin marketplace)"
  79. else
  80. warn "'skills remove' produced unexpected output — some agents may still have skill files"
  81. warn "Check manually: npx skills list -g"
  82. fi
  83. fi
  84. # ── 2. MCP config cleanup ────────────────────────────────────────────────
  85. step "2. MCP server entries"
  86. OS="$(uname -s)"
  87. # All known JSON MCP config paths across the 16 auto-supported agents. The
  88. # scrub logic is intentionally schema-agnostic — it walks the JSON tree and
  89. # drops any key named "agentkey" / "agentkey.app AgentKey" wherever it
  90. # finds it, so the same scrubber handles:
  91. # - mcpServers.agentkey (Claude Code, Desktop, Cursor, Gemini, Windsurf, Warp, Qwen, iFlow, Kimi, Kiro)
  92. # - projects.*.mcpServers (Claude Code's per-project shape)
  93. # - mcp.agentkey (OpenCode, Crush)
  94. # - amp.mcpServers.agentkey (Amp's flat dotted key)
  95. # Keep this list in sync with AGENT_REGISTRY in
  96. # AgentKey-Server/cli/src/lib/mcp-clients.ts.
  97. MCP_JSON_CONFIGS=(
  98. "$HOME/.claude.json" # Claude Code
  99. "$HOME/.cursor/mcp.json" # Cursor
  100. "$HOME/.gemini/settings.json" # Gemini CLI
  101. "$HOME/.qwen/settings.json" # Qwen Code
  102. "$HOME/.iflow/settings.json" # iFlow CLI
  103. "$HOME/.kimi/mcp.json" # Kimi CLI
  104. "$HOME/.kiro/settings/mcp.json" # Kiro CLI
  105. "$HOME/.codeium/windsurf/mcp_config.json" # Windsurf
  106. "$HOME/.warp/.mcp.json" # Warp
  107. "$HOME/.config/opencode/opencode.json" # OpenCode (mcp.<name>)
  108. "$HOME/.config/amp/settings.json" # Amp (amp.mcpServers.<name>)
  109. "$HOME/.config/crush/crush.json" # Crush (mcp.<name>)
  110. )
  111. if [ "$OS" = "Darwin" ]; then
  112. MCP_JSON_CONFIGS+=("$HOME/Library/Application Support/Claude/claude_desktop_config.json")
  113. else
  114. MCP_JSON_CONFIGS+=("$HOME/.config/Claude/claude_desktop_config.json")
  115. fi
  116. # TOML configs — handled separately because we can't parse TOML without a
  117. # library. We splice out `[mcp_servers.agentkey]` blocks via line-scan.
  118. MCP_TOML_CONFIGS=(
  119. "$HOME/.codex/config.toml" # Codex CLI
  120. )
  121. have_python() { command -v python3 >/dev/null 2>&1 || command -v python >/dev/null 2>&1; }
  122. py() { if command -v python3 >/dev/null 2>&1; then python3 "$@"; else python "$@"; fi; }
  123. if ! have_python; then
  124. warn "python not found — skipping JSON cleanup; edit these files manually:"
  125. for f in "${MCP_JSON_CONFIGS[@]}"; do [ -f "$f" ] && echo " $f"; done
  126. else
  127. for cfg in "${MCP_JSON_CONFIGS[@]}"; do
  128. if [ ! -f "$cfg" ]; then
  129. skipped "$(basename "$cfg") not found"
  130. continue
  131. fi
  132. RESULT=$(py - "$cfg" <<'EOF'
  133. import json, sys
  134. path = sys.argv[1]
  135. try:
  136. with open(path) as f: d = json.load(f)
  137. except Exception as e:
  138. print(f"ERROR: {e}"); sys.exit(0)
  139. # Schema-agnostic recursive scrub: drop any dict key whose name exactly
  140. # matches one of our known MCP server names (current + legacy). Covers every
  141. # dialect we write: mcpServers.agentkey, mcp.agentkey,
  142. # amp.mcpServers.agentkey, projects.X.mcpServers.agentkey, etc.
  143. # Exact-match (not substring) so we don't nuke unrelated user keys like
  144. # "agentkey-helper" or "my-agentkey-config".
  145. NAMES = {'agentkey', 'agentkey.app agentkey'}
  146. def scrub(obj):
  147. removed = 0
  148. if isinstance(obj, dict):
  149. for k in list(obj.keys()):
  150. if k.lower() in NAMES:
  151. del obj[k]; removed += 1
  152. else:
  153. removed += scrub(obj[k])
  154. elif isinstance(obj, list):
  155. for item in obj:
  156. removed += scrub(item)
  157. return removed
  158. removed = scrub(d)
  159. if removed:
  160. with open(path, 'w') as f:
  161. json.dump(d, f, indent=2)
  162. print(removed)
  163. EOF
  164. )
  165. if [ "$RESULT" = "0" ]; then
  166. skipped "No agentkey entry in $cfg"
  167. elif [[ "$RESULT" =~ ^[0-9]+$ ]]; then
  168. ok "Removed $RESULT entry/entries from $cfg"
  169. else
  170. warn "Failed to update $cfg: $RESULT"
  171. fi
  172. done
  173. fi
  174. # Codex TOML: splice out [mcp_servers.agentkey] blocks (bare + legacy quoted).
  175. # Bash-only — no Python dependency — because we never parse, only line-edit.
  176. for cfg in "${MCP_TOML_CONFIGS[@]}"; do
  177. if [ ! -f "$cfg" ]; then
  178. skipped "$(basename "$cfg") not found"
  179. continue
  180. fi
  181. if ! grep -qE '^\s*\[\s*mcp_servers\s*\.\s*(agentkey|"agentkey\.app AgentKey")\s*\]' "$cfg" 2>/dev/null; then
  182. skipped "No agentkey block in $cfg"
  183. continue
  184. fi
  185. # Line-scan: drop from our header line to the next [section] header or EOF.
  186. awk '
  187. BEGIN { skip = 0 }
  188. /^[[:space:]]*\[[[:space:]]*mcp_servers[[:space:]]*\.[[:space:]]*(agentkey|"agentkey\.app AgentKey")[[:space:]]*\][[:space:]]*$/ { skip = 1; next }
  189. /^[[:space:]]*\[[^]]+\][[:space:]]*$/ { skip = 0 }
  190. !skip { print }
  191. ' "$cfg" > "$cfg.tmp" && mv "$cfg.tmp" "$cfg"
  192. ok "Removed agentkey block from $cfg"
  193. done
  194. # DSH cleanup is marker-scoped so unrelated home/profile patches survive.
  195. DSH_ROOT="${DSH_HOME:-}"; [[ -n "$DSH_ROOT" && "$DSH_ROOT" == *[![:space:]]* ]] || DSH_ROOT="$HOME/.dsh"
  196. case "$DSH_ROOT" in "~"|"~/"*) DSH_ROOT="$HOME${DSH_ROOT#"~"}" ;; /*) ;; *) DSH_ROOT="$PWD/$DSH_ROOT" ;; esac
  197. DSH_CLEANED=false
  198. for cfg in "$DSH_ROOT/cordis.patch.yml" "$DSH_ROOT"/profiles/*/cordis.patch.yml; do
  199. [ -f "$cfg" ] || continue; grep -qE '^# agentkey:start([[:space:]]|$)' "$cfg" 2>/dev/null || { skipped "No AgentKey DSH block in $cfg"; continue; }; tmp="${cfg}.agentkey-uninstall.$$"
  200. if awk 'BEGIN{s=0;i=0} /^# agentkey:start([[:space:]]|$)/{if(s)i=1;s=1;next} /^# agentkey:end([[:space:]]|$)/{if(!s)i=1;else{s=0;next}} !s{print} END{if(s||i)exit 42}' "$cfg" > "$tmp"; then
  201. grep -q '^[[:space:]]*[^#[:space:]]' "$tmp" || printf '\n[]\n' >> "$tmp"
  202. chmod 600 "$tmp"; mv "$tmp" "$cfg"; DSH_CLEANED=true; ok "Removed AgentKey DSH block from $cfg"
  203. else
  204. rm -f "$tmp"; warn "Malformed AgentKey markers in $cfg — left unchanged"
  205. fi
  206. done
  207. LEGACY_DSH_PRESET="$DSH_ROOT/.agent-presets/agentkey"
  208. if [ -e "$LEGACY_DSH_PRESET" ] || [ -L "$LEGACY_DSH_PRESET" ]; then
  209. DSH_PRESET_BACKUP="${LEGACY_DSH_PRESET}.backup-$(date -u +%Y%m%dT%H%M%SZ)"; while [ -e "$DSH_PRESET_BACKUP" ]; do DSH_PRESET_BACKUP="${DSH_PRESET_BACKUP}-1"; done; mv "$LEGACY_DSH_PRESET" "$DSH_PRESET_BACKUP"; ok "Archived legacy DSH preset at $DSH_PRESET_BACKUP"; fi
  210. DSH_SETTINGS="$DSH_ROOT/settings.yaml"
  211. if [ -f "$DSH_SETTINGS" ]; then
  212. tmp="${DSH_SETTINGS}.agentkey-uninstall.$$"
  213. if awk 'BEGIN{p=0;r=0} /^[[:space:]]*agent-presets\.default:[[:space:]]*["\047]?agentkey["\047]?[[:space:]]*(#.*)?$/{r=1;next} /^[^[:space:]#][^:]*:[[:space:]]*/{p=($0~/^agent-presets:[[:space:]]*(#.*)?$/);print;next} p&&/^[[:space:]]+default:[[:space:]]*["\047]?agentkey["\047]?[[:space:]]*(#.*)?$/{r=1;next} {print} END{if(r)exit 10}' "$DSH_SETTINGS" > "$tmp"; then status=0; else status=$?; fi
  214. case "$status" in 0) rm -f "$tmp" ;; 10) mv "$tmp" "$DSH_SETTINGS"; ok "Removed legacy agent-presets default from $DSH_SETTINGS" ;; *) rm -f "$tmp"; warn "Could not clean legacy DSH settings in $DSH_SETTINGS" ;; esac
  215. fi
  216. # ── 2b. CLI-registered agents (droid / openclaw) ─────────────────────────
  217. # These two agents have no documented file-edit path; we registered them via
  218. # their own CLIs (`droid mcp add`, `openclaw mcp set`), so we have to use the
  219. # CLI to unregister. Best-effort — silently skip if the CLI isn't on PATH or
  220. # the entry was never created.
  221. step "2b. CLI-registered agents (droid / openclaw)"
  222. if command -v droid >/dev/null 2>&1; then
  223. if droid mcp remove agentkey >/dev/null 2>&1; then
  224. ok "Removed agentkey from droid (\`droid mcp remove\`)"
  225. else
  226. skipped "No agentkey entry in droid (or already removed)"
  227. fi
  228. else
  229. skipped "droid CLI not on PATH"
  230. fi
  231. if command -v openclaw >/dev/null 2>&1; then
  232. if openclaw mcp unset agentkey >/dev/null 2>&1; then
  233. ok "Removed agentkey from openclaw (\`openclaw mcp unset\`)"
  234. else
  235. skipped "No agentkey entry in openclaw (or already removed)"
  236. fi
  237. else
  238. skipped "openclaw CLI not on PATH"
  239. fi
  240. # ── 3. Claude Code plugin registrations (legacy) ─────────────────────────
  241. step "3. Claude Code plugin registrations (legacy)"
  242. if ! command -v claude >/dev/null 2>&1; then
  243. skipped "Claude Code CLI not on PATH — nothing to do here"
  244. else
  245. PLUGIN_LIST=$(claude plugin list 2>/dev/null || true)
  246. MARKETS=$(echo "$PLUGIN_LIST" | grep -oE 'agentkey@[a-zA-Z0-9_-]+' || true)
  247. if [ -z "$MARKETS" ]; then
  248. skipped "No agentkey plugin registered"
  249. else
  250. while IFS= read -r entry; do
  251. name="${entry%%@*}"
  252. info "Uninstalling $entry ..."
  253. if claude plugin uninstall "$name" --scope user 2>/dev/null; then
  254. ok "Removed $entry"
  255. else
  256. warn "Could not remove $entry — try: claude plugin uninstall $name --scope user"
  257. fi
  258. done <<< "$MARKETS"
  259. fi
  260. # Legacy MCP registration via `claude mcp`
  261. if claude mcp list 2>/dev/null | grep -q "^agentkey"; then
  262. info "Removing MCP server 'agentkey' via claude CLI ..."
  263. if claude mcp remove agentkey 2>/dev/null; then
  264. ok "MCP server removed"
  265. else
  266. warn "Could not remove MCP server via claude CLI"
  267. fi
  268. else
  269. skipped "No 'agentkey' MCP via claude CLI"
  270. fi
  271. # Marketplace entry
  272. if $KEEP_MARKETPLACE; then
  273. skipped "Marketplace removal skipped (--keep-marketplace)"
  274. else
  275. AGENTKEY_MARKETS=$(claude plugin marketplace list 2>/dev/null \
  276. | grep -B1 -A1 -E "(AgentKey-Skill|chainbase-labs/AgentKey-Skill|agentkey-skill|chainbase-labs/agentkey)" \
  277. | grep -oE '^ ❯ [a-zA-Z0-9_-]+' | awk '{print $2}' || true)
  278. if [ -z "$AGENTKEY_MARKETS" ]; then
  279. skipped "No AgentKey marketplace entry"
  280. else
  281. while IFS= read -r mkt; do
  282. info "Removing marketplace '$mkt' ..."
  283. if claude plugin marketplace remove "$mkt" 2>/dev/null; then
  284. ok "Removed marketplace '$mkt'"
  285. else
  286. warn "Could not remove marketplace '$mkt'"
  287. fi
  288. done <<< "$AGENTKEY_MARKETS"
  289. fi
  290. fi
  291. fi
  292. # ── 4. Plugin + marketplace caches ────────────────────────────────────────
  293. step "4. Plugin / marketplace caches"
  294. CACHE_HITS=()
  295. for d in "$HOME/.claude/plugins/cache"/agentkey \
  296. "$HOME/.claude/plugins/cache"/agentkey-skill \
  297. "$HOME/.claude/plugins/cache"/agentkey-*; do
  298. [ -d "$d" ] && CACHE_HITS+=("$d")
  299. done
  300. if [ -d "$HOME/.claude/plugins/marketplaces" ]; then
  301. for d in "$HOME/.claude/plugins/marketplaces"/*agentkey*; do
  302. [ -d "$d" ] && CACHE_HITS+=("$d")
  303. done
  304. fi
  305. if [ ${#CACHE_HITS[@]} -eq 0 ]; then
  306. skipped "No cache found"
  307. else
  308. for d in "${CACHE_HITS[@]}"; do
  309. rm -rf "$d" && ok "Removed $d"
  310. done
  311. fi
  312. # ── 5. Shell RC environment exports (legacy) ──────────────────────────────
  313. step "5. Shell environment exports (legacy)"
  314. changed=false
  315. for RC in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile"; do
  316. [ -f "$RC" ] || continue
  317. if grep -q "agentkey-env-start" "$RC" 2>/dev/null; then
  318. if have_python; then
  319. py - "$RC" <<'EOF'
  320. import re, sys
  321. p = sys.argv[1]
  322. c = open(p).read()
  323. n = re.sub(r'\n# agentkey-env-start.*?# agentkey-env-end', '', c, flags=re.DOTALL)
  324. if n != c: open(p, 'w').write(n)
  325. EOF
  326. ok "Cleaned agentkey env block from $RC"
  327. changed=true
  328. else
  329. warn "python not found — edit $RC manually (look for 'agentkey-env-start')"
  330. fi
  331. fi
  332. done
  333. $changed || skipped "No agentkey env block in any shell RC"
  334. # ── 6. CLAUDE.md cleanup (legacy) ─────────────────────────────────────────
  335. step "6. CLAUDE.md sections (legacy)"
  336. md_changed=false
  337. for CLAUDE_MD in "$HOME/.claude/CLAUDE.md" ".claude/CLAUDE.md" "CLAUDE.md"; do
  338. [ -f "$CLAUDE_MD" ] || continue
  339. grep -q "AgentKey\|agentkey\|AGENTKEY" "$CLAUDE_MD" 2>/dev/null || continue
  340. if have_python; then
  341. OUT=$(py - "$CLAUDE_MD" <<'EOF'
  342. import re, sys
  343. p = sys.argv[1]
  344. c = open(p).read()
  345. c2 = re.sub(r'\n# AgentKey\n.*?(?=\n# |\Z)', '', c, flags=re.DOTALL)
  346. c2 = re.sub(r'\n[^\n]*(\.agentkey|agentkey.*activation\.md|agentkey.*SKILL\.md)[^\n]*', '', c2, flags=re.IGNORECASE)
  347. if c2 != c:
  348. open(p, 'w').write(c2)
  349. print("CHANGED")
  350. else:
  351. print("NO_MATCH")
  352. EOF
  353. )
  354. if [ "$OUT" = "CHANGED" ]; then
  355. ok "Removed AgentKey section from $CLAUDE_MD"
  356. md_changed=true
  357. fi
  358. else
  359. warn "python not found — edit $CLAUDE_MD manually"
  360. fi
  361. done
  362. $md_changed || skipped "No removable AgentKey section in CLAUDE.md"
  363. # ── 7. npm / npx caches ───────────────────────────────────────────────────
  364. step "7. npm / npx caches"
  365. if command -v npm >/dev/null 2>&1; then
  366. _global_list="$(npm list -g --depth=0 2>/dev/null || true)"
  367. _removed_any=false
  368. # Sweep both the current package name and the legacy v0.x name so
  369. # users who installed before the @agentkey/mcp → @agentkey/cli rename
  370. # get a clean uninstall.
  371. for _pkg in "@agentkey/cli" "@agentkey/mcp"; do
  372. if echo "$_global_list" | grep -q "$_pkg"; then
  373. info "Uninstalling global $_pkg ..."
  374. if npm uninstall -g "$_pkg" >/dev/null 2>&1; then
  375. ok "Removed $_pkg"
  376. _removed_any=true
  377. else
  378. warn "Could not remove $_pkg — try: npm uninstall -g $_pkg"
  379. fi
  380. fi
  381. done
  382. if ! $_removed_any; then
  383. skipped "No global @agentkey/cli or @agentkey/mcp installed"
  384. fi
  385. else
  386. skipped "npm not on PATH"
  387. fi
  388. if [ -d "$HOME/.npm/_npx" ]; then
  389. NPX_HITS=$(find "$HOME/.npm/_npx" -maxdepth 3 -type d -iname "*agentkey*" 2>/dev/null || true)
  390. if [ -n "$NPX_HITS" ]; then
  391. echo "$NPX_HITS" | xargs rm -rf
  392. ok "Cleared agentkey entries from npx cache"
  393. else
  394. skipped "No agentkey entries in npx cache"
  395. fi
  396. else
  397. skipped "No ~/.npm/_npx directory"
  398. fi
  399. # ── 7b. AgentKey config dir (snooze/disable/telemetry state) ─────────────
  400. step "7b. AgentKey config directory"
  401. AGENTKEY_CFG="$HOME/.config/agentkey"
  402. if [ -d "$AGENTKEY_CFG" ]; then
  403. rm -rf "$AGENTKEY_CFG" && ok "Removed $AGENTKEY_CFG"
  404. else
  405. skipped "No $AGENTKEY_CFG directory"
  406. fi
  407. # ── 8. Residual artifacts ─────────────────────────────────────────────────
  408. step "8. Residual artifacts"
  409. # 8a. MCP stdio log (macOS only; Claude Desktop path)
  410. MCP_LOG_MAC="$HOME/Library/Logs/Claude/mcp-server-agentkey.log"
  411. if [ -f "$MCP_LOG_MAC" ]; then
  412. rm -f "$MCP_LOG_MAC" && ok "Removed $MCP_LOG_MAC"
  413. fi
  414. # 8b. Plugin registry JSONs — strip any agentkey-keyed entries
  415. if have_python; then
  416. for REG in "$HOME/.claude/plugins/installed_plugins.json" \
  417. "$HOME/.claude/plugins/known_marketplaces.json" \
  418. "$HOME/.claude/mcp-needs-auth-cache.json"; do
  419. [ -f "$REG" ] || continue
  420. RESULT=$(py - "$REG" <<'EOF'
  421. import json, sys
  422. p = sys.argv[1]
  423. try:
  424. with open(p) as f: d = json.load(f)
  425. except Exception: sys.exit(0)
  426. def scrub(obj):
  427. removed = 0
  428. if isinstance(obj, dict):
  429. for k in list(obj.keys()):
  430. if 'agentkey' in k.lower(): del obj[k]; removed += 1
  431. else: removed += scrub(obj[k])
  432. elif isinstance(obj, list):
  433. kept = []
  434. for item in obj:
  435. s = json.dumps(item).lower() if not isinstance(item, str) else item.lower()
  436. if 'agentkey' in s: removed += 1
  437. else: removed += scrub(item); kept.append(item)
  438. obj[:] = kept
  439. return removed
  440. n = scrub(d)
  441. if n:
  442. with open(p, 'w') as f: json.dump(d, f, indent=2)
  443. print(n)
  444. EOF
  445. )
  446. if [[ "$RESULT" =~ ^[0-9]+$ ]] && [ "$RESULT" -gt 0 ]; then
  447. ok "Cleaned $RESULT entry/entries from $REG"
  448. fi
  449. done
  450. fi
  451. # ── Done ──────────────────────────────────────────────────────────────────
  452. if $DSH_CLEANED; then
  453. printf "\n ${BOLD}✓ Uninstall complete.${NC} Running DSH profiles watch removal; close legacy sessions or restart once if needed.\n\n"
  454. else
  455. printf "\n ${BOLD}✓ Uninstall complete.${NC} Restart your agent to apply changes.\n\n"
  456. fi

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.