@j0hanz/filesystem-context-mcp 1.3.0 → 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.
Files changed (283) hide show
  1. package/README.md +251 -504
  2. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js +1 -1
  3. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js.map +1 -1
  4. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts +2 -0
  5. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts.map +1 -0
  6. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js +43 -0
  7. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js.map +1 -0
  8. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts +7 -0
  9. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts.map +1 -0
  10. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js +113 -0
  11. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js.map +1 -0
  12. package/dist/__tests__/lib/file-operations/search-definitions.test.js +1 -112
  13. package/dist/__tests__/lib/file-operations/search-definitions.test.js.map +1 -1
  14. package/dist/__tests__/lib/file-operations/sorting.test.js +15 -40
  15. package/dist/__tests__/lib/file-operations/sorting.test.js.map +1 -1
  16. package/dist/__tests__/lib/path-validation-errors.test.js +1 -1
  17. package/dist/__tests__/lib/path-validation-errors.test.js.map +1 -1
  18. package/dist/__tests__/lib/path-validation.test.js +17 -0
  19. package/dist/__tests__/lib/path-validation.test.js.map +1 -1
  20. package/dist/config/formatting.d.ts +14 -0
  21. package/dist/config/formatting.d.ts.map +1 -0
  22. package/dist/config/formatting.js +34 -0
  23. package/dist/config/formatting.js.map +1 -0
  24. package/dist/config/types.d.ts +3 -97
  25. package/dist/config/types.d.ts.map +1 -1
  26. package/dist/config/types.js.map +1 -1
  27. package/dist/index.js +26 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/instructions.md +151 -170
  30. package/dist/lib/constants.d.ts +1 -5
  31. package/dist/lib/constants.d.ts.map +1 -1
  32. package/dist/lib/constants.js +19 -15
  33. package/dist/lib/constants.js.map +1 -1
  34. package/dist/lib/errors.d.ts +0 -2
  35. package/dist/lib/errors.d.ts.map +1 -1
  36. package/dist/lib/errors.js +2 -30
  37. package/dist/lib/errors.js.map +1 -1
  38. package/dist/lib/file-operations/analyze-directory.d.ts.map +1 -1
  39. package/dist/lib/file-operations/analyze-directory.js +8 -1
  40. package/dist/lib/file-operations/analyze-directory.js.map +1 -1
  41. package/dist/lib/file-operations/batch-results.d.ts +2 -1
  42. package/dist/lib/file-operations/batch-results.d.ts.map +1 -1
  43. package/dist/lib/file-operations/compute-checksums.d.ts +1 -0
  44. package/dist/lib/file-operations/compute-checksums.d.ts.map +1 -1
  45. package/dist/lib/file-operations/compute-checksums.js +58 -45
  46. package/dist/lib/file-operations/compute-checksums.js.map +1 -1
  47. package/dist/lib/file-operations/directory-tree-builders.d.ts +7 -0
  48. package/dist/lib/file-operations/directory-tree-builders.d.ts.map +1 -0
  49. package/dist/lib/file-operations/directory-tree-builders.js +58 -0
  50. package/dist/lib/file-operations/directory-tree-builders.js.map +1 -0
  51. package/dist/lib/file-operations/directory-tree-helpers.d.ts +0 -5
  52. package/dist/lib/file-operations/directory-tree-helpers.d.ts.map +1 -1
  53. package/dist/lib/file-operations/directory-tree-helpers.js +21 -71
  54. package/dist/lib/file-operations/directory-tree-helpers.js.map +1 -1
  55. package/dist/lib/file-operations/directory-tree.d.ts.map +1 -1
  56. package/dist/lib/file-operations/directory-tree.js +2 -1
  57. package/dist/lib/file-operations/directory-tree.js.map +1 -1
  58. package/dist/lib/file-operations/file-info.d.ts +3 -1
  59. package/dist/lib/file-operations/file-info.d.ts.map +1 -1
  60. package/dist/lib/file-operations/file-info.js +16 -5
  61. package/dist/lib/file-operations/file-info.js.map +1 -1
  62. package/dist/lib/file-operations/get-multiple-file-info.d.ts +1 -1
  63. package/dist/lib/file-operations/get-multiple-file-info.d.ts.map +1 -1
  64. package/dist/lib/file-operations/get-multiple-file-info.js +6 -8
  65. package/dist/lib/file-operations/get-multiple-file-info.js.map +1 -1
  66. package/dist/lib/file-operations/list-directory-entry.d.ts.map +1 -1
  67. package/dist/lib/file-operations/list-directory-entry.js +5 -2
  68. package/dist/lib/file-operations/list-directory-entry.js.map +1 -1
  69. package/dist/lib/file-operations/list-directory-helpers.d.ts +5 -1
  70. package/dist/lib/file-operations/list-directory-helpers.d.ts.map +1 -1
  71. package/dist/lib/file-operations/list-directory-helpers.js +24 -16
  72. package/dist/lib/file-operations/list-directory-helpers.js.map +1 -1
  73. package/dist/lib/file-operations/list-directory.d.ts +1 -0
  74. package/dist/lib/file-operations/list-directory.d.ts.map +1 -1
  75. package/dist/lib/file-operations/list-directory.js +8 -3
  76. package/dist/lib/file-operations/list-directory.js.map +1 -1
  77. package/dist/lib/file-operations/read-media-file.d.ts.map +1 -1
  78. package/dist/lib/file-operations/read-media-file.js +5 -1
  79. package/dist/lib/file-operations/read-media-file.js.map +1 -1
  80. package/dist/lib/file-operations/read-multiple-files.d.ts +8 -0
  81. package/dist/lib/file-operations/read-multiple-files.d.ts.map +1 -1
  82. package/dist/lib/file-operations/read-multiple-files.js +15 -7
  83. package/dist/lib/file-operations/read-multiple-files.js.map +1 -1
  84. package/dist/lib/file-operations/search/engine-stream.d.ts +1 -1
  85. package/dist/lib/file-operations/search/engine-stream.d.ts.map +1 -1
  86. package/dist/lib/file-operations/search/engine-stream.js +21 -5
  87. package/dist/lib/file-operations/search/engine-stream.js.map +1 -1
  88. package/dist/lib/file-operations/search/engine.d.ts.map +1 -1
  89. package/dist/lib/file-operations/search/engine.js +42 -5
  90. package/dist/lib/file-operations/search/engine.js.map +1 -1
  91. package/dist/lib/file-operations/search/file-processor.d.ts.map +1 -1
  92. package/dist/lib/file-operations/search/file-processor.js +94 -54
  93. package/dist/lib/file-operations/search/file-processor.js.map +1 -1
  94. package/dist/lib/file-operations/search/match-strategy.d.ts.map +1 -1
  95. package/dist/lib/file-operations/search/match-strategy.js +2 -1
  96. package/dist/lib/file-operations/search/match-strategy.js.map +1 -1
  97. package/dist/lib/file-operations/search/types.d.ts +1 -0
  98. package/dist/lib/file-operations/search/types.d.ts.map +1 -1
  99. package/dist/lib/file-operations/search-definitions/matchers.d.ts +12 -0
  100. package/dist/lib/file-operations/search-definitions/matchers.d.ts.map +1 -0
  101. package/dist/lib/file-operations/search-definitions/matchers.js +122 -0
  102. package/dist/lib/file-operations/search-definitions/matchers.js.map +1 -0
  103. package/dist/lib/file-operations/search-definitions/patterns.d.ts +14 -0
  104. package/dist/lib/file-operations/search-definitions/patterns.d.ts.map +1 -0
  105. package/dist/lib/file-operations/search-definitions/patterns.js +83 -0
  106. package/dist/lib/file-operations/search-definitions/patterns.js.map +1 -0
  107. package/dist/lib/file-operations/search-definitions.d.ts.map +1 -1
  108. package/dist/lib/file-operations/search-definitions.js +3 -208
  109. package/dist/lib/file-operations/search-definitions.js.map +1 -1
  110. package/dist/lib/file-operations/search-files-helpers.d.ts +2 -2
  111. package/dist/lib/file-operations/search-files-helpers.d.ts.map +1 -1
  112. package/dist/lib/file-operations/search-files-helpers.js +17 -6
  113. package/dist/lib/file-operations/search-files-helpers.js.map +1 -1
  114. package/dist/lib/file-operations/search-files-options.d.ts +4 -2
  115. package/dist/lib/file-operations/search-files-options.d.ts.map +1 -1
  116. package/dist/lib/file-operations/search-files-options.js.map +1 -1
  117. package/dist/lib/file-operations/search-files.d.ts.map +1 -1
  118. package/dist/lib/file-operations/search-files.js +7 -2
  119. package/dist/lib/file-operations/search-files.js.map +1 -1
  120. package/dist/lib/file-operations/sorting.d.ts.map +1 -1
  121. package/dist/lib/file-operations/sorting.js +39 -14
  122. package/dist/lib/file-operations/sorting.js.map +1 -1
  123. package/dist/lib/file-operations.d.ts +0 -5
  124. package/dist/lib/file-operations.d.ts.map +1 -1
  125. package/dist/lib/file-operations.js +0 -5
  126. package/dist/lib/file-operations.js.map +1 -1
  127. package/dist/lib/fs-helpers/concurrency.d.ts +1 -1
  128. package/dist/lib/fs-helpers/concurrency.d.ts.map +1 -1
  129. package/dist/lib/fs-helpers/concurrency.js +37 -3
  130. package/dist/lib/fs-helpers/concurrency.js.map +1 -1
  131. package/dist/lib/fs-helpers/readers/head-file.js +1 -1
  132. package/dist/lib/fs-helpers/readers/head-file.js.map +1 -1
  133. package/dist/lib/fs-helpers/readers/read-buffer.d.ts +2 -0
  134. package/dist/lib/fs-helpers/readers/read-buffer.d.ts.map +1 -0
  135. package/dist/lib/fs-helpers/readers/read-buffer.js +52 -0
  136. package/dist/lib/fs-helpers/readers/read-buffer.js.map +1 -0
  137. package/dist/lib/fs-helpers/readers/read-file-content.d.ts +8 -1
  138. package/dist/lib/fs-helpers/readers/read-file-content.d.ts.map +1 -1
  139. package/dist/lib/fs-helpers/readers/read-file-content.js +30 -6
  140. package/dist/lib/fs-helpers/readers/read-file-content.js.map +1 -1
  141. package/dist/lib/fs-helpers/readers/read-file.d.ts +8 -0
  142. package/dist/lib/fs-helpers/readers/read-file.d.ts.map +1 -1
  143. package/dist/lib/fs-helpers/readers/read-file.js +31 -11
  144. package/dist/lib/fs-helpers/readers/read-file.js.map +1 -1
  145. package/dist/lib/fs-helpers/readers/tail-file.js +1 -1
  146. package/dist/lib/fs-helpers/readers/tail-file.js.map +1 -1
  147. package/dist/lib/path-utils.d.ts +1 -0
  148. package/dist/lib/path-utils.d.ts.map +1 -1
  149. package/dist/lib/path-utils.js +12 -0
  150. package/dist/lib/path-utils.js.map +1 -1
  151. package/dist/lib/path-validation/allowed-directories.d.ts.map +1 -1
  152. package/dist/lib/path-validation/allowed-directories.js +2 -9
  153. package/dist/lib/path-validation/allowed-directories.js.map +1 -1
  154. package/dist/lib/path-validation/errors.js +2 -2
  155. package/dist/lib/path-validation/errors.js.map +1 -1
  156. package/dist/lib/path-validation/validators.d.ts.map +1 -1
  157. package/dist/lib/path-validation/validators.js +3 -1
  158. package/dist/lib/path-validation/validators.js.map +1 -1
  159. package/dist/schemas/common.d.ts +0 -18
  160. package/dist/schemas/common.d.ts.map +1 -1
  161. package/dist/schemas/common.js +0 -10
  162. package/dist/schemas/common.js.map +1 -1
  163. package/dist/schemas/index.d.ts +2 -2
  164. package/dist/schemas/index.d.ts.map +1 -1
  165. package/dist/schemas/index.js +2 -2
  166. package/dist/schemas/index.js.map +1 -1
  167. package/dist/schemas/input-helpers.d.ts +1 -4
  168. package/dist/schemas/input-helpers.d.ts.map +1 -1
  169. package/dist/schemas/input-helpers.js +9 -33
  170. package/dist/schemas/input-helpers.js.map +1 -1
  171. package/dist/schemas/inputs/checksums.d.ts +0 -2
  172. package/dist/schemas/inputs/checksums.d.ts.map +1 -1
  173. package/dist/schemas/inputs/checksums.js +2 -7
  174. package/dist/schemas/inputs/checksums.js.map +1 -1
  175. package/dist/schemas/inputs/directory.d.ts +0 -16
  176. package/dist/schemas/inputs/directory.d.ts.map +1 -1
  177. package/dist/schemas/inputs/directory.js +2 -44
  178. package/dist/schemas/inputs/directory.js.map +1 -1
  179. package/dist/schemas/inputs/read.d.ts +0 -4
  180. package/dist/schemas/inputs/read.d.ts.map +1 -1
  181. package/dist/schemas/inputs/read.js +0 -15
  182. package/dist/schemas/inputs/read.js.map +1 -1
  183. package/dist/schemas/inputs/search.d.ts +1 -12
  184. package/dist/schemas/inputs/search.d.ts.map +1 -1
  185. package/dist/schemas/inputs/search.js +4 -30
  186. package/dist/schemas/inputs/search.js.map +1 -1
  187. package/dist/schemas/inputs.d.ts +3 -4
  188. package/dist/schemas/inputs.d.ts.map +1 -1
  189. package/dist/schemas/inputs.js +3 -4
  190. package/dist/schemas/inputs.js.map +1 -1
  191. package/dist/schemas/output-helpers.d.ts +59 -0
  192. package/dist/schemas/output-helpers.d.ts.map +1 -1
  193. package/dist/schemas/output-helpers.js +31 -0
  194. package/dist/schemas/output-helpers.js.map +1 -1
  195. package/dist/schemas/outputs/checksums.d.ts +4 -4
  196. package/dist/schemas/outputs/checksums.d.ts.map +1 -1
  197. package/dist/schemas/outputs/checksums.js +2 -7
  198. package/dist/schemas/outputs/checksums.js.map +1 -1
  199. package/dist/schemas/outputs/directory.d.ts +68 -230
  200. package/dist/schemas/outputs/directory.d.ts.map +1 -1
  201. package/dist/schemas/outputs/directory.js +14 -32
  202. package/dist/schemas/outputs/directory.js.map +1 -1
  203. package/dist/schemas/outputs/file-info.d.ts +14 -14
  204. package/dist/schemas/outputs/file-info.d.ts.map +1 -1
  205. package/dist/schemas/outputs/file-info.js +4 -31
  206. package/dist/schemas/outputs/file-info.js.map +1 -1
  207. package/dist/schemas/outputs/read.d.ts +141 -46
  208. package/dist/schemas/outputs/read.d.ts.map +1 -1
  209. package/dist/schemas/outputs/read.js +35 -12
  210. package/dist/schemas/outputs/read.js.map +1 -1
  211. package/dist/schemas/outputs/search.d.ts +134 -124
  212. package/dist/schemas/outputs/search.d.ts.map +1 -1
  213. package/dist/schemas/outputs/search.js +33 -35
  214. package/dist/schemas/outputs/search.js.map +1 -1
  215. package/dist/schemas/outputs.d.ts +3 -4
  216. package/dist/schemas/outputs.d.ts.map +1 -1
  217. package/dist/schemas/outputs.js +3 -4
  218. package/dist/schemas/outputs.js.map +1 -1
  219. package/dist/server.d.ts.map +1 -1
  220. package/dist/server.js +4 -1
  221. package/dist/server.js.map +1 -1
  222. package/dist/tools/analyze-directory.d.ts.map +1 -1
  223. package/dist/tools/analyze-directory.js +26 -28
  224. package/dist/tools/analyze-directory.js.map +1 -1
  225. package/dist/tools/compute-checksums.d.ts.map +1 -1
  226. package/dist/tools/compute-checksums.js +13 -21
  227. package/dist/tools/compute-checksums.js.map +1 -1
  228. package/dist/tools/directory-tree.d.ts.map +1 -1
  229. package/dist/tools/directory-tree.js +11 -9
  230. package/dist/tools/directory-tree.js.map +1 -1
  231. package/dist/tools/get-file-info.d.ts.map +1 -1
  232. package/dist/tools/get-file-info.js +8 -44
  233. package/dist/tools/get-file-info.js.map +1 -1
  234. package/dist/tools/get-multiple-file-info.d.ts.map +1 -1
  235. package/dist/tools/get-multiple-file-info.js +13 -55
  236. package/dist/tools/get-multiple-file-info.js.map +1 -1
  237. package/dist/tools/index.d.ts.map +1 -1
  238. package/dist/tools/index.js +0 -10
  239. package/dist/tools/index.js.map +1 -1
  240. package/dist/tools/list-allowed-dirs.d.ts.map +1 -1
  241. package/dist/tools/list-allowed-dirs.js +37 -31
  242. package/dist/tools/list-allowed-dirs.js.map +1 -1
  243. package/dist/tools/list-directory.d.ts.map +1 -1
  244. package/dist/tools/list-directory.js +83 -83
  245. package/dist/tools/list-directory.js.map +1 -1
  246. package/dist/tools/read-file.d.ts.map +1 -1
  247. package/dist/tools/read-file.js +57 -45
  248. package/dist/tools/read-file.js.map +1 -1
  249. package/dist/tools/read-media-file.d.ts.map +1 -1
  250. package/dist/tools/read-media-file.js +8 -6
  251. package/dist/tools/read-media-file.js.map +1 -1
  252. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  253. package/dist/tools/read-multiple-files.js +57 -28
  254. package/dist/tools/read-multiple-files.js.map +1 -1
  255. package/dist/tools/search-content.d.ts.map +1 -1
  256. package/dist/tools/search-content.js +14 -16
  257. package/dist/tools/search-content.js.map +1 -1
  258. package/dist/tools/search-definitions.d.ts.map +1 -1
  259. package/dist/tools/search-definitions.js +11 -8
  260. package/dist/tools/search-definitions.js.map +1 -1
  261. package/dist/tools/search-files.d.ts.map +1 -1
  262. package/dist/tools/search-files.js +61 -45
  263. package/dist/tools/search-files.js.map +1 -1
  264. package/dist/tools/shared/file-info.d.ts +17 -0
  265. package/dist/tools/shared/file-info.d.ts.map +1 -0
  266. package/dist/tools/shared/file-info.js +40 -0
  267. package/dist/tools/shared/file-info.js.map +1 -0
  268. package/dist/tools/shared/formatting.d.ts +5 -0
  269. package/dist/tools/shared/formatting.d.ts.map +1 -1
  270. package/dist/tools/shared/formatting.js +21 -1
  271. package/dist/tools/shared/formatting.js.map +1 -1
  272. package/dist/tools/shared/read-range.d.ts +7 -0
  273. package/dist/tools/shared/read-range.d.ts.map +1 -0
  274. package/dist/tools/shared/read-range.js +22 -0
  275. package/dist/tools/shared/read-range.js.map +1 -0
  276. package/dist/tools/shared/search-formatting.d.ts.map +1 -1
  277. package/dist/tools/shared/search-formatting.js +53 -28
  278. package/dist/tools/shared/search-formatting.js.map +1 -1
  279. package/dist/tools/tool-response.d.ts +22 -0
  280. package/dist/tools/tool-response.d.ts.map +1 -1
  281. package/dist/tools/tool-response.js +30 -0
  282. package/dist/tools/tool-response.js.map +1 -1
  283. package/package.json +2 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Filesystem Context MCP Server
2
2
 
3
- <img src="docs/logo.png" alt="Filesystem Context MCP Server Logo" width="125">
3
+ <img src="docs/logo.png" alt="Filesystem Context MCP Server Logo" width="125">
4
4
 
5
5
  A secure, read-only MCP server for filesystem scanning, searching, and analysis with comprehensive security validation.
6
6
 
@@ -16,56 +16,49 @@ A secure, read-only MCP server for filesystem scanning, searching, and analysis
16
16
 
17
17
  [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=filesystem-context&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovZmlsZXN5c3RlbS1jb250ZXh0LW1jcEBsYXRlc3QiLCIke3dvcmtzcGFjZUZvbGRlcn0iXX0=)
18
18
 
19
- ## Features
20
-
21
- | Feature | Description |
22
- | -------------------------- | ---------------------------------------------------------------------- |
23
- | 📂 **Directory Listing** | List and explore directory contents with recursive support |
24
- | 🔍 **File Search** | Find files using glob patterns like `**/*.ts` |
25
- | 📝 **Content Search** | Search text within files using regex with context lines |
26
- | 📊 **Directory Analysis** | Get statistics, file types, largest files, and recently modified files |
27
- | 🌳 **Directory Tree** | JSON tree structure optimized for AI parsing |
28
- | 📄 **File Reading** | Read single or multiple files with head/tail and line range support |
29
- | 🖼️ **Media File Support** | Read binary files (images, audio, video) as base64 |
30
- | 🔒 **Security First** | Path validation, symlink escape protection, and access control |
31
- | **Parallel Operations** | Efficient batch file reading with configurable concurrency |
32
-
33
- ## 🎯 When to Use
34
-
35
- | Task | Tool |
36
- | -------------------------------- | -------------------------- |
37
- | Explore project structure | `list_directory` |
38
- | Find specific file types | `search_files` |
39
- | Search for code patterns/text | `search_content` |
40
- | Find code definitions | `search_definitions` |
41
- | Understand codebase statistics | `analyze_directory` |
42
- | Get AI-friendly project overview | `directory_tree` |
43
- | Read source code | `read_file` |
44
- | Batch read multiple files | `read_multiple_files` |
45
- | Get file metadata (size, dates) | `get_file_info` |
46
- | Batch get file metadata | `get_multiple_file_info` |
47
- | Compute file checksums/hashes | `compute_checksums` |
48
- | Read images or binary files | `read_media_file` |
49
- | Check available directories | `list_allowed_directories` |
50
-
51
- ## 🚀 Quick Start
52
-
53
- ### NPX (Recommended - Zero Config)
19
+ ## Features
20
+
21
+ - Directory listing with recursive support
22
+ - File search with glob patterns
23
+ - Content search with regex and context lines
24
+ - File reading with head/tail/line ranges
25
+ - Batch reads and metadata lookups in parallel
26
+ - Security: path validation, symlink escape protection, read-only operations
27
+
28
+ ## When to Use
29
+
30
+ | Task | Tool |
31
+ | ------------------------------- | -------------------------- |
32
+ | Explore project structure | `list_directory` |
33
+ | Find specific file types | `search_files` |
34
+ | Search for code patterns/text | `search_content` |
35
+ | Read source code | `read_file` |
36
+ | Batch read multiple files | `read_multiple_files` |
37
+ | Get file metadata (size, dates) | `get_file_info` |
38
+ | Batch get file metadata | `get_multiple_file_info` |
39
+ | Check available directories | `list_allowed_directories` |
40
+
41
+ ## Quick Start
42
+
43
+ ### NPX (recommended)
44
+
45
+ Allow the current working directory explicitly:
54
46
 
55
47
  ```bash
56
- # Works in current directory automatically!
57
- npx -y @j0hanz/filesystem-context-mcp@latest
48
+ npx -y @j0hanz/filesystem-context-mcp@latest --allow-cwd
58
49
  ```
59
50
 
60
- Or specify directories explicitly:
51
+ Or pass explicit directories:
61
52
 
62
53
  ```bash
63
- npx -y @j0hanz/filesystem-context-mcp@latest /path/to/your/project
54
+ npx -y @j0hanz/filesystem-context-mcp@latest /path/to/project /path/to/docs
64
55
  ```
65
56
 
66
- ### VS Code (with workspace folder)
57
+ If your MCP client supports the Roots protocol, you can omit directory arguments and let the client provide allowed directories. Otherwise, pass explicit directories or use `--allow-cwd`.
58
+
59
+ ### VS Code (workspace folder)
67
60
 
68
- Add to your VS Code settings (`.vscode/mcp.json`):
61
+ Add to `.vscode/mcp.json`:
69
62
 
70
63
  ```json
71
64
  {
@@ -82,41 +75,22 @@ Add to your VS Code settings (`.vscode/mcp.json`):
82
75
  }
83
76
  ```
84
77
 
85
- > **Tip:** `${workspaceFolder}` automatically uses your current VS Code workspace. You can also omit it and the server will use its current working directory.
86
-
87
- ### Claude Desktop
88
-
89
- Add to your Claude Desktop configuration (`claude_desktop_config.json`):
90
-
91
- ```json
92
- {
93
- "mcpServers": {
94
- "filesystem-context": {
95
- "command": "npx",
96
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
97
- }
98
- }
99
- }
100
- ```
101
-
102
- > **Note:** Claude Desktop will use the current working directory automatically. No path arguments needed!
103
-
104
- ## 📦 Installation
78
+ ## Installation
105
79
 
106
- ### NPX (No Installation)
80
+ ### NPX (no install)
107
81
 
108
82
  ```bash
109
83
  npx -y @j0hanz/filesystem-context-mcp@latest /path/to/dir1 /path/to/dir2
110
84
  ```
111
85
 
112
- ### Global Installation
86
+ ### Global installation
113
87
 
114
88
  ```bash
115
89
  npm install -g @j0hanz/filesystem-context-mcp
116
90
  filesystem-context-mcp /path/to/your/project
117
91
  ```
118
92
 
119
- ### From Source
93
+ ### From source
120
94
 
121
95
  ```bash
122
96
  git clone https://github.com/j0hanz/filesystem-context-mcp-server.git
@@ -126,89 +100,83 @@ npm run build
126
100
  node dist/index.js /path/to/your/project
127
101
  ```
128
102
 
129
- ## ⚙️ Configuration
103
+ ## Directory Access and Resolution
130
104
 
131
- ### Directory Resolution (Priority Order)
105
+ Access is always restricted to explicitly allowed directories.
132
106
 
133
- The server determines which directories to access in this order:
107
+ 1. CLI directories are validated and added first (if provided).
108
+ 2. `--allow-cwd` optionally adds the current working directory.
109
+ 3. MCP Roots from the client are used next:
110
+ - If CLI and/or `--allow-cwd` are provided, only roots inside those baseline directories are accepted.
111
+ - If no baseline is provided, roots become the allowed directories.
112
+ 4. If nothing is configured and the client provides no roots, the server has no access and logs a warning.
134
113
 
135
- 1. **CLI Arguments** - Explicitly passed paths take highest priority
136
- 2. **MCP Roots Protocol** - Directories provided by the MCP client
137
- 3. **Current Working Directory** - Automatic fallback for plug-and-play experience
114
+ Notes:
138
115
 
139
- This means you can run the server with zero configuration and it will work!
116
+ - Windows drive-relative paths like `C:path` are rejected. Use `C:\path` or `C:/path`.
117
+ - Reserved Windows device names (e.g., `CON`, `NUL`) are blocked.
140
118
 
141
- ### Command Line Arguments
119
+ ## Configuration
142
120
 
143
- Optionally specify one or more directory paths as arguments:
121
+ All configuration is optional. Values are integers unless noted. Sizes are in bytes, timeouts in milliseconds.
144
122
 
145
- ```bash
146
- filesystem-context-mcp /home/user/project /home/user/docs
147
- ```
148
-
149
- ### MCP Roots Protocol
150
-
151
- If no CLI arguments are provided, the server will use the MCP Roots protocol to receive allowed directories from the client (if supported).
123
+ ### Environment Variables
152
124
 
153
- ### Zero-Config Mode
125
+ | Variable | Default | Range | Description |
126
+ | -------------------------------- | ----------------------- | ----------- | ---------------------------------------------------------------- |
127
+ | `UV_THREADPOOL_SIZE` | (unset) | 1-1024 | libuv threadpool size. If set, caps parallelism. |
128
+ | `FILESYSTEM_CONTEXT_CONCURRENCY` | Auto (2x cores, cap 50) | 1-100 | Parallel file operations. Further capped by `UV_THREADPOOL_SIZE` |
129
+ | `TRAVERSAL_JOBS` | 8 | 1-50 | Directory traversal concurrency |
130
+ | `REGEX_TIMEOUT` | 100 | 50-1000 | Regex timeout per line (prevents ReDoS) |
131
+ | `MAX_FILE_SIZE` | 10MB | 1MB-100MB | Max text file size (`read_file`, `read_multiple_files`) |
132
+ | `MAX_SEARCH_SIZE` | 1MB | 100KB-10MB | Max file size for content search (`search_content`) |
133
+ | `DEFAULT_DEPTH` | 10 | 1-100 | Default max depth (`list_directory`, `search_files`) |
134
+ | `DEFAULT_RESULTS` | 100 | 10-10000 | Default max results (`search_files`, `search_content`) |
135
+ | `DEFAULT_LIST_MAX_ENTRIES` | 10000 | 100-100000 | Default max entries (`list_directory`) |
136
+ | `DEFAULT_SEARCH_MAX_FILES` | 20000 | 100-100000 | Default max files scanned (`search_files`, `search_content`) |
137
+ | `DEFAULT_SEARCH_TIMEOUT` | 30000 | 100-3600000 | Default search timeout (`search_files`, `search_content`) |
154
138
 
155
- If neither CLI arguments nor MCP Roots provide directories, the server automatically uses the current working directory. This makes it truly plug-and-play!
139
+ See [CONFIGURATION.md](CONFIGURATION.md) for profiles and examples.
156
140
 
157
- ### Environment Variables
141
+ ## Tools
158
142
 
159
- All configuration values have sensible defaults and are optional. Only configure if you need to tune performance or resource usage.
160
-
161
- | Variable | Default | Range | Description |
162
- | -------------------------------- | --------------- | ----------- | ---------------------------------------- |
163
- | `FILESYSTEM_CONTEXT_CONCURRENCY` | Auto (2x cores) | 1-100 | Maximum parallel file operations |
164
- | `TRAVERSAL_JOBS` | 8 | 1-50 | Directory traversal concurrency |
165
- | `REGEX_TIMEOUT` | 100 | 50-1000 | Regex matching timeout (milliseconds) |
166
- | `MAX_FILE_SIZE` | 10MB | 1MB-100MB | Maximum text file size (bytes) |
167
- | `MAX_MEDIA_SIZE` | 50MB | 1MB-500MB | Maximum media file size (bytes) |
168
- | `MAX_SEARCH_SIZE` | 1MB | 100KB-10MB | Maximum file size for content search |
169
- | `DEFAULT_DEPTH` | 10 | 1-100 | Default maximum recursion depth |
170
- | `DEFAULT_RESULTS` | 100 | 10-10000 | Default maximum search results |
171
- | `DEFAULT_LIST_MAX_ENTRIES` | 10000 | 100-100000 | Default max entries for list_directory |
172
- | `DEFAULT_SEARCH_MAX_FILES` | 20000 | 100-100000 | Default max files to scan in searches |
173
- | `DEFAULT_SEARCH_TIMEOUT` | 30000 | 100-3600000 | Default search timeout (milliseconds) |
174
- | `DEFAULT_TOP` | 10 | 1-1000 | Default top N items in analysis |
175
- | `DEFAULT_ANALYZE_MAX_ENTRIES` | 20000 | 100-100000 | Default max entries in analyze_directory |
176
- | `DEFAULT_TREE` | 5 | 1-50 | Default directory tree depth |
177
- | `DEFAULT_TREE_MAX_FILES` | 5000 | 100-200000 | Default max files in directory tree |
178
-
179
- > **💡 Tip:** See [CONFIGURATION.md](CONFIGURATION.md) for detailed environment variable usage examples, configuration profiles, and best practices for different use cases.
180
-
181
- ## 🔧 Tools
143
+ All tools return both human-readable text and structured JSON. Structured
144
+ responses include `ok`, `error` (with `code`, `message`, `path`, `suggestion`),
145
+ and `effectiveOptions`/`summary` fields where applicable.
182
146
 
183
147
  ### `list_allowed_directories`
184
148
 
185
- List all directories that this server is allowed to access.
149
+ List all directories that this server can access.
186
150
 
187
- | Parameter | Type | Required | Default | Description |
188
- | --------- | ---- | -------- | ------- | ---------------------- |
189
- | _(none)_ | - | - | - | No parameters required |
151
+ | Parameter | Type | Required | Default | Description |
152
+ | --------- | ---- | -------- | ------- | ----------- |
153
+ | (none) | - | - | - | - |
190
154
 
191
- **Returns:** Array of allowed directory paths.
155
+ Returns: Allowed directory paths plus access status (accessible/readable),
156
+ count, and a configuration hint in structured output.
192
157
 
193
158
  ---
194
159
 
195
160
  ### `list_directory`
196
161
 
197
- List contents of a directory with optional recursive listing.
198
-
199
- | Parameter | Type | Required | Default | Description |
200
- | ----------------------- | -------- | -------- | ------- | ------------------------------------------- |
201
- | `path` | string | ? | - | Directory path to list |
202
- | `recursive` | boolean | ? | `false` | List recursively |
203
- | `includeHidden` | boolean | ? | `false` | Include hidden files |
204
- | `excludePatterns` | string[] | ? | `[]` | Patterns to exclude |
205
- | `pattern` | string | ? | - | Glob pattern to include |
206
- | `maxDepth` | number | ? | `10` | Maximum depth for recursive listing (0-100) |
207
- | `maxEntries` | number | ? | `10000` | Maximum entries to return (1-100,000) |
208
- | `sortBy` | string | ? | `name` | Sort by: `name`, `size`, `modified`, `type` |
209
- | `includeSymlinkTargets` | boolean | ? | `false` | Include symlink target paths |
210
-
211
- **Returns:** List of entries with name, type, size, and modified date.
162
+ List contents of a directory with optional recursion.
163
+
164
+ | Parameter | Type | Required | Default | Description |
165
+ | ----------------------- | -------- | -------- | ------- | -------------------------------------------------------- |
166
+ | `path` | string | Yes | - | Directory path to list |
167
+ | `recursive` | boolean | No | `false` | List subdirectories recursively |
168
+ | `includeHidden` | boolean | No | `false` | Include hidden files and directories |
169
+ | `excludePatterns` | string[] | No | `[]` | Glob patterns to exclude |
170
+ | `pattern` | string | No | - | Glob pattern to include (relative, no `..`) |
171
+ | `maxDepth` | number | No | `10` | Maximum depth for recursive listing (0-100) |
172
+ | `maxEntries` | number | No | `10000` | Maximum entries to return (1-100000) |
173
+ | `sortBy` | string | No | `name` | Sort by: `name`, `size`, `modified`, `type` |
174
+ | `includeSymlinkTargets` | boolean | No | `false` | Include symlink target paths (symlinks are not followed) |
175
+
176
+ Returns: Entries with name, relativePath, type, extension, size, modified time,
177
+ and symlink target. Structured output includes `effectiveOptions` and a
178
+ `summary` (totals, maxDepthReached, truncated/stoppedReason, entriesScanned,
179
+ entriesVisible, skippedInaccessible, symlinksNotFollowed).
212
180
 
213
181
  ---
214
182
 
@@ -216,28 +184,23 @@ List contents of a directory with optional recursive listing.
216
184
 
217
185
  Search for files (not directories) using glob patterns.
218
186
 
219
- | Parameter | Type | Required | Default | Description |
220
- | ----------------- | -------- | -------- | ------- | --------------------------------------------- |
221
- | `path` | string | | - | Base directory to search from |
222
- | `pattern` | string | | - | Glob pattern (e.g., `**/*.ts`, `src/**/*.js`) |
223
- | `excludePatterns` | string[] | | `[]` | Patterns to exclude |
224
- | `maxResults` | number | | `100` | Maximum matches to return (1-10,000) |
225
- | `sortBy` | string | | `path` | Sort by: `name`, `size`, `modified`, `path` |
226
- | `maxDepth` | number | | - | Maximum directory depth to search (1-100) |
227
- | `maxFilesScanned` | number | | `20000` | Maximum files to scan before stopping |
228
- | `timeoutMs` | number | | `30000` | Timeout in milliseconds (100-3,600,000) |
229
-
230
- **Returns:** List of matching files with path, type, size, and modified date.
231
-
232
- **Example:**
233
-
234
- ```json
235
- {
236
- "path": "/project",
237
- "pattern": "**/*.ts",
238
- "excludePatterns": ["node_modules/**", "dist/**"]
239
- }
240
- ```
187
+ | Parameter | Type | Required | Default | Description |
188
+ | ----------------- | -------- | -------- | --------------------- | ------------------------------------------------------------ |
189
+ | `path` | string | Yes | - | Base directory to search from |
190
+ | `pattern` | string | Yes | - | Glob pattern (e.g., `**/*.ts`, `src/**/*.js`) |
191
+ | `excludePatterns` | string[] | No | built-in exclude list | Glob patterns to exclude |
192
+ | `maxResults` | number | No | `100` | Maximum matches to return (1-10000) |
193
+ | `sortBy` | string | No | `path` | Sort by: `name`, `size`, `modified`, `path` |
194
+ | `maxDepth` | number | No | `10` | Maximum directory depth to search (0-100) |
195
+ | `maxFilesScanned` | number | No | `20000` | Maximum files to scan before stopping |
196
+ | `timeoutMs` | number | No | `30000` | Timeout in milliseconds |
197
+ | `baseNameMatch` | boolean | No | `false` | Match patterns without slashes against basenames |
198
+ | `skipSymlinks` | boolean | No | `true` | Must remain true; symlink traversal is disabled for security |
199
+ | `includeHidden` | boolean | No | `false` | Include hidden files and directories |
200
+
201
+ Returns: Matching files with relative path, type, size, and modified date.
202
+ Structured output includes `effectiveOptions` and a `summary` (matched,
203
+ filesScanned, truncated/stoppedReason, skippedInaccessible).
241
204
 
242
205
  ---
243
206
 
@@ -245,88 +208,48 @@ Search for files (not directories) using glob patterns.
245
208
 
246
209
  Read the contents of a text file.
247
210
 
248
- | Parameter | Type | Required | Default | Description |
249
- | ------------ | ------- | -------- | ------- | ---------------------------------------------------------- |
250
- | `path` | string | ? | - | File path to read |
251
- | `encoding` | string | ? | `utf-8` | File encoding (`utf-8`, `ascii`, `base64`, etc.) |
252
- | `maxSize` | number | ? | 10MB | Maximum file size in bytes |
253
- | `skipBinary` | boolean | ? | `false` | Reject binary files (use `read_media_file` instead) |
254
- | `lineStart` | number | ? | - | Start line (1-indexed, min 1) for reading a range |
255
- | `lineEnd` | number | ? | - | End line (1-indexed, inclusive, min 1) for reading a range |
256
- | `head` | number | ? | - | Read only first N lines |
257
- | `tail` | number | ? | - | Read only last N lines |
211
+ | Parameter | Type | Required | Default | Description |
212
+ | ------------ | ------- | -------- | ------- | ----------------------------------------------------------- |
213
+ | `path` | string | Yes | - | File path to read |
214
+ | `encoding` | string | No | `utf-8` | File encoding (`utf-8`, `ascii`, `base64`, `hex`, `latin1`) |
215
+ | `maxSize` | number | No | 10MB | Maximum file size in bytes (capped by `MAX_FILE_SIZE`) |
216
+ | `skipBinary` | boolean | No | `true` | Reject likely-binary files |
217
+ | `lineStart` | number | No | - | Start line (1-indexed) for range reading |
218
+ | `lineEnd` | number | No | - | End line (inclusive) for range reading |
219
+ | `head` | number | No | - | Read only first N lines |
220
+ | `tail` | number | No | - | Read only last N lines |
258
221
 
259
- > **Note:** Cannot specify both `head` and `tail` simultaneously. Use `lineStart`/`lineEnd` for range reading.
222
+ Notes:
260
223
 
261
- **Returns:** File contents as text.
224
+ - `head`, `tail`, and `lineStart/lineEnd` are mutually exclusive.
262
225
 
263
- ---
264
-
265
- ### `read_multiple_files`
266
-
267
- Read multiple files in parallel for efficient batch operations.
268
-
269
- | Parameter | Type | Required | Default | Description |
270
- | -------------- | -------- | -------- | ------- | ------------------------------------------ |
271
- | `paths` | string[] | ✅ | - | Array of file paths to read (max 100) |
272
- | `encoding` | string | ❌ | `utf-8` | File encoding |
273
- | `maxSize` | number | ❌ | 10MB | Maximum size per file in bytes |
274
- | `maxTotalSize` | number | ❌ | 100MB | Maximum total size for all files combined |
275
- | `head` | number | ❌ | - | Read only first N lines of each file |
276
- | `tail` | number | ❌ | - | Read only last N lines of each file |
277
- | `lineStart` | number | ❌ | - | Start line (1-indexed) for reading a range |
278
- | `lineEnd` | number | ❌ | - | End line (inclusive) for reading a range |
279
-
280
- **Returns:** Array of file contents with individual success/error status.
281
-
282
- ---
283
-
284
- ### `get_multiple_file_info`
285
-
286
- Get metadata for multiple files/directories in parallel.
287
-
288
- | Parameter | Type | Required | Default | Description |
289
- | ----------------- | -------- | -------- | ------- | --------------------------------- |
290
- | `paths` | string[] | ✅ | - | Array of paths to query (max 100) |
291
- | `includeMimeType` | boolean | ❌ | `true` | Include MIME type detection |
292
-
293
- **Returns:** Array of file info (name, path, type, size, timestamps, permissions, mimeType) with individual success/error status, plus summary.
226
+ Returns: File content plus structured metadata (readMode, linesRead,
227
+ totalLines, hasMoreLines, truncated, effectiveOptions).
294
228
 
295
229
  ---
296
230
 
297
- ### `compute_checksums`
298
-
299
- Compute cryptographic checksums for files using memory-efficient streaming.
300
-
301
- | Parameter | Type | Required | Default | Description |
302
- | ------------- | -------- | -------- | -------- | ------------------------------------------------- |
303
- | `paths` | string[] | ✅ | - | Array of file paths (max 50) |
304
- | `algorithm` | string | ❌ | `sha256` | Hash algorithm: `md5`, `sha1`, `sha256`, `sha512` |
305
- | `encoding` | string | ❌ | `hex` | Output encoding: `hex` or `base64` |
306
- | `maxFileSize` | number | ❌ | 100MB | Skip files larger than this |
307
-
308
- **Returns:** Array of checksums with file sizes, plus summary (total, succeeded, failed).
231
+ ### `read_multiple_files`
309
232
 
310
- **Use cases:**
233
+ Read multiple files in parallel.
311
234
 
312
- - Verify file integrity after transfers
313
- - Detect duplicate files by comparing hashes
314
- - Generate checksums for release artifacts
235
+ | Parameter | Type | Required | Default | Description |
236
+ | -------------- | -------- | -------- | ------- | ---------------------------------------------------------- |
237
+ | `paths` | string[] | Yes | - | Array of file paths (max 100) |
238
+ | `encoding` | string | No | `utf-8` | File encoding |
239
+ | `maxSize` | number | No | 10MB | Maximum size per file in bytes (capped by `MAX_FILE_SIZE`) |
240
+ | `maxTotalSize` | number | No | 100MB | Maximum total size across all files |
241
+ | `head` | number | No | - | Read only first N lines of each file |
242
+ | `tail` | number | No | - | Read only last N lines of each file |
243
+ | `lineStart` | number | No | - | Start line (1-indexed) for each file |
244
+ | `lineEnd` | number | No | - | End line (inclusive) for each file |
315
245
 
316
- ---
246
+ Notes:
317
247
 
318
- | Parameter | Type | Required | Default | Description |
319
- | -------------- | -------- | -------- | ------- | ----------------------------------------- |
320
- | `paths` | string[] | ✅ | - | Array of file paths (max 100) |
321
- | `encoding` | string | ❌ | `utf-8` | File encoding |
322
- | `maxSize` | number | ❌ | 10MB | Maximum file size per file |
323
- | `maxTotalSize` | number | ❌ | 100MB | Maximum total size for all files combined |
324
- | `head` | number | ❌ | - | Read only first N lines of each file |
325
- | `tail` | number | ❌ | - | Read only last N lines of each file |
248
+ - `lineStart` and `lineEnd` must be provided together.
249
+ - `head`, `tail`, and `lineStart/lineEnd` are mutually exclusive.
326
250
 
327
- > **Note:** Use `read_file` for single files with line ranges (`lineStart`/`lineEnd`). Use `read_multiple_files` for batch operations with `head`/`tail` parameters. The batch API does not support line ranges per file.
328
-
329
- **Returns:** Array of results with content or error for each file.
251
+ Returns: Per-file content or error, plus structured summary and
252
+ effectiveOptions.
330
253
 
331
254
  ---
332
255
 
@@ -336,145 +259,80 @@ Get detailed metadata about a file or directory.
336
259
 
337
260
  | Parameter | Type | Required | Default | Description |
338
261
  | --------- | ------ | -------- | ------- | ------------------------- |
339
- | `path` | string | | - | Path to file or directory |
340
-
341
- **Returns:** Metadata including name, type, size, created/modified/accessed timestamps, permissions, MIME type, and symlink target (if applicable).
342
-
343
- ---
344
-
345
- ### `search_content`
346
-
347
- Search for text content within files using regular expressions.
348
-
349
- | Parameter | Type | Required | Default | Description |
350
- | ----------------- | -------- | -------- | ------- | ------------------------------------------------ |
351
- | `path` | string | ✅ | - | Base directory to search in |
352
- | `pattern` | string | ✅ | - | Regex pattern to search for |
353
- | `filePattern` | string | ❌ | `**/*` | Glob pattern to filter files |
354
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
355
- | `caseSensitive` | boolean | ❌ | `false` | Case-sensitive search |
356
- | `maxResults` | number | ❌ | `100` | Maximum number of results (1-10,000) |
357
- | `maxFileSize` | number | ❌ | 1MB | Maximum file size to scan |
358
- | `maxFilesScanned` | number | ❌ | `20000` | Maximum files to scan before stopping |
359
- | `timeoutMs` | number | ❌ | `30000` | Timeout in milliseconds (100-3,600,000) |
360
- | `skipBinary` | boolean | ❌ | `true` | Skip binary files |
361
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
362
- | `contextLines` | number | ❌ | `0` | Lines of context before/after match (0-10) |
363
- | `wholeWord` | boolean | ❌ | `false` | Match whole words only |
364
- | `isLiteral` | boolean | ❌ | `false` | Treat pattern as literal string (escape special) |
365
-
366
- **Returns:** Matching lines with file path, line number, content, and optional context.
367
-
368
- **Example:**
369
-
370
- ```json
371
- {
372
- "path": "/project/src",
373
- "pattern": "TODO|FIXME",
374
- "filePattern": "**/*.ts",
375
- "contextLines": 2
376
- }
377
- ```
378
-
379
- ---
380
-
381
- ### `search_definitions`
382
-
383
- Find code definitions (classes, functions, interfaces, types, enums, variables) in TypeScript/JavaScript files without manual regex construction.
384
-
385
- | Parameter | Type | Required | Default | Description |
386
- | ----------------- | -------- | -------- | ------- | ------------------------------------------------------------------------------------- |
387
- | `path` | string | ❌ | - | Base directory to search in |
388
- | `name` | string | ❌ | - | Definition name to search for |
389
- | `type` | string | ❌ | - | Definition type to find: `class`, `function`, `interface`, `type`, `enum`, `variable` |
390
- | `caseSensitive` | boolean | ❌ | `true` | Case-sensitive name matching |
391
- | `maxResults` | number | ❌ | `100` | Maximum number of results (1-10,000) |
392
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
393
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
394
- | `contextLines` | number | ❌ | `0` | Lines of context before/after match (0-10) |
395
-
396
- **Returns:** List of definitions with name, type (class/function/interface/type/enum/variable), file path, line number, exported status, and code preview.
397
-
398
- **Use cases:**
399
-
400
- - **Find by name:** Search for a specific definition like `UserService`
401
- - **Discovery mode:** Find all definitions of a type (e.g., all interfaces)
402
- - **Combined:** Find definitions matching a name pattern and type
403
-
404
- **Examples:**
405
-
406
- ```json
407
- {
408
- "path": "/project/src",
409
- "name": "UserService"
410
- }
411
- ```
412
-
413
- ```json
414
- {
415
- "path": "/project/src",
416
- "type": "interface"
417
- }
418
- ```
262
+ | `path` | string | Yes | - | Path to file or directory |
419
263
 
420
- ```json
421
- {
422
- "path": "/project/src",
423
- "name": "Handler",
424
- "type": "class"
425
- }
426
- ```
264
+ Returns: name, path, type, size, created/modified/accessed timestamps,
265
+ permissions, isHidden, MIME type, and symlink target (if applicable).
427
266
 
428
267
  ---
429
268
 
430
- ### `analyze_directory`
269
+ ### `get_multiple_file_info`
431
270
 
432
- Analyze a directory structure and return statistics.
271
+ Get metadata for multiple files/directories in parallel.
433
272
 
434
- | Parameter | Type | Required | Default | Description |
435
- | ----------------- | -------- | -------- | ------- | ---------------------------------------- |
436
- | `path` | string | | - | Directory to analyze |
437
- | `maxDepth` | number | | `10` | Maximum depth to analyze (0-100) |
438
- | `topN` | number | ❌ | `10` | Number of top items to return (max 1000) |
439
- | `maxEntries` | number | ? | `20000` | Maximum entries to scan (1-100,000) |
440
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
441
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
273
+ | Parameter | Type | Required | Default | Description |
274
+ | ----------------- | -------- | -------- | ------- | --------------------------------- |
275
+ | `paths` | string[] | Yes | - | Array of paths to query (max 100) |
276
+ | `includeMimeType` | boolean | No | `true` | Include MIME type detection |
442
277
 
443
- **Returns:** Statistics including total files/directories, total size, file type distribution, largest files, and recently modified files.
278
+ Returns: Array of file info with individual success/error status, plus summary
279
+ (total, succeeded, failed, totalSize).
444
280
 
445
281
  ---
446
282
 
447
- ### `directory_tree`
448
-
449
- Get a JSON tree structure of a directory, optimized for AI parsing.
283
+ ### `search_content`
450
284
 
451
- | Parameter | Type | Required | Default | Description |
452
- | ----------------- | -------- | -------- | ------- | -------------------------------------------- |
453
- | `path` | string | ✅ | - | Directory path to build tree from |
454
- | `maxDepth` | number | ❌ | `5` | Maximum depth to traverse (0-50) |
455
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
456
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
457
- | `includeSize` | boolean | ❌ | `false` | Include file sizes in the tree |
458
- | `maxFiles` | number | ❌ | - | Maximum total files to include (max 100,000) |
285
+ Search for text content within files using regular expressions.
459
286
 
460
- **Returns:** Hierarchical tree structure with file/directory nodes.
287
+ | Parameter | Type | Required | Default | Description |
288
+ | ------------------------ | -------- | -------- | --------------------- | ---------------------------------------------------------- |
289
+ | `path` | string | Yes | - | Base directory to search in |
290
+ | `pattern` | string | Yes | - | Regex pattern to search for |
291
+ | `filePattern` | string | No | `**/*` | Glob pattern to filter files |
292
+ | `excludePatterns` | string[] | No | built-in exclude list | Glob patterns to exclude |
293
+ | `caseSensitive` | boolean | No | `false` | Case-sensitive search |
294
+ | `maxResults` | number | No | `100` | Maximum number of results |
295
+ | `maxFileSize` | number | No | 1MB | Maximum file size to scan (default from `MAX_SEARCH_SIZE`) |
296
+ | `maxFilesScanned` | number | No | `20000` | Maximum files to scan before stopping |
297
+ | `timeoutMs` | number | No | `30000` | Timeout in milliseconds |
298
+ | `skipBinary` | boolean | No | `true` | Skip likely-binary files |
299
+ | `includeHidden` | boolean | No | `false` | Include hidden files and directories |
300
+ | `contextLines` | number | No | `0` | Lines of context before/after match (0-10) |
301
+ | `wholeWord` | boolean | No | `false` | Match whole words only |
302
+ | `isLiteral` | boolean | No | `false` | Treat pattern as literal string (escape regex chars) |
303
+ | `baseNameMatch` | boolean | No | `false` | Match file patterns without slashes against basenames |
304
+ | `caseSensitiveFileMatch` | boolean | No | `true` | Case-sensitive filename matching |
305
+
306
+ Returns: Matching lines with file path, line number, content, and optional
307
+ context. Structured output includes `effectiveOptions` and a `summary`
308
+ (filesScanned/filesMatched, totalMatches, truncated/stoppedReason,
309
+ skippedTooLarge/skippedBinary/skippedInaccessible,
310
+ linesSkippedDueToRegexTimeout).
461
311
 
462
312
  ---
463
313
 
464
- ### `read_media_file`
465
-
466
- Read a binary/media file and return it as base64-encoded data.
467
-
468
- | Parameter | Type | Required | Default | Description |
469
- | --------- | ------ | -------- | ------- | -------------------------------------- |
470
- | `path` | string | ✅ | - | Path to the media file |
471
- | `maxSize` | number | ❌ | 50MB | Maximum file size in bytes (max 500MB) |
472
-
473
- **Supported formats:** Images (PNG, JPG, GIF, WebP, SVG, etc.), Audio (MP3, WAV, FLAC, etc.), Video (MP4, WebM, etc.), Fonts (TTF, WOFF, etc.), PDFs, and more.
474
-
475
- **Returns:** Base64-encoded data with MIME type and size.
476
-
477
- ## 🔌 Client Configuration
314
+ Built-in exclude list: common dependency/build/output directories (e.g.,
315
+ `node_modules`, `dist`, `build`, `coverage`, `.git`, `.vscode`, `.idea`,
316
+ `.cache`, `.next`, `.nuxt`, `.svelte-kit`). Pass `excludePatterns: []` to
317
+ disable it.
318
+
319
+ ## Error Codes
320
+
321
+ | Code | Meaning |
322
+ | ----------------------- | ----------------------------- |
323
+ | `E_ACCESS_DENIED` | Path outside allowed roots |
324
+ | `E_NOT_FOUND` | Path does not exist |
325
+ | `E_NOT_FILE` | Expected file, got directory |
326
+ | `E_NOT_DIRECTORY` | Expected directory, got file |
327
+ | `E_TOO_LARGE` | File exceeds size limits |
328
+ | `E_TIMEOUT` | Operation timed out |
329
+ | `E_INVALID_PATTERN` | Invalid glob/regex pattern |
330
+ | `E_INVALID_INPUT` | Invalid argument(s) |
331
+ | `E_PERMISSION_DENIED` | OS-level permission denied |
332
+ | `E_SYMLINK_NOT_ALLOWED` | Symlink escapes allowed roots |
333
+ | `E_UNKNOWN` | Unexpected error |
334
+
335
+ ## Client Configuration
478
336
 
479
337
  <details>
480
338
  <summary><b>VS Code</b></summary>
@@ -496,8 +354,6 @@ Add to `.vscode/mcp.json` (recommended) or `.vscode/settings.json`:
496
354
  }
497
355
  ```
498
356
 
499
- > **Note:** `${workspaceFolder}` is expanded by VS Code to the current workspace path.
500
-
501
357
  </details>
502
358
 
503
359
  <details>
@@ -511,12 +367,18 @@ Add to `.vscode/mcp.json` (recommended) or `.vscode/settings.json`:
511
367
  "mcpServers": {
512
368
  "filesystem-context": {
513
369
  "command": "npx",
514
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
370
+ "args": [
371
+ "-y",
372
+ "@j0hanz/filesystem-context-mcp@latest",
373
+ "C:\\path\\to\\project"
374
+ ]
515
375
  }
516
376
  }
517
377
  }
518
378
  ```
519
379
 
380
+ If your client supports MCP Roots, you can omit the path. Otherwise, pass a path or `--allow-cwd`.
381
+
520
382
  </details>
521
383
 
522
384
  <details>
@@ -529,7 +391,11 @@ Add to Cursor's MCP configuration:
529
391
  "mcpServers": {
530
392
  "filesystem-context": {
531
393
  "command": "npx",
532
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
394
+ "args": [
395
+ "-y",
396
+ "@j0hanz/filesystem-context-mcp@latest",
397
+ "${workspaceFolder}"
398
+ ]
533
399
  }
534
400
  }
535
401
  }
@@ -542,31 +408,13 @@ Add to Cursor's MCP configuration:
542
408
 
543
409
  Add to `~/.codex/config.toml`:
544
410
 
545
- **Basic Configuration (auto-detects current directory):**
546
-
547
- ```toml
548
- [mcp_servers.filesystem-context]
549
- command = "npx"
550
- args = ["-y", "@j0hanz/filesystem-context-mcp@latest"]
551
- ```
552
-
553
- **Configuration with Explicit Directory:**
554
-
555
411
  ```toml
556
412
  [mcp_servers.filesystem-context]
557
413
  command = "npx"
558
414
  args = ["-y", "@j0hanz/filesystem-context-mcp@latest", "/path/to/your/project"]
559
415
  ```
560
416
 
561
- **Configuration with Multiple Directories:**
562
-
563
- ```toml
564
- [mcp_servers.filesystem-context]
565
- command = "npx"
566
- args = ["-y", "@j0hanz/filesystem-context-mcp@latest", "/path/to/project1", "/path/to/project2"]
567
- ```
568
-
569
- > **Note:** You can access the config file via Codex IDE by clicking the gear icon → "Codex Settings > Open config.toml". If no directories are specified, it will use the current working directory automatically.
417
+ If your client supports MCP Roots, you can omit the path. Otherwise, pass a path or `--allow-cwd`.
570
418
 
571
419
  </details>
572
420
 
@@ -580,7 +428,11 @@ Add to Windsurf's MCP configuration:
580
428
  "mcpServers": {
581
429
  "filesystem-context": {
582
430
  "command": "npx",
583
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
431
+ "args": [
432
+ "-y",
433
+ "@j0hanz/filesystem-context-mcp@latest",
434
+ "${workspaceFolder}"
435
+ ]
584
436
  }
585
437
  }
586
438
  }
@@ -588,55 +440,21 @@ Add to Windsurf's MCP configuration:
588
440
 
589
441
  </details>
590
442
 
591
- ## 🔒 Security
443
+ ## Security
592
444
 
593
445
  This server implements multiple layers of security:
594
446
 
595
- | Protection | Description |
596
- | ----------------------------- | ------------------------------------------------------------------------- |
597
- | **Access Control** | Only explicitly allowed directories are accessible |
598
- | **Path Validation** | All paths are validated before any filesystem operation |
599
- | **Symlink Protection** | Symlinks that resolve outside allowed directories are blocked |
600
- | **Path Traversal Prevention** | Attempts to escape via `../` are detected and blocked |
601
- | **Read-Only Operations** | Server only performs read operations—no writes, deletes, or modifications |
602
- | **Safe Regex** | Regular expressions are validated to prevent ReDoS attacks |
603
- | **Size Limits** | Configurable limits prevent resource exhaustion |
447
+ | Protection | Description |
448
+ | ------------------------- | ------------------------------------------------------------- |
449
+ | Access control | Only explicitly allowed directories are accessible |
450
+ | Path validation | All paths are validated before any filesystem operation |
451
+ | Symlink protection | Symlinks that resolve outside allowed directories are blocked |
452
+ | Path traversal prevention | Attempts to escape via `..` are detected and blocked |
453
+ | Read-only operations | No writes, deletes, or modifications |
454
+ | Safe regex | Regex validation and timeouts prevent ReDoS |
455
+ | Size limits | Configurable limits prevent resource exhaustion |
604
456
 
605
- ### Security Model
606
-
607
- ```text
608
- ┌─────────────────────────────────────────────────────────┐
609
- │ MCP Client │
610
- └─────────────────────┬───────────────────────────────────┘
611
-
612
-
613
- ┌─────────────────────────────────────────────────────────┐
614
- │ Filesystem Context MCP Server │
615
- │ ┌───────────────────────────────────────────────────┐ │
616
- │ │ Path Validation Layer │ │
617
- │ │ • Normalize paths │ │
618
- │ │ • Check against allowed directories │ │
619
- │ │ • Resolve and validate symlinks │ │
620
- │ │ • Block traversal attempts │ │
621
- │ └───────────────────────────────────────────────────┘ │
622
- │ │ │
623
- │ ▼ │
624
- │ ┌───────────────────────────────────────────────────┐ │
625
- │ │ Read-Only File Operations │ │
626
- │ └───────────────────────────────────────────────────┘ │
627
- └─────────────────────────────────────────────────────────┘
628
-
629
-
630
- ┌─────────────────────────────────────────────────────────┐
631
- │ Allowed Directories Only │
632
- │ /home/user/project ✅ │
633
- │ /home/user/docs ✅ │
634
- │ /etc/passwd ❌ (blocked) │
635
- │ ../../../etc ❌ (blocked) │
636
- └─────────────────────────────────────────────────────────┘
637
- ```
638
-
639
- ## 🛠️ Development
457
+ ## Development
640
458
 
641
459
  ### Prerequisites
642
460
 
@@ -656,107 +474,36 @@ This server implements multiple layers of security:
656
474
  | `npm run lint` | Run ESLint |
657
475
  | `npm run format` | Format code with Prettier |
658
476
  | `npm run type-check` | TypeScript type checking |
477
+ | `npm run bench` | Run benchmarks |
659
478
  | `npm run inspector` | Test with MCP Inspector |
660
479
 
661
480
  ### Project Structure
662
481
 
663
482
  ```text
664
483
  src/
665
- ├── index.ts # Entry point, CLI argument parsing
666
- ├── server.ts # MCP server setup, roots protocol handling
667
- ├── instructions.md # AI instructions for tool usage (bundled with dist)
668
- ├── config/
669
- │ └── types.ts # Shared TypeScript types
670
- ├── lib/
671
- │ ├── constants.ts # Configuration constants and limits
672
- │ ├── errors.ts # Error handling utilities
673
- │ ├── file-operations.ts# Core filesystem operations (exports)
674
- │ ├── path-utils.ts # Path manipulation utilities
675
- │ ├── path-validation.ts# Security: path validation layer
676
- │ ├── fs-helpers.ts # Low-level filesystem helpers (exports)
677
- │ ├── file-operations/ # Core filesystem operations
678
- │ │ ├── analyze-directory.ts
679
- │ │ ├── directory-helpers.ts
680
- │ │ ├── directory-tree.ts
681
- │ │ ├── file-info.ts
682
- │ │ ├── list-directory.ts
683
- │ │ ├── pattern-validator.ts
684
- │ │ ├── read-media-file.ts
685
- │ │ ├── read-multiple-files.ts
686
- │ │ ├── search-content.ts
687
- │ │ ├── search-definitions.ts
688
- │ │ ├── search-files.ts
689
- │ │ └── sorting.ts
690
- │ ├── fs-helpers/ # Low-level filesystem helpers
691
- │ │ ├── binary-detect.ts
692
- │ │ ├── concurrency.ts
693
- │ │ ├── fs-utils.ts
694
- │ │ ├── readers.ts
695
- │ │ └── readers/ # File reading utilities
696
- │ │ ├── head-file.ts
697
- │ │ ├── line-range.ts
698
- │ │ ├── read-file.ts
699
- │ │ ├── tail-file.ts
700
- │ │ └── utf8.ts
701
- │ └── path-validation/ # Security: path validation
702
- │ ├── allowed-directories.ts
703
- │ ├── errors.ts
704
- │ ├── roots.ts
705
- │ └── validators.ts
706
- ├── schemas/
707
- │ ├── common.ts # Shared Zod schemas
708
- │ ├── input-helpers.ts # Input validation helpers
709
- │ ├── inputs.ts # Input validation schemas
710
- │ ├── output-helpers.ts # Output formatting helpers
711
- │ ├── outputs.ts # Output validation schemas
712
- │ └── index.ts # Schema exports
713
- ├── tools/
714
- │ ├── analyze-directory.ts
715
- │ ├── directory-tree.ts
716
- │ ├── get-file-info.ts
717
- │ ├── list-allowed-dirs.ts
718
- │ ├── list-directory.ts
719
- │ ├── read-file.ts
720
- │ ├── read-media-file.ts
721
- │ ├── read-multiple-files.ts
722
- │ ├── search-content.ts
723
- │ ├── search-definitions.ts
724
- │ ├── search-files.ts
725
- │ ├── tool-response.ts # Tool response formatting
726
- │ └── index.ts # Tool registration
727
- └── __tests__/ # Test files
728
- ├── lib/
729
- │ ├── errors.test.ts
730
- │ ├── file-operations.test.ts
731
- │ ├── fs-helpers.test.ts
732
- │ └── path-validation.test.ts
733
- ├── schemas/
734
- │ └── validators.test.ts
735
- └── security/
736
- └── filesystem-boundary.test.ts
484
+ index.ts # CLI entry point
485
+ server.ts # MCP server wiring and roots handling
486
+ instructions.md # Tool usage instructions (bundled in dist)
487
+ config/ # Shared types and formatting helpers
488
+ lib/ # Core logic and filesystem operations
489
+ schemas/ # Zod input/output schemas
490
+ tools/ # MCP tool registration
491
+ __tests__/ # Vitest tests
737
492
  ```
738
493
 
739
- ### Testing with MCP Inspector
740
-
741
- ```bash
742
- npm run inspector
743
- ```
744
-
745
- This launches the MCP Inspector for interactive testing of all tools.
746
-
747
- ## ❓ Troubleshooting
494
+ ## Troubleshooting
748
495
 
749
- | Issue | Solution |
750
- | --------------------------- | ---------------------------------------------------------------------------------------- |
751
- | "Access denied" error | Ensure the path is within an allowed directory. Use `list_allowed_directories` to check. |
752
- | "Path does not exist" error | Verify the path exists. Use `list_directory` to explore available files. |
753
- | "File too large" error | Use `head` or `tail` parameters for partial reading, or increase `maxSize`. |
754
- | "Binary file" warning | Use `read_media_file` for binary files, or set `skipBinary=false` in content search. |
755
- | Unexpected directory access | Server defaults to CWD if no args/roots provided. Pass explicit paths to restrict. |
756
- | Symlink blocked | Symlinks that resolve outside allowed directories are blocked for security. |
757
- | Regex timeout | Simplify the regex pattern or use `isLiteral=true` for literal string search. |
496
+ | Issue | Solution |
497
+ | ------------------------ | ---------------------------------------------------------------------------------------- |
498
+ | "Access denied" error | Ensure the path is within an allowed directory. Use `list_allowed_directories` to check. |
499
+ | "Path does not exist" | Verify the path exists. Use `list_directory` to explore available files. |
500
+ | "File too large" | Use `head`/`tail` or increase `maxSize`. |
501
+ | "Binary file" warning | Set `skipBinary=false` in `read_file` to read as text. |
502
+ | No directories available | Pass explicit paths, use `--allow-cwd`, or ensure the client provides MCP Roots. |
503
+ | Symlink blocked | Symlinks that resolve outside allowed directories are blocked. |
504
+ | Regex timeout | Simplify the regex or increase `REGEX_TIMEOUT`. |
758
505
 
759
- ## 🤝 Contributing
506
+ ## Contributing
760
507
 
761
508
  Contributions are welcome! Please follow these steps:
762
509