Load Research Cache
Check the research cache in .kuma/kuma.db (research_cache table). Found? Compare content hash vs current code. Fresh? Return cached result with confidence score.
Zero-setup MCP server that gives AI agents discipline — research before touching unfamiliar code, knowledge that persists across sessions, and a safety guard that catches mistakes.
Kuma is a safety-first context & orchestration engine that runs as an MCP server alongside your AI coding agent. Its job is simple: make sure the agent understands what it's about to change before it changes it.
Unlike other MCP tools that give agents more power (editing, searching, executing), Kuma gives agents discipline — a mandatory research pipeline, a knowledge graph of your codebase, impact analysis before every change, and a safety layer that catches mistakes.
Kuma works with any MCP-compatible AI agent: Claude Code, Cursor, Windsurf, Cline, Aider, OpenCode, Codex CLI, and 7 more.
npx -y @plumpslabs/kuma
That's it — zero configuration. The server starts, your agent connects, and Kuma auto-generates .kuma/init.md (behavioral rules) plus a native skill file for your agent.
# For all 13 supported agents
npx @plumpslabs/kuma init --all
# Or specific agents
npx @plumpslabs/kuma init --cursor --claude --aider
{
"mcpServers": {
"kuma": {
"command": "npx",
"args": ["-y", "@plumpslabs/kuma"]
}
}
}
Six principles guide every design decision in Kuma.
5 seconds slower but safe beats fast but business logic broken. Every operation has a safety net.
Agents must research, record, and validate before touching code. No direct edits without context.
Coarse-grained pipelines. One MCP call triggers multi-step deterministic flows — not micro-tools.
When significant changes happen, Kuma suggests recording decisions. Not silent auto-tracking.
Pipeline uses SQLite + graph + file operations. No LLM calls needed for core operations.
Documentation survives for humans AND future AI agents. Not just for the current session.
Kuma exposes 3 coarse-grained tools with 13 core actions — the agent picks an action, Kuma runs the internal workflow. Everything else was removed: the MCP schema rejects unknown actions.
| Action | Pipeline | Description |
|---|---|---|
init | Project brief | Lean project brief + session restore. Call first every session. |
research | 5-step pipeline | Cache → graph → scan → impact → decisions. Required before editing unfamiliar code. |
history | Cross-session trace | "Why is this file written this way" — gotchas, decisions, change log. |
flow | Domain flow | Read a recorded architecture flow (recorded via arch_flow). |
| Action | Description |
|---|---|
gotcha | Record bug/quirk — IMMEDIATELY when found. |
arch_flow | Record architecture flow (domain → hops, max 5 core files). |
decision | Record ADR-style decision — title + rationale + outcome. |
research_save | Save research findings to graph + research cache. |
search | Quick lookup of memory + knowledge graph. |
| Action | Description |
|---|---|
guard | Anti-pattern detection before risky edits. |
verify | Auto-verification — auto-detect runner, scoped tests. |
checkpoint | Labeled snapshot before risky work — the ONE rollback mechanism. |
rollback_label | Restore files from a checkpoint by label. |
The 5-step research pipeline is Kuma's core. It runs every time an agent calls kuma_context({ action: "research" }) — all in a single MCP call. No chaining. No guesswork.
Check the research cache in .kuma/kuma.db (research_cache table). Found? Compare content hash vs current code. Fresh? Return cached result with confidence score.
Query SQLite knowledge graph for all nodes and edges related to the scope. Identify entry points, dependencies, and flow paths.
Graph traversal to find references, affected files, test coverage, and API routes. "If I change X, what breaks?"
Check .kuma/memories/ and failure knowledge base. Surface previous decisions, known issues, and recurring patterns.
Validate policy compliance, active locks, and risk level. Return structured result with confidence score.
A typical Kuma-powered session follows this pattern:
# 1. Start session — understand the project
kuma_context({ action: "init", goal: "add password reset" })
# 2. Research before touching code
kuma_context({ action: "research", scope: "auth" })
# 3. Agent edits using native tools (not Kuma)
# 4. Save what you learned
kuma_memory({ action: "research_save", scope: "auth", confidence: 0.85 })
# 5. Record significant decisions
kuma_memory({
action: "decision",
title: "Use JWT for password reset tokens",
context: "Need stateless tokens that expire in 15min",
rationale: "No session store needed, mobile-compatible",
outcome: "Implemented JwtPasswordResetService"
})
# 6. Safety guard — verify nothing broke
kuma_safety({ action: "guard", guardGoal: "add password reset" })
# 7. Snapshot before risky work (the ONE rollback mechanism)
kuma_safety({ action: "checkpoint", label: "pre-password-reset" })
| Feature | Description |
|---|---|
| Knowledge Graph | SQLite-backed (pure WASM). Nodes + edges + sessions. FTS5 full-text search. |
| Research Pipeline | 5-step deterministic flow: cache → staleness → graph → impact → decisions. |
| Impact Analysis | Graph traversal tells you exactly what breaks before you change it. |
| Confidence Scoring | Age + file existence + edge weight → 0-1 confidence per research record. |
| Auto-Inject | Shadow memory injected before edits — gotchas, decisions, history. |
| Selective Undo | Session-level change tracking. Undo specific changes without affecting others. |
| Safety Guard | Anti-patterns, drift detection, tool-loop prevention, unresolved failure check. |
| Safety Policy | never_touch, require_review, block_commands via YAML. |
| Safety Audit | Every tool call recorded in SQLite. Queryable via audit. |
| Decision Memory | ADR-style: context → options → rationale → outcome. Trigger-based. |
| Session Memory | Real-time state: modified files, failures, goal progress, tool history. |
| Kuma Studio | Web-based dashboard with knowledge graph visualization, efficiency metrics, and activity tracking. |
| Arch Flow Anchors | feature_domain nodes anchor architecture flows with owns edges to files. |
| Session Memory | Track tool calls, recordings, and efficiency per session with enforcement. |
| Guard System | Real-time monitoring with blocking warnings for anti-patterns and missing recordings. |
| Checkpoint/Rollback | Atomic snapshots before major refactors with selective restore. |
| Policy-as-Code | Configurable safety rules in YAML for never_touch, require_review, and block_commands. |
| 15+ Agent Support | Claude Code, Cursor, Windsurf, Cline, Aider, OpenCode, Codex CLI, Zed, and more. |
Kuma's safety layer sits between the AI agent and your filesystem. Every operation is checked, logged, and auditable.
| Feature | Description |
|---|---|
| Anti-Pattern Detection | Script patching, bash grep, shell obfuscation, unsafe patterns. |
| Drift Detection | Edits made without corresponding tests — flagged and logged. |
| Tool-Loop Prevention | Same tool called 4+ times in last 10 calls triggers circuit breaker. |
| Policy Enforcement | YAML policy file: never_touch, require_review, block_commands. |
| Path Validation | All operations locked to project directory. System dirs protected. |
| Safety Audit | Every tool call recorded in SQLite safety_audit table. |
| Confidence Scoring | 0-1 confidence per research record based on age, file existence, edge weight. |
Kuma provides one rollback mechanism — labeled snapshots. Take a checkpoint before risky work, restore by label if something breaks:
# Snapshot before a risky refactor
kuma_safety({ action: "checkpoint", label: "pre-refactor-auth" })
# Restore if something breaks
kuma_safety({ action: "rollback_label", label: "pre-refactor-auth" })
# Label not found? Kuma lists the available labels
Snapshots capture the SQLite graph + referenced files. If a label isn't found, Kuma lists what's available so you never restore blind.
Kuma injects "where is this file fragile and why is it written this way" right before the agent touches it — zero extra steps:
# Claude Code hooks (auto-installed via `kuma init --claude`)
kuma hook pre-edit # injects gotchas + decisions + history before edits
kuma hook pre-bash # injects command-triggered gotchas
# Cursor (globs rules, auto-apply on file open)
.cursor/rules/kuma-gotchas/*.mdc
| Guard | Description |
|---|---|
| Freshness (F3) | Gotchas validated via content hash — stale ones excluded from inject. |
| Dedupe (I5) | Same file not re-injected within 15 minutes. |
| Loop Capture (I3) | 4+ edits within 30 min auto-records a low-severity gotcha. |
| Budget (F4) | Max ~400 tokens per inject — never a dump. |
| Verify Hint (I6) | Suggests kuma_safety verify after editing gotcha'd files. |
Kuma stores per-project data in .kuma/:
.kuma/
├── kuma.db # SQLite knowledge graph (WASM) — nodes, edges, research cache
├── init.md # Behavioral rules (generated by `kuma init`)
├── memory.json # Session state + metrics (auto)
├── auto-gotcha.json # Self-learning loop state (auto)
├── policy.yml # OPTIONAL safety policy — only read if you create it
├── KNOWN_GOTCHAS.md # Gotchas (human-readable layer)
├── ARCHITECTURE_FLOW.md # Recorded flows (human-readable layer)
├── memories/ # Decision log markdown
│ └── decisions.md # ADR-style architecture decisions
└── checkpoints/ # Atomic snapshots (label/ with kuma.db + files/)
Full API reference available in docs/api.md.
| Parameter | Type | Description |
|---|---|---|
action | "init" | "research" | "history" | "flow" | Action to perform |
scope | string? | Research scope (e.g. "auth") |
target | string? | File/domain for history/flow |
goal | string? | Current goal |
| Parameter | Type | Description |
|---|---|---|
action | "gotcha" | "arch_flow" | "decision" | "research_save" | "search" | Action to perform |
scope | string? | Scope for research_save/search |
query | string? | Search query |
content | string? | Content for research_save |
record | string? | JSON record string |
confidence | number (0-1)? | Confidence score |
trigger_command | string? | Gotcha trigger shell command |
title | string? | Decision title |
context | string? | Decision context |
rationale | string? | Decision rationale |
outcome | string? | Decision outcome |
limit | number? | Result limit |
description | string? | Gotcha workaround |
status | string? | Gotcha severity (low|medium|high|critical) |
| Parameter | Type | Description |
|---|---|---|
action | "guard" | "verify" | "checkpoint" | "rollback_label" | Action to perform |
guardGoal | string? | Goal for guard check |
guardGoal | string? | Goal for guard check |
scope | string? | Scope for verify (tests to run) |
label | string? | Checkpoint label / rollback target |
force | boolean? | Force bypass cache for verify |
scope | string? | Scope for verify/ast/validate |
since | number? | Timestamp filter for audit |
label | string? | Checkpoint label |
description | string? | Checkpoint description |
Kuma is memory & safety, not a code manager. The agent uses its own native tools for editing, searching, and execution.
| Tool | Core Actions | Purpose |
|---|---|---|
kuma_context | init, research, history | Load project context, understand unfamiliar code |
kuma_memory | gotcha, decision, arch_flow, research_save | Persistent knowledge that saves future sessions |
kuma_safety | guard, verify | Pre-risk check, post-edit verification |
| Feature | Description |
|---|---|
| Kuma Studio | Web-based dashboard with knowledge graph visualization, efficiency metrics, and activity tracking. |
| Arch Flow Anchors | feature_domain nodes anchor architecture flows with owns edges to files. |
| Guard System | Real-time monitoring with blocking warnings for anti-patterns and missing recordings. |
| Shadow Injection | Gotchas injected before edits via hooks — zero token waste when clean. |
| Checkpoint/Rollback | Atomic snapshots before major refactors with selective restore. |
| Knowledge Graph | SQLite + FTS5 full-text search with derived flow cache. |
| Feature | Kuma | agentmemory | PMB | PLUR | Memex |
|---|---|---|---|---|---|
| Research Protocol (required) | ✅ | ❌ | ❌ | ❌ | ❌ |
| Safety Policy | ✅ | ❌ | ❌ | ❌ | ❌ |
| Selective Undo | ✅ | ❌ | ❌ | ❌ | ❌ |
| Coarse-Grained Pipeline | ✅ | ❌ | ❌ | ❌ | ❌ |
| Impact Analysis | ✅ SQLite | ❌ | ❌ | ❌ | 🔶 Neo4j+Gemini |
| Local-First | ✅ SQLite WASM | ✅ | ✅ | ✅ | ❌ Needs Docker |
| Auto Memory | 🔶 Trigger-based | ✅ Auto | ❌ | ✅ | ✅ |