rmcp_memex
Lightweight Model Context Protocol (MCP) server written in Rust. Provides a local RAG (Retrieval-Augmented Generation) toolset backed by embedded LanceDB vector storage and local embeddings via fastembed. Optional MLX HTTP bridge for Apple Silicon acceleration.
Features
- Vector Memory: Store, search, and retrieve text chunks with semantic similarity
- Document Indexing: Index UTF-8 text files and PDFs for RAG queries
- Namespace Isolation: Organize data into separate namespaces
- Health Monitoring: Built-in health tool for status checks
- Configuration Wizard: Interactive TUI for easy setup and host configuration
- MCP Compatible: Works with Claude Desktop, Codex, Cursor, and other MCP hosts
Quick Start
Installation
# Clone and build
# Install to ~/.cargo/bin (optional)
Or use the install script:
# For macOS app bundle:
Run
# Default configuration (starts MCP server)
# Explicit serve subcommand
# With options
Configuration Wizard
Interactive TUI for setting up rmcp_memex and configuring MCP host integrations:
# Launch wizard
# Dry-run mode (preview changes without writing)
The wizard will:
- Auto-detect installed MCP hosts (Codex, Cursor, Claude Desktop, JetBrains, VS Code)
- Guide you through memex configuration (database path, cache size, log level, mode)
- Generate config snippets for selected hosts
- Run health checks to verify setup
- Optionally write configuration files (with backups)
Usage as Library
Add to your Cargo.toml:
[]
= { = "https://github.com/Loctree/rmcp-memex.git" }
Example: Direct RAG Pipeline Access
use ;
use Arc;
use Mutex;
async
Example: Run Full MCP Server Programmatically
use ;
async
Exported Types
| Type | Description |
|---|---|
ServerConfig |
Configuration for server/pipeline |
RAGPipeline |
Core RAG operations: index, search, memory |
SearchResult |
Search result with id, text, score, metadata |
StorageManager |
LanceDB + sled + moka cache layer |
ChromaDocument |
Document struct for storage |
FastEmbedder |
Local embeddings via fastembed |
MLXBridge |
Optional MLX HTTP bridge for Apple Silicon |
MCPServer |
MCP protocol handler |
MCP Tools
| Tool | Description |
|---|---|
health |
Server status: version, db_path, cache_dir, backend (mlx/fastembed) |
rag_index |
Index a file (UTF-8 text or PDF) into vector store |
rag_index_text |
Index raw text with optional ID and metadata |
rag_search |
Semantic search across indexed documents |
memory_upsert |
Store a text chunk in a namespace |
memory_get |
Retrieve a chunk by namespace + ID |
memory_search |
Semantic search within a namespace |
memory_delete |
Delete a chunk by namespace + ID |
memory_purge_namespace |
Delete all chunks in a namespace |
Namespace Conventions
Namespaces provide data isolation and multi-tenancy. We recommend these naming patterns:
| Pattern | Use Case | Example |
|---|---|---|
user:<id> |
Per-user memory isolation | user:alice, user:12345 |
agent:<id> |
Per-AI-agent memory | agent:claude, agent:codex |
session:<id> |
Ephemeral session data | session:abc123 |
kb:<name> |
Shared knowledge bases | kb:docs, kb:codebase |
project:<name> |
Project-scoped data | project:myapp, project:rmcp_memex |
Best Practices
- Use prefixes consistently — helps with retention policies and access control
- Keep IDs URL-safe — avoid special characters; use alphanumeric + hyphen/underscore
- Document your schema — maintain a mapping of namespace patterns in your project
- Consider lifecycle —
session:*for temporary,kb:*for persistent data
Examples
// Per-user memory
rag.memory_upsert.await?;
// Shared knowledge base
rag.memory_upsert.await?;
// Session-scoped (clean up after session ends)
rag.memory_upsert.await?;
rag.purge_namespace.await?; // Cleanup
Configuration
CLI Options
| Flag | Default | Description |
|---|---|---|
--config |
— | Path to TOML config file |
--mode |
full |
Server mode: memory (memory-only) or full (all features) |
--db-path |
~/.rmcp_servers/rmcp_memex/lancedb |
LanceDB storage path |
--cache-mb |
4096 |
Cache size in MB |
--log-level |
info |
Logging level: trace, debug, info, warn, error |
--max-request-bytes |
5242880 (5 MB) |
Max JSON-RPC request size |
--features |
filesystem,memory,search |
Feature flags (overrides --mode) |
Server Modes
| Mode | Features | Use Case |
|---|---|---|
full |
filesystem, memory, search | Full RAG with document indexing |
memory |
memory, search | Pure vector memory server (no filesystem access) |
# Memory-only mode (recommended for AI assistants)
# Full RAG mode (default)
TOML Config File
= "memory" # or "full"
= "~/.rmcp_servers/rmcp_memex/lancedb"
= 4096
= "info"
= 5242880
# features = "memory,search" # Optional: overrides mode
CLI flags override config file values.
Environment Variables
| Variable | Description |
|---|---|
FASTEMBED_CACHE_PATH |
Fastembed model cache (default: $HOME/.cache/fastembed) |
HF_HUB_CACHE |
HuggingFace cache path |
DISABLE_MLX |
Set to 1 or true to disable MLX bridge, use fastembed only |
DRAGON_BASE_URL |
MLX HTTP server base URL (default: http://localhost) |
MLX_JIT_MODE |
true for single-port MLX mode |
MLX_JIT_PORT |
JIT mode port (default: 1234) |
EMBEDDER_PORT |
Non-JIT embeddings port (default: 12345) |
RERANKER_PORT |
Non-JIT reranker port (default: 12346) |
MCP Host Configuration
Codex (~/.codex/config.toml)
[]
= "/path/to/rmcp_memex"
= ["--db-path", "~/.rmcp_servers/rmcp_memex/lancedb", "--log-level", "info"]
= 120
Claude Desktop (claude_desktop_config.json)
Cursor / Other MCP Hosts
Use stdio transport with the binary path and desired arguments.
Library Usage
use ;
async
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Client │────▶│ rmcp_memex │────▶│ LanceDB │
│ (Claude, Codex) │ │ (JSON-RPC/stdio)│ │ (embeddings) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ fastembed/MLX │
│ (embeddings) │
└──────────────────┘
- Transport: Newline-delimited JSON-RPC over stdio
- Vector Store: Embedded LanceDB (no external DB required)
- Embeddings: fastembed (default) or MLX HTTP bridge
- Caching: moka (in-memory) + sled (persistent KV)
Development
# Format
# Lint
# Test
# Build release
Git Hooks
Install pre-commit and pre-push hooks:
Pre-push runs: fmt check, clippy, tests, semgrep.
Requirements
- Rust: Stable toolchain
- OS: macOS, Linux (Windows untested)
- Protobuf: Build uses vendored protoc, but system protoc may be needed:
- macOS:
brew install protobuf - Linux:
apt install protobuf-compiler
- macOS:
License
MIT — see LICENSE.
Links
- Repository: https://github.com/Loctree/rmcp_memex
- Changelog: CHANGELOG.md
- Loctree Integration: docs/LOCTREE_INTEGRATION_PROPOSAL.md