@aivm/brain
v0.3.4
Published
AIVM Brain — one-command install for the governed MCP brain (npx @aivm/brain init).
Maintainers
Readme
@aivm/brain
One-command install for the governed MCP brain. Registers the AIVM Brain MCP server with your agent host (Claude Desktop / Claude Code / Cursor) so any MCP-speaking agent reaches your company brain only through AIVM's governed tools — identity is server-derived, every call is policy-checked and recorded.
Make every agent work through Brain — in 3 lines
withBrainMemory wraps any async agent handler so it recalls governed,
ACL-filtered context before the call and records the turn to the
tamper-evident ledger after — zero memory code in your function body.
import { AivmBrainClient, withBrainMemory } from "@aivm/brain";
const client = new AivmBrainClient({ baseUrl: "https://brain.aivm.io", machineToken: process.env.AIVM_KEY });
const agent = withBrainMemory(async ({ question }) => callYourLLM(question), { client });
const out = await agent({ question: "What's our refund policy?" });
// out.__brain.recall.recallEntry.seq + out.__brain.traceEntry.seq — every turn proven in the ledger.A denied recall never throws (empty context, the deny is still recorded); a
trace-write failure never breaks the agent (surfaced on __brain.traceError).
Toggle with withMemory / saveTraces / memoryQueryFixed / session.
Install
npx @aivm/brain initinit:
- detects your installed MCP host(s) and idempotently patches the host's
MCP config to register the
aivm-brainserver (a re-run never duplicates the entry, and never touches your other servers); - opens the SSO sign-in in your browser (no raw token to paste — the short-lived session is bound server-side);
- writes a resumable install state to
~/.aivm/brain-install.json.
npx @aivm/brain init --host claude-code # target a specific host
npx @aivm/brain init --agent-id erc8004:84532:0x… # headless / agent path (no SSO)
npx @aivm/brain init --brain-url https://brain.acme.com
npx @aivm/brain init --remove # unregister the server
npx @aivm/brain status # print the install stateThe config the installer writes carries only public references (the brain URL, your public agent/tenant id) — never a signing key or session token, so the config is safe to share or commit.
SDK (thin client)
import { AivmBrainClient } from "@aivm/brain";
const brain = new AivmBrainClient({ baseUrl: "https://brain.acme.com", sessionCookie });
const answer = await brain.search("What's our Q3 logistics SLA?");The SDK never re-implements auth or policy — it carries your session/agent credential and the server runs the full governed spine.
What this is / isn't
This package owns the install + config + thin SDK. The onboarding state
machine, progress streaming, and the Living-Brain visualization are the broader
SUR-02 / SUR-03 surfaces. The governed stdio server it registers lives in the
Brain repo (scripts/mcp-server.ts).
