Skip to content

nihalnihalani/agent-memory

Repository files navigation


Agent Memory

Agent Memory

The shared brain for AI agents

Store context in Claude. Recall it in ChatGPT. Hand off work to Cursor.
One memory layer across every AI tool you use.


MCP Apps Hackathon Built with Manufact TypeScript SQLite React 19 License


Get Started  ·  Features  ·  Architecture  ·  API Reference  ·  How It Works



Why

Every AI conversation starts from zero. Your agent doesn't remember you chose Supabase, prefer Tailwind, or that auth uses JWT. You re-explain — every single time.

That's 10,000-20,000 wasted tokens per day just on repeated context. At scale, that's billions of redundant GPU cycles per month.

Important

Agent Memory eliminates this. Agents remember what they already know, cutting token usage by up to 60% — less inference, less energy, less cost.


Get Started

Connect Agent Memory to any MCP-compatible client with a single URL:

https://winter-meadow-1651f.run.mcp-use.com/mcp
Claude Desktop / Claude Code
{
  "mcpServers": {
    "agent-memory": {
      "url": "https://winter-meadow-1651f.run.mcp-use.com/mcp"
    }
  }
}
ChatGPT

Connect via the Manufact MCP Apps marketplace.

Cursor / VS Code / Windsurf / Cline / Roo Code / Goose / Codex

Paste the URL into your MCP server configuration. Any client that speaks MCP can connect.

Run locally
git clone https://github.com/nihalnihalani/agent-memory.git
cd agent-memory
npm install
npm run dev

Then connect at http://localhost:3010/mcp or open the inspector.


Features

Intelligent Memory

  • 5 memory typesdecision preference task snippet note
  • FTS5 search with BM25 relevance ranking
  • Composite scoring — relevance, recency, access frequency, type priority
  • Tag-based organization with multi-tag filtering
  • Conflict detection across agents

Cross-Agent Collaboration

  • Universal MCP — works with every MCP-compatible client
  • Agent attribution — every memory tagged with its creator
  • Color-coded agents — Claude, ChatGPT, Cursor, and 10+ more
  • Activity feed — see what each agent did and when
  • Structured handoffs — pass work between agents seamlessly

Inline Dashboard

  • Renders inside conversations — no separate app
  • Search + filter compound — combine text search with type filters
  • Quick-add — create memories without tool calls
  • Inline editing — update memories in place
  • Dark & light mode — adapts to your client
  • Fullscreen responsive — expands to fill any viewport

Agent Handoffs

  • Structured work transfer — summary, context, next steps
  • Context inheritance — references to relevant memories
  • Atomic pickup — race-condition-safe with transaction locking
  • One-click pickup — accept handoffs from the dashboard
  • Auto-briefing — new agent gets full context on pickup

Backup & Analytics

  • Export memories — JSON with filters by agent, type, date, tags
  • Import memories — restore from backup, skip duplicates
  • Memory statistics — counts by type/agent, top accessed, FTS5 health
  • Automatic cleanup — TTL on activity logs (30d) and history (90d)

Production Hardened

  • Rate limiting — 100 ops/min per agent with sliding window
  • Input validation — key format, value size (10KB), tag limits
  • FTS5 injection protection — boolean operators and special chars stripped
  • Error recovery — DB retry with backoff, FTS5 auto-repair
  • Graceful shutdown — SIGINT/SIGTERM close DB cleanly
  • 158 tests — queries, schema, helpers, edge cases

What Makes This Different

Agent Memory Others
Inline widget inside conversations Yes No
Cross-agent memory (Claude + ChatGPT + Cursor) Yes Limited
Agent-to-agent handoffs with atomic locking Yes No
Visual agent attribution Yes No
FTS5 + composite scoring (4-signal ranking) Yes Keyword only
Export/import with backup & restore Yes Rarely
Rate limiting & input validation Yes Rarely
Auto-cleanup with TTL Yes No
Zero ML dependencies Yes Often heavy
Single URL to connect Yes Complex setup
158 automated tests Yes Varies

Architecture

graph TB
    subgraph Clients["MCP Clients"]
        Claude["Claude Code"]
        ChatGPT["ChatGPT"]
        Cursor["Cursor"]
        VSCode["VS Code"]
        Others["Any MCP Client"]
    end

    subgraph Server["Agent Memory Server"]
        direction TB
        Tools["11 Tools<br/><code>remember · recall · forget · list</code><br/><code>handoff · pickup · complete</code><br/><code>export · import · stats · cleanup</code>"]
        Resources["7 Resources<br/><code>current-context · agent-activity</code><br/><code>memory://{key} · handoff-queue · changelog</code>"]
        Prompt["1 Prompt<br/><code>session-briefing</code>"]
    end

    subgraph Storage["Persistence Layer"]
        SQLite["SQLite + WAL"]
        FTS5["FTS5 Search Engine"]
    end

    subgraph Widget["Inline Widget"]
        React["React 19 Dashboard"]
    end

    Clients -->|"MCP over SSE"| Server
    Server --> Storage
    Server --> Widget

    style Clients fill:#1e1b4b,stroke:#4f46e5,color:#e0e7ff
    style Server fill:#1a1a2e,stroke:#8b5cf6,color:#e0e7ff
    style Storage fill:#0f172a,stroke:#3b82f6,color:#e0e7ff
    style Widget fill:#0f172a,stroke:#10b981,color:#e0e7ff
Loading

Data Flow

sequenceDiagram
    participant A as Agent (Claude)
    participant S as Agent Memory
    participant B as Agent (ChatGPT)

    A->>S: remember("db-choice", "PostgreSQL")
    Note over S: SQLite INSERT + FTS5 index
    S-->>A: Stored + widget updates

    B->>S: recall("database")
    Note over S: FTS5 MATCH + composite scoring
    S-->>B: "PostgreSQL" (ranked result)

    A->>S: handoff(summary, context_keys)
    Note over S: Store handoff + link memories
    B->>S: pickup(handoff_id)
    Note over S: Load context + full briefing
    S-->>B: Complete project context
Loading

API Reference

Tools

Tool Description
remember Store a memory with key, value, type, tags, and context. Handles conflicts when agents update the same key.
recall Full-text search with FTS5 + BM25 composite scoring. Returns ranked results by relevance, recency, and access patterns.
forget Delete a memory by key with cascading cleanup of tags and history.
list-memories Browse memories with pagination, type filtering, and tag filtering.
handoff Create an agent-to-agent work transfer with summary, stuck reason, next steps, and context references.
pickup Accept a pending handoff with atomic locking. Auto-loads context memories and relevant decisions for a full briefing.
complete-handoff Mark a handoff as completed. Enforces ownership — only the agent that picked up the handoff can complete it.
export-memories Export memories as JSON with optional filters: agent, type, tags, date range.
import-memories Import memories from JSON backup. Validates entries and skips duplicates by key.
memory-stats Comprehensive statistics: totals by type/agent, top 10 most accessed, storage size, FTS5 health.
cleanup Manually trigger cleanup of old activity logs (>30 days) and memory history (>90 days).

Resources

URI Description
memory://current-context Full project briefing: decisions, preferences, recent tasks, stats, pending handoffs. This is what saves tokens.
memory://agent-activity Agent action feed — who did what and when across all agents.
memory://{key} Look up a specific memory by key.
memory://handoff-queue All pending, in-progress, and recently completed handoffs.
memory://changelog Memory modification history with old vs. new values and agent attribution.

Prompt

Name Description
session-briefing Full agent onboarding. Optional focus parameter to filter context to a specific topic.

How It Works

Composite Scoring

When you recall, Agent Memory ranks results using four signals:

Score = (0.6 × BM25) + (0.2 × Recency) + (0.1 × Access) + (0.1 × Type)
Signal Weight Why
BM25 Relevance 60% Most relevant results first
Recency 20% Recent memories surface higher
Access Count 10% Frequently used = important
Type Priority 10% decision > preference > task > snippet > note

Database Schema

SQLite in WAL mode with FTS5 for full-text search:

erDiagram
    memories ||--o{ tags : has
    memories ||--o{ memory_history : tracks
    memories }o--|| memories_fts : indexes
    activity_log }o--|| memories : references

    memories {
        int id PK
        text key UK
        text value
        text type
        text context
        text agent_id
        int access_count
        datetime created_at
        datetime updated_at
    }

    tags {
        int id PK
        int memory_id FK
        text tag
    }

    handoffs {
        int id PK
        text from_agent
        text to_agent
        text status
        text summary
        text next_steps
    }

    activity_log {
        int id PK
        text agent_id
        text action
        text target_key
        datetime created_at
    }
Loading

Tip

The memory://current-context resource automatically surfaces your decisions and preferences at the start of every conversation — so the agent already has your context without you spending tokens re-explaining it.


Token Savings

Scale Daily Waste With Agent Memory
1 user 10K-20K tokens Eliminated
1,000 users 10M-20M tokens ~60% reduction
1M users 10B-20B tokens Billions saved

Every token saved is a GPU cycle that doesn't fire. At scale, Agent Memory is infrastructure for sustainable AI.


Tech Stack

Layer Technology
Language TypeScript 5.9
Framework Manufact SDK (mcp-use)
Database SQLite via better-sqlite3 (WAL mode)
Search FTS5 with BM25 + Porter stemming
Validation Zod 4
UI React 19 + Tailwind CSS v4
Build Vite 7
Server Express 5
Deployment Manufact MCP Cloud (Fly.io)

Project Structure
agent-memory/
├── index.ts                          # Entry point — server init + module registration (70 lines)
├── src/
│   ├── db/
│   │   ├── schema.ts                 # SQLite schema + FTS5 + retry + cleanup
│   │   ├── queries.ts                # All DB operations + rate limiter + validation
│   │   ├── queries.test.ts           # 120 tests — CRUD, search, handoffs, edge cases
│   │   ├── schema.test.ts            # 17 tests — tables, FTS5, cleanup, triggers
│   │   └── seed.ts                   # Demo data (4 agents collaborating)
│   ├── tools/
│   │   ├── memory-tools.ts           # remember, recall, forget, list-memories
│   │   ├── handoff-tools.ts          # handoff, pickup, complete-handoff
│   │   ├── utility-tools.ts          # export, import, stats, cleanup
│   │   ├── helpers.ts                # Agent names + formatting
│   │   └── helpers.test.ts           # 20 tests — display names, timestamps
│   ├── resources/
│   │   └── index.ts                  # 5 resources + 2 widget resources
│   └── prompts/
│       └── index.ts                  # session-briefing prompt
├── resources/
│   └── memory-dashboard/
│       ├── widget.tsx                # Interactive dashboard (1,500+ lines)
│       ├── types.ts                  # TypeScript interfaces
│       ├── utils.ts                  # Agent colors, helpers
│       └── components/
│           ├── MemoryCard.tsx         # Memory display with agent colors
│           ├── SearchBar.tsx          # Debounced FTS5 search
│           ├── TypeFilter.tsx         # Type selector pills
│           ├── StatsBar.tsx           # Statistics bar
│           ├── ActivityFeed.tsx       # Agent timeline
│           ├── HandoffCard.tsx        # Handoff display
│           └── QuickAddForm.tsx       # Quick memory creation
├── vitest.config.ts                   # Test configuration
├── public/                            # Static assets
├── data/                              # SQLite database (runtime)
└── dist/                              # Compiled output + widget manifest
Run Tests
npm test          # run all 158 tests
npm run test:watch # watch mode

Tests cover: CRUD operations, FTS5 search, composite scoring, handoff state machine, rate limiting, input validation, TTL cleanup, and edge cases. All tests use in-memory SQLite for fast isolation (~180ms total).

Deploy
npm run build
npm run deploy

Deployed at https://winter-meadow-1651f.run.mcp-use.com/mcp — accessible from any MCP client worldwide.



Built for the MCP Apps Hackathon 2026 at Y Combinator

Powered by Manufact


TypeScript React SQLite Tailwind Node.js Vite

About

Universal Shared Memory MCP Server for AI Agents - MCP Apps Hackathon @ YC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors