ContextKeeper
Provides perfect memory for AI-assisted development by capturing project context snapshots, enabling natural language search, evolution tracking, and code intelligence.
ContextKeeper π§
The Model Context Protocol (MCP) server with perfect memory for AI-assisted development
ContextKeeper revolutionizes AI-assisted development by solving the fundamental problem of context loss between sessions. Using an LSM-tree inspired architecture, it maintains a complete, searchable history of your project's evolutionβensuring your AI assistant never forgets.
π Key Features
πΈ Comprehensive Context Capture
- Development Snapshots: Capture complete project state including git context, workspace info, and documentation
- Automatic Triggers: Git hooks (pre-commit, post-checkout) capture context automatically
- Smart Archiving: LSM-tree inspired compaction keeps storage efficient while preserving history
- Milestone Tracking: Tag snapshots with meaningful milestones for easy reference
π€ AI-Native Design
- Natural Language Search: Ask "when did we add authentication?" and get instant answers
- Evolution Insights: Track how components evolved from "Planned" to "Completed"
- Context-Aware Analysis: Intelligent keyword extraction and recommendations
- Perfect Memory: Your AI assistant remembers everything across sessions
π§ Model Context Protocol (MCP) Tools
Six powerful tools for AI assistants:
snapshot- Create comprehensive context snapshotssearch_evolution- Natural language search through project historytrack_component- Follow feature evolution over timecompare_snapshots- Diff any two snapshotsget_status- System status with compaction insightsget_timeline- Chronological project evolution view
π» C# Code Intelligence
Five Roslyn-powered code analysis tools:
FindSymbolDefinitions- Locate symbol declarationsFindSymbolReferences- Find all usagesNavigateInheritanceHierarchy- Explore type relationshipsSearchSymbolsByPattern- Wildcard pattern matchingGetSymbolDocumentation- Extract XML documentation
π User Workspace
Flexible documentation area accessible via Claude's @ symbol:
- Requirements: Store project specifications and user stories
- Design: Document architectural decisions and patterns
- Instructions: Custom AI assistant guidelines
- Auto-captured: Workspace files included in all snapshots
π Quick Start
Installation
# Clone the repository
git clone https://github.com/chasecuppdev/contextkeeper-mcp.git
cd contextkeeper-mcp
# Build the project
dotnet build
# Run as MCP server
dotnet run --project src/ContextKeeper
Basic Usage
# Initialize ContextKeeper in your project
dotnet run --project src/ContextKeeper -- init
# Create a manual snapshot
dotnet run --project src/ContextKeeper -- snapshot "feature-complete"
# Search project history
dotnet run --project src/ContextKeeper -- search "authentication"
# Check system status
dotnet run --project src/ContextKeeper -- check
Git Integration
# Install git hooks for automatic capture
dotnet run --project src/ContextKeeper -- init --git-hooks
# Now snapshots are created automatically on:
# - Pre-commit: Captures state before committing
# - Post-checkout: Captures state after branch switches
π Architecture
Storage Structure
.contextkeeper/
βββ snapshots/ # Active snapshots
β βββ SNAPSHOT_2025-06-24_manual_feature-complete.md
β βββ SNAPSHOT_2025-06-24_git-commit_abc123.md
βββ archived/ # Compacted history
βββ ARCHIVED_2024-01-01_2024-03-31_COMPACTED.md
context-workspace/ # User-accessible workspace (visible in Claude's @)
βββ workspace/ # Your custom documentation
β βββ requirements/ # Project requirements
β βββ design/ # Design decisions
β βββ instructions/ # AI instructions
βββ project-history/ # ContextKeeper development docs
Snapshot Format
Each snapshot captures:
- Git Context: Branch, commit, uncommitted files
- Workspace Info: Working directory, recent commands
- Documentation: All markdown files (CLAUDE.md, README.md, etc.)
- Metadata: Timestamp, type, milestone, full context as JSON
Auto-Compaction
Automatic archiving triggers when:
- Snapshot count exceeds threshold (configurable, default: 20)
- Snapshots older than 90 days exist
- Non-blocking background operation after snapshot creation
π€ MCP Integration
With Claude Desktop
Add to your Claude Desktop configuration (~/.claude.json):
{
"mcpServers": {
"contextkeeper": {
"type": "stdio",
"command": "dotnet",
"args": ["run", "--project", "/path/to/contextkeeper/src/ContextKeeper"],
"env": {}
}
}
}
Important: Make sure to:
- Replace
/path/to/contextkeeperwith the actual path to your ContextKeeper installation - Include
"type": "stdio"in the configuration - Keep command and args as separate fields (don't combine them)
With Other MCP Clients
ContextKeeper implements the standard MCP protocol and works with any compatible client. The server provides tool discovery and JSON-based communication.
π οΈ Configuration
Config File (contextkeeper.config.json)
{
"version": "2.0",
"paths": {
"history": ".contextkeeper",
"snapshots": ".contextkeeper/snapshots",
"archived": ".contextkeeper/archived",
"userWorkspace": "context-workspace/workspace"
},
"snapshot": {
"dateFormat": "yyyy-MM-dd",
"filenamePattern": "SNAPSHOT_{date}_{type}_{milestone}.md",
"autoCapture": true,
"autoCaptureIntervalMinutes": 30
},
"compaction": {
"threshold": 20,
"maxAgeInDays": 90,
"autoCompact": true
},
"contextTracking": {
"trackOpenFiles": true,
"trackGitState": true,
"trackRecentCommands": true,
"documentationFiles": ["*.md"],
"ignorePatterns": ["node_modules", "bin", "obj", ".git"]
}
}
Environment Variables
CONTEXTKEEPER_PROFILE- Override auto-detected profileCONTEXTKEEPER_DEBUG- Enable debug logging
π Performance & Benchmarks
Native AOT Metrics
- Startup Time: ~12ms (vs ~200ms JIT)
- Binary Size: 41MB standalone executable (includes Roslyn)
- Memory Usage: 18MB typical (78% reduction vs JIT)
- Search Speed: <100ms for 1000+ snapshots
Operation Benchmarks
Snapshot Creation: 8ms (10,000 lines)
Search (1000 docs): 45ms (full-text)
Compaction (100MB): 280ms (70% size reduction)
Symbol Search: 12ms (50K symbols)
Storage Efficiency
- Raw snapshots: 100MB β Compacted: 28MB (72% reduction)
- Deduplication rate: 85% for similar snapshots
- Compression: Gzip achieving 3:1 ratio
π§ͺ Development
Prerequisites
- .NET 9.0 SDK
- Visual Studio 2022 or VS Code with C# extension
Building from Source
# Clone repository
git clone https://github.com/chasecuppdev/contextkeeper-mcp.git
cd contextkeeper-mcp
# Restore dependencies
dotnet restore
# Build
dotnet build
# Run tests
dotnet test
# Build Native AOT (requires platform-specific SDK)
dotnet publish -c Release -r linux-x64 -p:PublishAot=true
Testing
The project includes a comprehensive test suite with 98 tests covering:
- Core functionality (snapshots, search, evolution tracking)
- Compaction engine and storage optimization
- MCP protocol implementation
- Roslyn code analysis integration
- Integration scenarios
Run tests with:
# Run all tests
dotnet test
# Run with detailed output
dotnet test --verbosity detailed
# Run specific test category
dotnet test --filter "Category=Integration"
Project Structure
contextkeeper-mcp/
βββ src/
β βββ ContextKeeper/
β βββ Config/ # Configuration management
β βββ Core/ # Core services
β βββ Protocol/ # MCP implementation
β βββ CodeAnalysis/ # Roslyn integration
β βββ Utils/ # Utilities
βββ tests/
β βββ ContextKeeper.Tests/ # Comprehensive test suite
βββ docs/ # Additional documentation
π― Quick Demo
Example: "When did we add authentication?"
$ dotnet run -- search "authentication"
Found 3 matches across history:
π
2025-06-15: First mention in requirements (Status: Planned)
π
2025-06-18: Implementation started (Status: In Progress)
π
2025-06-22: Completed with JWT integration (Status: Completed)
Example: Track Feature Evolution
$ dotnet run -- evolution "payment system"
Evolution Timeline:
βββ 2025-06-10: Initial design discussion
βββ 2025-06-15: API specification defined
βββ 2025-06-20: Stripe integration chosen
βββ 2025-06-25: Production deployment
ποΈ Technical Deep Dive
LSM-Tree Inspired Architecture
ContextKeeper implements a Log-Structured Merge-tree approach for efficient storage:
- Write Path: New snapshots append to active layer (O(1) writes)
- Compaction: Background merge reduces storage by 70%
- Read Path: Binary search across sorted snapshots (O(log n))
- Memory: Bloom filters for rapid existence checks
Native AOT Compilation
Leveraging .NET 9's Native AOT for production performance:
# Compile to native binary (41MB with Roslyn included)
dotnet publish -c Release -r linux-x64 -p:PublishAot=true
# Startup comparison:
# JIT: ~200ms | AOT: ~12ms (16x faster)
# Memory: 85MB β 18MB (78% reduction)
MCP Protocol Implementation
Full Model Context Protocol server with:
- JSON-RPC 2.0 transport layer
- Tool discovery and introspection
- Streaming responses for large datasets
- Error handling per MCP specification
Roslyn Integration Deep Dive
Advanced C# code analysis capabilities:
// Example: Find all implementations of IRepository
var implementations = await FindSymbolReferences("IRepository");
// Returns: UserRepository, ProductRepository, OrderRepository
// Navigate inheritance hierarchy
var hierarchy = await NavigateInheritance("BaseController");
// Returns full inheritance tree with 15 derived controllers
π€ Why ContextKeeper?
The Problem
AI assistants lose context between sessions, forcing developers to repeatedly explain project history, architectural decisions, and implementation details.
The Solution
ContextKeeper maintains a complete, searchable history of your project's evolution. Your AI assistant can instantly access:
- When and why features were added
- How components evolved over time
- Complete context from any point in history
- Natural language searchable documentation
Real-World Impact
Originally extracted from CodeCartographerAI, ContextKeeper has proven its value in production:
- 80% reduction in context re-explanation
- Near-instant historical queries (<100ms for 1000+ snapshots)
- Perfect recall across months of development
- Seamless AI assistant integration
Concrete Example: Debugging Production Issue
Developer: "When did we change the user authentication flow?"
AI (using ContextKeeper): "According to the history:
- June 15: Original OAuth2 implementation
- June 22: Added 2FA support (commit abc123)
- June 28: Switched to JWT tokens (security audit)
The JWT change on June 28 might be related to your production issue."
πΊοΈ Roadmap
Near Term
- Visual timeline interface (web UI)
- Context recovery (restore full dev state)
- VS Code extension
- Enhanced AI summaries
Future
- Team synchronization
- Export to Confluence/Notion
- TypeScript port for broader adoption
- Metrics dashboard
π€ Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
Development Workflow
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Built with the Model Context Protocol specification
- Powered by Roslyn for C# code analysis
- Inspired by LSM-tree storage architecture
- Originally extracted from CodeCartographerAI
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
ContextKeeper - Never lose context again π§ β¨
Related Servers
MCP Time Server
Provides tools for getting the current time and date, and formatting timestamps in various formats and timezones.
Nessus MCP Server
An MCP server for interacting with the Tenable Nessus vulnerability scanner.
LetzAI
An MCP server for image generation using the LetzAI API.
SimpleLocalize
A MCP server for SimpleLocalize, a translation management system. Requires a SimpleLocalize API key.
LLMS.TXT Documentation Server
Access and read llms.txt documentation files for various Large Language Models.
Repomix
Packs code repositories into a single, AI-friendly file using the repomix tool.
CursorRules MCP
An intelligent system for managing programming rules, supporting search, versioning, code validation, and prompt enhancement.
DiffuGen
Generate images from text using Flux and Stable Diffusion models.
MCPOmni Connect
A universal command-line interface (CLI) gateway to the MCP ecosystem, integrating multiple MCP servers, AI models, and transport protocols.
Design System Server
An MCP server for accessing and managing design system documentation from a GitHub repository.