MCP Memory Service Scripts

September 22, 2025 ยท View on GitHub

This directory contains organized utility scripts for maintaining, managing, and operating the MCP Memory Service. Scripts are categorized by function for easy navigation and maintenance.

๐Ÿ“ Directory Structure

scripts/
โ”œโ”€โ”€ backup/          # Backup and restore operations
โ”œโ”€โ”€ database/        # Database analysis and health monitoring
โ”œโ”€โ”€ development/     # Development tools and debugging utilities
โ”œโ”€โ”€ installation/    # Setup and installation scripts
โ”œโ”€โ”€ maintenance/     # Database cleanup and repair operations
โ”œโ”€โ”€ migration/       # Data migration and schema updates
โ”œโ”€โ”€ server/          # Server runtime and operational scripts
โ”œโ”€โ”€ service/         # Service management and deployment
โ”œโ”€โ”€ sync/            # Backend synchronization utilities
โ”œโ”€โ”€ testing/         # Test scripts and validation
โ”œโ”€โ”€ utils/           # General utility scripts and wrappers
โ”œโ”€โ”€ validation/      # Configuration and system validation
โ”œโ”€โ”€ run/             # Runtime execution scripts
โ”œโ”€โ”€ archive/         # Deprecated scripts (kept for reference)
โ””โ”€โ”€ README.md        # This file

๐Ÿš€ Quick Reference

Essential Daily Operations

# Service Management
./service/memory_service_manager.sh status           # Check service status
./service/memory_service_manager.sh start-cloudflare # Start with Cloudflare backend

# Backend Synchronization
./sync/claude_sync_commands.py status               # Check sync status
./sync/claude_sync_commands.py backup               # Backup Cloudflare โ†’ SQLite
./sync/claude_sync_commands.py sync                 # Bidirectional sync

# Configuration Validation
./validation/validate_config.py                     # Validate MCP configuration
./validation/verify_environment.py                  # Check environment setup

# Database Health
./database/simple_timestamp_check.py                # Quick health check
./database/db_health_check.py                       # Comprehensive health analysis

๐Ÿ“‚ Detailed Directory Guide

๐Ÿ”„ sync/ - Backend Synchronization

Essential for managing dual-backend setups and data synchronization.

ScriptPurposeQuick Usage
sync_memory_backends.pyCore bidirectional sync enginepython sync/sync_memory_backends.py --status
claude_sync_commands.pyUser-friendly sync wrapperpython sync/claude_sync_commands.py backup
export_memories.pyExport memories to JSONpython sync/export_memories.py
import_memories.pyImport memories from JSONpython sync/import_memories.py data.json

Key Features:

  • โœ… Bidirectional Cloudflare โ†” SQLite synchronization
  • โœ… Intelligent deduplication using content hashing
  • โœ… Dry-run mode for safe testing
  • โœ… Comprehensive status reporting

๐Ÿ› ๏ธ service/ - Service Management

Linux service management for production deployments.

ScriptPurposeQuick Usage
memory_service_manager.shComplete service lifecycle management./service/memory_service_manager.sh start-cloudflare
service_control.shBasic service control operations./service/service_control.sh restart
service_utils.pyService utility functionsUsed by other service scripts
deploy_dual_services.shDeploy dual-backend architecture./service/deploy_dual_services.sh
update_service.shUpdate running service./service/update_service.sh

Key Features:

  • โœ… Dual-backend configuration management
  • โœ… Environment file handling (.env, .env.sqlite)
  • โœ… Service health monitoring
  • โœ… Integrated sync operations

โœ… validation/ - Configuration & System Validation

Ensure proper setup and configuration.

ScriptPurposeQuick Usage
validate_config.pyMCP configuration validatorpython validation/validate_config.py
validate_memories.pyMemory data validationpython validation/validate_memories.py
verify_environment.pyEnvironment setup checkerpython validation/verify_environment.py
check_documentation_links.pyDocumentation link validatorpython validation/check_documentation_links.py
verify_pytorch_windows.pyPyTorch Windows validationpython validation/verify_pytorch_windows.py

Key Features:

  • โœ… Claude Code global configuration validation
  • โœ… Cloudflare credentials verification
  • โœ… Environment conflict detection
  • โœ… Comprehensive error reporting with solutions

๐Ÿ—„๏ธ database/ - Database Analysis & Health

Monitor and analyze database health and performance.

ScriptPurposeQuick Usage
simple_timestamp_check.pyQuick timestamp health checkpython database/simple_timestamp_check.py
db_health_check.pyComprehensive health analysispython database/db_health_check.py
analyze_sqlite_vec_db.pyDetailed SQLite-vec analysispython database/analyze_sqlite_vec_db.py
check_sqlite_vec_status.pySQLite-vec status checkerpython database/check_sqlite_vec_status.py

Exit Codes (for CI/CD):

  • 0 - Excellent/Good health
  • 1 - Warning status
  • 2 - Critical issues
  • 3 - Analysis failed

๐Ÿงน maintenance/ - Database Cleanup & Repair

Scripts for maintaining database integrity and performance.

ScriptPurposeQuick Usage
find_duplicates.pyFind and remove duplicate memoriespython maintenance/find_duplicates.py --execute
cleanup_corrupted_encoding.pyFix corrupted emoji encodingpython maintenance/cleanup_corrupted_encoding.py --execute
repair_memories.pyRepair corrupted memory entriespython maintenance/repair_memories.py
cleanup_memories.pyGeneral memory cleanuppython maintenance/cleanup_memories.py
repair_sqlite_vec_embeddings.pyFix embedding inconsistenciespython maintenance/repair_sqlite_vec_embeddings.py
repair_zero_embeddings.pyFix zero/null embeddingspython maintenance/repair_zero_embeddings.py

Safety Features:

  • โœ… Dry-run mode available for all scripts
  • โœ… Comprehensive backup recommendations
  • โœ… Detailed reporting of changes

๐Ÿ’พ backup/ - Backup & Restore Operations

Data protection and recovery operations.

ScriptPurposeQuick Usage
backup_memories.pyCreate memory backupspython backup/backup_memories.py
restore_memories.pyRestore from backupspython backup/restore_memories.py backup.json
backup_sqlite_vec.shSQLite-vec database backup./backup/backup_sqlite_vec.sh
export_distributable_memories.shCreate distributable exports./backup/export_distributable_memories.sh

๐Ÿ”„ migration/ - Data Migration & Schema Updates

Handle database migrations and data transformations.

ScriptPurposeQuick Usage
migrate_to_cloudflare.pyMigrate to Cloudflare backendpython migration/migrate_to_cloudflare.py
migrate_chroma_to_sqlite.pyChromaDB โ†’ SQLite migrationpython migration/migrate_chroma_to_sqlite.py
migrate_sqlite_vec_embeddings.pyUpdate embedding formatpython migration/migrate_sqlite_vec_embeddings.py
migrate_timestamps.pyFix timestamp issuespython migration/migrate_timestamps.py
cleanup_mcp_timestamps.pyClean timestamp proliferationpython migration/cleanup_mcp_timestamps.py
verify_mcp_timestamps.pyVerify timestamp consistencypython migration/verify_mcp_timestamps.py

๐Ÿ  installation/ - Setup & Installation

Platform-specific installation and setup scripts.

ScriptPurposeQuick Usage
install_linux_service.pyLinux service installationpython installation/install_linux_service.py
install_macos_service.pymacOS service setuppython installation/install_macos_service.py
install_windows_service.pyWindows service installationpython installation/install_windows_service.py
setup_cloudflare_resources.pyCloudflare resource setuppython installation/setup_cloudflare_resources.py
setup_backup_cron.shAutomated backup scheduling./installation/setup_backup_cron.sh

๐Ÿ–ฅ๏ธ server/ - Server Runtime & Operations

Scripts for running and managing the memory server.

ScriptPurposeQuick Usage
run_memory_server.pyStart memory serverpython server/run_memory_server.py
run_http_server.pyStart HTTP API serverpython server/run_http_server.py
check_server_health.pyHealth check endpointpython server/check_server_health.py
memory_offline.pyOffline memory operationspython server/memory_offline.py
preload_models.pyPre-load ML modelspython server/preload_models.py

๐Ÿงช testing/ - Test Scripts & Validation

Comprehensive testing and validation scripts.

ScriptPurposeQuick Usage
run_complete_test.pyComplete system testpython testing/run_complete_test.py
test_memory_api.pyAPI functionality testspython testing/test_memory_api.py
test_cloudflare_backend.pyCloudflare backend testspython testing/test_cloudflare_backend.py
test_sqlite_vec_embeddings.pyEmbedding system testspython testing/test_sqlite_vec_embeddings.py
simple_test.pyBasic functionality testpython testing/simple_test.py

๐Ÿ”ง utils/ - General Utilities

Helper scripts and utility functions.

ScriptPurposeQuick Usage
claude_commands_utils.pyClaude command utilitiesUsed by Claude Code hooks
query_memories.pyDirect memory queryingpython utils/query_memories.py "search term"
memory_wrapper_uv.pyUV package manager wrapperUsed by other scripts
generate_personalized_claude_md.shGenerate custom CLAUDE.md./utils/generate_personalized_claude_md.sh

๐Ÿ› ๏ธ development/ - Development Tools

Tools for developers and debugging.

ScriptPurposeQuick Usage
setup-git-merge-drivers.shConfigure git merge drivers./development/setup-git-merge-drivers.sh
fix_mdns.shFix mDNS issues./development/fix_mdns.sh
uv-lock-merge.shHandle UV lock file merges./development/uv-lock-merge.sh
find_orphaned_files.pyFind orphaned database filespython development/find_orphaned_files.py

๐ŸŽฏ Common Use Cases

Initial Setup

# 1. Validate environment
python validation/verify_environment.py

# 2. Install appropriate service
python installation/install_linux_service.py

# 3. Validate configuration
python validation/validate_config.py

# 4. Start service
./service/memory_service_manager.sh start-cloudflare

Daily Operations

# Check overall health
./service/memory_service_manager.sh status
python database/simple_timestamp_check.py

# Sync backends
python sync/claude_sync_commands.py sync

# Backup
python sync/claude_sync_commands.py backup

Troubleshooting

# Validate configuration
python validation/validate_config.py

# Check database health
python database/db_health_check.py

# Fix common issues
python maintenance/find_duplicates.py --execute
python maintenance/cleanup_corrupted_encoding.py --execute

Migration & Upgrades

# Before migration - backup
python backup/backup_memories.py

# Migrate to new backend
python migration/migrate_to_cloudflare.py

# Verify migration
python validation/validate_memories.py

๐Ÿšจ Safety Guidelines

Before Running Maintenance Scripts

  1. Always backup first: python backup/backup_memories.py
  2. Use dry-run mode: Most scripts support --dry-run or similar
  3. Test with small datasets when possible
  4. Check database health: python database/simple_timestamp_check.py

Script Execution Order

  1. Validation scripts first (check environment)
  2. Backup before any data modifications
  3. Maintenance operations (cleanup, repair)
  4. Verification after changes
  5. Service restart if needed

๐Ÿ”— Integration with Documentation

This scripts directory integrates with:

  • CLAUDE.md: Essential commands for Claude Code users
  • AGENTS.md: Agent development and release process
  • Wiki: Detailed setup and troubleshooting guides
  • GitHub Actions: CI/CD pipeline integration

๐Ÿ“ Adding New Scripts

When adding new scripts:

  1. Choose appropriate category based on primary function
  2. Follow naming conventions: snake_case.py or kebab-case.sh
  3. Include proper documentation in script headers
  4. Add safety mechanisms for data-modifying operations
  5. Update this README with script description
  6. Test with multiple backends (SQLite-vec, Cloudflare)

๐Ÿ†˜ Getting Help

  • Configuration issues: Run python validation/validate_config.py
  • Database problems: Run python database/db_health_check.py
  • Documentation links: Run python validation/check_documentation_links.py
  • General health: Run ./service/memory_service_manager.sh status

For complex issues, check the project wiki or create an issue with the output from relevant diagnostic scripts.