Hive MCP 命令行工具

hive-mcp-cli 是一个用于安装、配置并启动 hive-mcp 的命令行工具,为 Claude Code 等 MCP 客户端提供持久记忆、知识图谱、看板和集群协作功能。

  • by hive-agi
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 hive-agi/hive-mcp-cli

使用说明

hive-mcp-cli

The hive command: sets up hive-mcp on your machine and signs you in to your hive account. hive-mcp gives Claude Code persistent memory, a knowledge graph, kanban and swarm coordination.

Quick start

curl -fsSL https://hive-mcp.com/install.sh | sh    # 1. the hive CLI (10 seconds)
hive setup                                         # 2. everything else (about 5 minutes)
hive start                                         # 3. boot the backend (about a minute)

Install with curl -fsSL https://hive-mcp.com/install.sh | sh then hive setup. hive setup installs bb-mcp, publishes it at ~/.local/share/hive-mcp/bb-mcp, and registers hive with your MCP clients (Claude Code, Codex) through bb-mcp. Already have bb-mcp checked out somewhere? Run <that checkout>/bb-mcp setup: wherever bb-mcp lives becomes the reference. Verify with bb-mcp setup --check.

Open a new terminal, start claude (or codex) in any project, and hive is there. That is the free (FOSS) build, and it needs no account.

Registering by hand (any MCP client)

Point the client at the anchor, never at a checkout or a user-specific path:

{
  "mcpServers": {
    "hive": {
      "command": "${HOME}/.local/share/hive-mcp/bb-mcp/start-bb-mcp.sh"
    }
  }
}

No args: start-bb-mcp.sh takes the project from the client's working directory and the nREPL port from <project>/.nrepl-port, else 7910. Set BB_MCP_NREPL_PORT in env only for a non-default port. A client config without ${HOME} expansion gets the expanded absolute path of the anchor.

Subscribers add one more step:

hive login                  # opens your browser; sign in; you are done
hive addon add hive-carto   # any addon on your plan; then restart Claude Code

No keys to copy, no XML to paste.

What hive setup does, and what it needs

It runs on Linux (apt) and macOS (Homebrew). It asks for sudo once, to install packages.

  1. Clones hive-mcp, the backend, to ~/hive-mcp (HIVE_MCP_DIR overrides).
  2. Exports HIVE_MCP_DIR and BB_MCP_DIR in your shell rc file.
  3. Installs what is missing: Java 21, the Clojure CLI, Babashka, Docker with compose, and Git. On Linux it adds you to the docker group. A new terminal picks that up.
  4. Resolves the host's dependencies: the core plus the FOSS starter pack.
  5. Starts Chroma, the vector store, with Docker.
  6. Pulls the embedding model if Ollama is installed, and skips this otherwise.
  7. Installs bb-mcp and registers hive with your MCP clients. It reuses the bb-mcp already published at ~/.local/share/hive-mcp/bb-mcp, or clones bb-mcp to ${BB_MCP_DIR:-~/bb-mcp}, then runs <checkout>/bb-mcp setup --client all. bb-mcp setup owns registration: it publishes the anchor and points Claude Code (user scope) and Codex at ~/.local/share/hive-mcp/bb-mcp/start-bb-mcp.sh. An old entry that launched bin/hive-mcp-foss directly is replaced, and setup tells you so.

Every step checks first, so re-running hive setup is always safe.

MCP clients launch bb-mcp, a small Babashka server that talks to the hive-mcp JVM over nREPL (7910). bb-mcp never starts that JVM: hive start does, in the background (log in ~/.local/state/hive-mcp/backend.log); hive start --foreground keeps it in the terminal. It needs about a minute to boot.

You need Claude Code. These are optional:

  • Ollama, for semantic search over memory.
  • Emacs 28.1+, for the Emacs vessel (hive setup --emacs).
  • tmux with Python's libtmux, for headless lings.
  • clojure-lsp, clj-kondo and scc, for the code-intelligence addons.

Each missing one turns off that one feature. It never fails the setup.

Signing in

hive login works like gh auth login:

  • With a browser, it opens the sign-in page and waits for the redirect back to the CLI. You sign in the way you do on the web, including a second factor if your account has one.

  • Over ssh, or on a machine without a display, it prints a one-time code instead:

      First copy your one-time code: WDJB-MJHT
      Then open:                     https://auth.hive-mcp.com/realms/hive/device
    

    Open that URL on your laptop or phone, enter the code, and approve. The terminal continues. hive login --device forces this mode.

Once signed in, the CLI:

  1. keeps your session in the system keyring: GNOME Keyring or KWallet, the macOS Keychain, or the Windows Credential Manager. A machine without a keyring uses ~/.config/hive/credentials.json instead, mode 0600, and hive login says so.
  2. creates an artifact token for this machine only, named after its hostname. It writes the token to ~/.m2/settings.xml, which is what lets Maven download paid addons. The token appears in your dashboard, so you can revoke it there.
  3. prints who you are signed in as and what your plan includes.
hive auth status   # who is signed in, where the session is stored, what is set up
hive auth token    # a current access token, for scripts that call the store API
hive logout        # revokes this machine's token, removes it, ends the session

In CI, where no browser is available, pass a token you created in the dashboard: printf %s "$HIVE_ARTIFACT_TOKEN" | hive login --with-token. Setting HIVE_STORE_TOKEN overrides the session for store API calls.

Adding addons

hive addon search            # the whole shelf; `hive addon search graph` narrows it
hive addon show hive-carto   # what it does and needs, and whether your plan includes it
hive addon add hive-carto    # load it into your host

addon add writes the coordinate to ~/hive-mcp/local.deps.edn, your personal overlay. It is gitignored, and the launcher merges it over the starter pack at every boot. If you already wrote that file yourself, the command leaves it alone and prints the lines to add. After adding, restart Claude Code, or run /mcp and reconnect hive.

Updating

Your MCP clients launch bb-mcp through the anchor ~/.local/share/hive-mcp/bb-mcp, so an update is a fast-forward of the checkout it points at. bb-mcp prints one line on stderr when a newer release exists; then:

hive update --dry-run   # the plan: which checkout, which commands
hive update             # git fetch + fast-forward bb-mcp, then bb-mcp setup --check
hive update --all       # also the hive-mcp checkout ($HIVE_MCP_DIR, ~/hive-mcp)

It never stashes, rebases or switches branch for you. A checkout with local changes to tracked files, a detached HEAD, or no tracked branch is left alone, with the command that gets it unstuck. Restart your MCP clients afterwards (and hive start the backend again after --all).

Let Claude do it

The installer also teaches Claude Code the whole procedure. It installs two skills and a small setup MCP server. In Claude Code you can then say:

set up hive for me

I have a hive subscription, set up the paid addons

Claude runs hive setup, hive login and hive addon add for you. Your password and tokens never pass through the conversation: the sign-in happens in your browser.

When something is wrong

hive doctor          # every check, with the fix for each failure
hive doctor --fix    # applies the fixes it can
Symptom Fix
claude mcp list shows no hive bb-mcp setup --check, then ~/.local/share/hive-mcp/bb-mcp/bb-mcp setup (or re-run hive setup)
hive is listed but ✘ Failed to connect bb missing or the anchor broken: ~/.local/share/hive-mcp/bb-mcp/bb-mcp setup --check
hive tools fail with could not connect to 'localhost:7910' the backend is down: hive start, or hive start --foreground to read its log
permission denied on the docker socket open a new terminal; setup added you to the docker group
a paid addon will not resolve run hive auth status, then hive login again
hive login says the server does not recognise this CLI run hive store login and paste a token from the dashboard

Verifying the installer

Every binary is checked against a signed SHA256SUMS before it is made executable, and the installer prints which checks it managed. To read the script first, and check it against a second origin:

curl -fsSL https://hive-mcp.com/install.sh -o install.sh
curl -fsSL https://hive-mcp.com/install.sh.sha256    # served from our cluster, not GitHub
sha256sum -c install.sh.sha256
less install.sh && sh install.sh

sh -s -- --setup runs hive setup in the same pass. It is opt-in, because a script piped from the internet should not edit your shell config unless you ask it to. Verifying the install explains what each check proves.

With Go, instead of the installer:

go install github.com/hive-agi/hive-mcp-cli/cmd/hive@latest
go install github.com/hive-agi/hive-mcp-cli/cmd/hive-setup-mcp@latest
hive guide --install && claude mcp add hive-setup --scope user -- hive-setup-mcp

Command reference

Command Does
hive setup [--emacs] installs everything; registers hive through bb-mcp setup; safe to re-run
hive start [--foreground] boots the hive-mcp backend that bb-mcp talks to
hive update [--all] [--dry-run] fast-forwards bb-mcp (and hive-mcp) to its tracked branch; runs bb-mcp setup --check
hive login [--device | --with-token] signs in; creates this machine's artifact token
hive logout revokes and forgets this machine's credentials
hive auth status | token shows who is signed in; prints an access token
hive addon search | show | add | coord browses the store and loads an addon
hive addon skill [--owned] [--install] writes a Claude Code skill per addon
hive addon new <id> [--extends <other>] scaffolds your own addon
hive addon status shows what the host would mount, and why not
hive doctor [--fix] runs health checks
hive detect reports prerequisites and services, read-only
hive guide [--install] prints or installs the setup skills
hive store login [--check] pastes an artifact token by hand, or checks the wiring

Environment variables:

Variable Sets
HIVE_MCP_DIR where the host is checked out (~/hive-mcp)
BB_MCP_DIR where hive setup clones bb-mcp when none is published at the anchor (~/bb-mcp)
HIVE_NREPL_PORT the backend's nREPL port for hive start and hive doctor (7910)
HIVE_STORE_URL the store (https://store.hive-mcp.com)
HIVE_AUTH_ISSUER, HIVE_AUTH_CLIENT_ID the sign-in realm and client, for a dev realm
HIVE_CREDENTIAL_STORE keyring or file, to force a backend
HIVE_CONFIG_DIR where the session is kept (~/.config/hive)

hive-setup-mcp exposes these commands as MCP tools (hive_setup, hive_doctor, hive_addon_*, and so on). Its schemas are generated by Bonzai from each command's Mcp metadata.

Development

go test ./...                        # unit tests
test/auth/e2e.sh                     # hive login/logout against a real Keycloak 26 (docker)
test/vm/customer-journey.sh --dev    # a customer's first run on a fresh Ubuntu VM
  • test/auth/e2e.sh starts the Keycloak version production runs, with the hive-cli client configured as in k8s-agi/terraform/keycloak-hive-realm/clients-cli.tf. It also starts a stand-in store that enforces the real store's aud check. It then drives the real binary through both sign-in flows, token refresh, re-login and logout. A scripted browser fills in the Keycloak pages.
  • test/vm/customer-journey.sh needs VirtualBox, but no root. It installs Claude Code, runs install.sh and hive setup (which registers hive through bb-mcp setup), and checks claude mcp list from an unrelated project. It prints PASS or FAIL for each stage. HIVE_MCP_LAUNCHER swaps in a dev launcher, and test/vm/hive-vm drives the VM by hand.

How sign-in is built

internal/auth is stratified by the house pattern (CPPB, DDD, SOLID). Each layer is its own Go package, so the compiler enforces the layering:

Package Stratum Holds
auth/domain core value objects: Realm, Tokens, DeviceGrant, Account, ArtifactToken, Session
auth/policy promote (pure) every decision: method choice, PKCE, poll verdicts, offline fallback, error classes
auth/port protocol small interfaces: identity provider, callback, browser, credential store, accounts, and so on
auth/pipeline pipeline the Login, Logout, Status and AccessToken use cases, plus the sign-in flow registry
auth/adapter/* boundary Keycloak HTTP, the loopback listener, the keyring/file backend registry, the store API
internal/hive/wire.go composition root which adapter fills which port

Adding a sign-in method or a credential backend is a registration, never an edit. internal/auth/strata_test.go reads every package's imports and fails the build when a layer reaches past its stratum.

License

MIT