@j0hanz/filesystem-mcp 1.13.2 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -145
- package/dist/cli.js +2 -2
- package/dist/completions.js +54 -51
- package/dist/config.d.ts +13 -14
- package/dist/config.js +12 -12
- package/dist/index.js +1 -1
- package/dist/lib/abort.d.ts +7 -0
- package/dist/lib/abort.js +81 -0
- package/dist/lib/constants.d.ts +3 -1
- package/dist/lib/constants.js +8 -2
- package/dist/lib/errors.d.ts +7 -3
- package/dist/lib/errors.js +64 -41
- package/dist/lib/file-operations/core.d.ts +3 -3
- package/dist/lib/file-operations/core.js +23 -20
- package/dist/lib/file-operations/metadata.d.ts +2 -2
- package/dist/lib/file-operations/metadata.js +69 -22
- package/dist/lib/file-operations/search.d.ts +0 -1
- package/dist/lib/file-operations/search.js +87 -95
- package/dist/lib/file-operations/traversal.js +13 -15
- package/dist/lib/fs-helpers.d.ts +3 -10
- package/dist/lib/fs-helpers.js +29 -108
- package/dist/lib/globs.d.ts +2 -0
- package/dist/lib/globs.js +19 -0
- package/dist/lib/logger.d.ts +28 -0
- package/dist/lib/logger.js +91 -0
- package/dist/lib/observability.d.ts +7 -0
- package/dist/lib/observability.js +19 -9
- package/dist/lib/paths.js +55 -55
- package/dist/lib/resource-store.js +4 -4
- package/dist/lib/utils.d.ts +0 -12
- package/dist/lib/utils.js +0 -13
- package/dist/lib/zod-codecs.d.ts +2 -0
- package/dist/lib/zod-codecs.js +18 -0
- package/dist/pkg-info.d.ts +1 -0
- package/dist/pkg-info.js +2 -2
- package/dist/prompts.js +3 -3
- package/dist/resources/generated-instructions.js +41 -41
- package/dist/resources/tool-catalog.js +33 -58
- package/dist/resources/tool-info.d.ts +0 -1
- package/dist/resources/tool-info.js +44 -67
- package/dist/resources/workflows.js +47 -19
- package/dist/resources.d.ts +1 -1
- package/dist/resources.js +4 -4
- package/dist/schemas.d.ts +185 -465
- package/dist/schemas.js +174 -206
- package/dist/server/bootstrap.d.ts +12 -11
- package/dist/server/bootstrap.js +95 -86
- package/dist/server/roots-manager.d.ts +5 -2
- package/dist/server/roots-manager.js +9 -7
- package/dist/server/task-store.d.ts +10 -0
- package/dist/server/task-store.js +73 -0
- package/dist/tools/apply-patch.js +39 -20
- package/dist/tools/calculate-hash.js +14 -27
- package/dist/tools/create-directory.js +11 -9
- package/dist/tools/delete-file.js +19 -19
- package/dist/tools/diff-files.js +16 -18
- package/dist/tools/edit-file.js +11 -5
- package/dist/tools/list-directory.js +16 -21
- package/dist/tools/move-file.js +105 -100
- package/dist/tools/read-multiple.js +15 -10
- package/dist/tools/read.js +6 -7
- package/dist/tools/replace-in-files.js +76 -115
- package/dist/tools/roots.js +3 -7
- package/dist/tools/search-content.js +158 -203
- package/dist/tools/search-files.js +59 -50
- package/dist/tools/shared.d.ts +10 -0
- package/dist/tools/shared.js +105 -36
- package/dist/tools/stat-many.js +15 -9
- package/dist/tools/stat.js +6 -6
- package/dist/tools/task-support.d.ts +10 -9
- package/dist/tools/task-support.js +94 -23
- package/dist/tools/tree.js +4 -4
- package/dist/tools/write-file.js +11 -12
- package/package.json +10 -9
package/dist/tools/tree.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
2
|
import { DEFAULT_SEARCH_TIMEOUT_MS } from '../lib/constants.js';
|
|
3
3
|
import { ErrorCode } from '../lib/errors.js';
|
|
4
4
|
import { formatTreeAscii, treeDirectory, } from '../lib/file-operations/metadata.js';
|
|
@@ -14,7 +14,6 @@ export const TREE_TOOL = {
|
|
|
14
14
|
outputSchema: TreeOutputSchema,
|
|
15
15
|
annotations: READ_ONLY_TOOL_ANNOTATIONS,
|
|
16
16
|
taskSupport: 'optional',
|
|
17
|
-
gotchas: ['`maxDepth=0` returns only the root node.'],
|
|
18
17
|
};
|
|
19
18
|
async function handleTree(args, signal, onProgress) {
|
|
20
19
|
const basePath = resolvePathOrRoot(args.path);
|
|
@@ -45,10 +44,11 @@ export function registerTreeTool(server, options = {}) {
|
|
|
45
44
|
return executeToolWithDiagnostics({
|
|
46
45
|
toolName: 'tree',
|
|
47
46
|
extra,
|
|
47
|
+
outputSchema: TreeOutputSchema,
|
|
48
48
|
timedSignal: { timeoutMs: DEFAULT_SEARCH_TIMEOUT_MS },
|
|
49
49
|
context: { path: targetPath },
|
|
50
50
|
run: async (signal) => {
|
|
51
|
-
const context = args.path ?
|
|
51
|
+
const context = args.path ? basename(args.path) : '.';
|
|
52
52
|
let progressCursor = 0;
|
|
53
53
|
const knownTotal = args.maxEntries;
|
|
54
54
|
notifyProgress(extra, {
|
|
@@ -93,7 +93,7 @@ export function registerTreeTool(server, options = {}) {
|
|
|
93
93
|
throw error;
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
onError: (error) => buildToolErrorResponse(error, ErrorCode.
|
|
96
|
+
onError: (error) => buildToolErrorResponse(error, ErrorCode.NOT_DIRECTORY, targetPath),
|
|
97
97
|
});
|
|
98
98
|
};
|
|
99
99
|
const wrappedHandler = wrapToolHandler(handler, {
|
package/dist/tools/write-file.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname } from 'node:path';
|
|
3
|
+
import { withAbort } from '../lib/abort.js';
|
|
3
4
|
import { ErrorCode } from '../lib/errors.js';
|
|
4
|
-
import { atomicWriteFile
|
|
5
|
+
import { atomicWriteFile } from '../lib/fs-helpers.js';
|
|
6
|
+
import { Logger } from '../lib/logger.js';
|
|
5
7
|
import { validatePathForWrite } from '../lib/paths.js';
|
|
6
8
|
import { formatBytes } from '../config.js';
|
|
7
9
|
import { WriteFileInputSchema, WriteFileOutputSchema } from '../schemas.js';
|
|
@@ -14,17 +16,15 @@ export const WRITE_FILE_TOOL = {
|
|
|
14
16
|
inputSchema: WriteFileInputSchema,
|
|
15
17
|
outputSchema: WriteFileOutputSchema,
|
|
16
18
|
annotations: DESTRUCTIVE_WRITE_TOOL_ANNOTATIONS,
|
|
17
|
-
gotchas: [
|
|
18
|
-
'`write` replaces ALL existing content — use `edit` for partial updates.',
|
|
19
|
-
],
|
|
20
19
|
taskSupport: 'forbidden',
|
|
21
20
|
};
|
|
22
21
|
async function handleWriteFile(args, signal) {
|
|
23
22
|
const validPath = await validatePathForWrite(args.path, signal);
|
|
24
23
|
// Ensure parent directory exists
|
|
25
|
-
await withAbort(
|
|
24
|
+
await withAbort(mkdir(dirname(validPath), { recursive: true }), signal);
|
|
26
25
|
await atomicWriteFile(validPath, args.content, { encoding: 'utf-8', signal });
|
|
27
26
|
const bytesWritten = Buffer.byteLength(args.content, 'utf-8');
|
|
27
|
+
Logger.info(`write: ${args.path} (${bytesWritten} bytes)`);
|
|
28
28
|
return buildToolResponse(`Successfully wrote to file: ${args.path}`, {
|
|
29
29
|
ok: true,
|
|
30
30
|
path: validPath,
|
|
@@ -35,21 +35,20 @@ export function registerWriteFileTool(server, options = {}) {
|
|
|
35
35
|
const handler = (args, extra) => executeToolWithDiagnostics({
|
|
36
36
|
toolName: 'write',
|
|
37
37
|
extra,
|
|
38
|
+
outputSchema: WriteFileOutputSchema,
|
|
38
39
|
timedSignal: {},
|
|
39
40
|
context: { path: args.path },
|
|
40
41
|
run: (signal) => handleWriteFile(args, signal),
|
|
41
|
-
onError: (error) => buildToolErrorResponse(error, ErrorCode.
|
|
42
|
+
onError: (error) => buildToolErrorResponse(error, ErrorCode.UNKNOWN, args.path),
|
|
42
43
|
});
|
|
43
44
|
const wrappedHandler = wrapToolHandler(handler, {
|
|
44
45
|
guard: options.isInitialized,
|
|
45
|
-
progressMessage: (args) => `🛠 write: ${
|
|
46
|
+
progressMessage: (args) => `🛠 write: ${basename(args.path)}`,
|
|
46
47
|
completionMessage: (args, result) => {
|
|
47
|
-
const name =
|
|
48
|
+
const name = basename(args.path);
|
|
48
49
|
if (result.isError)
|
|
49
50
|
return `🛠 write: ${name} • failed`;
|
|
50
51
|
const sc = result.structuredContent;
|
|
51
|
-
if (!sc.ok)
|
|
52
|
-
return `🛠 write: ${name} • failed`;
|
|
53
52
|
return `🛠 write: ${name} • ${formatBytes(sc.bytesWritten ?? 0)}`;
|
|
54
53
|
},
|
|
55
54
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j0hanz/filesystem-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"mcpName": "io.github.j0hanz/filesystem-mcp",
|
|
5
5
|
"description": "A local filesystem MCP server that lets LLMs and AI agents read, write, search, diff, patch, and manage files safely and efficiently. Built for reliable, structured, and controlled filesystem interaction.",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"test": "node scripts/tasks.mjs test",
|
|
41
41
|
"test:fast": "node --test --import tsx/esm src/__tests__/**/*.test.ts node-tests/**/*.test.ts",
|
|
42
42
|
"test:coverage": "node scripts/tasks.mjs test --coverage",
|
|
43
|
+
"inspector:smoke": "node scripts/inspector-smoke.mjs",
|
|
43
44
|
"knip": "knip",
|
|
44
45
|
"knip:fix": "knip --fix",
|
|
45
46
|
"inspector": "npm run build && npx -y @modelcontextprotocol/inspector node dist/index.js ${workspaceFolder}",
|
|
@@ -74,28 +75,28 @@
|
|
|
74
75
|
},
|
|
75
76
|
"homepage": "https://github.com/j0hanz/filesystem-mcp#readme",
|
|
76
77
|
"dependencies": {
|
|
77
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
78
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
78
79
|
"commander": "^14.0.3",
|
|
79
|
-
"diff": "^8.0.
|
|
80
|
+
"diff": "^8.0.4",
|
|
80
81
|
"ignore": "^7.0.5",
|
|
81
|
-
"re2": "^1.
|
|
82
|
-
"safe-regex2": "^5.0.0",
|
|
82
|
+
"re2": "^1.24.0",
|
|
83
83
|
"zod": "^4.3.6"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@eslint/js": "^10.0.1",
|
|
87
87
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
88
88
|
"@types/node": "^24",
|
|
89
|
-
"eslint": "^10.0
|
|
89
|
+
"eslint": "^10.2.0",
|
|
90
90
|
"eslint-config-prettier": "^10.1.8",
|
|
91
91
|
"eslint-plugin-de-morgan": "^2.1.1",
|
|
92
92
|
"eslint-plugin-depend": "^1.5.0",
|
|
93
|
+
"eslint-plugin-sonarjs": "^4.0.2",
|
|
93
94
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
94
|
-
"knip": "^
|
|
95
|
+
"knip": "^6.3.1",
|
|
95
96
|
"prettier": "^3.8.1",
|
|
96
97
|
"tsx": "^4.21.0",
|
|
97
|
-
"typescript": "^
|
|
98
|
-
"typescript-eslint": "^8.
|
|
98
|
+
"typescript": "^6.0.2",
|
|
99
|
+
"typescript-eslint": "^8.58.1"
|
|
99
100
|
},
|
|
100
101
|
"engines": {
|
|
101
102
|
"node": ">=24"
|