Skip to main content
Glama

hive ๐Ÿ

A shared brain for Claude Code and its sub-agents (MCP server + CLI).

Agents share state, not conversations: a fresh agent boots with a ~350-token compiled working set instead of re-reading 30k tokens of files and transcripts. Decisions survive across sessions and days, sub-agents inherit each other's results (never their chat logs), and 50 parallel agents can write without clobbering each other.

Golden rule: never make an agent pay tokens to read information it doesn't need โ€” or pay twice for the same information.

Full design: docs/PLAN.md.


Install (global, like any CLI)

npm install -g hive-mcp

Or from source:

git clone https://github.com/HusseinTaha/hive-mcp.git && cd hive-mcp
npm install && npm run build
npm install -g .

Now hive works from anywhere. Data lives in one file: ~/.hive/ctx.db (an existing ~/.sharedctx/ctx.db from older versions is adopted automatically).

Related MCP server: LightRAG Code Brain MCP

Set up a project (once per repo)

cd your-project
hive init

This does three things:

  1. .mcp.json โ€” registers the hive MCP server, giving every agent five tools (below).

  2. .claude/settings.json โ€” wires three hooks:

    • SessionStart โ†’ injects a <800-token bootstrap, so every session starts already knowing the project

    • SubagentStop โ†’ commits each sub-agent's final report to shared memory automatically

    • PreCompact โ†’ snapshots state before Claude Code compacts, so nothing is lost mid-session

  3. CLAUDE.md โ€” adds the one-line norm: bootstrap with ctx_get, save results with ctx_commit.

Restart Claude Code afterwards so it picks up the config.

Daily use

You mostly don't do anything โ€” that's the point. The hooks bootstrap every session and capture every sub-agent's results. Your part is telling Claude things worth remembering, in plain language:

  • "Commit to shared memory: we're using PostgreSQL because we need transactions."

  • "Save the decision that access tokens expire in 15 minutes."

  • "Check shared memory before proposing a database."

And when you come back tomorrow, a new session already knows all of it.

What agents get (the 5 MCP tools)

Tool

What it does

ctx_get

The working set: objective, current tasks, blockers, hot decisions, recent changes, topic index โ€” compiled to a budget (~350โ€“800 tok). Pass since=<last CURSOR> on later calls to get only changes (~15โ€“100 tok). topic=auth drills into one topic.

ctx_search

BM25 search over everything ever stored, ~40 tok/hit with [e<id>] provenance refs. Zero local hits โ†’ labeled results from your other projects ([proj-a/e12] โ€ฆ).

ctx_commit

Save results: what changed, decisions (key/value/reason), facts, open questions, task updates. Hard size caps โ€” a commit is a telegram, not a memoir.

ctx_task

Lease-based task board: claim / release / complete. Two agents can never hold the same task; stale leases (30 min) are reclaimable; complete requires evidence.

ctx_compile

A bespoke context pack for one task description โ€” relevance-ranked, so cold facts matching the task resurface and hot-but-unrelated ones drop.

What a bootstrap looks like

== acme-api @ a3f9c21 ยท CURSOR: 412 ==
OBJECTIVE: Ship v1 auth
NOW: refresh-token rotation (task#12, owner: backend-2)
BLOCKED: none
DECISIONS: db=PostgreSQL(relational+tx) | auth=JWT(15m access) | api=REST
CHANGED: login endpoint impl (backend-1, 2h ago, ev: tests/auth โœ“)
OPEN: rate-limit login?
โš  VERIFY: 'api routes complete' written @ b2e11f0 (HEAD moved)
TOPICS: auth(9k) db(6k) api-contracts(7k)
MORE: d:cors ยท q:session-invalidation โ€” pull via topic= or ctx_search

~350 tokens replacing a 30k-token history dump. Superseded decisions never appear here, but stay searchable forever โ€” that's what stops agent #7 from re-proposing MongoDB.

CLI reference

hive init                          wire up .mcp.json + hooks + CLAUDE.md in cwd, seed DB
hive status   [--project P] [--role R] [--budget N] [--topic T] [--since N]
                                   print the compiled working set (what agents see)
hive stats    [--project P]        context-spend telemetry per tool + est. savings
hive distill  [--project P]        heat decay + working-set pressure valve (also runs
                                   automatically every ~25 events)
hive compress [--project P] [--model M] [--dry-run]
                                   model-assisted fact compression via the claude CLI;
                                   originals kept in supersede chains
hive dump     [--project P]        raw append-only event log as JSON lines
hive bootstrap                     alias of status (used by the SessionStart hook)

Environment: HIVE_DB overrides the DB path; HIVE_PROJECT overrides the project key (default: git-root basename). Legacy SHAREDCTX_* names still work.

Why it saves ~90%+ of context tokens

Naive shared-history

hive

Tool schemas

~2,000 (10 verbose tools)

~840 (5 terse tools, CI-guarded)

Bootstrap

20kโ€“80k transcript / file re-reads

~350โ€“800 (hook-injected)

Refresh checks

full re-dump each time

~15โ€“100 (cursor deltas)

Handoff

poisons the next agent

~200-tok structured commit

Under the hood: append-only SQLite event log (WAL โ€” 50 parallel writers, zero conflicts), facts with supersede-chains (nothing is ever deleted), provenance + git-drift โš  VERIFY flags on volatile facts, evidence-gated completion, and a distiller that keeps the hot working set โ‰ค ~1,500 tokens no matter how much knowledge accumulates.

Development

npm test          # 39 tests: behavior, eval harness (50k-token seeded project),
                  # multi-process stress (20 writers / 12-way lease race), schema-token guard
npm run build     # tsc โ†’ dist/
npm install -g .  # reinstall the global CLI after changes

Roadmap M0โ€“M4 from docs/PLAN.md is complete. Remaining work is field tuning: use it on real projects and let hive stats + the eval harness drive ranking changes.

Available Tools

5 tools
ctx_commitC

Save compact results before finishing; caps enforced.

ParametersJSON Schema
NameRequiredDescriptionDefault
nextNo
agentYes
factsNo
sinceNo
tasksNo
changedYes
projectNo
evidenceNo
decisionsNo
questionsNo

TDQS

C2.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. "Caps enforced" is a genuine hint that limits/truncation apply, but it is undefined โ€” no cap values, no behavior on overflow, no statement of whether prior context is replaced or merged, no auth requirements, and no idempotency info for a 10-parameter mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

At eight words it is front-loaded and wastes no filler, but this is under-specification masquerading as conciseness โ€” the brevity strips information an agent needs for a complex 10-parameter write rather than trimming redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Ten parameters, two required, zero schema descriptions, no annotations, no output schema, and an eight-word description leave the agent without enough to call this correctly or understand its effects. The definition is far too thin for the tool's complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 10 parameters, and the description adds no parameter meaning whatsoever โ€” agent, changed, facts, tasks, decisions, questions, since, next, project, and evidence are all unexplained in both places. "Caps enforced" is the only tangential hint and is too vague to compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a verb ("Save") and a loose resource ("compact results"), so an agent can infer this persists something before ending a session. However, "compact results" is jargon that doesn't map cleanly to the schema's facts/tasks/decisions/questions structures, and nothing distinguishes it from ctx_task or ctx_compile beyond the vague write implication.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Before finishing" gives a real timing trigger, implying this is the terminal/persist step of a session. But no alternatives are named and there is no when-not guidance, so the sibling relationship with ctx_get/ctx_search/ctx_task/ctx_compile is left entirely to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ctx_compileD

Context pack for one task.

ParametersJSON Schema
NameRequiredDescriptionDefault
roleNo
taskYes
budgetNo
projectNo

TDQS

D1.3/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure, and it discloses nothing. It does not state whether the operation is read-only, whether the budget parameter caps output, what side effects exist, or what permissions are needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single fragment is short but this is under-specification rather than effective conciseness. There is no front-loaded statement of action or outcome for the agent to anchor on.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a four-parameter tool with no annotations, no output schema, and no parameter descriptions, the definition leaves the agent with nothing to determine behavior or required inputs beyond the schema's field names. It is fundamentally incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across four parameters (role, task, budget, project), and the description explains none of them. The agent cannot learn what 'budget' constrains or how 'role' affects the compiled pack.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description is a noun phrase ('Context pack for one task') rather than a verb+resource statement, so it does not say what the tool actually does (compile/build a context window). It gives no differentiation from siblings like ctx_get, ctx_search, or ctx_task.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no when-to-use guidance, no exclusions, and no mention of alternatives. Nothing tells the agent when ctx_compile should be chosen over ctx_get, ctx_search, or ctx_task.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ctx_getB

Shared project context. Call at start; pass since= later for deltas. topic= drills in.

ParametersJSON Schema
NameRequiredDescriptionDefault
roleNo
sinceNo
topicNo
budgetNo
projectNo

TDQS

B3.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations and no output schema, the description carries the full load, and it does disclose meaningful behavior: since returns deltas relative to a cursor and topic drills in. It says nothing about auth/permissions, result format, budget behavior, or whether the call is read-only, leaving real gaps for a context-fetch tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three telegraphic fragments, front-loaded with the resource and the when-to-call guidance; nothing is redundant. It borders on under-specification rather than excess, so it is tight but not wasteful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 5-parameter tool with 0% schema coverage, no annotations, and no output schema, the description should explain role/budget/project and the return shape. It covers only since and topic, leaving the agent guessing on the majority of the surface.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 5 parameters, so the description must compensate and only partially does: it explains since (cursor for deltas) and topic (drill in) but says nothing about role (an enum with 6 values), budget, or project. Three of five parameters are undocumented in both the schema and the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

"Shared project context" names the resource but supplies no verb, so the agent must infer that this is a read/retrieval call (the name ctx_get and "Call at start" hint at it). It does not differentiate this tool from siblings like ctx_search or ctx_compile, so it lands at minimum-viable rather than clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete timing guidance ("Call at start") and conditional behavior ("pass since=<last CURSOR> later for deltas"), which tells the agent exactly when and how to re-invoke. It stops short of naming alternatives (ctx_search, ctx_commit) or stating when *not* to use it, so it is clear context without exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ctx_taskC

Claim|release|complete a task; complete needs evidence.

ParametersJSON Schema
NameRequiredDescriptionDefault
agentYes
actionYes
projectNo
task_idYes
evidenceNo

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden, yet it says nothing about what claiming does (locking, exclusivity, conflicts), whether release undoes a claim, what recovery follows a failed complete, or any permission requirements. 'complete needs evidence' is the only real behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely compact and front-loaded with the action verbs, so no sentence is wasted. However, at this level of compression for a 5-parameter mutating tool the terseness shades into under-specification.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

A concurrency-sensitive task-mutation tool with 5 params, zero schema descriptions, no annotations, and no output schema needs substantially more than 8 words. An agent cannot tell what a successful claim returns or how conflicts are surfaced.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 5 parameters, so the description must compensate, and it only partially does. It implies the action enum values and flags evidence for complete, but says nothing about the required agent or task_id, nor about the optional project.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names three specific verbs (claim, release, complete) against one resource (a task), which is enough to distinguish it from read-oriented siblings like ctx_get/ctx_search. The pipe-delimited form and lack of any scope statement keep it from a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The only guidance is that 'complete' requires evidence, which is a precondition rather than a when-to-use statement. It never says when to claim vs. release, or how this relates to the mutation-flavored sibling ctx_commit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.1.3
    • First observedctx_commit
    • First observedctx_compile
    • First observedctx_get
    • First observedctx_search
    • First observedctx_task

TDQS

C2.5/5.0

Scored across 5 tools

Disambiguation4/5

Most tools have clearly distinct purposes: get context, search memory, commit results, manage tasks, compile context pack. However, ctx_get and ctx_search both retrieve shared information, which could cause confusion for an agent unfamiliar with the system.

Naming Consistency4/5

All tools share the 'ctx_' prefix and mostly follow a verb-noun pattern (get, search, commit, compile). The exception is ctx_task, which uses a noun instead of a verb, creating a minor inconsistency.

Tool Count5/5

Five tools is well-scoped for a shared context and task management server. Each tool has a clear role and the set is neither too thin nor too heavy.

Completeness3/5

The surface covers retrieving context, searching, committing results, managing task states, and compiling context packs. However, there is no tool to create tasks, list tasks, or update/delete context, which are notable gaps for a collaborative context system.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Persistent shared memory for AI coding agents. Stores facts as entity/key/value triples with hybrid semantic search, task checkpoints, and conflict resolution โ€” shared across Claude Code, Codex CLI, and GitHub Copilot.
    16
    235 npm
    5
    AGPL 3.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Persistent, shared memory for Claude across sessions and clients (Code, Desktop, Cowork) โ€” deterministic diff reads, checkpoints, cross-client task handoff, and project-wide search. 100% local and deterministic, no API keys, no LLM summarization.
    4
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Acts as a persistent memory and cross-tool shared context store, and builds a queryable codebase knowledge graph to slash token usage via structural answers.
    9
    13 npm
    25
    MIT