Kuma Kumav2.4.3

KumaSafety-first context & orchestration engine for AI coding agents

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.

MCP Server SQLite Graph 3 Tools 13 Agents MIT License Node 18+ Zero Infra
$npx -y @plumpslabs/kuma
Quick Start The Philosophy

#Overview

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.

🧠
Think of it this way: your AI agent is the surgeon. Kuma is the pre-op checklist, the patient history, the X-ray, and the post-op report — all in one.

#Quick Start

Run the MCP server

bash
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.

Generate agent config (optional)

bash
# For all 13 supported agents
npx @plumpslabs/kuma init --all

# Or specific agents
npx @plumpslabs/kuma init --cursor --claude --aider

Add to your MCP client

json
{
  "mcpServers": {
    "kuma": {
      "command": "npx",
      "args": ["-y", "@plumpslabs/kuma"]
    }
  }
}

#Philosophy

Six principles guide every design decision in Kuma.

🛡️

Safety over Speed

5 seconds slower but safe beats fast but business logic broken. Every operation has a safety net.

🔬

Research First

Agents must research, record, and validate before touching code. No direct edits without context.

📦

1 Call = 1 Workflow

Coarse-grained pipelines. One MCP call triggers multi-step deterministic flows — not micro-tools.

📝

Trigger-based Docs

When significant changes happen, Kuma suggests recording decisions. Not silent auto-tracking.

🔗

Deterministic

Pipeline uses SQLite + graph + file operations. No LLM calls needed for core operations.

Long-term Continuity

Documentation survives for humans AND future AI agents. Not just for the current session.

#3 Coarse-Grained Tools

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.

🧠 kuma_context — Context & Research

ActionPipelineDescription
initProject briefLean project brief + session restore. Call first every session.
research5-step pipelineCache → graph → scan → impact → decisions. Required before editing unfamiliar code.
historyCross-session trace"Why is this file written this way" — gotchas, decisions, change log.
flowDomain flowRead a recorded architecture flow (recorded via arch_flow).

📝 kuma_memory — Knowledge Recording

ActionDescription
gotchaRecord bug/quirk — IMMEDIATELY when found.
arch_flowRecord architecture flow (domain → hops, max 5 core files).
decisionRecord ADR-style decision — title + rationale + outcome.
research_saveSave research findings to graph + research cache.
searchQuick lookup of memory + knowledge graph.

🛡️ kuma_safety — Safety & Verification

ActionDescription
guardAnti-pattern detection before risky edits.
verifyAuto-verification — auto-detect runner, scoped tests.
checkpointLabeled snapshot before risky work — the ONE rollback mechanism.
rollback_labelRestore files from a checkpoint by label.

#Research Pipeline

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.

01

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.

02

Graph Query

Query SQLite knowledge graph for all nodes and edges related to the scope. Identify entry points, dependencies, and flow paths.

03

Impact Analysis

Graph traversal to find references, affected files, test coverage, and API routes. "If I change X, what breaks?"

04

Decision & Failure Lookup

Check .kuma/memories/ and failure knowledge base. Surface previous decisions, known issues, and recurring patterns.

05

Safety Check

Validate policy compliance, active locks, and risk level. Return structured result with confidence score.

#Workflow

A typical Kuma-powered session follows this pattern:

text
# 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" })

#Features

FeatureDescription
Knowledge GraphSQLite-backed (pure WASM). Nodes + edges + sessions. FTS5 full-text search.
Research Pipeline5-step deterministic flow: cache → staleness → graph → impact → decisions.
Impact AnalysisGraph traversal tells you exactly what breaks before you change it.
Confidence ScoringAge + file existence + edge weight → 0-1 confidence per research record.
Auto-InjectShadow memory injected before edits — gotchas, decisions, history.
Selective UndoSession-level change tracking. Undo specific changes without affecting others.
Safety GuardAnti-patterns, drift detection, tool-loop prevention, unresolved failure check.
Safety Policynever_touch, require_review, block_commands via YAML.
Safety AuditEvery tool call recorded in SQLite. Queryable via audit.
Decision MemoryADR-style: context → options → rationale → outcome. Trigger-based.
Session MemoryReal-time state: modified files, failures, goal progress, tool history.
Kuma StudioWeb-based dashboard with knowledge graph visualization, efficiency metrics, and activity tracking.
Arch Flow Anchorsfeature_domain nodes anchor architecture flows with owns edges to files.
Session MemoryTrack tool calls, recordings, and efficiency per session with enforcement.
Guard SystemReal-time monitoring with blocking warnings for anti-patterns and missing recordings.
Checkpoint/RollbackAtomic snapshots before major refactors with selective restore.
Policy-as-CodeConfigurable safety rules in YAML for never_touch, require_review, and block_commands.
15+ Agent SupportClaude Code, Cursor, Windsurf, Cline, Aider, OpenCode, Codex CLI, Zed, and more.

#Safety

Kuma's safety layer sits between the AI agent and your filesystem. Every operation is checked, logged, and auditable.

FeatureDescription
Anti-Pattern DetectionScript patching, bash grep, shell obfuscation, unsafe patterns.
Drift DetectionEdits made without corresponding tests — flagged and logged.
Tool-Loop PreventionSame tool called 4+ times in last 10 calls triggers circuit breaker.
Policy EnforcementYAML policy file: never_touch, require_review, block_commands.
Path ValidationAll operations locked to project directory. System dirs protected.
Safety AuditEvery tool call recorded in SQLite safety_audit table.
Confidence Scoring0-1 confidence per research record based on age, file existence, edge weight.

#Checkpoints & Rollback

Kuma provides one rollback mechanism — labeled snapshots. Take a checkpoint before risky work, restore by label if something breaks:

text
# 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.

#Auto-Inject — Shadow Memory

Kuma injects "where is this file fragile and why is it written this way" right before the agent touches it — zero extra steps:

text
# 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
GuardDescription
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.

#Storage Layout

Kuma stores per-project data in .kuma/:

text
.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/)

#API Reference

Full API reference available in docs/api.md.

kuma_context

ParameterTypeDescription
action"init" | "research" | "history" | "flow"Action to perform
scopestring?Research scope (e.g. "auth")
targetstring?File/domain for history/flow
goalstring?Current goal

kuma_memory

ParameterTypeDescription
action"gotcha" | "arch_flow" | "decision" | "research_save" | "search"Action to perform
scopestring?Scope for research_save/search
querystring?Search query
contentstring?Content for research_save
recordstring?JSON record string
confidencenumber (0-1)?Confidence score
trigger_commandstring?Gotcha trigger shell command
titlestring?Decision title
contextstring?Decision context
rationalestring?Decision rationale
outcomestring?Decision outcome
limitnumber?Result limit
descriptionstring?Gotcha workaround
statusstring?Gotcha severity (low|medium|high|critical)

kuma_safety

ParameterTypeDescription
action"guard" | "verify" | "checkpoint" | "rollback_label"Action to perform
guardGoalstring?Goal for guard check
guardGoalstring?Goal for guard check
scopestring?Scope for verify (tests to run)
labelstring?Checkpoint label / rollback target
forceboolean?Force bypass cache for verify
scopestring?Scope for verify/ast/validate
sincenumber?Timestamp filter for audit
labelstring?Checkpoint label
descriptionstring?Checkpoint description

#Architecture — 6 Core Actions

Kuma is memory & safety, not a code manager. The agent uses its own native tools for editing, searching, and execution.

ToolCore ActionsPurpose
kuma_contextinit, research, historyLoad project context, understand unfamiliar code
kuma_memorygotcha, decision, arch_flow, research_savePersistent knowledge that saves future sessions
kuma_safetyguard, verifyPre-risk check, post-edit verification
💡
Everything else is internal — available for power users but not spotlighted to agents, so they never second-guess which action to pick.

What Kuma Provides

FeatureDescription
Kuma StudioWeb-based dashboard with knowledge graph visualization, efficiency metrics, and activity tracking.
Arch Flow Anchorsfeature_domain nodes anchor architecture flows with owns edges to files.
Guard SystemReal-time monitoring with blocking warnings for anti-patterns and missing recordings.
Shadow InjectionGotchas injected before edits via hooks — zero token waste when clean.
Checkpoint/RollbackAtomic snapshots before major refactors with selective restore.
Knowledge GraphSQLite + FTS5 full-text search with derived flow cache.

#Comparison

FeatureKumaagentmemoryPMBPLURMemex
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