Skip to content

[BUG] The basic-memory MCP server currently attempts to sync ALL files in a project directory, including hidden folders #287

Closed

Description

@FellowTraveler

Basic Memory MCP Server - Dot Folder Exclusion Feature Request

Problem Description

The basic-memory MCP server currently attempts to sync ALL files in a project directory, including hidden folders (folders starting with a dot). This causes several critical issues:

Current Issues:

  1. File Name Length Errors: When syncing .taskmaster/ folders that contain CLI output in filenames, the sync fails with:

    [Errno 63] File name too long: b"[INFO] Initialized Perplexity client...
    
  2. Unnecessary Processing: The server attempts to process tool-specific configuration and cache directories that are not relevant to project memory/knowledge management:

    • .taskmaster/ - TaskMaster task management files
    • .git/ - Git repository metadata
    • .vscode/ - VS Code configuration
    • target/ (Rust) - Build artifacts
    • node_modules/ - Node dependencies
    • .next/ - Next.js build cache
    • And many other tool-specific directories
  3. Performance Impact: Syncing thousands of build artifacts and dependency files unnecessarily slows down the sync process and inflates the database size.

  4. MCP Server Conflicts: Different MCP servers may use dot folders for their own purposes, causing interference between tools.

Proposed Solution

Add an option to automatically exclude all dot folders (folders starting with .) from file syncing and watching. This should be the default behavior, with an option to override if needed.

Implementation Suggestions:

  1. Default Exclusion Pattern: Add .* to the default exclude patterns
  2. Configuration Option: Add a setting like include_dot_folders: false (default)
  3. Respect .gitignore: Consider also respecting .gitignore patterns by default

Example Configuration:

{
  "exclude_patterns": [".*", "node_modules", "target", "dist", "build"],
  "include_dot_folders": false,
  "respect_gitignore": true
}

Benefits

  1. Prevents Sync Errors: Eliminates file name length errors from tool outputs
  2. Improves Performance: Reduces unnecessary file processing
  3. Better Tool Interoperability: Prevents conflicts between different MCP servers
  4. Follows Best Practices: Aligns with common practice of ignoring dot folders in many tools
  5. Cleaner Database: Only tracks actual project source files, not tool artifacts

Current Workaround

Currently, users must manually delete and recreate projects when sync errors occur, which is disruptive to workflow.

Additional Context

Many development tools follow the convention of using dot folders for configuration and cache:

  • Version control systems (.git, .svn, .hg)
  • IDEs and editors (.vscode, .idea, .sublime)
  • Language/framework tools (.cargo, .npm, .yarn)
  • Project management tools (.taskmaster, .github)

These folders typically contain:

  • Machine-generated files
  • Frequently changing cache files
  • Large binary artifacts
  • Tool-specific metadata

None of these are relevant to the semantic knowledge that basic-memory is designed to track.

Expected Behavior

When include_dot_folders is false (default):

  • The file watcher should skip all directories starting with .
  • The sync process should not attempt to process files in dot folders
  • The database should only contain actual project source files

Priority

High - This issue causes basic-memory to fail with errors and significantly impacts usability when used alongside other MCP servers or development tools.

Activity

  1. added
    bug
    on Sep 3, 2025
  2. FellowTraveler commented on Sep 3, 2025

    @FellowTraveler
    Author

    #286

    I think this issue is fixed with this PR. Was causing conflicts with .taskmaster

  3. added this to the v0.15.0 milestone on Sep 18, 2025
  4. phernandez commented on Sep 26, 2025

    @phernandez
    Member

    @claude we added an src/basic_memory/ignore_utils.py. Can we integrate this into the sync so it skips .gitignored files?

  5. claude commented on Sep 26, 2025

    @claude
    Contributor

    Claude finished @phernandez's task —— View job • claude/issue-287-20250926-1439 • Create PR ➔


    ✅ Completed integration of ignore_utils.py into sync process

    I've successfully integrated the existing src/basic_memory/ignore_utils.py into the sync process to skip .gitignored files.

    Changes Made:

    1. Updated src/basic_memory/sync/sync_service.py:

      • Added imports for load_gitignore_patterns and should_ignore_path from ignore_utils
      • Modified scan_directory method to load gitignore patterns and filter files/directories
      • Added logging for ignored files count
    2. Updated src/basic_memory/sync/watch_service.py:

      • Added imports for ignore utilities
      • Added gitignore pattern caching mechanism to avoid reloading patterns repeatedly
      • Modified _watch_projects_cycle to filter out changes for ignored files
      • Cache is cleared at the start of each watch cycle to pick up any .gitignore changes

    How It Works:

    • The sync process now respects .gitignore patterns plus default ignore patterns (e.g., .git, node_modules, __pycache__, etc.)
    • Files and directories matching these patterns are skipped during:
      • Initial directory scanning
      • File watching for changes
    • The implementation uses the existing ignore_utils.py module which was already in the codebase with comprehensive tests

    Result:

    This fixes issue #287 by preventing the sync of:

    • Dot folders (.git, .vscode, .taskmaster, etc.)
    • Files specified in .gitignore
    • Common build artifacts and dependencies

    Branch: claude/issue-287-20250926-1439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions