context-mcp
MCP server for context management, temporal metadata, and lightweight retrieval plumbing.
This crate provides a "memory service" for agents: store/retrieve context items with timestamps and metadata, supporting basic query/retrieval patterns via text matching and filtering.
Quick Start
Install
|
Or via cargo:
See INSTALL.md for detailed installation instructions and VS Code configuration.
Run
# Stdio transport (for MCP clients like VS Code)
# HTTP server
Features
- Multi-tier Storage: In-memory LRU cache with optional sled-based disk persistence
- Temporal Tracking: Timestamps, age tracking, and time-based filtering for context relevance
- CPU-Optimized Retrieval: Parallel processing with rayon for text-based context queries
- MCP Protocol Support: JSON-RPC server implementation with HTTP/WebSocket and stdio transports
- Screening Status Fields: Built-in fields for tracking security screening state (integration not included)
Performance
Validated through comprehensive benchmarking:
- 7,421 contexts/second sustained throughput
- Sub-millisecond latency (0.13-0.23ms average)
- 100% test pass rate across all 9 MCP tools
See ASSESSMENT_REPORT.md for detailed performance analysis.
Documentation
- INSTALL.md - Installation and setup guide
- USAGE_EXAMPLES.md - Usage examples and scenarios
- ASSESSMENT_REPORT.md - Performance benchmarks and validation
- API Documentation - Rust API reference
Status
Production-ready for context management and lightweight RAG. APIs are stable.
Usage
As a Library
use ;
async
As an MCP Server
Run as HTTP server:
Run as stdio transport:
What It Does (Verified by Code/Tests)
- JSON-RPC MCP Server: Runs over HTTP/WebSocket or stdio transport
- Context Storage: Store/retrieve contexts with IDs, domains, timestamps, tags, and custom metadata
- Tiered Storage: In-memory LRU cache (always) + optional sled disk persistence
- Text-Based Queries: Query by text content, domain, tags, time ranges with simple text matching
- Temporal Filtering: Filter contexts by creation time, last access, age, and expiration
- Parallel Processing: CPU-optimized retrieval using rayon for performance
- MCP Tools: 10 tools including store_context, get_context, query_contexts, retrieve_contexts, delete_context, update_screening, get_temporal_stats, get_storage_stats, cleanup_expired
What It Does Not Do (Yet)
- Vector embeddings: Mock implementation only - no real embedding generation or similarity search
- Semantic search: Text matching is literal, not semantic
- External integrations: No active security-mcp or other service integrations (only status fields)
- Chunking/citations: No automatic document chunking or citation tracking
- Distributed storage: Single-node only, no replication or clustering
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Client │ │ JSON-RPC Server │ │ Storage Layer │
│ │ │ │ │ │
│ • HTTP/WS │◄──►│ • Store/Retrieve │◄──►│ • In-Memory LRU │
│ • stdio │ │ • Query/Filter │ │ • Sled (opt) │
│ • curl/tools │ │ • Temporal Stats │ │ • Domain Index │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────┐
│ RAG Processor│
│ • Text Match │
│ • Parallel │
│ • Scoring │
└──────────────┘
Development
Setup
-
Install development dependencies:
-
Run all quality checks:
Available Commands
This project uses just for development tasks:
Code Quality
- Formatting:
cargo fmt(enforced) - Linting:
cargo clippywith warnings as errors - Testing: 100% test coverage target with
cargo tarpaulin - Security:
cargo auditandcargo denyfor vulnerabilities and license compliance - Documentation:
cargo docwith warning checks - Dependencies: Unused dependency detection with
cargo udeps
Security Scanning
The project includes comprehensive security scanning:
- Vulnerability scanning:
cargo auditchecks for known security issues - License compliance:
cargo denyensures only approved licenses - Dependency analysis: Checks for unused and outdated dependencies
- Pre-commit hooks: Automatic quality checks before commits
Benchmarking
Performance benchmarks are included for critical paths:
Contributing
See CONTRIBUTING.md for development setup and contribution guidelines.
License
Licensed under the MIT License. See LICENSE for details.