@j0hanz/filesystem-context-mcp 1.2.9 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -453
- package/dist/__tests__/lib/file-operations/compute-checksums.test.d.ts +2 -0
- package/dist/__tests__/lib/file-operations/compute-checksums.test.d.ts.map +1 -0
- package/dist/__tests__/lib/file-operations/compute-checksums.test.js +59 -0
- package/dist/__tests__/lib/file-operations/compute-checksums.test.js.map +1 -0
- package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.d.ts +2 -0
- package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.d.ts.map +1 -0
- package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.js +46 -0
- package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.js.map +1 -0
- package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js +1 -1
- package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js.map +1 -1
- package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts +2 -0
- package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts.map +1 -0
- package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js +43 -0
- package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js.map +1 -0
- package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts +7 -0
- package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts.map +1 -0
- package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js +113 -0
- package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js.map +1 -0
- package/dist/__tests__/lib/file-operations/search-definitions.test.js +153 -280
- package/dist/__tests__/lib/file-operations/search-definitions.test.js.map +1 -1
- package/dist/__tests__/lib/file-operations/sorting.test.d.ts +2 -0
- package/dist/__tests__/lib/file-operations/sorting.test.d.ts.map +1 -0
- package/dist/__tests__/lib/file-operations/sorting.test.js +22 -0
- package/dist/__tests__/lib/file-operations/sorting.test.js.map +1 -0
- package/dist/__tests__/lib/fs-helpers/utf8.test.d.ts +2 -0
- package/dist/__tests__/lib/fs-helpers/utf8.test.d.ts.map +1 -0
- package/dist/__tests__/lib/fs-helpers/utf8.test.js +43 -0
- package/dist/__tests__/lib/fs-helpers/utf8.test.js.map +1 -0
- package/dist/__tests__/lib/path-validation-errors.test.d.ts +2 -0
- package/dist/__tests__/lib/path-validation-errors.test.d.ts.map +1 -0
- package/dist/__tests__/lib/path-validation-errors.test.js +35 -0
- package/dist/__tests__/lib/path-validation-errors.test.js.map +1 -0
- package/dist/__tests__/lib/path-validation-roots.test.d.ts +2 -0
- package/dist/__tests__/lib/path-validation-roots.test.d.ts.map +1 -0
- package/dist/__tests__/lib/path-validation-roots.test.js +42 -0
- package/dist/__tests__/lib/path-validation-roots.test.js.map +1 -0
- package/dist/__tests__/lib/path-validation.test.js +22 -0
- package/dist/__tests__/lib/path-validation.test.js.map +1 -1
- package/dist/__tests__/security/filesystem-boundary.test.js +20 -12
- package/dist/__tests__/security/filesystem-boundary.test.js.map +1 -1
- package/dist/config/formatting.d.ts +14 -0
- package/dist/config/formatting.d.ts.map +1 -0
- package/dist/config/formatting.js +34 -0
- package/dist/config/formatting.js.map +1 -0
- package/dist/config/types.d.ts +12 -75
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions.md +159 -149
- package/dist/lib/constants.d.ts +1 -5
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +31 -11
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/errors.d.ts +0 -2
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +2 -30
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/file-operations/analyze-directory-helpers.d.ts +24 -0
- package/dist/lib/file-operations/analyze-directory-helpers.d.ts.map +1 -0
- package/dist/lib/file-operations/analyze-directory-helpers.js +50 -0
- package/dist/lib/file-operations/analyze-directory-helpers.js.map +1 -0
- package/dist/lib/file-operations/analyze-directory.d.ts +1 -0
- package/dist/lib/file-operations/analyze-directory.d.ts.map +1 -1
- package/dist/lib/file-operations/analyze-directory.js +11 -59
- package/dist/lib/file-operations/analyze-directory.js.map +1 -1
- package/dist/lib/file-operations/batch-results.d.ts +13 -0
- package/dist/lib/file-operations/batch-results.d.ts.map +1 -0
- package/dist/lib/file-operations/batch-results.js +23 -0
- package/dist/lib/file-operations/batch-results.js.map +1 -0
- package/dist/lib/file-operations/compute-checksums.d.ts +10 -0
- package/dist/lib/file-operations/compute-checksums.d.ts.map +1 -0
- package/dist/lib/file-operations/compute-checksums.js +134 -0
- package/dist/lib/file-operations/compute-checksums.js.map +1 -0
- package/dist/lib/file-operations/directory-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/directory-helpers.js +18 -10
- package/dist/lib/file-operations/directory-helpers.js.map +1 -1
- package/dist/lib/file-operations/directory-tree-builders.d.ts +7 -0
- package/dist/lib/file-operations/directory-tree-builders.d.ts.map +1 -0
- package/dist/lib/file-operations/directory-tree-builders.js +58 -0
- package/dist/lib/file-operations/directory-tree-builders.js.map +1 -0
- package/dist/lib/file-operations/directory-tree-helpers.d.ts +0 -5
- package/dist/lib/file-operations/directory-tree-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/directory-tree-helpers.js +21 -64
- package/dist/lib/file-operations/directory-tree-helpers.js.map +1 -1
- package/dist/lib/file-operations/directory-tree.d.ts +1 -0
- package/dist/lib/file-operations/directory-tree.d.ts.map +1 -1
- package/dist/lib/file-operations/directory-tree.js +5 -10
- package/dist/lib/file-operations/directory-tree.js.map +1 -1
- package/dist/lib/file-operations/file-info.d.ts +3 -1
- package/dist/lib/file-operations/file-info.d.ts.map +1 -1
- package/dist/lib/file-operations/file-info.js +16 -5
- package/dist/lib/file-operations/file-info.js.map +1 -1
- package/dist/lib/file-operations/get-multiple-file-info.d.ts +7 -0
- package/dist/lib/file-operations/get-multiple-file-info.d.ts.map +1 -0
- package/dist/lib/file-operations/get-multiple-file-info.js +57 -0
- package/dist/lib/file-operations/get-multiple-file-info.js.map +1 -0
- package/dist/lib/file-operations/list-directory-entry.d.ts +18 -0
- package/dist/lib/file-operations/list-directory-entry.d.ts.map +1 -0
- package/dist/lib/file-operations/list-directory-entry.js +93 -0
- package/dist/lib/file-operations/list-directory-entry.js.map +1 -0
- package/dist/lib/file-operations/list-directory-helpers.d.ts +6 -1
- package/dist/lib/file-operations/list-directory-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/list-directory-helpers.js +83 -97
- package/dist/lib/file-operations/list-directory-helpers.js.map +1 -1
- package/dist/lib/file-operations/list-directory.d.ts +2 -0
- package/dist/lib/file-operations/list-directory.d.ts.map +1 -1
- package/dist/lib/file-operations/list-directory.js +11 -11
- package/dist/lib/file-operations/list-directory.js.map +1 -1
- package/dist/lib/file-operations/read-media-file.d.ts.map +1 -1
- package/dist/lib/file-operations/read-media-file.js +5 -1
- package/dist/lib/file-operations/read-media-file.js.map +1 -1
- package/dist/lib/file-operations/read-multiple-files.d.ts +8 -0
- package/dist/lib/file-operations/read-multiple-files.d.ts.map +1 -1
- package/dist/lib/file-operations/read-multiple-files.js +15 -7
- package/dist/lib/file-operations/read-multiple-files.js.map +1 -1
- package/dist/lib/file-operations/search/engine-options.d.ts.map +1 -1
- package/dist/lib/file-operations/search/engine-options.js +1 -8
- package/dist/lib/file-operations/search/engine-options.js.map +1 -1
- package/dist/lib/file-operations/search/engine-stream.d.ts +1 -1
- package/dist/lib/file-operations/search/engine-stream.d.ts.map +1 -1
- package/dist/lib/file-operations/search/engine-stream.js +21 -5
- package/dist/lib/file-operations/search/engine-stream.js.map +1 -1
- package/dist/lib/file-operations/search/engine.d.ts +1 -1
- package/dist/lib/file-operations/search/engine.d.ts.map +1 -1
- package/dist/lib/file-operations/search/engine.js +43 -3
- package/dist/lib/file-operations/search/engine.js.map +1 -1
- package/dist/lib/file-operations/search/file-processor.d.ts.map +1 -1
- package/dist/lib/file-operations/search/file-processor.js +94 -54
- package/dist/lib/file-operations/search/file-processor.js.map +1 -1
- package/dist/lib/file-operations/search/match-strategy.d.ts.map +1 -1
- package/dist/lib/file-operations/search/match-strategy.js +2 -1
- package/dist/lib/file-operations/search/match-strategy.js.map +1 -1
- package/dist/lib/file-operations/search/types.d.ts +1 -0
- package/dist/lib/file-operations/search/types.d.ts.map +1 -1
- package/dist/lib/file-operations/search-content.d.ts +1 -0
- package/dist/lib/file-operations/search-content.d.ts.map +1 -1
- package/dist/lib/file-operations/search-content.js +1 -1
- package/dist/lib/file-operations/search-content.js.map +1 -1
- package/dist/lib/file-operations/search-definitions/matchers.d.ts +12 -0
- package/dist/lib/file-operations/search-definitions/matchers.d.ts.map +1 -0
- package/dist/lib/file-operations/search-definitions/matchers.js +122 -0
- package/dist/lib/file-operations/search-definitions/matchers.js.map +1 -0
- package/dist/lib/file-operations/search-definitions/patterns.d.ts +14 -0
- package/dist/lib/file-operations/search-definitions/patterns.d.ts.map +1 -0
- package/dist/lib/file-operations/search-definitions/patterns.js +83 -0
- package/dist/lib/file-operations/search-definitions/patterns.js.map +1 -0
- package/dist/lib/file-operations/search-definitions.d.ts.map +1 -1
- package/dist/lib/file-operations/search-definitions.js +25 -199
- package/dist/lib/file-operations/search-definitions.js.map +1 -1
- package/dist/lib/file-operations/search-files-helpers.d.ts +3 -27
- package/dist/lib/file-operations/search-files-helpers.d.ts.map +1 -1
- package/dist/lib/file-operations/search-files-helpers.js +18 -45
- package/dist/lib/file-operations/search-files-helpers.js.map +1 -1
- package/dist/lib/file-operations/search-files-options.d.ts +33 -0
- package/dist/lib/file-operations/search-files-options.d.ts.map +1 -0
- package/dist/lib/file-operations/search-files-options.js +33 -0
- package/dist/lib/file-operations/search-files-options.js.map +1 -0
- package/dist/lib/file-operations/search-files.d.ts +1 -1
- package/dist/lib/file-operations/search-files.d.ts.map +1 -1
- package/dist/lib/file-operations/search-files.js +9 -3
- package/dist/lib/file-operations/search-files.js.map +1 -1
- package/dist/lib/file-operations/sorting.d.ts.map +1 -1
- package/dist/lib/file-operations/sorting.js +39 -14
- package/dist/lib/file-operations/sorting.js.map +1 -1
- package/dist/lib/file-operations.d.ts +1 -4
- package/dist/lib/file-operations.d.ts.map +1 -1
- package/dist/lib/file-operations.js +1 -4
- package/dist/lib/file-operations.js.map +1 -1
- package/dist/lib/fs-helpers/binary-detect.d.ts.map +1 -1
- package/dist/lib/fs-helpers/binary-detect.js +13 -16
- package/dist/lib/fs-helpers/binary-detect.js.map +1 -1
- package/dist/lib/fs-helpers/concurrency.d.ts +1 -1
- package/dist/lib/fs-helpers/concurrency.d.ts.map +1 -1
- package/dist/lib/fs-helpers/concurrency.js +37 -3
- package/dist/lib/fs-helpers/concurrency.js.map +1 -1
- package/dist/lib/fs-helpers/readers/head-file.js +1 -1
- package/dist/lib/fs-helpers/readers/head-file.js.map +1 -1
- package/dist/lib/fs-helpers/readers/read-buffer.d.ts +2 -0
- package/dist/lib/fs-helpers/readers/read-buffer.d.ts.map +1 -0
- package/dist/lib/fs-helpers/readers/read-buffer.js +52 -0
- package/dist/lib/fs-helpers/readers/read-buffer.js.map +1 -0
- package/dist/lib/fs-helpers/readers/read-file-content.d.ts +36 -0
- package/dist/lib/fs-helpers/readers/read-file-content.d.ts.map +1 -0
- package/dist/lib/fs-helpers/readers/read-file-content.js +49 -0
- package/dist/lib/fs-helpers/readers/read-file-content.js.map +1 -0
- package/dist/lib/fs-helpers/readers/read-file.d.ts +9 -0
- package/dist/lib/fs-helpers/readers/read-file.d.ts.map +1 -1
- package/dist/lib/fs-helpers/readers/read-file.js +56 -36
- package/dist/lib/fs-helpers/readers/read-file.js.map +1 -1
- package/dist/lib/fs-helpers/readers/tail-file.js +1 -1
- package/dist/lib/fs-helpers/readers/tail-file.js.map +1 -1
- package/dist/lib/merge-defined.d.ts +2 -0
- package/dist/lib/merge-defined.d.ts.map +1 -0
- package/dist/lib/merge-defined.js +8 -0
- package/dist/lib/merge-defined.js.map +1 -0
- package/dist/lib/path-utils.d.ts +1 -0
- package/dist/lib/path-utils.d.ts.map +1 -1
- package/dist/lib/path-utils.js +12 -0
- package/dist/lib/path-utils.js.map +1 -1
- package/dist/lib/path-validation/allowed-directories.d.ts.map +1 -1
- package/dist/lib/path-validation/allowed-directories.js +2 -9
- package/dist/lib/path-validation/allowed-directories.js.map +1 -1
- package/dist/lib/path-validation/errors.js +2 -2
- package/dist/lib/path-validation/errors.js.map +1 -1
- package/dist/lib/path-validation/validators.d.ts.map +1 -1
- package/dist/lib/path-validation/validators.js +11 -1
- package/dist/lib/path-validation/validators.js.map +1 -1
- package/dist/schemas/common.d.ts +0 -18
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/common.js +0 -10
- package/dist/schemas/common.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +2 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/input-helpers.d.ts +1 -4
- package/dist/schemas/input-helpers.d.ts.map +1 -1
- package/dist/schemas/input-helpers.js +9 -33
- package/dist/schemas/input-helpers.js.map +1 -1
- package/dist/schemas/inputs/checksums.d.ts +8 -0
- package/dist/schemas/inputs/checksums.d.ts.map +1 -0
- package/dist/schemas/inputs/checksums.js +25 -0
- package/dist/schemas/inputs/checksums.js.map +1 -0
- package/dist/schemas/inputs/directory.d.ts +13 -0
- package/dist/schemas/inputs/directory.d.ts.map +1 -0
- package/dist/schemas/inputs/directory.js +33 -0
- package/dist/schemas/inputs/directory.js.map +1 -0
- package/dist/schemas/inputs/file-info.d.ts +9 -0
- package/dist/schemas/inputs/file-info.d.ts.map +1 -0
- package/dist/schemas/inputs/file-info.js +20 -0
- package/dist/schemas/inputs/file-info.js.map +1 -0
- package/dist/schemas/inputs/read.d.ts +22 -0
- package/dist/schemas/inputs/read.d.ts.map +1 -0
- package/dist/schemas/inputs/read.js +39 -0
- package/dist/schemas/inputs/read.js.map +1 -0
- package/dist/schemas/inputs/search.d.ts +33 -0
- package/dist/schemas/inputs/search.d.ts.map +1 -0
- package/dist/schemas/inputs/search.js +89 -0
- package/dist/schemas/inputs/search.js.map +1 -0
- package/dist/schemas/inputs.d.ts +4 -94
- package/dist/schemas/inputs.d.ts.map +1 -1
- package/dist/schemas/inputs.js +4 -227
- package/dist/schemas/inputs.js.map +1 -1
- package/dist/schemas/output-helpers.d.ts +59 -0
- package/dist/schemas/output-helpers.d.ts.map +1 -1
- package/dist/schemas/output-helpers.js +31 -0
- package/dist/schemas/output-helpers.js.map +1 -1
- package/dist/schemas/outputs/checksums.d.ts +93 -0
- package/dist/schemas/outputs/checksums.d.ts.map +1 -0
- package/dist/schemas/outputs/checksums.js +18 -0
- package/dist/schemas/outputs/checksums.js.map +1 -0
- package/dist/schemas/outputs/directory.d.ts +257 -0
- package/dist/schemas/outputs/directory.d.ts.map +1 -0
- package/dist/schemas/outputs/directory.js +63 -0
- package/dist/schemas/outputs/directory.js.map +1 -0
- package/dist/schemas/outputs/file-info.d.ts +270 -0
- package/dist/schemas/outputs/file-info.d.ts.map +1 -0
- package/dist/schemas/outputs/file-info.js +30 -0
- package/dist/schemas/outputs/file-info.js.map +1 -0
- package/dist/schemas/outputs/read.d.ts +282 -0
- package/dist/schemas/outputs/read.d.ts.map +1 -0
- package/dist/schemas/outputs/read.js +62 -0
- package/dist/schemas/outputs/read.js.map +1 -0
- package/dist/schemas/outputs/search.d.ts +370 -0
- package/dist/schemas/outputs/search.d.ts.map +1 -0
- package/dist/schemas/outputs/search.js +96 -0
- package/dist/schemas/outputs/search.js.map +1 -0
- package/dist/schemas/outputs.d.ts +4 -1059
- package/dist/schemas/outputs.d.ts.map +1 -1
- package/dist/schemas/outputs.js +4 -229
- package/dist/schemas/outputs.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +28 -15
- package/dist/server.js.map +1 -1
- package/dist/tools/analyze-directory.d.ts.map +1 -1
- package/dist/tools/analyze-directory.js +26 -28
- package/dist/tools/analyze-directory.js.map +1 -1
- package/dist/tools/compute-checksums.d.ts +3 -0
- package/dist/tools/compute-checksums.d.ts.map +1 -0
- package/dist/tools/compute-checksums.js +69 -0
- package/dist/tools/compute-checksums.js.map +1 -0
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +17 -11
- package/dist/tools/directory-tree.js.map +1 -1
- package/dist/tools/get-file-info.d.ts.map +1 -1
- package/dist/tools/get-file-info.js +8 -44
- package/dist/tools/get-file-info.js.map +1 -1
- package/dist/tools/get-multiple-file-info.d.ts +3 -0
- package/dist/tools/get-multiple-file-info.d.ts.map +1 -0
- package/dist/tools/get-multiple-file-info.js +53 -0
- package/dist/tools/get-multiple-file-info.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -8
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-allowed-dirs.d.ts.map +1 -1
- package/dist/tools/list-allowed-dirs.js +46 -29
- package/dist/tools/list-allowed-dirs.js.map +1 -1
- package/dist/tools/list-directory.d.ts.map +1 -1
- package/dist/tools/list-directory.js +83 -77
- package/dist/tools/list-directory.js.map +1 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +57 -37
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/read-media-file.d.ts.map +1 -1
- package/dist/tools/read-media-file.js +8 -6
- package/dist/tools/read-media-file.js.map +1 -1
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +58 -23
- package/dist/tools/read-multiple-files.js.map +1 -1
- package/dist/tools/search-content.d.ts.map +1 -1
- package/dist/tools/search-content.js +14 -16
- package/dist/tools/search-content.js.map +1 -1
- package/dist/tools/search-definitions.d.ts.map +1 -1
- package/dist/tools/search-definitions.js +59 -42
- package/dist/tools/search-definitions.js.map +1 -1
- package/dist/tools/search-files.d.ts.map +1 -1
- package/dist/tools/search-files.js +65 -45
- package/dist/tools/search-files.js.map +1 -1
- package/dist/tools/shared/file-info.d.ts +17 -0
- package/dist/tools/shared/file-info.d.ts.map +1 -0
- package/dist/tools/shared/file-info.js +40 -0
- package/dist/tools/shared/file-info.js.map +1 -0
- package/dist/tools/shared/formatting.d.ts +5 -0
- package/dist/tools/shared/formatting.d.ts.map +1 -1
- package/dist/tools/shared/formatting.js +21 -1
- package/dist/tools/shared/formatting.js.map +1 -1
- package/dist/tools/shared/read-range.d.ts +7 -0
- package/dist/tools/shared/read-range.d.ts.map +1 -0
- package/dist/tools/shared/read-range.js +22 -0
- package/dist/tools/shared/read-range.js.map +1 -0
- package/dist/tools/shared/search-formatting.d.ts.map +1 -1
- package/dist/tools/shared/search-formatting.js +57 -29
- package/dist/tools/shared/search-formatting.js.map +1 -1
- package/dist/tools/tool-response.d.ts +22 -0
- package/dist/tools/tool-response.d.ts.map +1 -1
- package/dist/tools/tool-response.js +30 -0
- package/dist/tools/tool-response.js.map +1 -1
- package/package.json +2 -1
package/dist/instructions.md
CHANGED
|
@@ -1,57 +1,65 @@
|
|
|
1
1
|
# Filesystem Context MCP Server
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Read-only tools for exploring directories, searching files, and reading
|
|
4
|
+
> content via the Model Context Protocol (MCP).
|
|
4
5
|
|
|
5
|
-
This server
|
|
6
|
+
This server lets assistants inspect files safely. All operations are limited to
|
|
7
|
+
explicitly allowed directories and never write to disk.
|
|
6
8
|
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
## Quick Reference
|
|
10
12
|
|
|
11
|
-
| Goal | Tool | Key Parameters
|
|
12
|
-
| ------------------- | -------------------------- |
|
|
13
|
-
| Check access | `list_allowed_directories` |
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
| Goal | Tool | Key Parameters |
|
|
14
|
+
| ------------------- | -------------------------- | ----------------------------------- |
|
|
15
|
+
| Check access | `list_allowed_directories` | - |
|
|
16
|
+
| List contents | `list_directory` | `recursive`, `maxDepth`, `sortBy` |
|
|
17
|
+
| Find files | `search_files` | `pattern` (glob), `maxResults` |
|
|
18
|
+
| Search in files | `search_content` | `pattern` (regex), `contextLines` |
|
|
19
|
+
| Read file | `read_file` | `head`, `tail`, `lineStart/lineEnd` |
|
|
20
|
+
| Read multiple files | `read_multiple_files` | `paths[]` - preferred for 2+ |
|
|
21
|
+
| File metadata | `get_file_info` | `path` |
|
|
22
|
+
| Batch file metadata | `get_multiple_file_info` | `paths[]` - preferred for 2+ |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Core Concepts
|
|
27
|
+
|
|
28
|
+
- **Allowed directories:** All tools only operate inside the allowed roots.
|
|
29
|
+
Run `list_allowed_directories` first to confirm scope.
|
|
30
|
+
- **Globs vs regex:** `search_files` uses glob patterns, `search_content` uses
|
|
31
|
+
regex (set `isLiteral=true` to search for exact text).
|
|
32
|
+
- **Symlinks:** Symlinks are never followed for security. You can request the
|
|
33
|
+
target path (e.g., `includeSymlinkTargets`) but traversal stays inside roots.
|
|
24
34
|
|
|
25
35
|
---
|
|
26
36
|
|
|
27
37
|
## Workflows
|
|
28
38
|
|
|
29
|
-
### Project
|
|
39
|
+
### Project discovery
|
|
30
40
|
|
|
31
41
|
```text
|
|
32
|
-
list_allowed_directories
|
|
42
|
+
list_allowed_directories
|
|
43
|
+
list_directory(path=".", recursive=true, maxDepth=3)
|
|
44
|
+
read_multiple_files(["package.json", "README.md"])
|
|
33
45
|
```
|
|
34
46
|
|
|
35
|
-
### Find
|
|
47
|
+
### Find and read code
|
|
36
48
|
|
|
37
49
|
```text
|
|
38
|
-
search_files(pattern="**/*.ts")
|
|
50
|
+
search_files(pattern="**/*.ts")
|
|
51
|
+
read_multiple_files([...results])
|
|
39
52
|
```
|
|
40
53
|
|
|
41
|
-
### Search
|
|
54
|
+
### Search patterns in code
|
|
42
55
|
|
|
43
56
|
```text
|
|
44
57
|
search_content(pattern="TODO|FIXME", filePattern="**/*.ts", contextLines=2)
|
|
45
58
|
```
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
```text
|
|
50
|
-
search_definitions(path="src/", name="User") → Find classes/functions/types named "User"
|
|
51
|
-
search_definitions(path="src/", type="interface") → Discover all interfaces
|
|
52
|
-
```
|
|
60
|
+
---
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
## Common Glob Patterns
|
|
55
63
|
|
|
56
64
|
| Pattern | Matches |
|
|
57
65
|
| --------------------- | ----------------------------------------- |
|
|
@@ -67,158 +75,160 @@ search_definitions(path="src/", type="interface") → Discover all interfaces
|
|
|
67
75
|
|
|
68
76
|
**Do:**
|
|
69
77
|
|
|
70
|
-
- Use `read_multiple_files` for 2+ files (parallel, resilient)
|
|
71
|
-
- Set `maxResults`, `maxDepth`, `maxEntries` limits
|
|
72
|
-
- Use `excludePatterns=["node_modules", ".git", "dist"]
|
|
73
|
-
- Preview with `head=50` before full reads
|
|
78
|
+
- Use `read_multiple_files` for 2+ files (parallel, resilient).
|
|
79
|
+
- Set `maxResults`, `maxDepth`, and `maxEntries` limits.
|
|
80
|
+
- Use `excludePatterns=["node_modules/**", ".git/**", "dist/**"]`.
|
|
81
|
+
- Preview large files with `head=50` before full reads.
|
|
74
82
|
|
|
75
83
|
**Don't:**
|
|
76
84
|
|
|
77
|
-
- Loop `read_file`
|
|
78
|
-
-
|
|
79
|
-
- Search without `maxResults` on large codebases
|
|
85
|
+
- Loop `read_file` for multiple files.
|
|
86
|
+
- Run recursive searches without `maxDepth`.
|
|
87
|
+
- Search without `maxResults` on large codebases.
|
|
80
88
|
|
|
81
|
-
|
|
89
|
+
---
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
## Tool Details
|
|
84
92
|
|
|
85
|
-
|
|
93
|
+
### `list_allowed_directories`
|
|
86
94
|
|
|
87
|
-
|
|
88
|
-
| ----------------- | ------- | --------------------- |
|
|
89
|
-
| `path` | — | Directory path |
|
|
90
|
-
| `maxDepth` | 5 | Depth limit (0-50) |
|
|
91
|
-
| `excludePatterns` | [] | Glob patterns to skip |
|
|
92
|
-
| `includeHidden` | false | Include dotfiles |
|
|
93
|
-
| `includeSize` | false | Show file sizes |
|
|
94
|
-
| `maxFiles` | — | Limit total files |
|
|
95
|
+
List all directories this server can access.
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
| Parameter | Default | Description |
|
|
98
|
+
| --------- | ------- | ----------- |
|
|
99
|
+
| (none) | - | - |
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
---
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
| ----------------- | ------- | ------------------------- |
|
|
102
|
-
| `path` | - | Base directory |
|
|
103
|
-
| `pattern` | - | Glob: `**/*.ts`, `src/**` |
|
|
104
|
-
| `excludePatterns` | [] | Patterns to skip |
|
|
105
|
-
| `maxResults` | - | Limit (up to 10,000) |
|
|
106
|
-
| `sortBy` | "path" | `name/size/modified/path` |
|
|
107
|
-
| `includeHidden` | false | Include dotfiles |
|
|
103
|
+
### `list_directory`
|
|
108
104
|
|
|
109
|
-
|
|
105
|
+
List contents of a directory with optional recursion. Returns entry name,
|
|
106
|
+
relative path, type, size, and modified date. Symlinks are not followed.
|
|
110
107
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
| `
|
|
116
|
-
| `pattern`
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `isLiteral` | false | Escape regex |
|
|
122
|
-
| `maxResults` | 100 | Limit matches |
|
|
123
|
-
| `skipBinary` | true | Skip binary files |
|
|
124
|
-
|
|
125
|
-
### `search_definitions`
|
|
126
|
-
|
|
127
|
-
Find code definitions (classes, functions, interfaces, types, enums, variables) without manual regex construction.
|
|
128
|
-
|
|
129
|
-
| Parameter | Default | Description |
|
|
130
|
-
| ----------------- | ------- | ----------------------------------------------------------------------------- |
|
|
131
|
-
| `path` | - | Base directory to search |
|
|
132
|
-
| `name` | - | Definition name to find |
|
|
133
|
-
| `type` | - | Definition type: `class`, `function`, `interface`, `type`, `enum`, `variable` |
|
|
134
|
-
| `caseSensitive` | true | Case-sensitive name matching |
|
|
135
|
-
| `maxResults` | 100 | Limit matches |
|
|
136
|
-
| `excludePatterns` | [] | Glob patterns to exclude |
|
|
137
|
-
| `includeHidden` | false | Include hidden files and directories |
|
|
138
|
-
| `contextLines` | 0 | Lines of context before/after match (0-10) |
|
|
139
|
-
|
|
140
|
-
**Usage patterns:**
|
|
141
|
-
|
|
142
|
-
- **Find by name:** `search_definitions(path="src/", name="UserService")` — finds class/function/type named UserService
|
|
143
|
-
- **Discovery mode:** `search_definitions(path="src/", type="interface")` — lists all interfaces
|
|
144
|
-
- **Combined:** `search_definitions(path="src/", name="Handler", type="class")` — finds classes named "Handler"
|
|
108
|
+
| Parameter | Default | Description |
|
|
109
|
+
| ----------------------- | ------- | ---------------------------------------- |
|
|
110
|
+
| `path` | - | Directory path |
|
|
111
|
+
| `recursive` | false | Include subdirectories |
|
|
112
|
+
| `excludePatterns` | [] | Glob patterns to skip |
|
|
113
|
+
| `pattern` | - | Glob pattern to include (relative only) |
|
|
114
|
+
| `sortBy` | "name" | `name/size/modified/type` |
|
|
115
|
+
| `maxDepth` | 10 | Depth when recursive |
|
|
116
|
+
| `maxEntries` | 10000 | Limit (up to 100,000) |
|
|
117
|
+
| `includeSymlinkTargets` | false | Include target paths for symlink entries |
|
|
145
118
|
|
|
146
|
-
|
|
119
|
+
Structured output note: `entries[].relativePath` is relative to the base path.
|
|
147
120
|
|
|
148
|
-
|
|
121
|
+
---
|
|
149
122
|
|
|
150
|
-
|
|
151
|
-
| ----------- | ------- | ------------------------------- |
|
|
152
|
-
| `path` | — | File path |
|
|
153
|
-
| `encoding` | utf-8 | `utf-8/ascii/base64/hex/latin1` |
|
|
154
|
-
| `maxSize` | 10MB | Size limit |
|
|
155
|
-
| `head` | — | First N lines |
|
|
156
|
-
| `tail` | — | Last N lines |
|
|
157
|
-
| `lineStart` | — | Start line (1-indexed) |
|
|
158
|
-
| `lineEnd` | — | End line (inclusive) |
|
|
123
|
+
### `search_files`
|
|
159
124
|
|
|
160
|
-
|
|
125
|
+
Find files (not directories) using glob patterns.
|
|
126
|
+
|
|
127
|
+
| Parameter | Default | Description |
|
|
128
|
+
| ----------------- | -------- | ---------------------------------------- |
|
|
129
|
+
| `path` | - | Base directory |
|
|
130
|
+
| `pattern` | - | Glob: `**/*.ts`, `src/**` |
|
|
131
|
+
| `excludePatterns` | built-in | Patterns to skip (pass [] to disable) |
|
|
132
|
+
| `maxResults` | 100 | Limit (up to 10,000) |
|
|
133
|
+
| `sortBy` | "path" | `name/size/modified/path` |
|
|
134
|
+
| `maxDepth` | 10 | Maximum depth to scan |
|
|
135
|
+
| `maxFilesScanned` | 20000 | Maximum files to scan before stopping |
|
|
136
|
+
| `timeoutMs` | 30000 | Timeout in milliseconds |
|
|
137
|
+
| `baseNameMatch` | false | Match basename for patterns without '/' |
|
|
138
|
+
| `skipSymlinks` | true | Must remain true (symlink traversal off) |
|
|
139
|
+
| `includeHidden` | false | Include dotfiles and hidden directories |
|
|
161
140
|
|
|
162
|
-
|
|
141
|
+
---
|
|
163
142
|
|
|
164
|
-
|
|
143
|
+
### `search_content`
|
|
165
144
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
|
169
|
-
|
|
|
170
|
-
| `
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
145
|
+
Grep-like search across file contents using regex.
|
|
146
|
+
|
|
147
|
+
| Parameter | Default | Description |
|
|
148
|
+
| ----------------- | -------- | ------------------------------------------ | ------ |
|
|
149
|
+
| `path` | - | Base directory |
|
|
150
|
+
| `pattern` | - | Regex: `TODO | FIXME` |
|
|
151
|
+
| `filePattern` | `**/*` | Glob filter for files |
|
|
152
|
+
| `excludePatterns` | built-in | Glob patterns to skip (pass [] to disable) |
|
|
153
|
+
| `contextLines` | 0 | Lines before/after match (0-10) |
|
|
154
|
+
| `caseSensitive` | false | Case-sensitive matching |
|
|
155
|
+
| `wholeWord` | false | Match whole words only |
|
|
156
|
+
| `isLiteral` | false | Treat pattern as literal string |
|
|
157
|
+
| `maxResults` | 100 | Maximum matches to return |
|
|
158
|
+
| `maxFileSize` | 1MB | Maximum file size to scan |
|
|
159
|
+
| `maxFilesScanned` | 20000 | Maximum files to scan before stopping |
|
|
160
|
+
| `timeoutMs` | 30000 | Timeout in milliseconds |
|
|
161
|
+
| `skipBinary` | true | Skip likely-binary files |
|
|
162
|
+
| `includeHidden` | false | Include dotfiles and hidden directories |
|
|
163
|
+
|
|
164
|
+
Note: `excludePatterns` uses a built-in list of common dependency/build
|
|
165
|
+
folders (e.g., `node_modules`, `dist`, `build`, `coverage`, `.git`, `.vscode`).
|
|
166
|
+
Pass `excludePatterns: []` to disable it.
|
|
175
167
|
|
|
176
|
-
|
|
168
|
+
---
|
|
177
169
|
|
|
178
|
-
### `
|
|
170
|
+
### `read_file`
|
|
179
171
|
|
|
180
|
-
|
|
172
|
+
Read a single text file with optional line selection.
|
|
181
173
|
|
|
182
|
-
| Parameter | Default | Description
|
|
183
|
-
| ------------ | ------- |
|
|
184
|
-
| `path` | - |
|
|
185
|
-
| `
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
| `
|
|
174
|
+
| Parameter | Default | Description |
|
|
175
|
+
| ------------ | ------- | ------------------------------- |
|
|
176
|
+
| `path` | - | File path |
|
|
177
|
+
| `encoding` | utf-8 | `utf-8/ascii/base64/hex/latin1` |
|
|
178
|
+
| `maxSize` | 10MB | Size limit |
|
|
179
|
+
| `skipBinary` | true | Reject binary files |
|
|
180
|
+
| `head` | - | First N lines |
|
|
181
|
+
| `tail` | - | Last N lines |
|
|
182
|
+
| `lineStart` | - | Start line (1-indexed) |
|
|
183
|
+
| `lineEnd` | - | End line (inclusive) |
|
|
189
184
|
|
|
190
|
-
|
|
185
|
+
Note: `head`/`tail` cannot be combined with `lineStart`/`lineEnd`.
|
|
191
186
|
|
|
192
|
-
|
|
187
|
+
---
|
|
193
188
|
|
|
194
|
-
|
|
189
|
+
### `read_multiple_files`
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
| ----------------- | ------- | ------------------- |
|
|
198
|
-
| `path` | - | Directory path |
|
|
199
|
-
| `maxDepth` | 10 | Analysis depth |
|
|
200
|
-
| `topN` | 10 | Top largest/recent |
|
|
201
|
-
| `maxEntries` | 20000 | Max entries scanned |
|
|
202
|
-
| `excludePatterns` | [] | Patterns to skip |
|
|
191
|
+
Read multiple files in parallel. Each file reports success or error.
|
|
203
192
|
|
|
204
|
-
|
|
193
|
+
| Parameter | Default | Description |
|
|
194
|
+
| -------------- | ------- | ------------------------------- |
|
|
195
|
+
| `paths` | - | Array (max 100) |
|
|
196
|
+
| `encoding` | utf-8 | Encoding for all |
|
|
197
|
+
| `maxSize` | 10MB | Per-file limit |
|
|
198
|
+
| `maxTotalSize` | 100MB | Total size limit across files |
|
|
199
|
+
| `head` | - | First N lines each |
|
|
200
|
+
| `tail` | - | Last N lines each |
|
|
201
|
+
| `lineStart` | - | Start line (1-indexed) per file |
|
|
202
|
+
| `lineEnd` | - | End line (inclusive) per file |
|
|
205
203
|
|
|
206
|
-
|
|
204
|
+
Note: `head`/`tail` cannot be combined with `lineStart`/`lineEnd`.
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
| --------- | ------- | --------------- |
|
|
210
|
-
| `path` | — | Media file path |
|
|
211
|
-
| `maxSize` | 50MB | Size limit |
|
|
206
|
+
---
|
|
212
207
|
|
|
213
208
|
### `get_file_info`
|
|
214
209
|
|
|
215
|
-
|
|
210
|
+
Get metadata about a file or directory without reading contents.
|
|
216
211
|
|
|
217
212
|
| Parameter | Default | Description |
|
|
218
213
|
| --------- | ------- | ------------------------- |
|
|
219
|
-
| `path` |
|
|
214
|
+
| `path` | - | Path to file or directory |
|
|
215
|
+
|
|
216
|
+
Returns: name, path, type, size, created, modified, accessed, permissions,
|
|
217
|
+
isHidden, mimeType, symlinkTarget (if applicable).
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
### `get_multiple_file_info`
|
|
222
|
+
|
|
223
|
+
Get metadata for multiple files/directories in parallel.
|
|
224
|
+
|
|
225
|
+
| Parameter | Default | Description |
|
|
226
|
+
| ----------------- | ------- | --------------------------- |
|
|
227
|
+
| `paths` | - | Array of paths (max 100) |
|
|
228
|
+
| `includeMimeType` | true | Include MIME type detection |
|
|
220
229
|
|
|
221
|
-
|
|
230
|
+
Returns: Array of file info with individual success/error status, plus
|
|
231
|
+
summary (total, succeeded, failed, totalSize).
|
|
222
232
|
|
|
223
233
|
---
|
|
224
234
|
|
|
@@ -227,19 +237,19 @@ Detailed metadata about a file or directory.
|
|
|
227
237
|
| Code | Cause | Solution |
|
|
228
238
|
| --------------------- | ---------------------------- | ------------------------------------- |
|
|
229
239
|
| `E_ACCESS_DENIED` | Path outside allowed dirs | Check `list_allowed_directories` |
|
|
230
|
-
| `E_NOT_FOUND` | Path
|
|
240
|
+
| `E_NOT_FOUND` | Path does not exist | Verify path with `list_directory` |
|
|
231
241
|
| `E_NOT_FILE` | Expected file, got directory | Use `list_directory` instead |
|
|
232
242
|
| `E_NOT_DIRECTORY` | Expected directory, got file | Use `read_file` instead |
|
|
233
243
|
| `E_TOO_LARGE` | File exceeds size limit | Use `head/tail` or increase `maxSize` |
|
|
234
|
-
| `E_TIMEOUT` | Operation took too long | Reduce limits
|
|
235
|
-
| `E_INVALID_PATTERN` | Malformed glob/regex | Check
|
|
244
|
+
| `E_TIMEOUT` | Operation took too long | Reduce scope or increase limits |
|
|
245
|
+
| `E_INVALID_PATTERN` | Malformed glob/regex | Check pattern syntax |
|
|
236
246
|
| `E_PERMISSION_DENIED` | OS-level access denied | Check file permissions |
|
|
237
247
|
|
|
238
248
|
---
|
|
239
249
|
|
|
240
250
|
## Security
|
|
241
251
|
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
-
|
|
252
|
+
- Read-only: no writes, deletes, or modifications.
|
|
253
|
+
- Path validation: symlinks cannot escape allowed directories.
|
|
254
|
+
- Binary detection: prevents accidental binary reads.
|
|
255
|
+
- Input sanitization: patterns validated for ReDoS protection.
|
package/dist/lib/constants.d.ts
CHANGED
|
@@ -3,18 +3,14 @@ export declare const DIR_TRAVERSAL_CONCURRENCY: number;
|
|
|
3
3
|
export declare const REGEX_MATCH_TIMEOUT_MS: number;
|
|
4
4
|
export declare const MAX_SEARCHABLE_FILE_SIZE: number;
|
|
5
5
|
export declare const MAX_TEXT_FILE_SIZE: number;
|
|
6
|
-
export declare const MAX_MEDIA_FILE_SIZE: number;
|
|
7
6
|
export declare const MAX_LINE_CONTENT_LENGTH = 200;
|
|
7
|
+
export declare const MAX_SEARCH_LINE_LENGTH = 100000;
|
|
8
8
|
export declare const BINARY_CHECK_BUFFER_SIZE = 512;
|
|
9
9
|
export declare const DEFAULT_MAX_DEPTH: number;
|
|
10
10
|
export declare const DEFAULT_MAX_RESULTS: number;
|
|
11
11
|
export declare const DEFAULT_LIST_MAX_ENTRIES: number;
|
|
12
12
|
export declare const DEFAULT_SEARCH_MAX_FILES: number;
|
|
13
13
|
export declare const DEFAULT_SEARCH_TIMEOUT_MS: number;
|
|
14
|
-
export declare const DEFAULT_TOP_N: number;
|
|
15
|
-
export declare const DEFAULT_ANALYZE_MAX_ENTRIES: number;
|
|
16
|
-
export declare const DEFAULT_TREE_DEPTH: number;
|
|
17
|
-
export declare const DEFAULT_TREE_MAX_FILES: number;
|
|
18
14
|
export declare const KNOWN_BINARY_EXTENSIONS: Set<string>;
|
|
19
15
|
export declare const DEFAULT_EXCLUDE_PATTERNS: string[];
|
|
20
16
|
export declare function getMimeType(ext: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAuEA,eAAO,MAAM,oBAAoB,QAGF,CAAC;AAChC,eAAO,MAAM,yBAAyB,QAKrC,CAAC;AACF,eAAO,MAAM,sBAAsB,QAKlC,CAAC;AACF,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AACF,eAAO,MAAM,kBAAkB,QAK9B,CAAC;AAEF,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,sBAAsB,SAAU,CAAC;AAC9C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,eAAO,MAAM,iBAAiB,QAA2C,CAAC;AAC1E,eAAO,MAAM,mBAAmB,QAK/B,CAAC;AACF,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AACF,eAAO,MAAM,wBAAwB,QAKpC,CAAC;AACF,eAAO,MAAM,yBAAyB,QAKrC,CAAC;AACF,eAAO,MAAM,uBAAuB,aAyClC,CAAC;AAEH,eAAO,MAAM,wBAAwB,UAwBpC,CAAC;AA+DF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C"}
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,39 +1,59 @@
|
|
|
1
1
|
import { availableParallelism } from 'node:os';
|
|
2
|
-
|
|
3
|
-
function parseEnvInt(envVar, defaultValue, min, max) {
|
|
2
|
+
function parseEnvIntValue(envVar, min, max) {
|
|
4
3
|
const value = process.env[envVar];
|
|
5
|
-
if (!value)
|
|
6
|
-
return
|
|
7
|
-
}
|
|
4
|
+
if (!value)
|
|
5
|
+
return undefined;
|
|
8
6
|
const parsed = parseInt(value, 10);
|
|
9
7
|
if (Number.isNaN(parsed) || parsed < min || parsed > max) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return parsed;
|
|
11
|
+
}
|
|
12
|
+
// Helper function for parsing and validating integer environment variables
|
|
13
|
+
function parseEnvInt(envVar, defaultValue, min, max) {
|
|
14
|
+
const parsed = parseEnvIntValue(envVar, min, max);
|
|
15
|
+
if (parsed === undefined)
|
|
16
|
+
return defaultValue;
|
|
17
|
+
if (parsed === null) {
|
|
18
|
+
const value = process.env[envVar] ?? '';
|
|
10
19
|
console.error(`[WARNING] Invalid ${envVar} value: ${value} (must be ${min}-${max}). Using default: ${defaultValue}`);
|
|
11
20
|
return defaultValue;
|
|
12
21
|
}
|
|
13
22
|
return parsed;
|
|
14
23
|
}
|
|
24
|
+
function parseOptionalEnvInt(envVar, min, max) {
|
|
25
|
+
const parsed = parseEnvIntValue(envVar, min, max);
|
|
26
|
+
if (parsed === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
if (parsed === null) {
|
|
29
|
+
const value = process.env[envVar] ?? '';
|
|
30
|
+
console.error(`[WARNING] Invalid ${envVar} value: ${value} (must be ${min}-${max}). Ignoring.`);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return parsed;
|
|
34
|
+
}
|
|
15
35
|
// Determine optimal parallelism based on CPU cores
|
|
16
36
|
function getOptimalParallelism() {
|
|
17
37
|
const cpuCores = availableParallelism();
|
|
18
38
|
return Math.min(cpuCores * 2, 50);
|
|
19
39
|
}
|
|
20
|
-
|
|
40
|
+
const UV_THREADPOOL_LIMIT = parseOptionalEnvInt('UV_THREADPOOL_SIZE', 1, 1024);
|
|
41
|
+
const BASE_PARALLEL_CONCURRENCY = parseEnvInt('FILESYSTEM_CONTEXT_CONCURRENCY', getOptimalParallelism(), 1, 100);
|
|
42
|
+
export const PARALLEL_CONCURRENCY = UV_THREADPOOL_LIMIT !== undefined
|
|
43
|
+
? Math.min(BASE_PARALLEL_CONCURRENCY, UV_THREADPOOL_LIMIT)
|
|
44
|
+
: BASE_PARALLEL_CONCURRENCY;
|
|
21
45
|
export const DIR_TRAVERSAL_CONCURRENCY = parseEnvInt('TRAVERSAL_JOBS', 8, 1, 50);
|
|
22
46
|
export const REGEX_MATCH_TIMEOUT_MS = parseEnvInt('REGEX_TIMEOUT', 100, 50, 1000);
|
|
23
47
|
export const MAX_SEARCHABLE_FILE_SIZE = parseEnvInt('MAX_SEARCH_SIZE', 1024 * 1024, 100 * 1024, 10 * 1024 * 1024);
|
|
24
48
|
export const MAX_TEXT_FILE_SIZE = parseEnvInt('MAX_FILE_SIZE', 10 * 1024 * 1024, 1024 * 1024, 100 * 1024 * 1024);
|
|
25
|
-
export const MAX_MEDIA_FILE_SIZE = parseEnvInt('MAX_MEDIA_SIZE', 50 * 1024 * 1024, 1024 * 1024, 500 * 1024 * 1024);
|
|
26
49
|
export const MAX_LINE_CONTENT_LENGTH = 200;
|
|
50
|
+
export const MAX_SEARCH_LINE_LENGTH = 100_000;
|
|
27
51
|
export const BINARY_CHECK_BUFFER_SIZE = 512;
|
|
28
52
|
export const DEFAULT_MAX_DEPTH = parseEnvInt('DEFAULT_DEPTH', 10, 1, 100);
|
|
29
53
|
export const DEFAULT_MAX_RESULTS = parseEnvInt('DEFAULT_RESULTS', 100, 10, 10000);
|
|
30
54
|
export const DEFAULT_LIST_MAX_ENTRIES = parseEnvInt('DEFAULT_LIST_MAX_ENTRIES', 10000, 100, 100000);
|
|
31
55
|
export const DEFAULT_SEARCH_MAX_FILES = parseEnvInt('DEFAULT_SEARCH_MAX_FILES', 20000, 100, 100000);
|
|
32
56
|
export const DEFAULT_SEARCH_TIMEOUT_MS = parseEnvInt('DEFAULT_SEARCH_TIMEOUT', 30000, 100, 3600000);
|
|
33
|
-
export const DEFAULT_TOP_N = parseEnvInt('DEFAULT_TOP', 10, 1, 1000);
|
|
34
|
-
export const DEFAULT_ANALYZE_MAX_ENTRIES = parseEnvInt('DEFAULT_ANALYZE_MAX_ENTRIES', 20000, 100, 100000);
|
|
35
|
-
export const DEFAULT_TREE_DEPTH = parseEnvInt('DEFAULT_TREE', 5, 1, 50);
|
|
36
|
-
export const DEFAULT_TREE_MAX_FILES = parseEnvInt('DEFAULT_TREE_MAX_FILES', 5000, 100, 200000);
|
|
37
57
|
export const KNOWN_BINARY_EXTENSIONS = new Set([
|
|
38
58
|
'.png',
|
|
39
59
|
'.jpg',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAI/C,SAAS,gBAAgB,CACvB,MAAc,EACd,GAAW,EACX,GAAW;IAEX,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAE7B,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,2EAA2E;AAC3E,SAAS,WAAW,CAClB,MAAc,EACd,YAAoB,EACpB,GAAW,EACX,GAAW;IAEX,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC;IAC9C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CACX,qBAAqB,MAAM,WAAW,KAAK,aAAa,GAAG,IAAI,GAAG,qBAAqB,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BAAiB,CAAC;IAC3B,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAC7B,CAAC,KAAK,EAAE,kBAAkB,CAAC;IAC3B,CAAC,KAAK,EAAE,6BAA6B,CAAC;IACtC,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAC/B,CAAC,MAAM,EAAE,UAAU,CAAC;IACpB,CAAC,MAAM,EAAE,UAAU,CAAC;IACpB,CAAC,OAAO,EAAE,WAAW,CAAC;IACtB,CAAC,QAAQ,EAAE,YAAY,CAAC;IACxB,CAAC,OAAO,EAAE,kBAAkB,CAAC;CAC9B,CAAC,CAAC;AAEH,gDAAgD;AAChD,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAC;AAChE,CAAC"}
|
package/dist/lib/errors.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { McpError as RpcMcpError } from '@modelcontextprotocol/sdk/types.js';
|
|
2
1
|
import { ErrorCode } from '../config/types.js';
|
|
3
2
|
export { ErrorCode };
|
|
4
3
|
interface DetailedError {
|
|
@@ -21,5 +20,4 @@ export declare function classifyError(error: unknown): ErrorCode;
|
|
|
21
20
|
export declare function createDetailedError(error: unknown, path?: string, additionalDetails?: Record<string, unknown>): DetailedError;
|
|
22
21
|
export declare function formatDetailedError(error: DetailedError): string;
|
|
23
22
|
export declare function getSuggestion(code: ErrorCode): string;
|
|
24
|
-
export declare function toRpcError(error: unknown, defaultCode: ErrorCode, path?: string): RpcMcpError;
|
|
25
23
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":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MAAM,EAAE,OAAO,CAAC,GAC1C,aAAa,CAYf;AAqBD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAYhE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAErD"}
|
package/dist/lib/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { joinLines } from '../config/formatting.js';
|
|
2
2
|
import { ErrorCode } from '../config/types.js';
|
|
3
3
|
export { ErrorCode };
|
|
4
4
|
export function isNodeError(error) {
|
|
@@ -55,17 +55,6 @@ const ERROR_SUGGESTIONS = {
|
|
|
55
55
|
[ErrorCode.E_SYMLINK_NOT_ALLOWED]: 'Symbolic links that escape allowed directories are not permitted for security reasons.',
|
|
56
56
|
[ErrorCode.E_UNKNOWN]: 'An unexpected error occurred. Check the error message for details.',
|
|
57
57
|
};
|
|
58
|
-
const INVALID_PARAMS_CODES = new Set([
|
|
59
|
-
ErrorCode.E_ACCESS_DENIED,
|
|
60
|
-
ErrorCode.E_NOT_FOUND,
|
|
61
|
-
ErrorCode.E_NOT_FILE,
|
|
62
|
-
ErrorCode.E_NOT_DIRECTORY,
|
|
63
|
-
ErrorCode.E_TOO_LARGE,
|
|
64
|
-
ErrorCode.E_INVALID_PATTERN,
|
|
65
|
-
ErrorCode.E_INVALID_INPUT,
|
|
66
|
-
ErrorCode.E_PERMISSION_DENIED,
|
|
67
|
-
ErrorCode.E_SYMLINK_NOT_ALLOWED,
|
|
68
|
-
]);
|
|
69
58
|
function getDirectErrorCode(error) {
|
|
70
59
|
if (error instanceof McpError) {
|
|
71
60
|
return error.code;
|
|
@@ -126,26 +115,9 @@ export function formatDetailedError(error) {
|
|
|
126
115
|
if (error.suggestion) {
|
|
127
116
|
lines.push(`Suggestion: ${error.suggestion}`);
|
|
128
117
|
}
|
|
129
|
-
return lines
|
|
118
|
+
return joinLines(lines);
|
|
130
119
|
}
|
|
131
120
|
export function getSuggestion(code) {
|
|
132
121
|
return ERROR_SUGGESTIONS[code];
|
|
133
122
|
}
|
|
134
|
-
export function toRpcError(error, defaultCode, path) {
|
|
135
|
-
const detailed = createDetailedError(error, path);
|
|
136
|
-
const finalCode = detailed.code === ErrorCode.E_UNKNOWN ? defaultCode : detailed.code;
|
|
137
|
-
detailed.code = finalCode;
|
|
138
|
-
const rpcCode = INVALID_PARAMS_CODES.has(finalCode)
|
|
139
|
-
? RpcErrorCode.InvalidParams
|
|
140
|
-
: RpcErrorCode.InternalError;
|
|
141
|
-
return new RpcMcpError(rpcCode, detailed.message, {
|
|
142
|
-
toolError: {
|
|
143
|
-
code: detailed.code,
|
|
144
|
-
message: detailed.message,
|
|
145
|
-
path: detailed.path,
|
|
146
|
-
suggestion: detailed.suggestion,
|
|
147
|
-
details: detailed.details,
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
123
|
//# sourceMappingURL=errors.js.map
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,CAAC;AAUrB,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACf,OAAQ,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAC1D,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAwC;IACtE,MAAM,EAAE,SAAS,CAAC,WAAW;IAC7B,MAAM,EAAE,SAAS,CAAC,mBAAmB;IACrC,KAAK,EAA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