Skip to content

Refactor filesystem MCP server path logic to fix Linux support and follow DRY #37

@abi-chatterjee

Description

@abi-chatterjee

GitHub Issue Content

Title: Refactor filesystem MCP server path logic to fix Linux support and follow DRY

Body:

Problem

The filesystem MCP server initialization logic is duplicated across multiple files and contains incorrect platform detection for Linux systems. Currently, it defaults to /Users for all non-Windows platforms, but Linux uses /home for user directories, causing failures on Linux.

Current Issues

  • DRY Violation: Same logic repeated in 3+ places (src/core/config.ts, src/interfaces/cli/index.ts, src/interfaces/http/session-manager.ts)
  • Linux Bug: Uses /Users instead of /home on Linux, causing "ENOENT: no such file or directory, stat '/Users'" errors
  • Maintainability: Platform changes require updates in multiple locations

Proposed Solution

  1. Create src/utils/platform.ts with getDefaultFilesystemAllowedPath() utility function
  2. Update all usage locations to import and use this centralized function
  3. Fix platform detection: Windows → C:\Users, macOS → /Users, Linux → /home

Files to Modify

  • src/utils/platform.ts (new file)
  • src/core/config.ts
  • src/interfaces/cli/index.ts
  • src/interfaces/http/session-manager.ts
  • Update documentation in docs/architecture/FILESYSTEM_ACCESS.md

Acceptance Criteria

  • No more "ENOENT: no such file or directory, stat '/Users'" on Linux
  • Single source of truth for platform-specific filesystem paths
  • All interfaces (CLI, HTTP, programmatic) use consistent path logic
  • Backward compatibility maintained

Additional Context

This fixes the error encountered on Linux where the filesystem MCP server tries to access /Users which doesn't exist, and consolidates the logic to prevent future inconsistencies.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions