consigcody94/code-memory
If you are the rightful owner of code-memory and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Code Memory is a Model Context Protocol (MCP) server designed to address the 'missing context' problem in AI-assisted development by providing a persistent context vault.
Code Memory
HIGHEST PRIORITY - A production-ready Model Context Protocol (MCP) server that solves the #1 validated pain point: the 65% "missing context" problem in AI-assisted development.
The Problem It Solves
Research shows that 65% of developers struggle with AI assistants losing context between sessions. Code Memory provides a persistent context vault that:
- Remembers decisions - Never explain the same architectural choice twice
- Indexes codebases - Fast semantic search across your entire project
- Preserves conversations - Pick up exactly where you left off
- Tracks evolution - Understand why code exists the way it does
Features
-
5 Powerful Tools:
index_codebase- Index any codebase for fast searchingsearch_code- Semantic search across files, decisions, and conversationsremember_decision- Save architectural decisions with reasoningget_context- Retrieve current project context and statssave_conversation- Preserve important conversations
-
Simple File-Based Storage: JSON files, no database required
-
Semantic Search: Keyword matching with relevance ranking
-
Type-Safe: Full TypeScript strict mode
-
Production-Ready: Comprehensive error handling
-
Zero Dependencies: Only MCP SDK required
Installation
npm install code-memory
Or clone and build from source:
git clone https://github.com/consigcody94/code-memory.git
cd code-memory
npm install
npm run build
Setup
Configuration for Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"code-memory": {
"command": "node",
"args": ["/path/to/code-memory/dist/index.js"],
"env": {
"CODE_MEMORY_DIR": "/path/to/your/memory/storage"
}
}
}
}
Or if installed globally:
{
"mcpServers": {
"code-memory": {
"command": "code-memory",
"env": {
"CODE_MEMORY_DIR": "/path/to/your/memory/storage"
}
}
}
}
Environment Variables
CODE_MEMORY_DIR(optional): Directory for storing memory files. Defaults to.code-memoryin current directory.
Usage Examples
Index Your Codebase
{
"tool": "index_codebase",
"arguments": {
"path": "/path/to/your/project"
}
}
Response:
{
"success": true,
"filesIndexed": 247,
"rootPath": "/path/to/your/project",
"lastIndexed": "2025-11-21T12:00:00.000Z"
}
Search Code
{
"tool": "search_code",
"arguments": {
"query": "authentication middleware",
"type": "all" // or "files", "decisions", "conversations"
}
}
Response:
{
"query": "authentication middleware",
"resultCount": 5,
"results": [
{
"type": "file",
"path": "/path/to/auth.ts",
"relevance": 1.0,
"preview": "...authentication middleware implementation..."
},
{
"type": "decision",
"id": "abc123",
"title": "JWT Authentication Strategy",
"relevance": 0.8,
"preview": "...decided to use JWT for authentication..."
}
]
}
Remember a Decision
{
"tool": "remember_decision",
"arguments": {
"title": "Use PostgreSQL for main database",
"description": "Selected PostgreSQL as the primary database for user data and transactions",
"reasoning": "Need ACID compliance, complex queries, and strong community support. MongoDB considered but relational model fits our use case better.",
"tags": ["database", "architecture", "backend"],
"relatedFiles": ["/src/database/config.ts", "/src/models/user.ts"]
}
}
Get Context
{
"tool": "get_context",
"arguments": {
"includeDecisions": true,
"includeStats": true
}
}
Response:
{
"stats": {
"filesIndexed": 247,
"lastIndexed": "2025-11-21T12:00:00.000Z",
"rootPath": "/path/to/project"
},
"totalDecisions": 12,
"totalConversations": 8,
"recentDecisions": [
{
"id": "abc123",
"timestamp": "2025-11-21T11:30:00.000Z",
"title": "Use PostgreSQL for main database",
"description": "...",
"reasoning": "...",
"tags": ["database", "architecture"],
"relatedFiles": [...]
}
]
}
Save a Conversation
{
"tool": "save_conversation",
"arguments": {
"title": "Implementing user authentication flow",
"context": "Working on adding JWT-based authentication to the API",
"messages": [
{
"role": "user",
"content": "How should I implement JWT refresh tokens?"
},
{
"role": "assistant",
"content": "Here's a secure approach using HTTP-only cookies..."
}
],
"tags": ["authentication", "jwt", "security"]
}
}
Storage Structure
Code Memory stores data in JSON files:
.code-memory/
├── index.json # Codebase file index
├── decisions.json # Architectural decisions
└── conversations.json # Saved conversations
index.json
{
"files": [
{
"path": "/path/to/file.ts",
"hash": "abc123...",
"size": 1024,
"lastModified": "2025-11-21T12:00:00.000Z"
}
],
"lastIndexed": "2025-11-21T12:00:00.000Z",
"rootPath": "/path/to/project"
}
decisions.json
[
{
"id": "abc123",
"timestamp": "2025-11-21T12:00:00.000Z",
"title": "Decision title",
"description": "...",
"reasoning": "...",
"tags": ["tag1", "tag2"],
"relatedFiles": ["/path/to/file.ts"]
}
]
conversations.json
[
{
"id": "xyz789",
"timestamp": "2025-11-21T12:00:00.000Z",
"title": "Conversation title",
"context": "What we were working on",
"messages": [...],
"tags": ["tag1", "tag2"]
}
]
Supported File Types
Code Memory indexes these file extensions:
Languages: .js, .ts, .jsx, .tsx, .py, .java, .c, .cpp, .h, .hpp, .cs, .rb, .go, .rs, .php, .swift, .kt, .scala, .sh
Data/Config: .sql, .json, .yaml, .yml, .toml, .xml
Web: .html, .css, .scss
Docs: .md, .txt
Excluded Directories
These directories are automatically excluded from indexing:
node_modules.gitdist/buildcoverage.next__pycache__.pytest_cachevendortarget
Use Cases
1. Onboarding New Developers
Index the codebase and save key architectural decisions. New team members can search for context instantly.
2. Long-Running Projects
Save conversations about complex features. Return weeks later and pick up exactly where you left off.
3. Architectural Documentation
Remember decisions as you make them. Build living documentation that explains "why" not just "what".
4. Code Reviews
Search for related decisions and conversations when reviewing changes. Ensure consistency with past choices.
5. Debugging Sessions
Save debugging conversations with context. Reference them when similar issues arise.
Development
# Install dependencies
npm install
# Build TypeScript
npm run build
# Watch mode for development
npm run watch
Requirements
- Node.js >= 18.0.0
- TypeScript 5.7+
Performance
- Indexing: ~1000 files/second on average hardware
- Search: Sub-100ms for most queries
- Storage: ~1KB per file entry, ~2KB per decision
Security
- All data stored locally in JSON files
- No external API calls
- No data leaves your machine
- Storage directory can be encrypted at filesystem level
Troubleshooting
"Path does not exist" error
- Verify the path is correct and accessible
- Use absolute paths rather than relative paths
Slow indexing
- Exclude large directories (already auto-excluded)
- Consider indexing only source directories
Search not finding results
- Ensure codebase has been indexed first
- Check query matches content (case-insensitive)
- Try broader search terms
Contributing
Contributions are welcome! Please see for guidelines.
License
MIT License - see file for details.
Impact
Solves the validated 65% "missing context" problem identified in AI-assisted development research. Developers no longer need to:
- Re-explain architectural decisions
- Remember why code exists
- Lose conversation context between sessions
- Search through Slack/emails for technical discussions
Links
Support
For bugs and feature requests, please use GitHub Issues.