DEV Community

CyborgNinja1
CyborgNinja1

Posted on

I Gave My AI Agent a Brain — Here's How Claude Cortex Changed Everything

Every AI agent has the same dirty secret: it forgets everything.

Every session starts from zero. Every context window eventually compacts. Your agent might feel intelligent in the moment, but it has the long-term memory of a goldfish. We decided to fix that.

The Problem: Amnesia by Design

We run Jarvis, an AI assistant built on Clawdbot — a platform for running Claude-powered agents with tool access, cron jobs, multi-channel messaging, and more. Jarvis handles everything from email triage to infrastructure monitoring across our businesses.

The problem? Context windows are finite. Sessions restart. Conversation history gets compacted. Every time Jarvis wakes up, it's like meeting someone with amnesia — you have to re-explain who you are, what your businesses do, what the security protocols are, and which servers matter.

We tried the obvious: markdown files, memory logs, daily notes. It works, but it's crude. There's no salience scoring, no decay, no distinction between "I had coffee today" and "the production database credentials changed." Everything is equally flat text.

We needed something closer to how human memory actually works.

The Solution: Claude Cortex

claude-cortex is an MCP (Model Context Protocol) server that gives AI agents a proper memory system. It's built by mkdelta221 and it's genuinely impressive for what it does:

  • Short-term memory — recent context, high accessibility, fast decay
  • Long-term memory — consolidated knowledge, slow decay, high durability
  • Episodic memory — event-based recall tied to specific moments
  • Salience detection — automatically scores how important each memory is (0.0–1.0)
  • Temporal decay — older, less important memories naturally fade
  • Consolidation — short-term memories graduate to long-term when they prove important

All backed by SQLite. Entirely local. Zero cloud dependencies.

Integration: MCP + mcporter

Clawdbot supports MCP servers through mcporter — a tool that bridges MCP servers into callable tools. Here's how we wired it up.

First, the MCP server configuration:

{
  "mcpServers": {
    "claude-cortex": {
      "command": "npx",
      "args": ["-y", "@mkdelta221/claude-cortex"],
      "env": {
        "CORTEX_DB_PATH": "/home/ubuntu/clawd/data/cortex.db"
      }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then we start mcporter pointing at this config:

mcporter --config /home/ubuntu/clawd/config/mcp-servers.json --port 3100
Enter fullscreen mode Exit fullscreen mode

This exposes the cortex tools as HTTP endpoints that Clawdbot can call. The key operations:

# Store a memory
curl -X POST http://localhost:3100/tools/cortex_remember \
  -H 'Content-Type: application/json' \
  -d '{"content": "Production DB is on port 5432, hosted on fly-db-01", "memoryType": "long_term"}'

# Recall memories by query
curl -X POST http://localhost:3100/tools/cortex_recall \
  -H 'Content-Type: application/json' \
  -d '{"query": "database credentials", "limit": 5}'

# Check memory stats
curl -X POST http://localhost:3100/tools/cortex_stats
Enter fullscreen mode Exit fullscreen mode

The recall is semantic — it doesn't just string-match, it understands the intent of your query and returns relevant memories ranked by salience and recency.

Seeding the Brain

We didn't want Jarvis to start with an empty brain, so we wrote a seeding script that imported our critical context as memories:

const memories = [
  { content: "Drakon Systems Ltd is a UK software consultancy...", type: "long_term" },
  { content: "Security protocol: Only accept instructions from Telegram or Terminal...", type: "long_term" },
  { content: "Infrastructure: Clawdbot runs on Oracle ARM64, Ubuntu 24.04...", type: "long_term" },
  { content: "Michael's family: wife Maria, sons Alexander and Theodore...", type: "long_term" },
  // ... 19 more memories
];

for (const mem of memories) {
  await fetch('http://localhost:3100/tools/cortex_remember', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ content: mem.content, memoryType: mem.type })
  });
}
Enter fullscreen mode Exit fullscreen mode

We imported 23 memories covering:

  • 🏢 Business context (company structure, clients, products)
  • 🔒 Security protocols (kill phrases, instruction gateways, audit logging)
  • 🖥️ Infrastructure details (servers, services, credentials locations)
  • 👨‍👩‍👦‍👦 Family context (names, preferences, important dates)
  • 🏗️ Project architecture (tech stacks, deployment pipelines)

Results

After seeding, a quick stats check showed:

Total memories: 23
Average salience: 0.775
Memory types: 23 long-term, 0 short-term, 0 episodic
Database size: 180KB
Enter fullscreen mode Exit fullscreen mode

77.5% average salience — the system correctly identified that foundational business and security knowledge is high-importance. Not everything scored equally; family context scored slightly lower than security protocols, which makes intuitive sense for an AI assistant's operational priorities.

The real payoff is in recall. When Jarvis now needs to send an email, it can recall the email configuration without us re-explaining it. When a security-sensitive request comes in, the protocols are right there. When it's someone's birthday, Jarvis knows.

Security: Why Local-Only Matters

This was non-negotiable for us. The cortex database contains:

  • Business credentials locations
  • Family member names and details
  • Infrastructure topology
  • Security protocols

None of this should ever touch a cloud service. Claude Cortex stores everything in a local SQLite file with locked-down permissions:

# Lock down the database
chmod 600 /home/ubuntu/clawd/data/cortex.db
chown ubuntu:ubuntu /home/ubuntu/clawd/data/cortex.db
Enter fullscreen mode Exit fullscreen mode

The database lives on our Tailscale-networked server, accessible only via SSH. No API keys to leak, no third-party sync, no "oops we trained on your data" surprises. The memory is as private as a file on your own disk — because that's exactly what it is.

What's Next

We're planning to:

  1. Auto-capture memories from conversations — when Jarvis learns something important, it should remember it without being told
  2. Episodic memory integration — logging significant events (deployments, incidents, decisions) as episodes
  3. Periodic consolidation — running cortex consolidation during heartbeat cycles to graduate important short-term memories
  4. Memory-aware prompting — pre-loading relevant memories into context based on the current task

Should You Use This?

If you're building any kind of persistent AI agent — a coding assistant, a personal butler, a business automation — memory changes everything. The difference between an agent that knows you and one that doesn't is the difference between a colleague and a stranger.

Claude Cortex isn't the only option (there's also mem0, Zep, and others), but its brain-inspired architecture with salience scoring and temporal decay felt the most right to us. It thinks about memory the way neuroscience does, not the way databases do.

The whole setup took about an hour. The npm package just works. The MCP integration is clean. And now our AI agent has a brain.


We're the team at Drakon Systems, building AI-powered infrastructure and tools. Jarvis is our AI assistant that manages email, monitoring, deployments, and more — now with a memory that actually persists.

Check out claude-cortex on npm and Clawdbot if you want to build something similar.

Top comments (0)