Forked from taderich73/filesystem-access
README.md
Source code | LM Studio listing
Allows filesystem access for the following actions:
All tools now return a JSON string with one of the following shapes:
{ "ok": true, "operation": "write_file", "data": {} }
{ "ok": false, "operation": "read_file", "error": { "code": "FILE_NOT_FOUND", "message": "File does not exist" } }
code: stable machine-readable error codemessage: human-readable explanationCurrent error codes include:
DIR_NOT_SETDIR_NOT_AVAILABLEFILE_PATH_OUTSIDE_BASEDIRECTORY_PATH_OUTSIDE_BASEFILE_NOT_FOUNDFILE_NOT_FILEDIRECTORY_NOT_FOUNDDIRECTORY_NOT_DIRECTORYDIRECTORY_NOT_EMPTYDELETE_FAILEDPATH_OUTSIDE_BASEpath_exists can also return:
PATH_OUTSIDE_BASEmove_file can also return:
SOURCE_PATH_OUTSIDE_BASEDESTINATION_PATH_OUTSIDE_BASESOURCE_EQUALS_DESTINATIONSOURCE_FILE_NOT_FOUNDSOURCE_NOT_FILEDESTINATION_IS_DIRECTORYDESTINATION_EXISTSCROSS_DEVICE_MOVE_UNSUPPORTEDMOVE_FAILEDcopy_file can also return:
SOURCE_PATH_OUTSIDE_BASEDESTINATION_PATH_OUTSIDE_BASESOURCE_EQUALS_DESTINATIONSOURCE_FILE_NOT_FOUNDSOURCE_NOT_FILEDESTINATION_IS_DIRECTORYDESTINATION_EXISTSCOPY_FAILEDcopy_directory can also return:
SOURCE_PATH_OUTSIDE_BASEDESTINATION_PATH_OUTSIDE_BASESOURCE_EQUALS_DESTINATIONDESTINATION_INSIDE_SOURCESOURCE_DIRECTORY_NOT_FOUNDSOURCE_NOT_DIRECTORYDESTINATION_NOT_DIRECTORYDESTINATION_EXISTSCOPY_FAILEDmove_directory can also return:
SOURCE_PATH_OUTSIDE_BASEDESTINATION_PATH_OUTSIDE_BASESOURCE_EQUALS_DESTINATIONDESTINATION_INSIDE_SOURCESOURCE_DIRECTORY_NOT_FOUNDSOURCE_NOT_DIRECTORYDESTINATION_NOT_DIRECTORYDESTINATION_EXISTSCROSS_DEVICE_MOVE_UNSUPPORTEDMOVE_FAILEDmove_file moves a file from source_path to destination_path within the configured base directory.
source_path must exist and be a file.overwrite is not true, the tool returns DESTINATION_EXISTS.destination_path are created automatically.copy_file copies a file from source_path to destination_path within the configured base directory.
source_path must exist and be a file.overwrite is not true, the tool returns DESTINATION_EXISTS.destination_path are created automatically.copy_directory copies a directory from source_path to destination_path within the configured base directory.
source_path must exist and be a directory.overwrite is not true, the tool returns DESTINATION_EXISTS.destination_path are created automatically.move_directory moves a directory from source_path to destination_path within the configured base directory.
source_path must exist and be a directory.overwrite is not true, the tool returns DESTINATION_EXISTS.destination_path are created automatically.delete_file deletes a single file at file_name within the configured base directory.
deleted: true with file_name and relative_path.delete_directory deletes a directory at directory_path within the configured base directory.
recursive is false; non-empty directories return DIRECTORY_NOT_EMPTY.recursive: true to delete non-empty directories.find_file searches recursively inside the configured base directory:
file_name query supports spaces and common filename characters.matches with fields: file_name, relative_path, score.score: 1 and match_type: "exact".0 < score < 1 and match_type: "lax".ok remains true with match_type: "none" and matches: [].Example find_file success payload:
{ "ok": true, "operation": "find_file", "data": { "query": "report_2026", "match_type": "lax", "count": 1, "matches": [ { "file_name": "report-final-2026.md", "relative_path": "notes/report-final-2026.md", "score": 0.83 } ] } }
write_file, read_file, find_file, and create_directory accept names with spaces and common path characters.
Path safety is enforced by keeping all resolved paths inside the configured base directory.
path_exists checks whether a path exists inside the configured base directory.
exists: true and path_type as file or directory.ok: true with exists: false and path_type: "missing".PATH_OUTSIDE_BASE.This project uses vitest for unit tests.
Install dependencies and run tests:
npm install npm test
Watch mode:
npm run test:watch
Coverage report:
npm run test:coverage
Coverage output is generated in coverage/ with HTML (coverage/index.html) and lcov formats.
The coverage run includes a threshold gate and fails if global coverage drops below: statements 80%, lines 80%, functions 70%, branches 60%.