Documentation
Learn how to use ContextFS to give your AI agents persistent memory.
Getting Started
CLI Reference
MCP Integration
Cloud Sync
Installation
Install ContextFS using pip:
pip install contextfsRequires Python 3.9 or higher.
Quick Start
1. Initialize a repository
$ contextfs index init2. Save a memory
$ contextfs memory save "API uses JWT auth" --type fact3. Search memories
$ contextfs memory search "authentication"4. Index your codebase
$ contextfs index indexBasic Usage
Saving Memories
Save facts, decisions, errors, and procedures that your AI agents can recall later:
# Save a fact
contextfs memory save "Database uses PostgreSQL" --type fact
# Save a decision with rationale
contextfs memory save "Chose React over Vue for component library" --type decision
# Save an error resolution
contextfs memory save "Fixed CORS by adding middleware" --type errorSearching Memories
Use semantic search to find relevant memories:
# Search by topic
contextfs memory search "database configuration"
# Search with type filter
contextfs memory search "auth" --type decision
# Limit results
contextfs memory search "API" --limit 5Auto-Recall
Automatically load relevant context at session start:
$ contextfs memory auto-recallCLI Commands
| Command | Description |
|---|---|
memory save | Save a new memory |
memory search | Search memories semantically |
memory list | List recent memories |
memory auto-recall | Auto-load relevant context |
index init | Initialize repository for indexing |
index index | Index repository files and commits |
index status | Check indexing status |
cloud sync | Sync memories to cloud |
Configuration
Config File Location
ContextFS stores configuration in ~/.contextfs/config.yaml
Example Configuration
# ~/.contextfs/config.yaml
embedding_backend: auto # auto, fastembed, or sentence_transformers
auto_index: true # Auto-index on session start
max_results: 10 # Default search result limit
# Cloud sync settings
cloud:
api_url: https://api.contextfs.ai
auto_sync: falseEnvironment Variables
CONTEXTFS_API_KEY=your-api-key # For cloud sync
CONTEXTFS_DATA_DIR=~/.contextfs # Data directoryClaude Desktop Integration
Add ContextFS to your Claude Desktop configuration:
{
"mcpServers": {
"contextfs": {
"command": "uvx",
"args": ["contextfs"]
}
}
}Restart Claude Desktop after updating the configuration.
MCP Tools
ContextFS exposes the following MCP tools for AI agents:
| Tool | Description |
|---|---|
contextfs_save | Save a memory with type, tags, and content |
contextfs_search | Semantic search across all memories |
contextfs_list | List recent memories |
contextfs_recall | Recall a specific memory by ID |
contextfs_evolve | Update a memory with version history |
contextfs_link | Create relationships between memories |
contextfs_sync | Sync memories with cloud |
Custom MCP Clients
ContextFS can be integrated with any MCP-compatible client. Here are examples for different tools:
Claude Code
# In your .mcp.json or claude_desktop_config.json
{
"mcpServers": {
"contextfs": {
"command": "uvx",
"args": ["contextfs"]
}
}
}Cursor
# In Cursor settings, add MCP server:
Command: uvx
Args: contextfsProgrammatic Access
from contextfs import ContextFS
ctx = ContextFS()
ctx.save("API uses JWT", type="fact")
results = ctx.search("authentication")Cloud Sync Setup
1. Login to ContextFS Cloud
$ contextfs cloud loginThis will open a browser to authenticate with your ContextFS account.
2. Sync Your Memories
# Push local memories to cloud
contextfs cloud sync --direction push
# Pull cloud memories to local
contextfs cloud sync --direction pull
# Two-way sync (default)
contextfs cloud sync3. Check Sync Status
$ contextfs cloud statusMulti-Device Sync
ContextFS Cloud enables seamless memory synchronization across all your development machines.
How It Works
- Each device registers with your ContextFS account
- Memories are encrypted locally before upload
- Changes sync automatically in the background
- Conflict resolution preserves both versions
Register a New Device
# On your new device
contextfs cloud login
# Device is automatically registered
contextfs cloud syncView Connected Devices
$ contextfs cloud devicesMemory Types
factGeneral facts and knowledge
decisionArchitectural and design decisions
codeCode snippets and patterns
errorError resolutions and fixes
commitGit commit information
workflowMulti-step process definitions
taskIndividual task tracking
agent_runAgent execution records