@payloadcms/plugin-mcp 3.81.0 → 3.82.0-canary.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.
@@ -1 +1 @@
1
- {"version":3,"file":"convertCollectionSchemaToZod.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAU9C,eAAO,MAAM,4BAA4B,WAAY,WAAW,QA4B/D,CAAA"}
1
+ {"version":3,"file":"convertCollectionSchemaToZod.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAU9C,eAAO,MAAM,4BAA4B,WAAY,WAAW,QAyC/D,CAAA"}
@@ -5,29 +5,39 @@ import { sanitizeJsonSchema } from './sanitizeJsonSchema.js';
5
5
  import { simplifyRelationshipFields } from './simplifyRelationshipFields.js';
6
6
  import { transformPointFieldsForMCP } from './transformPointFields.js';
7
7
  export const convertCollectionSchemaToZod = (schema)=>{
8
- // Clone to avoid mutating the original schema (used elsewhere for tool listing)
9
- const schemaClone = JSON.parse(JSON.stringify(schema));
10
- const sanitized = sanitizeJsonSchema(schemaClone);
11
- const pointTransformed = transformPointFieldsForMCP(sanitized);
12
- const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed));
13
- // Transpile TypeScript to JavaScript
14
- const transpileResult = ts.transpileModule(zodSchemaAsString, {
15
- compilerOptions: {
16
- module: ts.ModuleKind.CommonJS,
17
- removeComments: true,
18
- strict: false,
19
- target: ts.ScriptTarget.ES2018
20
- }
21
- });
22
- /**
23
- * This Function evaluation is safe because:
24
- * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer
25
- * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code
26
- * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic
27
- * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing
28
- * 5. No user input or external data is involved in the schema generation process
29
- */ // eslint-disable-next-line @typescript-eslint/no-implied-eval
30
- return new Function('z', `return ${transpileResult.outputText}`)(z);
8
+ try {
9
+ // Clone to avoid mutating the original schema (used elsewhere for tool listing)
10
+ const schemaClone = JSON.parse(JSON.stringify(schema));
11
+ const sanitized = sanitizeJsonSchema(schemaClone);
12
+ const pointTransformed = transformPointFieldsForMCP(sanitized);
13
+ const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed));
14
+ // Transpile TypeScript to JavaScript
15
+ const transpileResult = ts.transpileModule(zodSchemaAsString, {
16
+ compilerOptions: {
17
+ module: ts.ModuleKind.CommonJS,
18
+ removeComments: true,
19
+ strict: false,
20
+ target: ts.ScriptTarget.ES2018
21
+ }
22
+ });
23
+ /**
24
+ * This Function evaluation is safe because:
25
+ * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer
26
+ * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code
27
+ * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic
28
+ * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing
29
+ * 5. No user input or external data is involved in the schema generation process
30
+ */ // eslint-disable-next-line @typescript-eslint/no-implied-eval
31
+ return new Function('z', `return ${transpileResult.outputText}`)(z);
32
+ } catch (error) {
33
+ // If schema conversion fails (e.g., due to Zod v4 toJSONSchema null-check bug
34
+ // with record schemas that have undefined valueType, or bundler transforms
35
+ // stripping Zod internals), return a permissive schema so tools/list doesn't
36
+ // crash entirely. The tool will still be listed but without strict validation.
37
+ // See: https://github.com/colinhacks/zod/issues/5821
38
+ console.warn(`[plugin-mcp] Schema conversion failed, using permissive fallback:`, error instanceof Error ? error.message : error);
39
+ return z.record(z.any());
40
+ }
31
41
  };
32
42
 
33
43
  //# sourceMappingURL=convertCollectionSchemaToZod.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { jsonSchemaToZod } from 'json-schema-to-zod'\nimport * as ts from 'typescript'\nimport { z } from 'zod'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\nexport const convertCollectionSchemaToZod = (schema: JSONSchema4) => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))\n\n // Transpile TypeScript to JavaScript\n const transpileResult = ts.transpileModule(zodSchemaAsString, {\n compilerOptions: {\n module: ts.ModuleKind.CommonJS,\n removeComments: true,\n strict: false,\n target: ts.ScriptTarget.ES2018,\n },\n })\n\n /**\n * This Function evaluation is safe because:\n * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer\n * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code\n * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic\n * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing\n * 5. No user input or external data is involved in the schema generation process\n */\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n return new Function('z', `return ${transpileResult.outputText}`)(z)\n}\n"],"names":["jsonSchemaToZod","ts","z","sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","convertCollectionSchemaToZod","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","zodSchemaAsString","transpileResult","transpileModule","compilerOptions","module","ModuleKind","CommonJS","removeComments","strict","target","ScriptTarget","ES2018","Function","outputText"],"mappings":"AAEA,SAASA,eAAe,QAAQ,qBAAoB;AACpD,YAAYC,QAAQ,aAAY;AAChC,SAASC,CAAC,QAAQ,MAAK;AAEvB,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE,OAAO,MAAMC,+BAA+B,CAACC;IAC3C,gFAAgF;IAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAE9C,MAAMK,YAAYT,mBAAmBK;IACrC,MAAMK,mBAAmBR,2BAA2BO;IACpD,MAAME,oBAAoBd,gBAAgBI,2BAA2BS;IAErE,qCAAqC;IACrC,MAAME,kBAAkBd,GAAGe,eAAe,CAACF,mBAAmB;QAC5DG,iBAAiB;YACfC,QAAQjB,GAAGkB,UAAU,CAACC,QAAQ;YAC9BC,gBAAgB;YAChBC,QAAQ;YACRC,QAAQtB,GAAGuB,YAAY,CAACC,MAAM;QAChC;IACF;IAEA;;;;;;;GAOC,GACD,8DAA8D;IAC9D,OAAO,IAAIC,SAAS,KAAK,CAAC,OAAO,EAAEX,gBAAgBY,UAAU,EAAE,EAAEzB;AACnE,EAAC"}
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { jsonSchemaToZod } from 'json-schema-to-zod'\nimport * as ts from 'typescript'\nimport { z } from 'zod'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\nexport const convertCollectionSchemaToZod = (schema: JSONSchema4) => {\n try {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))\n\n // Transpile TypeScript to JavaScript\n const transpileResult = ts.transpileModule(zodSchemaAsString, {\n compilerOptions: {\n module: ts.ModuleKind.CommonJS,\n removeComments: true,\n strict: false,\n target: ts.ScriptTarget.ES2018,\n },\n })\n\n /**\n * This Function evaluation is safe because:\n * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer\n * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code\n * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic\n * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing\n * 5. No user input or external data is involved in the schema generation process\n */\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n return new Function('z', `return ${transpileResult.outputText}`)(z)\n } catch (error) {\n // If schema conversion fails (e.g., due to Zod v4 toJSONSchema null-check bug\n // with record schemas that have undefined valueType, or bundler transforms\n // stripping Zod internals), return a permissive schema so tools/list doesn't\n // crash entirely. The tool will still be listed but without strict validation.\n // See: https://github.com/colinhacks/zod/issues/5821\n console.warn(\n `[plugin-mcp] Schema conversion failed, using permissive fallback:`,\n error instanceof Error ? error.message : error,\n )\n return z.record(z.any())\n }\n}\n"],"names":["jsonSchemaToZod","ts","z","sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","convertCollectionSchemaToZod","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","zodSchemaAsString","transpileResult","transpileModule","compilerOptions","module","ModuleKind","CommonJS","removeComments","strict","target","ScriptTarget","ES2018","Function","outputText","error","console","warn","Error","message","record","any"],"mappings":"AAEA,SAASA,eAAe,QAAQ,qBAAoB;AACpD,YAAYC,QAAQ,aAAY;AAChC,SAASC,CAAC,QAAQ,MAAK;AAEvB,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE,OAAO,MAAMC,+BAA+B,CAACC;IAC3C,IAAI;QACF,gFAAgF;QAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;QAE9C,MAAMK,YAAYT,mBAAmBK;QACrC,MAAMK,mBAAmBR,2BAA2BO;QACpD,MAAME,oBAAoBd,gBAAgBI,2BAA2BS;QAErE,qCAAqC;QACrC,MAAME,kBAAkBd,GAAGe,eAAe,CAACF,mBAAmB;YAC5DG,iBAAiB;gBACfC,QAAQjB,GAAGkB,UAAU,CAACC,QAAQ;gBAC9BC,gBAAgB;gBAChBC,QAAQ;gBACRC,QAAQtB,GAAGuB,YAAY,CAACC,MAAM;YAChC;QACF;QAEA;;;;;;;KAOC,GACD,8DAA8D;QAC9D,OAAO,IAAIC,SAAS,KAAK,CAAC,OAAO,EAAEX,gBAAgBY,UAAU,EAAE,EAAEzB;IACnE,EAAE,OAAO0B,OAAO;QACd,8EAA8E;QAC9E,2EAA2E;QAC3E,6EAA6E;QAC7E,+EAA+E;QAC/E,qDAAqD;QACrDC,QAAQC,IAAI,CACV,CAAC,iEAAiE,CAAC,EACnEF,iBAAiBG,QAAQH,MAAMI,OAAO,GAAGJ;QAE3C,OAAO1B,EAAE+B,MAAM,CAAC/B,EAAEgC,GAAG;IACvB;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "3.81.0",
3
+ "version": "3.82.0-canary.1",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
6
  "plugin",
@@ -45,10 +45,10 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@payloadcms/eslint-config": "3.28.0",
48
- "payload": "3.81.0"
48
+ "payload": "3.82.0-canary.1"
49
49
  },
50
50
  "peerDependencies": {
51
- "payload": "3.81.0"
51
+ "payload": "3.82.0-canary.1"
52
52
  },
53
53
  "homepage:": "https://payloadcms.com",
54
54
  "scripts": {
@@ -9,31 +9,44 @@ import { simplifyRelationshipFields } from './simplifyRelationshipFields.js'
9
9
  import { transformPointFieldsForMCP } from './transformPointFields.js'
10
10
 
11
11
  export const convertCollectionSchemaToZod = (schema: JSONSchema4) => {
12
- // Clone to avoid mutating the original schema (used elsewhere for tool listing)
13
- const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4
12
+ try {
13
+ // Clone to avoid mutating the original schema (used elsewhere for tool listing)
14
+ const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4
14
15
 
15
- const sanitized = sanitizeJsonSchema(schemaClone)
16
- const pointTransformed = transformPointFieldsForMCP(sanitized)
17
- const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))
16
+ const sanitized = sanitizeJsonSchema(schemaClone)
17
+ const pointTransformed = transformPointFieldsForMCP(sanitized)
18
+ const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))
18
19
 
19
- // Transpile TypeScript to JavaScript
20
- const transpileResult = ts.transpileModule(zodSchemaAsString, {
21
- compilerOptions: {
22
- module: ts.ModuleKind.CommonJS,
23
- removeComments: true,
24
- strict: false,
25
- target: ts.ScriptTarget.ES2018,
26
- },
27
- })
20
+ // Transpile TypeScript to JavaScript
21
+ const transpileResult = ts.transpileModule(zodSchemaAsString, {
22
+ compilerOptions: {
23
+ module: ts.ModuleKind.CommonJS,
24
+ removeComments: true,
25
+ strict: false,
26
+ target: ts.ScriptTarget.ES2018,
27
+ },
28
+ })
28
29
 
29
- /**
30
- * This Function evaluation is safe because:
31
- * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer
32
- * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code
33
- * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic
34
- * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing
35
- * 5. No user input or external data is involved in the schema generation process
36
- */
37
- // eslint-disable-next-line @typescript-eslint/no-implied-eval
38
- return new Function('z', `return ${transpileResult.outputText}`)(z)
30
+ /**
31
+ * This Function evaluation is safe because:
32
+ * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer
33
+ * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code
34
+ * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic
35
+ * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing
36
+ * 5. No user input or external data is involved in the schema generation process
37
+ */
38
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
39
+ return new Function('z', `return ${transpileResult.outputText}`)(z)
40
+ } catch (error) {
41
+ // If schema conversion fails (e.g., due to Zod v4 toJSONSchema null-check bug
42
+ // with record schemas that have undefined valueType, or bundler transforms
43
+ // stripping Zod internals), return a permissive schema so tools/list doesn't
44
+ // crash entirely. The tool will still be listed but without strict validation.
45
+ // See: https://github.com/colinhacks/zod/issues/5821
46
+ console.warn(
47
+ `[plugin-mcp] Schema conversion failed, using permissive fallback:`,
48
+ error instanceof Error ? error.message : error,
49
+ )
50
+ return z.record(z.any())
51
+ }
39
52
  }