filesystem-mcp 1.1.0 → 1.2.0

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.
@@ -39,6 +39,7 @@ const fs = __importStar(require("node:fs/promises"));
39
39
  const path = __importStar(require("node:path"));
40
40
  const response_js_1 = require("../utils/response.js");
41
41
  const paths_js_1 = require("../utils/paths.js");
42
+ const schema_js_1 = require("../utils/schema.js");
42
43
  const description = `Create or overwrite a file with the specified content.
43
44
 
44
45
  - Creates parent directories if they don't exist
@@ -48,10 +49,12 @@ function registerCreate(server) {
48
49
  server.registerTool('create', {
49
50
  title: 'Create',
50
51
  description,
51
- inputSchema: {
52
+ inputSchema: (0, schema_js_1.strictSchemaWithAliases)({
52
53
  path: zod_1.z.string().describe('Absolute path where file will be created'),
53
54
  content: zod_1.z.string().describe('Content to write to the file'),
54
- },
55
+ }, {
56
+ file_text: 'content',
57
+ }),
55
58
  annotations: {
56
59
  readOnlyHint: false,
57
60
  destructiveHint: true,
@@ -38,6 +38,7 @@ const zod_1 = require("zod");
38
38
  const fs = __importStar(require("node:fs/promises"));
39
39
  const response_js_1 = require("../utils/response.js");
40
40
  const paths_js_1 = require("../utils/paths.js");
41
+ const schema_js_1 = require("../utils/schema.js");
41
42
  const description = `Insert text at a specific line in a file.
42
43
 
43
44
  - insert_line = 0: Insert at the beginning
@@ -49,11 +50,11 @@ function registerInsert(server) {
49
50
  server.registerTool('insert', {
50
51
  title: 'Insert',
51
52
  description,
52
- inputSchema: {
53
+ inputSchema: (0, schema_js_1.strictSchemaWithAliases)({
53
54
  path: zod_1.z.string().describe('Absolute path to file'),
54
55
  insert_line: zod_1.z.number().int().min(-1).describe('Line number to insert after (0 = beginning, -1 = end)'),
55
56
  insert_text: zod_1.z.string().describe('Text to insert (should end with newline)'),
56
- },
57
+ }, {}),
57
58
  annotations: {
58
59
  readOnlyHint: false,
59
60
  destructiveHint: true,
@@ -38,6 +38,7 @@ const zod_1 = require("zod");
38
38
  const fs = __importStar(require("node:fs/promises"));
39
39
  const response_js_1 = require("../utils/response.js");
40
40
  const paths_js_1 = require("../utils/paths.js");
41
+ const schema_js_1 = require("../utils/schema.js");
41
42
  const description = `Replace an exact string in a file.
42
43
 
43
44
  - old_str must match exactly and be unique in the file
@@ -48,11 +49,14 @@ function registerStrReplace(server) {
48
49
  server.registerTool('str_replace', {
49
50
  title: 'String Replace',
50
51
  description,
51
- inputSchema: {
52
+ inputSchema: (0, schema_js_1.strictSchemaWithAliases)({
52
53
  path: zod_1.z.string().describe('Absolute path to file'),
53
54
  old_str: zod_1.z.string().describe('Exact string to find (must be unique)'),
54
55
  new_str: zod_1.z.string().optional().describe('Replacement string (omit to delete)'),
55
- },
56
+ }, {
57
+ old_string: 'old_str',
58
+ new_string: 'new_str',
59
+ }),
56
60
  annotations: {
57
61
  readOnlyHint: false,
58
62
  destructiveHint: true,
@@ -39,6 +39,7 @@ const fs = __importStar(require("node:fs/promises"));
39
39
  const path = __importStar(require("node:path"));
40
40
  const response_js_1 = require("../utils/response.js");
41
41
  const paths_js_1 = require("../utils/paths.js");
42
+ const schema_js_1 = require("../utils/schema.js");
42
43
  const description = `View file contents or list directory.
43
44
 
44
45
  For files:
@@ -54,10 +55,10 @@ function registerView(server) {
54
55
  server.registerTool('view', {
55
56
  title: 'View',
56
57
  description,
57
- inputSchema: {
58
+ inputSchema: (0, schema_js_1.strictSchemaWithAliases)({
58
59
  path: zod_1.z.string().describe('Absolute path to file or directory'),
59
60
  view_range: zod_1.z.tuple([zod_1.z.number(), zod_1.z.number()]).optional().describe('Line range [start, end] for text files (1-indexed, inclusive)'),
60
- },
61
+ }, {}),
61
62
  annotations: {
62
63
  readOnlyHint: true,
63
64
  },
@@ -0,0 +1,9 @@
1
+ import { type ZodRawShape, type ZodTypeAny } from 'zod';
2
+ type AliasMap = Record<string, string>;
3
+ /**
4
+ * Creates a strict Zod object schema that:
5
+ * 1. Accepts aliased parameter names (e.g., new_string -> new_str)
6
+ * 2. Rejects any unknown parameters after alias resolution
7
+ */
8
+ export declare function strictSchemaWithAliases<T extends ZodRawShape>(shape: T, aliases?: AliasMap): ZodTypeAny;
9
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.strictSchemaWithAliases = strictSchemaWithAliases;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Creates a strict Zod object schema that:
7
+ * 1. Accepts aliased parameter names (e.g., new_string -> new_str)
8
+ * 2. Rejects any unknown parameters after alias resolution
9
+ */
10
+ function strictSchemaWithAliases(shape, aliases = {}) {
11
+ const objectSchema = zod_1.z.object(shape).strict();
12
+ return zod_1.z.preprocess((args) => {
13
+ if (typeof args !== 'object' || args === null) {
14
+ return args;
15
+ }
16
+ const input = args;
17
+ const result = {};
18
+ // Build result object, mapping aliases to canonical names
19
+ for (const key of Object.keys(input)) {
20
+ const canonicalKey = aliases[key] ?? key;
21
+ // Only use alias if canonical key isn't already set
22
+ if (!(canonicalKey in result)) {
23
+ result[canonicalKey] = input[key];
24
+ }
25
+ }
26
+ return result;
27
+ }, objectSchema);
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filesystem-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "MCP server for filesystem operations (view, create, edit files)",
5
5
  "license": "MIT",
6
6
  "author": "Adam Jones (domdomegg)",
@@ -32,7 +32,8 @@
32
32
  "eslint-config-domdomegg": "^2.0.0",
33
33
  "tsconfig-domdomegg": "^1.0.0",
34
34
  "typescript": "^5.8.0",
35
- "vitest": "^3.0.0"
35
+ "vitest": "^3.0.0",
36
+ "zod-to-json-schema": "^3.25.1"
36
37
  },
37
38
  "dependencies": {
38
39
  "@modelcontextprotocol/sdk": "^1.24.0",