Skip to main content

MCP Integration

Kernle provides an MCP (Model Context Protocol) server that exposes memory operations as tools for AI assistants.

What is MCP?

MCP is a protocol that allows AI assistants to use external tools. When you add Kernle as an MCP server, your AI assistant gains access to memory operations like:
  • Loading working memory
  • Saving checkpoints
  • Recording episodes and notes
  • Searching memory
  • Managing beliefs and values

Starting the MCP Server

kernle -s <stack_id> mcp
This starts an MCP server using stdio transport. The server stays running and responds to tool calls from the connected client.

How Memory Works via MCP

MCP provides a protocol for AI assistants to call external tools. Kernle exposes its full memory API as MCP tools. Any MCP-compatible client — Claude Code, Claude Desktop, Cursor, custom agents — can use Kernle memory through standard tool calls.

All Memory Handling is Manual

There is no automatic memory loading or saving. The client SI must call tools explicitly at each stage: Session start — Call memory_load to restore context. This returns values, beliefs, goals, episodes, notes, checkpoint, and relationships, priority-ordered within the token budget. Without this call, the SI starts with no memory context. During the session — Call capture tools (memory_episode, memory_note, memory_raw, etc.) as the SI works. Each call immediately persists to the local SQLite database. Nothing is buffered or batched. Session end — Call memory_checkpoint_save to record what the SI was working on, pending items, and context for next time. This checkpoint is loaded first on the next memory_load. Searchmemory_search runs semantic search across all memory types. memory_raw_search uses FTS5 for keyword search on raw entries. Processingmemory_process runs automated memory processing (raw entries to episodes to beliefs to values) using the bound inference model. memory_process_status shows what is pending.

What the MCP Server Does NOT Do

  • Does not auto-load memory at connection time
  • Does not auto-save when the client disconnects
  • Does not run background maintenance or processing
  • Does not push notifications about memory state
The server is purely reactive — it waits for tool calls and executes them.

Immediate Persistence Model

Every memory_* capture tool writes directly to the SQLite database on call. If the client crashes after calling memory_episode but before memory_checkpoint_save, the episode is still saved — only the checkpoint summary is lost. This means partial sessions are never completely lost; whatever was captured before the interruption remains in the database.

Relationship to Native Memory Systems

Kernle works alongside whatever native memory your MCP client already provides. It does not require exclusive access.

Claude Code

Claude Code has two native memory mechanisms: CLAUDE.md files (static project instructions loaded at session start) and auto-memory (~/.claude/projects/.../memory/MEMORY.md, simple text notes the agent writes during sessions). Kernle provides structured, typed memory with provenance, strength decay, hierarchy, and search — capabilities that flat text files cannot offer. CLAUDE.md is still the right place for static project instructions. Auto-memory can coexist with Kernle — some users keep auto-memory for quick project notes and use Kernle for the full stratified memory system.

Claude Desktop

Claude Desktop has Projects with pinned knowledge files (static documents). It has no persistent dynamic memory between conversations. Kernle fills the gap entirely, giving the assistant memory that survives across conversations. See the Claude Desktop guide for setup.

Other MCP Clients (Cursor, Custom Agents)

Kernle provides the complete memory layer. Whatever native memory the client has can coexist — Kernle does not require exclusive access and does not interfere with other memory systems.

Available Tools

When connected, the MCP server exposes these tools:

Core Memory Operations

ToolDescription
memory_loadLoad working memory with priority-based budget allocation
memory_checkpoint_saveSave checkpoint with task description
memory_checkpoint_loadLoad previous checkpoint
memory_statusGet memory statistics
memory_syncTrigger synchronization with cloud storage

memory_load Tool Details

The memory_load tool uses priority-based budget allocation to load the most important memories within token limits. Parameters:
ParameterTypeDefaultDescription
formatstring"text"Output format: "text" or "json"
budgetinteger8000Token budget (100-50000)
truncatebooleantrueTruncate long content to fit more items
Priority Ordering: Memories are loaded by priority until the budget is exhausted:
  1. Checkpoint (1.00) - Always loaded first for task continuity
  2. Values (0.90) - Sorted by priority descending
  3. Beliefs (0.70) - Sorted by confidence descending
  4. Goals (0.65) - Sorted by recency
  5. Drives (0.60) - Sorted by intensity descending
  6. Episodes (0.40) - Sorted by recency
  7. Notes (0.35) - Sorted by recency
  8. Relationships (0.30) - Sorted by last interaction
Response Metadata (_meta): When using JSON format, the response includes budget metrics:
{
  "_meta": {
    "budget_used": 5200,
    "budget_total": 8000,
    "excluded_count": 12
  }
}
FieldDescription
budget_usedTokens consumed by loaded memories
budget_totalOriginal budget requested
excluded_countNumber of memories that could not fit
Token Estimation: Tokens are estimated at approximately 4 characters per token, with a 1.3x safety margin for JSON serialization overhead. Access Tracking: Loading memories automatically records access for salience-based forgetting. This helps Kernle identify frequently-used memories that should be preserved.

Memory Capture

ToolDescription
memory_episodeRecord an experience with lessons
memory_noteCapture a note (decision/insight/quote)
memory_rawQuick capture to raw layer
memory_valueDefine core values
memory_goalSet and manage goals
memory_driveSet or update drives (motivations)
Playbooks are currently available via CLI only. MCP tools for playbook operations are planned for a future release.

Search & Query

ToolDescription
memory_searchSemantic search across all memory
memory_raw_searchFTS5 keyword search on raw entries
memory_note_searchSearch notes by content and type
memory_whenQuery memories by time period (today, yesterday, this week)
memory_promoteGet reflection scaffold with recent episodes and beliefs

Processing

ToolDescription
memory_processRun automated memory processing through hierarchy layers
memory_process_statusCheck status of memory processing

List Operations

ToolDescription
memory_belief_listList all active beliefs with confidence levels
memory_value_listList all core values ordered by priority
memory_goal_listList goals filtered by status
memory_drive_listList all drives with current intensities

Update Operations

ToolDescription
memory_episode_updateUpdate an episode (add lessons, change outcome, add tags)
memory_goal_updateUpdate a goal’s status, priority, or description
memory_belief_updateUpdate a belief’s confidence or deactivate it

Suggestions

ToolDescription
suggestion_listList and filter memory suggestions by status, type, confidence, age
suggestion_acceptAccept a suggestion and create structured memory (with optional modifications)
suggestion_dismissDismiss a suggestion with an optional reason
suggestion_extractExtract suggestions from unprocessed raw entries

Client Configuration

Claude Code

Add Kernle as an MCP server using the Claude CLI:
claude mcp add kernle -- kernle -s <stack_id> mcp
This registers Kernle with Claude Code. You can verify with:
claude mcp list

General MCP Configuration

For clients that use a JSON configuration file:
{
  "mcpServers": {
    "kernle": {
      "command": "kernle",
      "args": ["-s", "<stack_id>", "mcp"]
    }
  }
}
Replace <stack_id> with your actual stack identifier.

Usage Example

Once configured, your AI assistant can use memory tools naturally:
"Let me save my current progress..."
→ Tool call: memory_checkpoint_save(task="Working on user auth")

"What have I learned about caching?"
→ Tool call: memory_search(query="caching")

"I should remember this insight about rate limiting."
→ Tool call: memory_note(content="Rate limits are per-user, not per-key", type="insight")

Best Practices

Session Start: Always call memory_load at the beginning of a session to restore context.
Save Often: Use memory_checkpoint_save before context gets full, not just at session end.
Record Lessons: Use memory_episode with lessons when you learn something significant.

Troubleshooting

Server Not Starting

Verify Kernle is installed and accessible:
which kernle
kernle --version

Tools Not Appearing

  1. Restart your MCP client
  2. Check the MCP configuration path
  3. Verify the stack ID exists: kernle -s <stack_id> status

Permission Issues

The MCP server runs with the same permissions as your user. Ensure ~/.kernle/ is accessible.