Local Setup
AutoMem Server — Local Setup
Section titled “AutoMem Server — Local Setup”Prerequisites
Section titled “Prerequisites”Before setting up the development environment, ensure the following tools are installed:
| Tool | Minimum Version | Purpose |
|---|---|---|
| Python | 3.10+ | Core runtime |
| pip | Latest | Package management |
| Docker | Latest | Local service dependencies (optional) |
| Docker Compose | Latest | Multi-container orchestration (optional) |
| git | Any recent version | Source control |
Repository Contents
Section titled “Repository Contents”After cloning the repository, the structure relevant to development:
| Path | Description |
|---|---|
app.py | Main Flask API application |
consolidation.py | Background consolidation engine |
requirements.txt | Production dependencies |
requirements-dev.txt | Development dependencies |
Dockerfile | Container image definition |
docker-compose.yml | Local service orchestration |
tests/ | Test suite |
scripts/ | Utility scripts |
Virtual Environment Setup
Section titled “Virtual Environment Setup”Create an isolated Python environment to avoid dependency conflicts:
python3 -m venv venvsource venv/bin/activate # macOS/Linux# or: venv\Scripts\activate # WindowsThe virtual environment isolates all installed packages from system Python, ensuring reproducible builds.
Install Dependencies
Section titled “Install Dependencies”Development Dependencies (Recommended)
Section titled “Development Dependencies (Recommended)”pip install -r requirements-dev.txtThis installs:
- Production dependencies via
-r requirements.txt - Testing tools:
pytest==8.3.4 - HTTP client:
requests==2.31.0(for integration tests) - Configuration:
python-dotenv==1.0.1 - Code quality:
black==24.8.0,flake8==7.1.1
Production Dependencies Only
Section titled “Production Dependencies Only”pip install -r requirements.txtUse this for minimal installations without testing/development tools.
Optional: spaCy for Enhanced Entity Extraction
Section titled “Optional: spaCy for Enhanced Entity Extraction”pip install spacypython -m spacy download en_core_web_smThe en_core_web_sm model enables Named Entity Recognition (NER) in the enrichment pipeline for extracting persons, organizations, locations, and temporal entities from memory content. AutoMem degrades gracefully if spaCy is unavailable — entity extraction simply won’t run.
Running Dependencies
Section titled “Running Dependencies”Development Environment Architecture
Section titled “Development Environment Architecture”graph TB
subgraph "Developer Machine"
subgraph "Virtual Environment (venv)"
Flask["app.py\nFlask API\nPort 8001"]
Consol["consolidation.py\nBackground Engine"]
end
subgraph "Docker Compose Stack (make dev)"
DC["docker-compose.yml"]
Falkor["falkordb/falkordb:latest\nPort 6379\nVolume: ./data/falkordb"]
Qdrant["qdrant/qdrant:latest\nPort 6333\nVolume: ./data/qdrant"]
APIContainer["memory-service\nPort 8001\nOptional"]
end
subgraph "External Services (Optional)"
ExtFalkor["External FalkorDB\nlocalhost:6379"]
ExtQdrant["External Qdrant\nlocalhost:6333"]
end
end
Flask -->|"FALKORDB_HOST=localhost\nFALKORDB_PORT=6379"| Falkor
Flask -->|"QDRANT_URL=http://localhost:6333"| Qdrant
Flask -.->|"Alternative"| ExtFalkor
Flask -.->|"Alternative"| ExtQdrant
DC --> Falkor
DC --> Qdrant
DC -.->|"Optional"| APIContainer
Two primary approaches exist for running the database dependencies.
Option 1: Docker Compose (Recommended)
Section titled “Option 1: Docker Compose (Recommended)”make dev # equivalent to: docker-compose up -dThis starts:
- FalkorDB on port
6379with volume mount at./data/falkordb - Qdrant on port
6333with volume mount at./data/qdrant
The docker-compose.yml defines these services with persistent storage, ensuring data survives container restarts.
# Stop servicesdocker-compose down
# Check service statusdocker-compose ps
# View logsdocker-compose logs -f falkordbOption 2: External Services
Section titled “Option 2: External Services”Run FalkorDB and Qdrant independently (bare metal, separate Docker containers, or cloud) and configure connection via environment variables (see Development Configuration below).
Running the API
Section titled “Running the API”With dependencies running, start the Flask API:
python app.pyThe Flask application binds to 0.0.0.0:8001 by default. The PORT environment variable controls the listening port.
Verify startup:
curl http://localhost:8001/healthExpected response:
{ "status": "healthy", "falkordb": "connected", "qdrant": "connected"}Startup Sequence
Section titled “Startup Sequence”sequenceDiagram
participant Dev as "Developer"
participant Flask as "app.py (Flask)"
participant Falkor as "FalkorDB :6379"
participant Qdrant as "Qdrant :6333"
participant Enrich as "EnrichmentWorker"
participant Embed as "EmbeddingWorker"
participant Sched as "ConsolidationScheduler"
Dev->>Flask: "python app.py"
Flask->>Flask: "Load env vars\n(PORT, FALKORDB_HOST, etc.)"
Flask->>Falkor: "Connect to localhost:6379"
alt Qdrant configured
Flask->>Qdrant: "Connect to localhost:6333"
Qdrant-->>Flask: "Connection OK"
else No Qdrant
Flask->>Flask: "Graceful degradation\n(FalkorDB-only mode)"
end
Flask->>Enrich: "Start worker thread"
Enrich->>Enrich: "Begin polling queue"
Flask->>Embed: "Start worker thread"
Embed->>Embed: "Begin batch accumulator"
Flask->>Sched: "Initialize scheduler"
Sched->>Sched: "Schedule decay (1h)\ncreative (1h)\ncluster (6h)\nforget (1d)"
Flask->>Flask: "Bind to 0.0.0.0:8001"
Flask-->>Dev: "Server ready"
Dev->>Flask: "GET /health"
Flask->>Falkor: "Ping"
Falkor-->>Flask: "PONG"
Flask->>Qdrant: "Collection info"
Qdrant-->>Flask: "Collection exists"
Flask-->>Dev: '{"status": "healthy"}'
Development Configuration
Section titled “Development Configuration”AutoMem loads configuration from three sources in order of precedence:
- Process environment (highest priority)
.envfile in project root~/.config/automem/.env(user-wide config)
Minimal development configuration — create .env in the project root:
PORT=8001FALKORDB_HOST=localhostFALKORDB_PORT=6379QDRANT_URL=http://localhost:6333OPENAI_API_KEY=sk-...AUTOMEM_API_TOKEN=your-dev-tokenFull Configuration Reference
Section titled “Full Configuration Reference”| Variable | Default | Description |
|---|---|---|
PORT | 8001 | Flask API port |
FALKORDB_HOST | localhost | FalkorDB hostname |
FALKORDB_PORT | 6379 | FalkorDB port |
FALKORDB_PASSWORD | unset | FalkorDB auth password |
FALKORDB_GRAPH | memories | Graph database name |
QDRANT_URL | unset | Qdrant endpoint URL |
QDRANT_API_KEY | unset | Qdrant API key |
QDRANT_COLLECTION | memories | Qdrant collection name |
VECTOR_SIZE | 768 | Embedding dimension |
OPENAI_API_KEY | unset | OpenAI API key |
ENRICHMENT_MAX_ATTEMPTS | 3 | Enrichment retry limit |
ENRICHMENT_SIMILARITY_LIMIT | 5 | Semantic neighbors count |
ENRICHMENT_SIMILARITY_THRESHOLD | 0.8 | SIMILAR_TO edge threshold |
FLASK_ENV | production | Flask mode (development enables debug) |
LOG_LEVEL | INFO | Logging verbosity |
Enable development mode for verbose logging and auto-reload:
FLASK_ENV=developmentLOG_LEVEL=DEBUGThe FLASK_ENV=development setting enables: detailed error pages with stack traces, auto-reload on file changes, and more verbose console output.
Development Workflow
Section titled “Development Workflow”Code formatting with Black:
black app.py consolidation.py tests/Code linting with Flake8:
flake8 app.py consolidation.pyRunning tests:
pytest tests/ -vManual API testing:
# Store a test memorycurl -X POST http://localhost:8001/memory \ -H "Authorization: Bearer your-dev-token" \ -H "Content-Type: application/json" \ -d '{"content": "Test memory", "tags": ["test"], "importance": 0.5}'
# Recall memoriescurl "http://localhost:8001/recall?query=test&limit=5" \ -H "Authorization: Bearer your-dev-token"Troubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”Symptom: OSError: [Errno 48] Address already in use
lsof -i :8001 # Find process using portkill -9 <PID> # Kill itOr change the port: PORT=8002 python app.py
FalkorDB Connection Failed
Section titled “FalkorDB Connection Failed”Symptom: 503 Service Unavailable or FalkorDB is unavailable
docker-compose ps # Check if FalkorDB container is runningdocker-compose up -d falkordb # Start it if notdocker-compose logs falkordb # Check for errorsImport Errors
Section titled “Import Errors”Symptom: ModuleNotFoundError: No module named 'flask'
source venv/bin/activate # Activate virtualenvpip install -r requirements-dev.txtQdrant Not Working
Section titled “Qdrant Not Working”Symptom: Qdrant errors in logs but API still works
Behavior: AutoMem operates in graceful degradation mode, using FalkorDB-only functionality. Vector search is replaced by keyword search. This is acceptable for development but impacts recall quality.
docker-compose up -d qdrantcurl http://localhost:6333/health # Verify Qdrant is accessibleEnrichment Worker Not Processing
Section titled “Enrichment Worker Not Processing”Symptom: Memories stored but enrichment: queued never completes
Debug steps: Check logs for enrichment_worker thread exceptions. Look for metadata.enriched_at field to confirm enrichment ran.
Common causes:
- Worker thread crashed (check logs for exceptions)
- spaCy model not installed (
pip install spacy && python -m spacy download en_core_web_sm) - Memory already enriched (check
metadata.enriched_atfield)
Docker Volumes Permission Issues
Section titled “Docker Volumes Permission Issues”Symptom: Permission denied errors when writing to ./data/falkordb or ./data/qdrant
sudo chown -R $(whoami) ./data/mcp-automem Client — Local Setup
Section titled “mcp-automem Client — Local Setup”Prerequisites
Section titled “Prerequisites”- Node.js: Version 20.0.0 or higher
- npm: Comes with Node.js
- git: For version control
- AutoMem Service: Running instance for integration testing (local or Railway-hosted)
Quick Start
Section titled “Quick Start”git clone https://github.com/verygoodplugins/mcp-automemcd mcp-automemnpm install # Also installs Husky git hooks via "prepare" lifecycle scriptnpm Scripts Reference
Section titled “npm Scripts Reference”| Script | Command | Purpose |
|---|---|---|
build | tsc && npm run postbuild | Compile TypeScript to dist/, make executable |
postbuild | chmod +x dist/index.js | Ensure binary is executable |
dev | tsx watch src/index.ts | Hot-reload development server |
lint | eslint . | Run ESLint static analysis |
prepare | husky | Install git hooks (runs on npm install) |
start | node dist/index.js | Run compiled server |
test | vitest run | Execute unit tests |
test:watch | vitest | Run tests in watch mode |
test:coverage | vitest run --coverage | Generate coverage report |
test:integration | vitest run --config vitest.integration.config.ts | Run integration tests |
test:all | vitest run && vitest run --config vitest.integration.config.ts | Run all test suites |
typecheck | tsc --noEmit | Type-check without compilation |
prepublishOnly | npm run build && npm run test | Pre-publish validation |
build:extension | npm run build && npx @anthropic-ai/mcpb pack | Build .mcpb Claude Desktop extension |
Development Environment Configuration
Section titled “Development Environment Configuration”Create a .env file in the project root:
AUTOMEM_ENDPOINT=http://localhost:8001AUTOMEM_API_KEY=your-api-keyConfiguration is read in priority order:
- Constructor arguments (programmatic usage)
- Process environment variables (
process.env) .envfile in current directory.envfile in home directory
Development Mode
Section titled “Development Mode”The dev script uses tsx for hot-reload development — TypeScript runs directly without a compilation step:
npm run dev # Watch mode, restarts on file changesThis is the recommended mode when actively developing. For testing the compiled output:
npm run build && node dist/index.jsDebugging the MCP Server
Section titled “Debugging the MCP Server”Method 1: Direct invocation — test CLI commands without MCP client:
node dist/index.js setup # Test setup wizardnode dist/index.js --help # Show available commandsMethod 2: Hot-reload in server mode — run without arguments to enter server mode, then send JSON-RPC messages via stdin.
Debugging tips:
- Add
console.error()statements (goes to stderr, doesn’t corrupt stdio protocol) - Use
DEBUG=*environment variable if using the debug library - Check AutoMem service logs for backend errors
- Validate JSON payloads with
jqor online validators
Pre-Commit Checklist
Section titled “Pre-Commit Checklist”Before committing changes to mcp-automem:
- Run
npm run lint(no errors) - Run
npm run typecheck(no type errors) - Run
npm test(all tests pass) - Ensure commit message follows Conventional Commits format
- Update documentation if adding new features
- Add tests for new functionality