Skip to main content
Glama

filesystem-mcp

by sylphxltd
.clinerules2.07 kB
<!-- Version: 4.6 | Last Updated: 2025-04-06 | Updated By: Roo --> # Cline Rules for filesystem-mcp Project ## Tool Usage Preferences - **Prioritize Edit Tools:** When modifying existing files, prefer using `apply_diff`, `insert_content`, or `search_and_replace` over `write_to_file`. `write_to_file` should primarily be used for creating new files or when a complete rewrite is necessary, as it can be less efficient for large files or minor edits. ## Technical Notes & Workarounds - **Vitest ESM Mocking:** Mocking Node.js built-in ES Modules (like `fs/promises`) or external libraries (`glob`) using `vi.mock` or `vi.doMock` in Vitest can be problematic due to hoisting, scope, and type inference issues, especially when trying to modify mock behavior within tests. **Prefer direct dependency injection:** - Export the core logic function from the handler file, accepting dependencies as an argument. - In tests, import the core logic function. - In `beforeEach`, create mock functions (`vi.fn()`) for dependencies. - Use `vi.importActual` to get the real implementations and set them as the default for the mock functions. - Create a `dependencies` object, passing in the mock functions. - Call the core logic function with the `dependencies` object. - Within specific tests requiring mocked behavior, modify the implementation of the mock function (e.g., `mockDependency.mockImplementation(...)`). - *Obsolete `editFile` Strategy:* Previous attempts used `jest.unstable_mockModule` (likely a typo, meant Vitest equivalent) which was also unreliable. - *Obsolete `listFiles` Strategy:* Initial integration tests avoided mocking but couldn't test error paths effectively. Dependency injection proved superior. - **Execution Requirement:** Tests still require `NODE_OPTIONS=--experimental-vm-modules` (handled by `cross-env` in `package.json`). - **`write_content` Tool Limitation:** This tool might incorrectly escape certain characters within the `<content>` block. Prefer `apply_diff` or `replace_content` for modifications.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sylphxltd/filesystem-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server