@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.
Files changed (340) hide show
  1. package/README.md +254 -453
  2. package/dist/__tests__/lib/file-operations/compute-checksums.test.d.ts +2 -0
  3. package/dist/__tests__/lib/file-operations/compute-checksums.test.d.ts.map +1 -0
  4. package/dist/__tests__/lib/file-operations/compute-checksums.test.js +59 -0
  5. package/dist/__tests__/lib/file-operations/compute-checksums.test.js.map +1 -0
  6. package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.d.ts +2 -0
  7. package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.d.ts.map +1 -0
  8. package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.js +46 -0
  9. package/dist/__tests__/lib/file-operations/get-multiple-file-info.test.js.map +1 -0
  10. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js +1 -1
  11. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js.map +1 -1
  12. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts +2 -0
  13. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.d.ts.map +1 -0
  14. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js +43 -0
  15. package/dist/__tests__/lib/file-operations/search-definitions-helpers.test.js.map +1 -0
  16. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts +7 -0
  17. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.d.ts.map +1 -0
  18. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js +113 -0
  19. package/dist/__tests__/lib/file-operations/search-definitions.fixtures.js.map +1 -0
  20. package/dist/__tests__/lib/file-operations/search-definitions.test.js +153 -280
  21. package/dist/__tests__/lib/file-operations/search-definitions.test.js.map +1 -1
  22. package/dist/__tests__/lib/file-operations/sorting.test.d.ts +2 -0
  23. package/dist/__tests__/lib/file-operations/sorting.test.d.ts.map +1 -0
  24. package/dist/__tests__/lib/file-operations/sorting.test.js +22 -0
  25. package/dist/__tests__/lib/file-operations/sorting.test.js.map +1 -0
  26. package/dist/__tests__/lib/fs-helpers/utf8.test.d.ts +2 -0
  27. package/dist/__tests__/lib/fs-helpers/utf8.test.d.ts.map +1 -0
  28. package/dist/__tests__/lib/fs-helpers/utf8.test.js +43 -0
  29. package/dist/__tests__/lib/fs-helpers/utf8.test.js.map +1 -0
  30. package/dist/__tests__/lib/path-validation-errors.test.d.ts +2 -0
  31. package/dist/__tests__/lib/path-validation-errors.test.d.ts.map +1 -0
  32. package/dist/__tests__/lib/path-validation-errors.test.js +35 -0
  33. package/dist/__tests__/lib/path-validation-errors.test.js.map +1 -0
  34. package/dist/__tests__/lib/path-validation-roots.test.d.ts +2 -0
  35. package/dist/__tests__/lib/path-validation-roots.test.d.ts.map +1 -0
  36. package/dist/__tests__/lib/path-validation-roots.test.js +42 -0
  37. package/dist/__tests__/lib/path-validation-roots.test.js.map +1 -0
  38. package/dist/__tests__/lib/path-validation.test.js +22 -0
  39. package/dist/__tests__/lib/path-validation.test.js.map +1 -1
  40. package/dist/__tests__/security/filesystem-boundary.test.js +20 -12
  41. package/dist/__tests__/security/filesystem-boundary.test.js.map +1 -1
  42. package/dist/config/formatting.d.ts +14 -0
  43. package/dist/config/formatting.d.ts.map +1 -0
  44. package/dist/config/formatting.js +34 -0
  45. package/dist/config/formatting.js.map +1 -0
  46. package/dist/config/types.d.ts +12 -75
  47. package/dist/config/types.d.ts.map +1 -1
  48. package/dist/config/types.js.map +1 -1
  49. package/dist/index.js +26 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/instructions.md +159 -149
  52. package/dist/lib/constants.d.ts +1 -5
  53. package/dist/lib/constants.d.ts.map +1 -1
  54. package/dist/lib/constants.js +31 -11
  55. package/dist/lib/constants.js.map +1 -1
  56. package/dist/lib/errors.d.ts +0 -2
  57. package/dist/lib/errors.d.ts.map +1 -1
  58. package/dist/lib/errors.js +2 -30
  59. package/dist/lib/errors.js.map +1 -1
  60. package/dist/lib/file-operations/analyze-directory-helpers.d.ts +24 -0
  61. package/dist/lib/file-operations/analyze-directory-helpers.d.ts.map +1 -0
  62. package/dist/lib/file-operations/analyze-directory-helpers.js +50 -0
  63. package/dist/lib/file-operations/analyze-directory-helpers.js.map +1 -0
  64. package/dist/lib/file-operations/analyze-directory.d.ts +1 -0
  65. package/dist/lib/file-operations/analyze-directory.d.ts.map +1 -1
  66. package/dist/lib/file-operations/analyze-directory.js +11 -59
  67. package/dist/lib/file-operations/analyze-directory.js.map +1 -1
  68. package/dist/lib/file-operations/batch-results.d.ts +13 -0
  69. package/dist/lib/file-operations/batch-results.d.ts.map +1 -0
  70. package/dist/lib/file-operations/batch-results.js +23 -0
  71. package/dist/lib/file-operations/batch-results.js.map +1 -0
  72. package/dist/lib/file-operations/compute-checksums.d.ts +10 -0
  73. package/dist/lib/file-operations/compute-checksums.d.ts.map +1 -0
  74. package/dist/lib/file-operations/compute-checksums.js +134 -0
  75. package/dist/lib/file-operations/compute-checksums.js.map +1 -0
  76. package/dist/lib/file-operations/directory-helpers.d.ts.map +1 -1
  77. package/dist/lib/file-operations/directory-helpers.js +18 -10
  78. package/dist/lib/file-operations/directory-helpers.js.map +1 -1
  79. package/dist/lib/file-operations/directory-tree-builders.d.ts +7 -0
  80. package/dist/lib/file-operations/directory-tree-builders.d.ts.map +1 -0
  81. package/dist/lib/file-operations/directory-tree-builders.js +58 -0
  82. package/dist/lib/file-operations/directory-tree-builders.js.map +1 -0
  83. package/dist/lib/file-operations/directory-tree-helpers.d.ts +0 -5
  84. package/dist/lib/file-operations/directory-tree-helpers.d.ts.map +1 -1
  85. package/dist/lib/file-operations/directory-tree-helpers.js +21 -64
  86. package/dist/lib/file-operations/directory-tree-helpers.js.map +1 -1
  87. package/dist/lib/file-operations/directory-tree.d.ts +1 -0
  88. package/dist/lib/file-operations/directory-tree.d.ts.map +1 -1
  89. package/dist/lib/file-operations/directory-tree.js +5 -10
  90. package/dist/lib/file-operations/directory-tree.js.map +1 -1
  91. package/dist/lib/file-operations/file-info.d.ts +3 -1
  92. package/dist/lib/file-operations/file-info.d.ts.map +1 -1
  93. package/dist/lib/file-operations/file-info.js +16 -5
  94. package/dist/lib/file-operations/file-info.js.map +1 -1
  95. package/dist/lib/file-operations/get-multiple-file-info.d.ts +7 -0
  96. package/dist/lib/file-operations/get-multiple-file-info.d.ts.map +1 -0
  97. package/dist/lib/file-operations/get-multiple-file-info.js +57 -0
  98. package/dist/lib/file-operations/get-multiple-file-info.js.map +1 -0
  99. package/dist/lib/file-operations/list-directory-entry.d.ts +18 -0
  100. package/dist/lib/file-operations/list-directory-entry.d.ts.map +1 -0
  101. package/dist/lib/file-operations/list-directory-entry.js +93 -0
  102. package/dist/lib/file-operations/list-directory-entry.js.map +1 -0
  103. package/dist/lib/file-operations/list-directory-helpers.d.ts +6 -1
  104. package/dist/lib/file-operations/list-directory-helpers.d.ts.map +1 -1
  105. package/dist/lib/file-operations/list-directory-helpers.js +83 -97
  106. package/dist/lib/file-operations/list-directory-helpers.js.map +1 -1
  107. package/dist/lib/file-operations/list-directory.d.ts +2 -0
  108. package/dist/lib/file-operations/list-directory.d.ts.map +1 -1
  109. package/dist/lib/file-operations/list-directory.js +11 -11
  110. package/dist/lib/file-operations/list-directory.js.map +1 -1
  111. package/dist/lib/file-operations/read-media-file.d.ts.map +1 -1
  112. package/dist/lib/file-operations/read-media-file.js +5 -1
  113. package/dist/lib/file-operations/read-media-file.js.map +1 -1
  114. package/dist/lib/file-operations/read-multiple-files.d.ts +8 -0
  115. package/dist/lib/file-operations/read-multiple-files.d.ts.map +1 -1
  116. package/dist/lib/file-operations/read-multiple-files.js +15 -7
  117. package/dist/lib/file-operations/read-multiple-files.js.map +1 -1
  118. package/dist/lib/file-operations/search/engine-options.d.ts.map +1 -1
  119. package/dist/lib/file-operations/search/engine-options.js +1 -8
  120. package/dist/lib/file-operations/search/engine-options.js.map +1 -1
  121. package/dist/lib/file-operations/search/engine-stream.d.ts +1 -1
  122. package/dist/lib/file-operations/search/engine-stream.d.ts.map +1 -1
  123. package/dist/lib/file-operations/search/engine-stream.js +21 -5
  124. package/dist/lib/file-operations/search/engine-stream.js.map +1 -1
  125. package/dist/lib/file-operations/search/engine.d.ts +1 -1
  126. package/dist/lib/file-operations/search/engine.d.ts.map +1 -1
  127. package/dist/lib/file-operations/search/engine.js +43 -3
  128. package/dist/lib/file-operations/search/engine.js.map +1 -1
  129. package/dist/lib/file-operations/search/file-processor.d.ts.map +1 -1
  130. package/dist/lib/file-operations/search/file-processor.js +94 -54
  131. package/dist/lib/file-operations/search/file-processor.js.map +1 -1
  132. package/dist/lib/file-operations/search/match-strategy.d.ts.map +1 -1
  133. package/dist/lib/file-operations/search/match-strategy.js +2 -1
  134. package/dist/lib/file-operations/search/match-strategy.js.map +1 -1
  135. package/dist/lib/file-operations/search/types.d.ts +1 -0
  136. package/dist/lib/file-operations/search/types.d.ts.map +1 -1
  137. package/dist/lib/file-operations/search-content.d.ts +1 -0
  138. package/dist/lib/file-operations/search-content.d.ts.map +1 -1
  139. package/dist/lib/file-operations/search-content.js +1 -1
  140. package/dist/lib/file-operations/search-content.js.map +1 -1
  141. package/dist/lib/file-operations/search-definitions/matchers.d.ts +12 -0
  142. package/dist/lib/file-operations/search-definitions/matchers.d.ts.map +1 -0
  143. package/dist/lib/file-operations/search-definitions/matchers.js +122 -0
  144. package/dist/lib/file-operations/search-definitions/matchers.js.map +1 -0
  145. package/dist/lib/file-operations/search-definitions/patterns.d.ts +14 -0
  146. package/dist/lib/file-operations/search-definitions/patterns.d.ts.map +1 -0
  147. package/dist/lib/file-operations/search-definitions/patterns.js +83 -0
  148. package/dist/lib/file-operations/search-definitions/patterns.js.map +1 -0
  149. package/dist/lib/file-operations/search-definitions.d.ts.map +1 -1
  150. package/dist/lib/file-operations/search-definitions.js +25 -199
  151. package/dist/lib/file-operations/search-definitions.js.map +1 -1
  152. package/dist/lib/file-operations/search-files-helpers.d.ts +3 -27
  153. package/dist/lib/file-operations/search-files-helpers.d.ts.map +1 -1
  154. package/dist/lib/file-operations/search-files-helpers.js +18 -45
  155. package/dist/lib/file-operations/search-files-helpers.js.map +1 -1
  156. package/dist/lib/file-operations/search-files-options.d.ts +33 -0
  157. package/dist/lib/file-operations/search-files-options.d.ts.map +1 -0
  158. package/dist/lib/file-operations/search-files-options.js +33 -0
  159. package/dist/lib/file-operations/search-files-options.js.map +1 -0
  160. package/dist/lib/file-operations/search-files.d.ts +1 -1
  161. package/dist/lib/file-operations/search-files.d.ts.map +1 -1
  162. package/dist/lib/file-operations/search-files.js +9 -3
  163. package/dist/lib/file-operations/search-files.js.map +1 -1
  164. package/dist/lib/file-operations/sorting.d.ts.map +1 -1
  165. package/dist/lib/file-operations/sorting.js +39 -14
  166. package/dist/lib/file-operations/sorting.js.map +1 -1
  167. package/dist/lib/file-operations.d.ts +1 -4
  168. package/dist/lib/file-operations.d.ts.map +1 -1
  169. package/dist/lib/file-operations.js +1 -4
  170. package/dist/lib/file-operations.js.map +1 -1
  171. package/dist/lib/fs-helpers/binary-detect.d.ts.map +1 -1
  172. package/dist/lib/fs-helpers/binary-detect.js +13 -16
  173. package/dist/lib/fs-helpers/binary-detect.js.map +1 -1
  174. package/dist/lib/fs-helpers/concurrency.d.ts +1 -1
  175. package/dist/lib/fs-helpers/concurrency.d.ts.map +1 -1
  176. package/dist/lib/fs-helpers/concurrency.js +37 -3
  177. package/dist/lib/fs-helpers/concurrency.js.map +1 -1
  178. package/dist/lib/fs-helpers/readers/head-file.js +1 -1
  179. package/dist/lib/fs-helpers/readers/head-file.js.map +1 -1
  180. package/dist/lib/fs-helpers/readers/read-buffer.d.ts +2 -0
  181. package/dist/lib/fs-helpers/readers/read-buffer.d.ts.map +1 -0
  182. package/dist/lib/fs-helpers/readers/read-buffer.js +52 -0
  183. package/dist/lib/fs-helpers/readers/read-buffer.js.map +1 -0
  184. package/dist/lib/fs-helpers/readers/read-file-content.d.ts +36 -0
  185. package/dist/lib/fs-helpers/readers/read-file-content.d.ts.map +1 -0
  186. package/dist/lib/fs-helpers/readers/read-file-content.js +49 -0
  187. package/dist/lib/fs-helpers/readers/read-file-content.js.map +1 -0
  188. package/dist/lib/fs-helpers/readers/read-file.d.ts +9 -0
  189. package/dist/lib/fs-helpers/readers/read-file.d.ts.map +1 -1
  190. package/dist/lib/fs-helpers/readers/read-file.js +56 -36
  191. package/dist/lib/fs-helpers/readers/read-file.js.map +1 -1
  192. package/dist/lib/fs-helpers/readers/tail-file.js +1 -1
  193. package/dist/lib/fs-helpers/readers/tail-file.js.map +1 -1
  194. package/dist/lib/merge-defined.d.ts +2 -0
  195. package/dist/lib/merge-defined.d.ts.map +1 -0
  196. package/dist/lib/merge-defined.js +8 -0
  197. package/dist/lib/merge-defined.js.map +1 -0
  198. package/dist/lib/path-utils.d.ts +1 -0
  199. package/dist/lib/path-utils.d.ts.map +1 -1
  200. package/dist/lib/path-utils.js +12 -0
  201. package/dist/lib/path-utils.js.map +1 -1
  202. package/dist/lib/path-validation/allowed-directories.d.ts.map +1 -1
  203. package/dist/lib/path-validation/allowed-directories.js +2 -9
  204. package/dist/lib/path-validation/allowed-directories.js.map +1 -1
  205. package/dist/lib/path-validation/errors.js +2 -2
  206. package/dist/lib/path-validation/errors.js.map +1 -1
  207. package/dist/lib/path-validation/validators.d.ts.map +1 -1
  208. package/dist/lib/path-validation/validators.js +11 -1
  209. package/dist/lib/path-validation/validators.js.map +1 -1
  210. package/dist/schemas/common.d.ts +0 -18
  211. package/dist/schemas/common.d.ts.map +1 -1
  212. package/dist/schemas/common.js +0 -10
  213. package/dist/schemas/common.js.map +1 -1
  214. package/dist/schemas/index.d.ts +2 -2
  215. package/dist/schemas/index.d.ts.map +1 -1
  216. package/dist/schemas/index.js +2 -2
  217. package/dist/schemas/index.js.map +1 -1
  218. package/dist/schemas/input-helpers.d.ts +1 -4
  219. package/dist/schemas/input-helpers.d.ts.map +1 -1
  220. package/dist/schemas/input-helpers.js +9 -33
  221. package/dist/schemas/input-helpers.js.map +1 -1
  222. package/dist/schemas/inputs/checksums.d.ts +8 -0
  223. package/dist/schemas/inputs/checksums.d.ts.map +1 -0
  224. package/dist/schemas/inputs/checksums.js +25 -0
  225. package/dist/schemas/inputs/checksums.js.map +1 -0
  226. package/dist/schemas/inputs/directory.d.ts +13 -0
  227. package/dist/schemas/inputs/directory.d.ts.map +1 -0
  228. package/dist/schemas/inputs/directory.js +33 -0
  229. package/dist/schemas/inputs/directory.js.map +1 -0
  230. package/dist/schemas/inputs/file-info.d.ts +9 -0
  231. package/dist/schemas/inputs/file-info.d.ts.map +1 -0
  232. package/dist/schemas/inputs/file-info.js +20 -0
  233. package/dist/schemas/inputs/file-info.js.map +1 -0
  234. package/dist/schemas/inputs/read.d.ts +22 -0
  235. package/dist/schemas/inputs/read.d.ts.map +1 -0
  236. package/dist/schemas/inputs/read.js +39 -0
  237. package/dist/schemas/inputs/read.js.map +1 -0
  238. package/dist/schemas/inputs/search.d.ts +33 -0
  239. package/dist/schemas/inputs/search.d.ts.map +1 -0
  240. package/dist/schemas/inputs/search.js +89 -0
  241. package/dist/schemas/inputs/search.js.map +1 -0
  242. package/dist/schemas/inputs.d.ts +4 -94
  243. package/dist/schemas/inputs.d.ts.map +1 -1
  244. package/dist/schemas/inputs.js +4 -227
  245. package/dist/schemas/inputs.js.map +1 -1
  246. package/dist/schemas/output-helpers.d.ts +59 -0
  247. package/dist/schemas/output-helpers.d.ts.map +1 -1
  248. package/dist/schemas/output-helpers.js +31 -0
  249. package/dist/schemas/output-helpers.js.map +1 -1
  250. package/dist/schemas/outputs/checksums.d.ts +93 -0
  251. package/dist/schemas/outputs/checksums.d.ts.map +1 -0
  252. package/dist/schemas/outputs/checksums.js +18 -0
  253. package/dist/schemas/outputs/checksums.js.map +1 -0
  254. package/dist/schemas/outputs/directory.d.ts +257 -0
  255. package/dist/schemas/outputs/directory.d.ts.map +1 -0
  256. package/dist/schemas/outputs/directory.js +63 -0
  257. package/dist/schemas/outputs/directory.js.map +1 -0
  258. package/dist/schemas/outputs/file-info.d.ts +270 -0
  259. package/dist/schemas/outputs/file-info.d.ts.map +1 -0
  260. package/dist/schemas/outputs/file-info.js +30 -0
  261. package/dist/schemas/outputs/file-info.js.map +1 -0
  262. package/dist/schemas/outputs/read.d.ts +282 -0
  263. package/dist/schemas/outputs/read.d.ts.map +1 -0
  264. package/dist/schemas/outputs/read.js +62 -0
  265. package/dist/schemas/outputs/read.js.map +1 -0
  266. package/dist/schemas/outputs/search.d.ts +370 -0
  267. package/dist/schemas/outputs/search.d.ts.map +1 -0
  268. package/dist/schemas/outputs/search.js +96 -0
  269. package/dist/schemas/outputs/search.js.map +1 -0
  270. package/dist/schemas/outputs.d.ts +4 -1059
  271. package/dist/schemas/outputs.d.ts.map +1 -1
  272. package/dist/schemas/outputs.js +4 -229
  273. package/dist/schemas/outputs.js.map +1 -1
  274. package/dist/server.d.ts.map +1 -1
  275. package/dist/server.js +28 -15
  276. package/dist/server.js.map +1 -1
  277. package/dist/tools/analyze-directory.d.ts.map +1 -1
  278. package/dist/tools/analyze-directory.js +26 -28
  279. package/dist/tools/analyze-directory.js.map +1 -1
  280. package/dist/tools/compute-checksums.d.ts +3 -0
  281. package/dist/tools/compute-checksums.d.ts.map +1 -0
  282. package/dist/tools/compute-checksums.js +69 -0
  283. package/dist/tools/compute-checksums.js.map +1 -0
  284. package/dist/tools/directory-tree.d.ts.map +1 -1
  285. package/dist/tools/directory-tree.js +17 -11
  286. package/dist/tools/directory-tree.js.map +1 -1
  287. package/dist/tools/get-file-info.d.ts.map +1 -1
  288. package/dist/tools/get-file-info.js +8 -44
  289. package/dist/tools/get-file-info.js.map +1 -1
  290. package/dist/tools/get-multiple-file-info.d.ts +3 -0
  291. package/dist/tools/get-multiple-file-info.d.ts.map +1 -0
  292. package/dist/tools/get-multiple-file-info.js +53 -0
  293. package/dist/tools/get-multiple-file-info.js.map +1 -0
  294. package/dist/tools/index.d.ts.map +1 -1
  295. package/dist/tools/index.js +2 -8
  296. package/dist/tools/index.js.map +1 -1
  297. package/dist/tools/list-allowed-dirs.d.ts.map +1 -1
  298. package/dist/tools/list-allowed-dirs.js +46 -29
  299. package/dist/tools/list-allowed-dirs.js.map +1 -1
  300. package/dist/tools/list-directory.d.ts.map +1 -1
  301. package/dist/tools/list-directory.js +83 -77
  302. package/dist/tools/list-directory.js.map +1 -1
  303. package/dist/tools/read-file.d.ts.map +1 -1
  304. package/dist/tools/read-file.js +57 -37
  305. package/dist/tools/read-file.js.map +1 -1
  306. package/dist/tools/read-media-file.d.ts.map +1 -1
  307. package/dist/tools/read-media-file.js +8 -6
  308. package/dist/tools/read-media-file.js.map +1 -1
  309. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  310. package/dist/tools/read-multiple-files.js +58 -23
  311. package/dist/tools/read-multiple-files.js.map +1 -1
  312. package/dist/tools/search-content.d.ts.map +1 -1
  313. package/dist/tools/search-content.js +14 -16
  314. package/dist/tools/search-content.js.map +1 -1
  315. package/dist/tools/search-definitions.d.ts.map +1 -1
  316. package/dist/tools/search-definitions.js +59 -42
  317. package/dist/tools/search-definitions.js.map +1 -1
  318. package/dist/tools/search-files.d.ts.map +1 -1
  319. package/dist/tools/search-files.js +65 -45
  320. package/dist/tools/search-files.js.map +1 -1
  321. package/dist/tools/shared/file-info.d.ts +17 -0
  322. package/dist/tools/shared/file-info.d.ts.map +1 -0
  323. package/dist/tools/shared/file-info.js +40 -0
  324. package/dist/tools/shared/file-info.js.map +1 -0
  325. package/dist/tools/shared/formatting.d.ts +5 -0
  326. package/dist/tools/shared/formatting.d.ts.map +1 -1
  327. package/dist/tools/shared/formatting.js +21 -1
  328. package/dist/tools/shared/formatting.js.map +1 -1
  329. package/dist/tools/shared/read-range.d.ts +7 -0
  330. package/dist/tools/shared/read-range.d.ts.map +1 -0
  331. package/dist/tools/shared/read-range.js +22 -0
  332. package/dist/tools/shared/read-range.js.map +1 -0
  333. package/dist/tools/shared/search-formatting.d.ts.map +1 -1
  334. package/dist/tools/shared/search-formatting.js +57 -29
  335. package/dist/tools/shared/search-formatting.js.map +1 -1
  336. package/dist/tools/tool-response.d.ts +22 -0
  337. package/dist/tools/tool-response.d.ts.map +1 -1
  338. package/dist/tools/tool-response.js +30 -0
  339. package/dist/tools/tool-response.js.map +1 -1
  340. 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,54 +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
- | Read images or binary files | `read_media_file` |
47
- | Check available directories | `list_allowed_directories` |
48
-
49
- ## 🚀 Quick Start
50
-
51
- ### 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:
52
46
 
53
47
  ```bash
54
- # Works in current directory automatically!
55
- npx -y @j0hanz/filesystem-context-mcp@latest
48
+ npx -y @j0hanz/filesystem-context-mcp@latest --allow-cwd
56
49
  ```
57
50
 
58
- Or specify directories explicitly:
51
+ Or pass explicit directories:
59
52
 
60
53
  ```bash
61
- 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
62
55
  ```
63
56
 
64
- ### 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`.
65
58
 
66
- Add to your VS Code settings (`.vscode/mcp.json`):
59
+ ### VS Code (workspace folder)
60
+
61
+ Add to `.vscode/mcp.json`:
67
62
 
68
63
  ```json
69
64
  {
@@ -80,41 +75,22 @@ Add to your VS Code settings (`.vscode/mcp.json`):
80
75
  }
81
76
  ```
82
77
 
83
- > **Tip:** `${workspaceFolder}` automatically uses your current VS Code workspace. You can also omit it and the server will use its current working directory.
84
-
85
- ### Claude Desktop
78
+ ## Installation
86
79
 
87
- Add to your Claude Desktop configuration (`claude_desktop_config.json`):
88
-
89
- ```json
90
- {
91
- "mcpServers": {
92
- "filesystem-context": {
93
- "command": "npx",
94
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
95
- }
96
- }
97
- }
98
- ```
99
-
100
- > **Note:** Claude Desktop will use the current working directory automatically. No path arguments needed!
101
-
102
- ## 📦 Installation
103
-
104
- ### NPX (No Installation)
80
+ ### NPX (no install)
105
81
 
106
82
  ```bash
107
83
  npx -y @j0hanz/filesystem-context-mcp@latest /path/to/dir1 /path/to/dir2
108
84
  ```
109
85
 
110
- ### Global Installation
86
+ ### Global installation
111
87
 
112
88
  ```bash
113
89
  npm install -g @j0hanz/filesystem-context-mcp
114
90
  filesystem-context-mcp /path/to/your/project
115
91
  ```
116
92
 
117
- ### From Source
93
+ ### From source
118
94
 
119
95
  ```bash
120
96
  git clone https://github.com/j0hanz/filesystem-context-mcp-server.git
@@ -124,116 +100,107 @@ npm run build
124
100
  node dist/index.js /path/to/your/project
125
101
  ```
126
102
 
127
- ## ⚙️ Configuration
128
-
129
- ### Directory Resolution (Priority Order)
103
+ ## Directory Access and Resolution
130
104
 
131
- The server determines which directories to access in this order:
105
+ Access is always restricted to explicitly allowed directories.
132
106
 
133
- 1. **CLI Arguments** - Explicitly passed paths take highest priority
134
- 2. **MCP Roots Protocol** - Directories provided by the MCP client
135
- 3. **Current Working Directory** - Automatic fallback for plug-and-play experience
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.
136
113
 
137
- This means you can run the server with zero configuration and it will work!
114
+ Notes:
138
115
 
139
- ### Command Line Arguments
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
- Optionally specify one or more directory paths as arguments:
119
+ ## Configuration
142
120
 
143
- ```bash
144
- filesystem-context-mcp /home/user/project /home/user/docs
145
- ```
121
+ All configuration is optional. Values are integers unless noted. Sizes are in bytes, timeouts in milliseconds.
146
122
 
147
- ### MCP Roots Protocol
148
-
149
- 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
150
124
 
151
- ### 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`) |
152
138
 
153
- 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.
154
140
 
155
- ### Environment Variables
141
+ ## Tools
156
142
 
157
- All configuration values have sensible defaults and are optional. Only configure if you need to tune performance or resource usage.
158
-
159
- | Variable | Default | Range | Description |
160
- | -------------------------------- | --------------- | ----------- | ---------------------------------------- |
161
- | `FILESYSTEM_CONTEXT_CONCURRENCY` | Auto (2x cores) | 1-100 | Maximum parallel file operations |
162
- | `TRAVERSAL_JOBS` | 8 | 1-50 | Directory traversal concurrency |
163
- | `REGEX_TIMEOUT` | 100 | 50-1000 | Regex matching timeout (milliseconds) |
164
- | `MAX_FILE_SIZE` | 10MB | 1MB-100MB | Maximum text file size (bytes) |
165
- | `MAX_MEDIA_SIZE` | 50MB | 1MB-500MB | Maximum media file size (bytes) |
166
- | `MAX_SEARCH_SIZE` | 1MB | 100KB-10MB | Maximum file size for content search |
167
- | `DEFAULT_DEPTH` | 10 | 1-100 | Default maximum recursion depth |
168
- | `DEFAULT_RESULTS` | 100 | 10-10000 | Default maximum search results |
169
- | `DEFAULT_LIST_MAX_ENTRIES` | 10000 | 100-100000 | Default max entries for list_directory |
170
- | `DEFAULT_SEARCH_MAX_FILES` | 20000 | 100-100000 | Default max files to scan in searches |
171
- | `DEFAULT_SEARCH_TIMEOUT` | 30000 | 100-3600000 | Default search timeout (milliseconds) |
172
- | `DEFAULT_TOP` | 10 | 1-1000 | Default top N items in analysis |
173
- | `DEFAULT_ANALYZE_MAX_ENTRIES` | 20000 | 100-100000 | Default max entries in analyze_directory |
174
- | `DEFAULT_TREE` | 5 | 1-50 | Default directory tree depth |
175
- | `DEFAULT_TREE_MAX_FILES` | 5000 | 100-200000 | Default max files in directory tree |
176
-
177
- > **💡 Tip:** See [CONFIGURATION.md](CONFIGURATION.md) for detailed environment variable usage examples, configuration profiles, and best practices for different use cases.
178
-
179
- ## 🔧 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.
180
146
 
181
147
  ### `list_allowed_directories`
182
148
 
183
- List all directories that this server is allowed to access.
149
+ List all directories that this server can access.
184
150
 
185
- | Parameter | Type | Required | Default | Description |
186
- | --------- | ---- | -------- | ------- | ---------------------- |
187
- | _(none)_ | - | - | - | No parameters required |
151
+ | Parameter | Type | Required | Default | Description |
152
+ | --------- | ---- | -------- | ------- | ----------- |
153
+ | (none) | - | - | - | - |
188
154
 
189
- **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.
190
157
 
191
158
  ---
192
159
 
193
160
  ### `list_directory`
194
161
 
195
- List contents of a directory with optional recursive listing.
196
-
197
- | Parameter | Type | Required | Default | Description |
198
- | ----------------------- | ------- | -------- | ------- | ------------------------------------------- |
199
- | `path` | string | | - | Directory path to list |
200
- | `recursive` | boolean | | `false` | List recursively |
201
- | `includeHidden` | boolean | | `false` | Include hidden files |
202
- | `maxDepth` | number | | `10` | Maximum depth for recursive listing (0-100) |
203
- | `maxEntries` | number | | `10000` | Maximum entries to return (1-100,000) |
204
- | `sortBy` | string | | `name` | Sort by: `name`, `size`, `modified`, `type` |
205
- | `includeSymlinkTargets` | boolean | | `false` | Include symlink target paths |
206
-
207
- **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).
208
180
 
209
181
  ---
210
182
 
211
183
  ### `search_files`
212
184
 
213
- Search for files using glob patterns.
214
-
215
- | Parameter | Type | Required | Default | Description |
216
- | ----------------- | -------- | -------- | ------- | --------------------------------------------- |
217
- | `path` | string | | - | Base directory to search from |
218
- | `pattern` | string | | - | Glob pattern (e.g., `**/*.ts`, `src/**/*.js`) |
219
- | `excludePatterns` | string[] | | `[]` | Patterns to exclude |
220
- | `maxResults` | number | | `100` | Maximum matches to return (1-10,000) |
221
- | `sortBy` | string | | `path` | Sort by: `name`, `size`, `modified`, `path` |
222
- | `maxDepth` | number | | - | Maximum directory depth to search (1-100) |
223
- | `maxFilesScanned` | number | | `20000` | Maximum files to scan before stopping |
224
- | `timeoutMs` | number | | `30000` | Timeout in milliseconds (100-3,600,000) |
225
-
226
- **Returns:** List of matching files with path, type, size, and modified date.
227
-
228
- **Example:**
229
-
230
- ```json
231
- {
232
- "path": "/project",
233
- "pattern": "**/*.ts",
234
- "excludePatterns": ["node_modules/**", "dist/**"]
235
- }
236
- ```
185
+ Search for files (not directories) using glob patterns.
186
+
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).
237
204
 
238
205
  ---
239
206
 
@@ -241,38 +208,48 @@ Search for files using glob patterns.
241
208
 
242
209
  Read the contents of a text file.
243
210
 
244
- | Parameter | Type | Required | Default | Description |
245
- | ----------- | ------ | -------- | ------- | ---------------------------------------------------------- |
246
- | `path` | string | | - | File path to read |
247
- | `encoding` | string | | `utf-8` | File encoding (`utf-8`, `ascii`, `base64`, etc.) |
248
- | `maxSize` | number | | 10MB | Maximum file size in bytes |
249
- | `lineStart` | number | | - | Start line (1-indexed, min 1) for reading a range |
250
- | `lineEnd` | number | | - | End line (1-indexed, inclusive, min 1) for reading a range |
251
- | `head` | number | | - | Read only first N lines |
252
- | `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 |
253
221
 
254
- > **Note:** Cannot specify both `head` and `tail` simultaneously. Use `lineStart`/`lineEnd` for range reading.
222
+ Notes:
255
223
 
256
- **Returns:** File contents as text.
224
+ - `head`, `tail`, and `lineStart/lineEnd` are mutually exclusive.
225
+
226
+ Returns: File content plus structured metadata (readMode, linesRead,
227
+ totalLines, hasMoreLines, truncated, effectiveOptions).
257
228
 
258
229
  ---
259
230
 
260
231
  ### `read_multiple_files`
261
232
 
262
- Read multiple files in parallel for efficient batch operations.
233
+ Read multiple files in parallel.
234
+
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 |
263
245
 
264
- | Parameter | Type | Required | Default | Description |
265
- | -------------- | -------- | -------- | ------- | ----------------------------------------- |
266
- | `paths` | string[] | ✅ | - | Array of file paths (max 100) |
267
- | `encoding` | string | ❌ | `utf-8` | File encoding |
268
- | `maxSize` | number | ❌ | 10MB | Maximum file size per file |
269
- | `maxTotalSize` | number | ❌ | 100MB | Maximum total size for all files combined |
270
- | `head` | number | ❌ | - | Read only first N lines of each file |
271
- | `tail` | number | ❌ | - | Read only last N lines of each file |
246
+ Notes:
272
247
 
273
- > **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.
248
+ - `lineStart` and `lineEnd` must be provided together.
249
+ - `head`, `tail`, and `lineStart/lineEnd` are mutually exclusive.
274
250
 
275
- **Returns:** Array of results with content or error for each file.
251
+ Returns: Per-file content or error, plus structured summary and
252
+ effectiveOptions.
276
253
 
277
254
  ---
278
255
 
@@ -282,145 +259,80 @@ Get detailed metadata about a file or directory.
282
259
 
283
260
  | Parameter | Type | Required | Default | Description |
284
261
  | --------- | ------ | -------- | ------- | ------------------------- |
285
- | `path` | string | | - | Path to file or directory |
262
+ | `path` | string | Yes | - | Path to file or directory |
286
263
 
287
- **Returns:** Metadata including name, type, size, created/modified/accessed timestamps, permissions, MIME type, and symlink target (if applicable).
264
+ Returns: name, path, type, size, created/modified/accessed timestamps,
265
+ permissions, isHidden, MIME type, and symlink target (if applicable).
288
266
 
289
267
  ---
290
268
 
291
- ### `search_content`
269
+ ### `get_multiple_file_info`
292
270
 
293
- Search for text content within files using regular expressions.
271
+ Get metadata for multiple files/directories in parallel.
294
272
 
295
- | Parameter | Type | Required | Default | Description |
296
- | ----------------- | -------- | -------- | ------- | ------------------------------------------------ |
297
- | `path` | string | | - | Base directory to search in |
298
- | `pattern` | string | | - | Regex pattern to search for |
299
- | `filePattern` | string | ❌ | `**/*` | Glob pattern to filter files |
300
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
301
- | `caseSensitive` | boolean | ❌ | `false` | Case-sensitive search |
302
- | `maxResults` | number | ❌ | `100` | Maximum number of results (1-10,000) |
303
- | `maxFileSize` | number | ❌ | 1MB | Maximum file size to scan |
304
- | `maxFilesScanned` | number | ❌ | `20000` | Maximum files to scan before stopping |
305
- | `timeoutMs` | number | ❌ | `30000` | Timeout in milliseconds (100-3,600,000) |
306
- | `skipBinary` | boolean | ❌ | `true` | Skip binary files |
307
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
308
- | `contextLines` | number | ❌ | `0` | Lines of context before/after match (0-10) |
309
- | `wholeWord` | boolean | ❌ | `false` | Match whole words only |
310
- | `isLiteral` | boolean | ❌ | `false` | Treat pattern as literal string (escape special) |
311
-
312
- **Returns:** Matching lines with file path, line number, content, and optional context.
313
-
314
- **Example:**
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 |
315
277
 
316
- ```json
317
- {
318
- "path": "/project/src",
319
- "pattern": "TODO|FIXME",
320
- "filePattern": "**/*.ts",
321
- "contextLines": 2
322
- }
323
- ```
278
+ Returns: Array of file info with individual success/error status, plus summary
279
+ (total, succeeded, failed, totalSize).
324
280
 
325
281
  ---
326
282
 
327
- ### `search_definitions`
328
-
329
- Find code definitions (classes, functions, interfaces, types, enums, variables) in TypeScript/JavaScript files without manual regex construction.
330
-
331
- | Parameter | Type | Required | Default | Description |
332
- | ----------------- | -------- | -------- | ------- | ------------------------------------------------------------------------------------- |
333
- | `path` | string | ❌ | - | Base directory to search in |
334
- | `name` | string | ❌ | - | Definition name to search for |
335
- | `type` | string | ❌ | - | Definition type to find: `class`, `function`, `interface`, `type`, `enum`, `variable` |
336
- | `caseSensitive` | boolean | ❌ | `true` | Case-sensitive name matching |
337
- | `maxResults` | number | ❌ | `100` | Maximum number of results (1-10,000) |
338
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
339
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
340
- | `contextLines` | number | ❌ | `0` | Lines of context before/after match (0-10) |
341
-
342
- **Returns:** List of definitions with name, type (class/function/interface/type/enum/variable), file path, line number, exported status, and code preview.
343
-
344
- **Use cases:**
345
-
346
- - **Find by name:** Search for a specific definition like `UserService`
347
- - **Discovery mode:** Find all definitions of a type (e.g., all interfaces)
348
- - **Combined:** Find definitions matching a name pattern and type
349
-
350
- **Examples:**
351
-
352
- ```json
353
- {
354
- "path": "/project/src",
355
- "name": "UserService"
356
- }
357
- ```
358
-
359
- ```json
360
- {
361
- "path": "/project/src",
362
- "type": "interface"
363
- }
364
- ```
365
-
366
- ```json
367
- {
368
- "path": "/project/src",
369
- "name": "Handler",
370
- "type": "class"
371
- }
372
- ```
373
-
374
- ---
375
-
376
- ### `analyze_directory`
377
-
378
- Analyze a directory structure and return statistics.
379
-
380
- | Parameter | Type | Required | Default | Description |
381
- | ----------------- | -------- | -------- | ------- | ---------------------------------------- |
382
- | `path` | string | ✅ | - | Directory to analyze |
383
- | `maxDepth` | number | ❌ | `10` | Maximum depth to analyze (0-100) |
384
- | `topN` | number | ❌ | `10` | Number of top items to return (max 1000) |
385
- | `maxEntries` | number | ? | `20000` | Maximum entries to scan (1-100,000) |
386
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
387
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
388
-
389
- **Returns:** Statistics including total files/directories, total size, file type distribution, largest files, and recently modified files.
390
-
391
- ---
392
-
393
- ### `directory_tree`
394
-
395
- Get a JSON tree structure of a directory, optimized for AI parsing.
283
+ ### `search_content`
396
284
 
397
- | Parameter | Type | Required | Default | Description |
398
- | ----------------- | -------- | -------- | ------- | -------------------------------------------- |
399
- | `path` | string | ✅ | - | Directory path to build tree from |
400
- | `maxDepth` | number | ❌ | `5` | Maximum depth to traverse (0-50) |
401
- | `excludePatterns` | string[] | ❌ | `[]` | Glob patterns to exclude |
402
- | `includeHidden` | boolean | ❌ | `false` | Include hidden files and directories |
403
- | `includeSize` | boolean | ❌ | `false` | Include file sizes in the tree |
404
- | `maxFiles` | number | ❌ | - | Maximum total files to include (max 100,000) |
285
+ Search for text content within files using regular expressions.
405
286
 
406
- **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).
407
311
 
408
312
  ---
409
313
 
410
- ### `read_media_file`
411
-
412
- Read a binary/media file and return it as base64-encoded data.
413
-
414
- | Parameter | Type | Required | Default | Description |
415
- | --------- | ------ | -------- | ------- | -------------------------------------- |
416
- | `path` | string | ✅ | - | Path to the media file |
417
- | `maxSize` | number | ❌ | 50MB | Maximum file size in bytes (max 500MB) |
418
-
419
- **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.
420
-
421
- **Returns:** Base64-encoded data with MIME type and size.
422
-
423
- ## 🔌 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
424
336
 
425
337
  <details>
426
338
  <summary><b>VS Code</b></summary>
@@ -442,8 +354,6 @@ Add to `.vscode/mcp.json` (recommended) or `.vscode/settings.json`:
442
354
  }
443
355
  ```
444
356
 
445
- > **Note:** `${workspaceFolder}` is expanded by VS Code to the current workspace path.
446
-
447
357
  </details>
448
358
 
449
359
  <details>
@@ -457,12 +367,18 @@ Add to `.vscode/mcp.json` (recommended) or `.vscode/settings.json`:
457
367
  "mcpServers": {
458
368
  "filesystem-context": {
459
369
  "command": "npx",
460
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
370
+ "args": [
371
+ "-y",
372
+ "@j0hanz/filesystem-context-mcp@latest",
373
+ "C:\\path\\to\\project"
374
+ ]
461
375
  }
462
376
  }
463
377
  }
464
378
  ```
465
379
 
380
+ If your client supports MCP Roots, you can omit the path. Otherwise, pass a path or `--allow-cwd`.
381
+
466
382
  </details>
467
383
 
468
384
  <details>
@@ -475,7 +391,11 @@ Add to Cursor's MCP configuration:
475
391
  "mcpServers": {
476
392
  "filesystem-context": {
477
393
  "command": "npx",
478
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
394
+ "args": [
395
+ "-y",
396
+ "@j0hanz/filesystem-context-mcp@latest",
397
+ "${workspaceFolder}"
398
+ ]
479
399
  }
480
400
  }
481
401
  }
@@ -488,31 +408,13 @@ Add to Cursor's MCP configuration:
488
408
 
489
409
  Add to `~/.codex/config.toml`:
490
410
 
491
- **Basic Configuration (auto-detects current directory):**
492
-
493
- ```toml
494
- [mcp_servers.filesystem-context]
495
- command = "npx"
496
- args = ["-y", "@j0hanz/filesystem-context-mcp@latest"]
497
- ```
498
-
499
- **Configuration with Explicit Directory:**
500
-
501
411
  ```toml
502
412
  [mcp_servers.filesystem-context]
503
413
  command = "npx"
504
414
  args = ["-y", "@j0hanz/filesystem-context-mcp@latest", "/path/to/your/project"]
505
415
  ```
506
416
 
507
- **Configuration with Multiple Directories:**
508
-
509
- ```toml
510
- [mcp_servers.filesystem-context]
511
- command = "npx"
512
- args = ["-y", "@j0hanz/filesystem-context-mcp@latest", "/path/to/project1", "/path/to/project2"]
513
- ```
514
-
515
- > **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`.
516
418
 
517
419
  </details>
518
420
 
@@ -526,7 +428,11 @@ Add to Windsurf's MCP configuration:
526
428
  "mcpServers": {
527
429
  "filesystem-context": {
528
430
  "command": "npx",
529
- "args": ["-y", "@j0hanz/filesystem-context-mcp@latest"]
431
+ "args": [
432
+ "-y",
433
+ "@j0hanz/filesystem-context-mcp@latest",
434
+ "${workspaceFolder}"
435
+ ]
530
436
  }
531
437
  }
532
438
  }
@@ -534,55 +440,21 @@ Add to Windsurf's MCP configuration:
534
440
 
535
441
  </details>
536
442
 
537
- ## 🔒 Security
443
+ ## Security
538
444
 
539
445
  This server implements multiple layers of security:
540
446
 
541
- | Protection | Description |
542
- | ----------------------------- | ------------------------------------------------------------------------- |
543
- | **Access Control** | Only explicitly allowed directories are accessible |
544
- | **Path Validation** | All paths are validated before any filesystem operation |
545
- | **Symlink Protection** | Symlinks that resolve outside allowed directories are blocked |
546
- | **Path Traversal Prevention** | Attempts to escape via `../` are detected and blocked |
547
- | **Read-Only Operations** | Server only performs read operations—no writes, deletes, or modifications |
548
- | **Safe Regex** | Regular expressions are validated to prevent ReDoS attacks |
549
- | **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 |
550
456
 
551
- ### Security Model
552
-
553
- ```text
554
- ┌─────────────────────────────────────────────────────────┐
555
- │ MCP Client │
556
- └─────────────────────┬───────────────────────────────────┘
557
-
558
-
559
- ┌─────────────────────────────────────────────────────────┐
560
- │ Filesystem Context MCP Server │
561
- │ ┌───────────────────────────────────────────────────┐ │
562
- │ │ Path Validation Layer │ │
563
- │ │ • Normalize paths │ │
564
- │ │ • Check against allowed directories │ │
565
- │ │ • Resolve and validate symlinks │ │
566
- │ │ • Block traversal attempts │ │
567
- │ └───────────────────────────────────────────────────┘ │
568
- │ │ │
569
- │ ▼ │
570
- │ ┌───────────────────────────────────────────────────┐ │
571
- │ │ Read-Only File Operations │ │
572
- │ └───────────────────────────────────────────────────┘ │
573
- └─────────────────────────────────────────────────────────┘
574
-
575
-
576
- ┌─────────────────────────────────────────────────────────┐
577
- │ Allowed Directories Only │
578
- │ /home/user/project ✅ │
579
- │ /home/user/docs ✅ │
580
- │ /etc/passwd ❌ (blocked) │
581
- │ ../../../etc ❌ (blocked) │
582
- └─────────────────────────────────────────────────────────┘
583
- ```
584
-
585
- ## 🛠️ Development
457
+ ## Development
586
458
 
587
459
  ### Prerequisites
588
460
 
@@ -602,107 +474,36 @@ This server implements multiple layers of security:
602
474
  | `npm run lint` | Run ESLint |
603
475
  | `npm run format` | Format code with Prettier |
604
476
  | `npm run type-check` | TypeScript type checking |
477
+ | `npm run bench` | Run benchmarks |
605
478
  | `npm run inspector` | Test with MCP Inspector |
606
479
 
607
480
  ### Project Structure
608
481
 
609
482
  ```text
610
483
  src/
611
- ├── index.ts # Entry point, CLI argument parsing
612
- ├── server.ts # MCP server setup, roots protocol handling
613
- ├── instructions.md # AI instructions for tool usage (bundled with dist)
614
- ├── config/
615
- │ └── types.ts # Shared TypeScript types
616
- ├── lib/
617
- │ ├── constants.ts # Configuration constants and limits
618
- │ ├── errors.ts # Error handling utilities
619
- │ ├── file-operations.ts# Core filesystem operations (exports)
620
- │ ├── path-utils.ts # Path manipulation utilities
621
- │ ├── path-validation.ts# Security: path validation layer
622
- │ ├── fs-helpers.ts # Low-level filesystem helpers (exports)
623
- │ ├── file-operations/ # Core filesystem operations
624
- │ │ ├── analyze-directory.ts
625
- │ │ ├── directory-helpers.ts
626
- │ │ ├── directory-tree.ts
627
- │ │ ├── file-info.ts
628
- │ │ ├── list-directory.ts
629
- │ │ ├── pattern-validator.ts
630
- │ │ ├── read-media-file.ts
631
- │ │ ├── read-multiple-files.ts
632
- │ │ ├── search-content.ts
633
- │ │ ├── search-definitions.ts
634
- │ │ ├── search-files.ts
635
- │ │ └── sorting.ts
636
- │ ├── fs-helpers/ # Low-level filesystem helpers
637
- │ │ ├── binary-detect.ts
638
- │ │ ├── concurrency.ts
639
- │ │ ├── fs-utils.ts
640
- │ │ ├── readers.ts
641
- │ │ └── readers/ # File reading utilities
642
- │ │ ├── head-file.ts
643
- │ │ ├── line-range.ts
644
- │ │ ├── read-file.ts
645
- │ │ ├── tail-file.ts
646
- │ │ └── utf8.ts
647
- │ └── path-validation/ # Security: path validation
648
- │ ├── allowed-directories.ts
649
- │ ├── errors.ts
650
- │ ├── roots.ts
651
- │ └── validators.ts
652
- ├── schemas/
653
- │ ├── common.ts # Shared Zod schemas
654
- │ ├── input-helpers.ts # Input validation helpers
655
- │ ├── inputs.ts # Input validation schemas
656
- │ ├── output-helpers.ts # Output formatting helpers
657
- │ ├── outputs.ts # Output validation schemas
658
- │ └── index.ts # Schema exports
659
- ├── tools/
660
- │ ├── analyze-directory.ts
661
- │ ├── directory-tree.ts
662
- │ ├── get-file-info.ts
663
- │ ├── list-allowed-dirs.ts
664
- │ ├── list-directory.ts
665
- │ ├── read-file.ts
666
- │ ├── read-media-file.ts
667
- │ ├── read-multiple-files.ts
668
- │ ├── search-content.ts
669
- │ ├── search-definitions.ts
670
- │ ├── search-files.ts
671
- │ ├── tool-response.ts # Tool response formatting
672
- │ └── index.ts # Tool registration
673
- └── __tests__/ # Test files
674
- ├── lib/
675
- │ ├── errors.test.ts
676
- │ ├── file-operations.test.ts
677
- │ ├── fs-helpers.test.ts
678
- │ └── path-validation.test.ts
679
- ├── schemas/
680
- │ └── validators.test.ts
681
- └── security/
682
- └── 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
683
492
  ```
684
493
 
685
- ### Testing with MCP Inspector
686
-
687
- ```bash
688
- npm run inspector
689
- ```
690
-
691
- This launches the MCP Inspector for interactive testing of all tools.
692
-
693
- ## ❓ Troubleshooting
494
+ ## Troubleshooting
694
495
 
695
- | Issue | Solution |
696
- | --------------------------- | ---------------------------------------------------------------------------------------- |
697
- | "Access denied" error | Ensure the path is within an allowed directory. Use `list_allowed_directories` to check. |
698
- | "Path does not exist" error | Verify the path exists. Use `list_directory` to explore available files. |
699
- | "File too large" error | Use `head` or `tail` parameters for partial reading, or increase `maxSize`. |
700
- | "Binary file" warning | Use `read_media_file` for binary files, or set `skipBinary=false` in content search. |
701
- | Unexpected directory access | Server defaults to CWD if no args/roots provided. Pass explicit paths to restrict. |
702
- | Symlink blocked | Symlinks that resolve outside allowed directories are blocked for security. |
703
- | 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`. |
704
505
 
705
- ## 🤝 Contributing
506
+ ## Contributing
706
507
 
707
508
  Contributions are welcome! Please follow these steps:
708
509