Codebase Memory
FreeNot checkedProvides persistent memory for AI coding agents through the Model Context Protocol, enabling them to store and retrieve project knowledge across sessions.
About
Provides persistent memory for AI coding agents through the Model Context Protocol, enabling them to store and retrieve project knowledge across sessions.
README
Your AI agent forgets everything between sessions. This MCP server fixes that.
You: "What architecture pattern does this project use?"
Without codebase-memory:
AI: "I'd need to look through the codebase to determine that."
With codebase-memory:
AI: "This project uses a hexagonal architecture with ports and adapters.
The decision was made in March 2026 to improve testability.
Related files: src/ports/, src/adapters/, src/domain/"
The Problem
AI coding agents (Cursor, Claude, Copilot) lose all context between sessions:
- Architecture decisions get forgotten and re-asked
- Code patterns get violated because the AI doesn't know your conventions
- Bug workarounds get re-introduced after being fixed
- Every session starts from zero
codebase-memory gives your AI persistent memory through the Model Context Protocol (MCP).
Quick Start
# Install
npm install -g codebase-memory
# Add to Claude Desktop config (~/.config/claude/claude_desktop_config.json)
{
"mcpServers": {
"codebase-memory": {
"command": "npx",
"args": ["codebase-memory"]
}
}
}
That's it. Your AI agent now has 5 memory tools:
| Tool | Description |
|---|---|
remember |
Store architecture decisions, patterns, conventions, bugs, context |
recall |
Search memories by query, category, tags, or file path |
update_memory |
Update existing memories when things change |
forget |
Delete outdated or incorrect memories |
project_summary |
Get overview of all memories (call at session start) |
Memory Categories
| Category | Use For |
|---|---|
architecture |
System design decisions, service boundaries, data flow |
pattern |
Code patterns: repository, factory, observer, etc. |
decision |
Why choices were made ("We chose Postgres over MongoDB because...") |
dependency |
Package choices, version constraints, compatibility notes |
convention |
Naming rules, file structure, formatting standards |
bug |
Known bugs, workarounds, things that look wrong but aren't |
context |
Domain knowledge, business rules, user requirements |
todo |
Planned improvements, tech debt, future work |
relationship |
How files/modules connect, dependency graphs |
How It Works
- AI stores knowledge — As your agent learns about the codebase, it calls
rememberto save important information - Persisted in SQLite — Memories are stored locally in
.codebase-memory/memory.db - Retrieved on demand — When the agent needs context, it calls
recallwith a search query - Full-text search — SQLite FTS5 enables fast, relevant search across all memories
- Importance scoring — High-importance memories surface first
Example Workflow
Session 1 (you're setting up the project):
AI remembers:
- "architecture: Monorepo with turborepo, apps/ for services, packages/ for shared"
- "convention: All API routes use zod validation middleware"
- "decision: Chose Drizzle ORM over Prisma for edge runtime support"
- "bug: Don't use Date objects in API responses, use ISO strings (timezone issues)"
Session 2 (next day, different task):
AI calls project_summary -> instantly knows the project structure
AI calls recall({query: "API validation"}) -> knows to use zod middleware
AI calls recall({filePath: "src/api/"}) -> gets all API-related memories
-> Writes code that follows all your established patterns
Configuration
Claude Desktop
{
"mcpServers": {
"codebase-memory": {
"command": "npx",
"args": ["codebase-memory"]
}
}
}
Cursor
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"codebase-memory": {
"command": "npx",
"args": ["codebase-memory"]
}
}
}
Custom Database Location
{
"mcpServers": {
"codebase-memory": {
"command": "npx",
"args": ["codebase-memory", "--db", "/path/to/memory.db"]
}
}
}
Programmatic API
import { MemoryDatabase } from 'codebase-memory';
const db = new MemoryDatabase({ path: './memory.db' });
// Store a memory
const entry = db.create({
category: 'architecture',
title: 'Event-driven messaging',
content: 'Services communicate via RabbitMQ. Orders service publishes OrderCreated events.',
tags: ['messaging', 'rabbitmq'],
filePaths: ['src/events/', 'src/services/orders/'],
importance: 9,
});
// Search memories
const results = db.query({
query: 'messaging',
category: 'architecture',
minImportance: 7,
});
// Get project overview
const summary = db.getSummary();
console.log(`Total memories: ${summary.totalMemories}`);
console.log(`Top tags: ${summary.topTags.map(t => t.tag).join(', ')}`);
db.close();
Data Storage
- Location:
.codebase-memory/memory.db(in your project root) - Format: SQLite with FTS5 full-text search
- Size: Typically under 1MB for thousands of memories
- Backup: Just copy the
.dbfile - Git: Add
.codebase-memory/to.gitignore(per-developer memories) or commit it (shared team knowledge)
CLI Options
codebase-memory [options]
--db <path> SQLite database path (default: .codebase-memory/memory.db)
--project <path> Project root directory (default: cwd)
--version Show version
--help Show help
License
MIT
Install Codebase Memory in Claude Desktop, Claude Code & Cursor
unyly install codebase-memoryInstalls into Claude Desktop, Claude Code, Cursor & VS Code — handles npx, uvx and build-from-source repos for you.
First time? Get the CLI: curl -fsSL https://unyly.org/install | sh
Or configure manually
Run in your terminal:
claude mcp add codebase-memory -- npx -y codebase-memoryFAQ
Is Codebase Memory MCP free?
Yes, Codebase Memory MCP is free — one-click install via Unyly at no cost.
Does Codebase Memory need an API key?
No, Codebase Memory runs without API keys or environment variables.
Is Codebase Memory hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Codebase Memory in Claude Desktop, Claude Code or Cursor?
Open Codebase Memory on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare Codebase Memory with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
