@payloadcms/plugin-mcp 3.65.0-canary.7 → 3.65.0-internal.5b33fe0

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":"create.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,UACzC,WAAW,SA2IpB,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,UACzC,WAAW,SAyGpB,CAAA"}
@@ -1,12 +1,11 @@
1
- import { z } from 'zod';
2
1
  import { toCamelCase } from '../../../utils/camelCase.js';
3
2
  import { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js';
4
3
  import { toolSchemas } from '../schemas.js';
5
4
  export const createResourceTool = (server, req, user, verboseLogs, collectionSlug, collections, schema)=>{
6
- const tool = async (data, draft, locale, fallbackLocale)=>{
5
+ const tool = async (data)=>{
7
6
  const payload = req.payload;
8
7
  if (verboseLogs) {
9
- payload.logger.info(`[payload-mcp] Creating resource in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`);
8
+ payload.logger.info(`[payload-mcp] Creating resource in collection: ${collectionSlug}`);
10
9
  }
11
10
  try {
12
11
  // Parse the data JSON
@@ -31,16 +30,9 @@ export const createResourceTool = (server, req, user, verboseLogs, collectionSlu
31
30
  const result = await payload.create({
32
31
  collection: collectionSlug,
33
32
  data: parsedData,
34
- draft,
35
33
  overrideAccess: false,
36
34
  req,
37
- user,
38
- ...locale && {
39
- locale
40
- },
41
- ...fallbackLocale && {
42
- fallbackLocale
43
- }
35
+ user
44
36
  });
45
37
  if (verboseLogs) {
46
38
  payload.logger.info(`[payload-mcp] Successfully created resource in ${collectionSlug} with ID: ${result.id}`);
@@ -74,17 +66,9 @@ ${JSON.stringify(result, null, 2)}
74
66
  };
75
67
  if (collections?.[collectionSlug]?.enabled) {
76
68
  const convertedFields = convertCollectionSchemaToZod(schema);
77
- // Create a new schema that combines the converted fields with create-specific parameters
78
- const createResourceSchema = z.object({
79
- ...convertedFields.shape,
80
- draft: z.boolean().optional().default(false).describe('Whether to create the document as a draft'),
81
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
82
- locale: z.string().optional().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale')
83
- });
84
- server.tool(`create${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.createResource.description.trim()}`, createResourceSchema.shape, async (params)=>{
85
- const { draft, fallbackLocale, locale, ...fieldData } = params;
86
- const data = JSON.stringify(fieldData);
87
- return await tool(data, draft, locale, fallbackLocale);
69
+ server.tool(`create${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.createResource.description.trim()}`, convertedFields.shape, async (params)=>{
70
+ const data = JSON.stringify(params);
71
+ return await tool(data);
88
72
  });
89
73
  }
90
74
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/resource/create.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js'\nimport { toolSchemas } from '../schemas.js'\nexport const createResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n draft: boolean,\n locale?: string,\n fallbackLocale?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Creating resource in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n return {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n }\n\n // Create the resource\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n draft,\n overrideAccess: false,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n })\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully created resource in ${collectionSlug} with ID: ${result.id}`,\n )\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource created successfully in collection \"${collectionSlug}\"!\nCreated resource:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error creating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error creating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n // Create a new schema that combines the converted fields with create-specific parameters\n const createResourceSchema = z.object({\n ...convertedFields.shape,\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n })\n\n server.tool(\n `create${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.createResource.description.trim()}`,\n createResourceSchema.shape,\n async (params: Record<string, unknown>) => {\n const { draft, fallbackLocale, locale, ...fieldData } = params\n const data = JSON.stringify(fieldData)\n return await tool(\n data,\n draft as boolean,\n locale as string | undefined,\n fallbackLocale as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","toolSchemas","createResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","draft","locale","fallbackLocale","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","content","type","text","result","create","collection","overrideAccess","id","response","overrideResponse","errorMessage","Error","message","enabled","convertedFields","createResourceSchema","object","shape","boolean","optional","default","describe","string","charAt","toUpperCase","slice","description","createResource","trim","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,4BAA4B,QAAQ,iDAAgD;AAC7F,SAASC,WAAW,QAAQ,gBAAe;AAC3C,OAAO,MAAMC,qBAAqB,CAChCC,QACAC,KACAC,MACAC,aACAC,gBACAC,aACAC;IAEA,MAAMC,OAAO,OACXC,MACAC,OACAC,QACAC;QAOA,MAAMC,UAAUX,IAAIW,OAAO;QAE3B,IAAIT,aAAa;YACfS,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,+CAA+C,EAAEV,iBAAiBM,SAAS,CAAC,cAAc,EAAEA,QAAQ,GAAG,IAAI;QAEhH;QAEA,IAAI;YACF,sBAAsB;YACtB,IAAIK;YACJ,IAAI;gBACFA,aAAaC,KAAKC,KAAK,CAACT;gBACxB,IAAIL,aAAa;oBACfS,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,8BAA8B,EAAEV,eAAe,EAAE,EAAEY,KAAKE,SAAS,CAACH,aAAa;gBAEpF;YACF,EAAE,OAAOI,aAAa;gBACpBP,QAAQC,MAAM,CAACO,KAAK,CAAC,CAAC,0CAA0C,EAAEZ,MAAM;gBACxE,OAAO;oBACLa,SAAS;wBAAC;4BAAEC,MAAM;4BAAiBC,MAAM;wBAAoC;qBAAE;gBACjF;YACF;YAEA,sBAAsB;YACtB,MAAMC,SAAS,MAAMZ,QAAQa,MAAM,CAAC;gBAClCC,YAAYtB;gBACZI,MAAMO;gBACNN;gBACAkB,gBAAgB;gBAChB1B;gBACAC;gBACA,GAAIQ,UAAU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QAEN;QAEA1C,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAewC,MAAM,CAAC,GAAGC,WAAW,KAAKjD,YAAYQ,gBAAgB0C,KAAK,CAAC,IAAI,EACxF,GAAGzC,aAAa,CAACD,eAAe,EAAE2C,eAAejD,YAAYkD,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGb,qBAAqBE,KAAK,EAC1B,OAAOY;YACL,MAAM,EAAEzC,KAAK,EAAEE,cAAc,EAAED,MAAM,EAAE,GAAGyC,WAAW,GAAGD;YACxD,MAAM1C,OAAOQ,KAAKE,SAAS,CAACiC;YAC5B,OAAO,MAAM5C,KACXC,MACAC,OACAC,QACAC;QAEJ;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/mcp/tools/resource/create.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js'\nimport { toolSchemas } from '../schemas.js'\nexport const createResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Creating resource in collection: ${collectionSlug}`)\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n return {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n }\n\n // Create the resource\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n overrideAccess: false,\n req,\n user,\n })\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully created resource in ${collectionSlug} with ID: ${result.id}`,\n )\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource created successfully in collection \"${collectionSlug}\"!\nCreated resource:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error creating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error creating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n server.tool(\n `create${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.createResource.description.trim()}`,\n convertedFields.shape,\n async (params: Record<string, unknown>) => {\n const data = JSON.stringify(params)\n return await tool(data)\n },\n )\n }\n}\n"],"names":["toCamelCase","convertCollectionSchemaToZod","toolSchemas","createResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","content","type","text","result","create","collection","overrideAccess","id","response","overrideResponse","errorMessage","Error","message","enabled","convertedFields","charAt","toUpperCase","slice","description","createResource","trim","shape","params"],"mappings":"AAMA,SAASA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AA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,SAqMlD,CAAA"}
@@ -1,10 +1,10 @@
1
1
  import { toCamelCase } from '../../../utils/camelCase.js';
2
2
  import { toolSchemas } from '../schemas.js';
3
3
  export const deleteResourceTool = (server, req, user, verboseLogs, collectionSlug, collections)=>{
4
- const tool = async (id, where, depth = 0, locale, fallbackLocale)=>{
4
+ const tool = async (id, where, depth = 0)=>{
5
5
  const payload = req.payload;
6
6
  if (verboseLogs) {
7
- payload.logger.info(`[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`);
7
+ payload.logger.info(`[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}`);
8
8
  }
9
9
  try {
10
10
  // Validate that either id or where is provided
@@ -47,13 +47,7 @@ export const deleteResourceTool = (server, req, user, verboseLogs, collectionSlu
47
47
  depth,
48
48
  overrideAccess: false,
49
49
  req,
50
- user,
51
- ...locale && {
52
- locale
53
- },
54
- ...fallbackLocale && {
55
- fallbackLocale
56
- }
50
+ user
57
51
  };
58
52
  // Delete by ID or where clause
59
53
  if (id) {
@@ -139,8 +133,8 @@ ${JSON.stringify(errors, null, 2)}
139
133
  }
140
134
  };
141
135
  if (collections?.[collectionSlug]?.enabled) {
142
- server.tool(`delete${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.deleteResource.description.trim()}`, toolSchemas.deleteResource.parameters.shape, async ({ id, depth, fallbackLocale, locale, where })=>{
143
- return await tool(id, where, depth, locale, fallbackLocale);
136
+ server.tool(`delete${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.deleteResource.description.trim()}`, toolSchemas.deleteResource.parameters.shape, async ({ id, depth, where })=>{
137
+ return await tool(id, where, depth);
144
138
  });
145
139
  }
146
140
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/resource/delete.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const deleteResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: number | string,\n where?: string,\n depth: number = 0,\n locale?: string,\n fallbackLocale?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Build delete options\n const deleteOptions: Record<string, unknown> = {\n collection: collectionSlug,\n depth,\n overrideAccess: false,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n }\n\n // Delete by ID or where clause\n if (id) {\n deleteOptions.id = id\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Deleting single document with ID: ${id}`)\n }\n } else {\n deleteOptions.where = whereClause\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Deleting multiple documents with where clause`)\n }\n }\n\n const result = await payload.delete(deleteOptions as Parameters<typeof payload.delete>[0])\n\n // Handle different result types\n if (id) {\n // Single document deletion\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully deleted document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document deleted successfully from collection \"${collectionSlug}\"!\nDeleted document:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents deletion\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully deleted ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Document deleted successfully from collection \"${collectionSlug}\"!\nDeleted: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nDeleted documents:\n\\`\\`\\`json\n${JSON.stringify(docs, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error deleting resource from ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error deleting resource from collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n server.tool(\n `delete${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.deleteResource.description.trim()}`,\n toolSchemas.deleteResource.parameters.shape,\n async ({ id, depth, fallbackLocale, locale, where }) => {\n return await tool(id, where, depth, locale, fallbackLocale)\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","deleteResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","where","depth","locale","fallbackLocale","payload","logger","info","error","response","content","type","text","overrideResponse","whereClause","JSON","parse","_parseError","warn","deleteOptions","collection","overrideAccess","result","delete","stringify","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","deleteResource","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,qBAAqB,CACh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;YACjD,OAAO,MAAMF,KAAKC,IAAIC,OAAOC,OAAOC,QAAQC;QAC9C;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/mcp/tools/resource/delete.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const deleteResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: string,\n where?: string,\n depth: number = 0,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}`,\n )\n }\n\n try {\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Build delete options\n const deleteOptions: Record<string, unknown> = {\n collection: collectionSlug,\n depth,\n overrideAccess: false,\n req,\n user,\n }\n\n // Delete by ID or where clause\n if (id) {\n deleteOptions.id = id\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Deleting single document with ID: ${id}`)\n }\n } else {\n deleteOptions.where = whereClause\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Deleting multiple documents with where clause`)\n }\n }\n\n const result = await payload.delete(deleteOptions as Parameters<typeof payload.delete>[0])\n\n // Handle different result types\n if (id) {\n // Single document deletion\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully deleted document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document deleted successfully from collection \"${collectionSlug}\"!\nDeleted document:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents deletion\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully deleted ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Document deleted successfully from collection \"${collectionSlug}\"!\nDeleted: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nDeleted documents:\n\\`\\`\\`json\n${JSON.stringify(docs, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error deleting resource from ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error deleting resource from collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n server.tool(\n `delete${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.deleteResource.description.trim()}`,\n toolSchemas.deleteResource.parameters.shape,\n async ({ id, depth, where }) => {\n return await tool(id, where, depth)\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","deleteResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","where","depth","payload","logger","info","error","response","content","type","text","overrideResponse","whereClause","JSON","parse","_parseError","warn","deleteOptions","collection","overrideAccess","result","delete","stringify","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","deleteResource","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,qBAAqB,CAChCC,QACAC,KACAC,MACAC,aACAC,gBACAC;IAEA,MAAMC,OAAO,OACXC,IACAC,OACAC,QAAgB,CAAC;QAOjB,MAAMC,UAAUT,IAAIS,OAAO;QAE3B,IAAIP,aAAa;YACfO,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,iDAAiD,EAAER,iBAAiBG,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,sBAAsB;QAExH;QAEA,IAAI;YACF,+CAA+C;YAC/C,IAAI,CAACA,MAAM,CAACC,OAAO;gBACjBE,QAAQC,MAAM,CAACE,KAAK,CAAC;gBACrB,MAAMC,WAAW;oBACfC,SAAS;wBACP;4BAAEC,MAAM;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2CAA2C,EAAET,eAAe,EAAE,EAAE+B,cAAc;YAGjF,MAAMrB,WAAW;gBACfC,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,yCAAyC,EAAEb,eAAe,GAAG,EAAE+B,cAAc;oBACtF;iBACD;YACH;YAEA,OAAQ9B,aAAa,CAACD,eAAe,EAAEc,mBAAmBJ,UAAU,CAAC,GAAGb,QAAQa;QAMlF;IACF;IAEA,IAAIT,aAAa,CAACD,eAAe,EAAEkC,SAAS;QAC1CtC,OAAOM,IAAI,CACT,CAAC,MAAM,EAAEF,eAAemC,MAAM,CAAC,GAAGC,WAAW,KAAK3C,YAAYO,gBAAgBqC,KAAK,CAAC,IAAI,EACxF,GAAGpC,aAAa,CAACD,eAAe,EAAEsC,eAAe5C,YAAY6C,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChG9C,YAAY6C,cAAc,CAACE,UAAU,CAACC,KAAK,EAC3C,OAAO,EAAEvC,EAAE,EAAEE,KAAK,EAAED,KAAK,EAAE;YACzB,OAAO,MAAMF,KAAKC,IAAIC,OAAOC;QAC/B;IAEJ;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,gBAAgB,WACnB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,SA6LlD,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,gBAAgB,WACnB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,SAuLlD,CAAA"}
@@ -1,10 +1,10 @@
1
1
  import { toCamelCase } from '../../../utils/camelCase.js';
2
2
  import { toolSchemas } from '../schemas.js';
3
3
  export const findResourceTool = (server, req, user, verboseLogs, collectionSlug, collections)=>{
4
- const tool = async (id, limit = 10, page = 1, sort, where, locale, fallbackLocale)=>{
4
+ const tool = async (id, limit = 10, page = 1, sort, where)=>{
5
5
  const payload = req.payload;
6
6
  if (verboseLogs) {
7
- payload.logger.info(`[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`);
7
+ payload.logger.info(`[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}`);
8
8
  }
9
9
  try {
10
10
  // Parse where clause if provided
@@ -36,13 +36,7 @@ export const findResourceTool = (server, req, user, verboseLogs, collectionSlug,
36
36
  collection: collectionSlug,
37
37
  overrideAccess: false,
38
38
  req,
39
- user,
40
- ...locale && {
41
- locale
42
- },
43
- ...fallbackLocale && {
44
- fallbackLocale
45
- }
39
+ user
46
40
  });
47
41
  if (verboseLogs) {
48
42
  payload.logger.info(`[payload-mcp] Found document with ID: ${id}`);
@@ -77,13 +71,7 @@ ${JSON.stringify(doc, null, 2)}`
77
71
  overrideAccess: false,
78
72
  page,
79
73
  req,
80
- user,
81
- ...locale && {
82
- locale
83
- },
84
- ...fallbackLocale && {
85
- fallbackLocale
86
- }
74
+ user
87
75
  };
88
76
  if (sort) {
89
77
  findOptions.sort = sort;
@@ -126,8 +114,8 @@ Page: ${result.page} of ${result.totalPages}
126
114
  }
127
115
  };
128
116
  if (collections?.[collectionSlug]?.enabled) {
129
- server.tool(`find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`, toolSchemas.findResources.parameters.shape, async ({ id, fallbackLocale, limit, locale, page, sort, where })=>{
130
- return await tool(id, limit, page, sort, where, locale, fallbackLocale);
117
+ server.tool(`find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`, toolSchemas.findResources.parameters.shape, async ({ id, limit, page, sort, where })=>{
118
+ return await tool(id, limit, page, sort, where);
131
119
  });
132
120
  }
133
121
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/resource/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const findResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: number | string,\n limit: number = 10,\n page: number = 1,\n sort?: string,\n where?: string,\n locale?: string,\n fallbackLocale?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // If ID is provided, use findByID\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n overrideAccess: false,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n })\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource from collection \"${collectionSlug}\":\n${JSON.stringify(doc, null, 2)}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, doc, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (_findError) {\n payload.logger.warn(\n `[payload-mcp] Document not found with ID: ${id} in collection: ${collectionSlug}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Otherwise, use find to get multiple documents\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n limit,\n overrideAccess: false,\n page,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n\n if (Object.keys(whereClause).length > 0) {\n findOptions.where = whereClause\n }\n\n const result = await payload.find(findOptions)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Found ${result.docs.length} documents in collection: ${collectionSlug}`,\n )\n }\n\n let responseText = `Collection: \"${collectionSlug}\"\nTotal: ${result.totalDocs} documents\nPage: ${result.page} of ${result.totalPages}\n`\n\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc, null, 2)}\\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error reading resources from collection ${collectionSlug}: ${errorMessage}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading resources from collection \"${collectionSlug}\":** ${errorMessage}`,\n },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n server.tool(\n `find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`,\n toolSchemas.findResources.parameters.shape,\n async ({ id, fallbackLocale, limit, locale, page, sort, where }) => {\n return await tool(id, limit, page, sort, where, locale, fallbackLocale)\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","findResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","limit","page","sort","where","locale","fallbackLocale","payload","logger","info","whereClause","JSON","parse","_parseError","warn","response","content","type","text","overrideResponse","doc","findByID","collection","overrideAccess","stringify","_findError","findOptions","Object","keys","length","result","find","docs","responseText","totalDocs","totalPages","error","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","findResources","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,CAC9BC,QACAC,K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AAOC,QAAQC;QAC1D;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/mcp/tools/resource/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const findResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: string,\n limit: number = 10,\n page: number = 1,\n sort?: string,\n where?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}`,\n )\n }\n\n try {\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // If ID is provided, use findByID\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n overrideAccess: false,\n req,\n user,\n })\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource from collection \"${collectionSlug}\":\n${JSON.stringify(doc, null, 2)}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, doc, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (_findError) {\n payload.logger.warn(\n `[payload-mcp] Document not found with ID: ${id} in collection: ${collectionSlug}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Otherwise, use find to get multiple documents\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n limit,\n overrideAccess: false,\n page,\n req,\n user,\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n\n if (Object.keys(whereClause).length > 0) {\n findOptions.where = whereClause\n }\n\n const result = await payload.find(findOptions)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Found ${result.docs.length} documents in collection: ${collectionSlug}`,\n )\n }\n\n let responseText = `Collection: \"${collectionSlug}\"\nTotal: ${result.totalDocs} documents\nPage: ${result.page} of ${result.totalPages}\n`\n\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc, null, 2)}\\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error reading resources from collection ${collectionSlug}: ${errorMessage}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading resources from collection \"${collectionSlug}\":** ${errorMessage}`,\n },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n server.tool(\n `find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`,\n toolSchemas.findResources.parameters.shape,\n async ({ id, limit, page, sort, where }) => {\n return await tool(id, limit, page, sort, where)\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","findResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","limit","page","sort","where","payload","logger","info","whereClause","JSON","parse","_parseError","warn","response","content","type","text","overrideResponse","doc","findByID","collection","overrideAccess","stringify","_findError","findOptions","Object","keys","length","result","find","docs","responseText","totalDocs","totalPages","error","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","findResources","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,CAC9BC,QACAC,KACAC,MACAC,aACAC,gBACAC;IAEA,MAAMC,OAAO,OACXC,IACAC,QAAgB,EAAE,EAClBC,OAAe,CAAC,EAChBC,MACAC;QAOA,MAAMC,UAAUX,IAAIW,OAAO;QAE3B,IAAIT,aAAa;YACfS,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,gDAAgD,EAAEV,iBAAiBG,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,GAAG,SAAS,EAAEC,MAAM,QAAQ,EAAEC,MAAM;QAErI;QAEA,IAAI;YACF,iCAAiC;YACjC,IAAIM,cAAc,CAAC;YACnB,IAAIJ,OAAO;gBACT,IAAI;oBACFI,cAAcC,KAAKC,KAAK,CAACN;oBACzB,IAAIR,aAAa;wBACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,kCAAkC,EAAEH,OAAO;oBAClE;gBACF,EAAE,OAAOO,aAAa;oBACpBN,QAAQC,MAAM,CAACM,IAAI,CAAC,CAAC,yCAAyC,EAAER,OAAO;oBACvE,MAAMS,WAAW;wBACfC,SAAS;4BAAC;gCAAEC,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gB4C,KAAK,CAAC,IAAI,EACtF,GAAG3C,aAAa,CAACD,eAAe,EAAE6C,eAAenD,YAAYoD,aAAa,CAACD,WAAW,CAACE,IAAI,IAAI,EAC/FrD,YAAYoD,aAAa,CAACE,UAAU,CAACC,KAAK,EAC1C,OAAO,EAAE9C,EAAE,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE;YACrC,OAAO,MAAML,KAAKC,IAAIC,OAAOC,MAAMC,MAAMC;QAC3C;IAEJ;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,UACzC,WAAW,SAgUpB,CAAA"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,UACzC,WAAW,SA2SpB,CAAA"}
@@ -3,10 +3,10 @@ import { toCamelCase } from '../../../utils/camelCase.js';
3
3
  import { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js';
4
4
  import { toolSchemas } from '../schemas.js';
5
5
  export const updateResourceTool = (server, req, user, verboseLogs, collectionSlug, collections, schema)=>{
6
- const tool = async (data, id, where, draft = false, depth = 0, overrideLock = true, filePath, overwriteExistingFiles = false, locale, fallbackLocale)=>{
6
+ const tool = async (data, id, where, draft = false, depth = 0, overrideLock = true, filePath, overwriteExistingFiles = false)=>{
7
7
  const payload = req.payload;
8
8
  if (verboseLogs) {
9
- payload.logger.info(`[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
9
+ payload.logger.info(`[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}`);
10
10
  }
11
11
  try {
12
12
  // Parse the data JSON
@@ -80,12 +80,6 @@ export const updateResourceTool = (server, req, user, verboseLogs, collectionSlu
80
80
  },
81
81
  ...overwriteExistingFiles && {
82
82
  overwriteExistingFiles
83
- },
84
- ...locale && {
85
- locale
86
- },
87
- ...fallbackLocale && {
88
- fallbackLocale
89
83
  }
90
84
  };
91
85
  if (verboseLogs) {
@@ -128,12 +122,6 @@ ${JSON.stringify(result, null, 2)}
128
122
  },
129
123
  ...overwriteExistingFiles && {
130
124
  overwriteExistingFiles
131
- },
132
- ...locale && {
133
- locale
134
- },
135
- ...fallbackLocale && {
136
- fallbackLocale
137
125
  }
138
126
  };
139
127
  if (verboseLogs) {
@@ -195,27 +183,21 @@ ${JSON.stringify(errors, null, 2)}
195
183
  if (collections?.[collectionSlug]?.enabled) {
196
184
  const convertedFields = convertCollectionSchemaToZod(schema);
197
185
  // Create a new schema that combines the converted fields with update-specific parameters
198
- // Use .partial() to make all fields optional for partial updates
199
186
  const updateResourceSchema = z.object({
200
- ...convertedFields.partial().shape,
201
- id: z.union([
202
- z.string(),
203
- z.number()
204
- ]).optional().describe('The ID of the document to update'),
187
+ ...convertedFields.shape,
188
+ id: z.string().optional().describe('The ID of the document to update'),
205
189
  depth: z.number().optional().default(0).describe('How many levels deep to populate relationships'),
206
190
  draft: z.boolean().optional().default(false).describe('Whether to update the document as a draft'),
207
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
208
191
  filePath: z.string().optional().describe('File path for file uploads'),
209
- locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
210
192
  overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
211
193
  overwriteExistingFiles: z.boolean().optional().default(false).describe('Whether to overwrite existing files'),
212
194
  where: z.string().optional().describe('JSON string for where clause to update multiple documents')
213
195
  });
214
196
  server.tool(`update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`, updateResourceSchema.shape, async (params)=>{
215
- const { id, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, where, ...fieldData } = params;
197
+ const { id, depth, draft, filePath, overrideLock, overwriteExistingFiles, where, ...fieldData } = params;
216
198
  // Convert field data back to JSON string format expected by the tool
217
199
  const data = JSON.stringify(fieldData);
218
- return await tool(data, id, where, draft, depth, overrideLock, filePath, overwriteExistingFiles, locale, fallbackLocale);
200
+ return await tool(data, id, where, draft, depth, overrideLock, filePath, overwriteExistingFiles);
219
201
  });
220
202
  }
221
203
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/resource/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js'\nimport { toolSchemas } from '../schemas.js'\nexport const updateResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n id?: number | string,\n where?: string,\n draft: boolean = false,\n depth: number = 0,\n overrideLock: boolean = true,\n filePath?: string,\n overwriteExistingFiles: boolean = false,\n locale?: string,\n fallbackLocale?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Update by ID or where clause\n if (id) {\n // Single document update\n const updateOptions = {\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating single document with ID: ${id}`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document updated successfully in collection \"${collectionSlug}\"!\nUpdated document:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents update\n const updateOptions = {\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n where: whereClause,\n ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating multiple documents with where clause`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully updated ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\n\\`\\`\\`json\n${JSON.stringify(docs, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error updating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n // Create a new schema that combines the converted fields with update-specific parameters\n // Use .partial() to make all fields optional for partial updates\n const updateResourceSchema = z.object({\n ...convertedFields.partial().shape,\n id: z.union([z.string(), z.number()]).optional().describe('The ID of the document to update'),\n depth: z\n .number()\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n filePath: z.string().optional().describe('File path for file uploads'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.tool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n updateResourceSchema.shape,\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\n where,\n ...fieldData\n } = params\n // Convert field data back to JSON string format expected by the tool\n const data = JSON.stringify(fieldData)\n return await tool(\n data,\n id as number | string | undefined,\n where as string | undefined,\n draft as boolean,\n depth as number,\n overrideLock as boolean,\n filePath as string | undefined,\n overwriteExistingFiles as boolean,\n locale as string | undefined,\n fallbackLocale as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","locale","fallbackLocale","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","updateOptions","collection","overrideAccess","result","update","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","convertedFields","updateResourceSchema","object","partial","shape","union","string","number","optional","describe","default","boolean","charAt","toUpperCase","slice","description","updateResource","trim","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,4BAA4B,QAAQ,iDAAgD;AAC7F,SAASC,WAAW,QAAQ,gBAAe;AAC3C,OAAO,MAAMC,qBAAqB,CAChCC,QACAC,KACAC,MACAC,aAC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AAGC,QAAQ,CAAC;YACzCxC,QAAQrB,EACL0D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJ3C,cAAclB,EACX+D,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,MACRD,QAAQ,CAAC;YACZzC,wBAAwBpB,EACrB+D,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,OACRD,QAAQ,CAAC;YACZ9C,OAAOf,EACJ0D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEAxD,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAeuD,MAAM,CAAC,GAAGC,WAAW,KAAKhE,YAAYQ,gBAAgByD,KAAK,CAAC,IAAI,EACxF,GAAGxD,aAAa,CAACD,eAAe,EAAE0D,eAAehE,YAAYiE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGhB,qBAAqBG,KAAK,EAC1B,OAAOc;YACL,MAAM,EACJxD,EAAE,EACFG,KAAK,EACLD,KAAK,EACLM,cAAc,EACdH,QAAQ,EACRE,MAAM,EACNH,YAAY,EACZE,sBAAsB,EACtBL,KAAK,EACL,GAAGwD,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAMzD,OAAOc,KAAKE,SAAS,CAAC0C;YAC5B,OAAO,MAAM3D,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC,wBACAC,QACAC;QAEJ;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/mcp/tools/resource/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js'\nimport { toolSchemas } from '../schemas.js'\nexport const updateResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n id?: string,\n where?: string,\n draft: boolean = false,\n depth: number = 0,\n overrideLock: boolean = true,\n filePath?: string,\n overwriteExistingFiles: boolean = false,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}`,\n )\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Update by ID or where clause\n if (id) {\n // Single document update\n const updateOptions = {\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating single document with ID: ${id}`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document updated successfully in collection \"${collectionSlug}\"!\nUpdated document:\n\\`\\`\\`json\n${JSON.stringify(result, null, 2)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents update\n const updateOptions = {\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n where: whereClause,\n ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating multiple documents with where clause`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully updated ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\n\\`\\`\\`json\n${JSON.stringify(docs, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error updating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n // Create a new schema that combines the converted fields with update-specific parameters\n const updateResourceSchema = z.object({\n ...convertedFields.shape,\n id: z.string().optional().describe('The ID of the document to update'),\n depth: z\n .number()\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update the document as a draft'),\n filePath: z.string().optional().describe('File path for file uploads'),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.tool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n updateResourceSchema.shape,\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n filePath,\n overrideLock,\n overwriteExistingFiles,\n where,\n ...fieldData\n } = params\n // Convert field data back to JSON string format expected by the tool\n const data = JSON.stringify(fieldData)\n return await tool(\n data,\n id as string | undefined,\n where as string | undefined,\n draft as boolean,\n depth as number,\n overrideLock as boolean,\n filePath as string | undefined,\n overwriteExistingFiles as boolean,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","updateOptions","collection","overrideAccess","result","update","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","convertedFields","updateResourceSchema","object","shape","string","optional","describe","number","default","boolean","charAt","toUpperCase","slice","description","updateResource","trim","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,4BAA4B,QAAQ,iDAAgD;AAC7F,SAASC,WAAW,QAAQ,gBAAe;AAC3C,OAAO,MAAMC,qBAAqB,CAChCC,QACAC,KACAC,MACAC,aACAC,gBACAC,aACAC;IAEA,MAAMC,OAAO,OACXC,MACAC,IACAC,OACAC,QAAiB,KAAK,EACtBC,QAAgB,CAAC,EACjBC,eAAwB,IAAI,EAC5BC,UACAC,yBAAkC,KAAK;QAOvC,MAAMC,UAAUf,IAAIe,OAAO;QAE3B,IAAIb,aAAa;YACfa,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,+CAA+C,EAAEd,iBAAiBK,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,qBAAqB,SAAS,EAAEE,OAAO;QAEvI;QAEA,IAAI;YACF,sBAAsB;YACtB,IAAIQ;YACJ,IAAI;gBACFA,aAAaC,KAAKC,KAAK,CAACb;gBACxB,IAAIL,aAAa;oBACfa,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,8BAA8B,EAAEd,eAAe,EAAE,EAAEgB,KAAKE,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CAAC;YACpC,GAAGF,gBAAgBG,KAAK;YACxBvC,IAAId,EAAEsD,MAAM,GAAGC,QAAQ,GAAGC,QAAQ,CAAC;YACnCvC,OAAOjB,EACJyD,MAAM,GACNF,QAAQ,GACRG,OAAO,CAAC,GACRF,QAAQ,CAAC;YACZxC,OAAOhB,EACJ2D,OAAO,GACPJ,QAAQ,GACRG,OAAO,CAAC,OACRF,QAAQ,CAAC;YACZrC,UAAUnB,EAAEsD,MAAM,GAAGC,QAAQ,GAAGC,QAAQ,CAAC;YACzCtC,cAAclB,EACX2D,OAAO,GACPJ,QAAQ,GACRG,OAAO,CAAC,MACRF,QAAQ,CAAC;YACZpC,wBAAwBpB,EACrB2D,OAAO,GACPJ,QAAQ,GACRG,OAAO,CAAC,OACRF,QAAQ,CAAC;YACZzC,OAAOf,EACJsD,MAAM,GACNC,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEAnD,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAemD,MAAM,CAAC,GAAGC,WAAW,KAAK5D,YAAYQ,gBAAgBqD,KAAK,CAAC,IAAI,EACxF,GAAGpD,aAAa,CAACD,eAAe,EAAEsD,eAAe5D,YAAY6D,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGd,qBAAqBE,KAAK,EAC1B,OAAOa;YACL,MAAM,EACJpD,EAAE,EACFG,KAAK,EACLD,KAAK,EACLG,QAAQ,EACRD,YAAY,EACZE,sBAAsB,EACtBL,KAAK,EACL,GAAGoD,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAMrD,OAAOY,KAAKE,SAAS,CAACwC;YAC5B,OAAO,MAAMvD,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC;QAEJ;IAEJ;AACF,EAAC"}
@@ -3,10 +3,8 @@ export declare const toolSchemas: {
3
3
  findResources: {
4
4
  description: string;
5
5
  parameters: z.ZodObject<{
6
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
7
- fallbackLocale: z.ZodOptional<z.ZodString>;
6
+ id: z.ZodOptional<z.ZodString>;
8
7
  limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
- locale: z.ZodOptional<z.ZodString>;
10
8
  page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
9
  sort: z.ZodOptional<z.ZodString>;
12
10
  where: z.ZodOptional<z.ZodString>;
@@ -14,15 +12,11 @@ export declare const toolSchemas: {
14
12
  limit: number;
15
13
  page: number;
16
14
  sort?: string | undefined;
17
- locale?: string | undefined;
18
- id?: string | number | undefined;
19
- fallbackLocale?: string | undefined;
15
+ id?: string | undefined;
20
16
  where?: string | undefined;
21
17
  }, {
22
18
  sort?: string | undefined;
23
- locale?: string | undefined;
24
- id?: string | number | undefined;
25
- fallbackLocale?: string | undefined;
19
+ id?: string | undefined;
26
20
  limit?: number | undefined;
27
21
  page?: number | undefined;
28
22
  where?: string | undefined;
@@ -33,30 +27,22 @@ export declare const toolSchemas: {
33
27
  parameters: z.ZodObject<{
34
28
  data: z.ZodString;
35
29
  draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
36
- fallbackLocale: z.ZodOptional<z.ZodString>;
37
- locale: z.ZodOptional<z.ZodString>;
38
30
  }, "strip", z.ZodTypeAny, {
39
31
  draft: boolean;
40
32
  data: string;
41
- locale?: string | undefined;
42
- fallbackLocale?: string | undefined;
43
33
  }, {
44
34
  data: string;
45
- locale?: string | undefined;
46
35
  draft?: boolean | undefined;
47
- fallbackLocale?: string | undefined;
48
36
  }>;
49
37
  };
50
38
  updateResource: {
51
39
  description: string;
52
40
  parameters: z.ZodObject<{
53
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
41
+ id: z.ZodOptional<z.ZodString>;
54
42
  data: z.ZodString;
55
43
  depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
56
44
  draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
57
- fallbackLocale: z.ZodOptional<z.ZodString>;
58
45
  filePath: z.ZodOptional<z.ZodString>;
59
- locale: z.ZodOptional<z.ZodString>;
60
46
  overrideLock: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
61
47
  overwriteExistingFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
62
48
  where: z.ZodOptional<z.ZodString>;
@@ -66,18 +52,14 @@ export declare const toolSchemas: {
66
52
  data: string;
67
53
  overrideLock: boolean;
68
54
  overwriteExistingFiles: boolean;
69
- locale?: string | undefined;
70
- id?: string | number | undefined;
71
- fallbackLocale?: string | undefined;
55
+ id?: string | undefined;
72
56
  where?: string | undefined;
73
57
  filePath?: string | undefined;
74
58
  }, {
75
59
  data: string;
76
60
  depth?: number | undefined;
77
- locale?: string | undefined;
78
61
  draft?: boolean | undefined;
79
- id?: string | number | undefined;
80
- fallbackLocale?: string | undefined;
62
+ id?: string | undefined;
81
63
  where?: string | undefined;
82
64
  filePath?: string | undefined;
83
65
  overrideLock?: boolean | undefined;
@@ -87,22 +69,16 @@ export declare const toolSchemas: {
87
69
  deleteResource: {
88
70
  description: string;
89
71
  parameters: z.ZodObject<{
90
- id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
72
+ id: z.ZodOptional<z.ZodString>;
91
73
  depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
92
- fallbackLocale: z.ZodOptional<z.ZodString>;
93
- locale: z.ZodOptional<z.ZodString>;
94
74
  where: z.ZodOptional<z.ZodString>;
95
75
  }, "strip", z.ZodTypeAny, {
96
76
  depth: number;
97
- locale?: string | undefined;
98
- id?: string | number | undefined;
99
- fallbackLocale?: string | undefined;
77
+ id?: string | undefined;
100
78
  where?: string | undefined;
101
79
  }, {
102
80
  depth?: number | undefined;
103
- locale?: string | undefined;
104
- id?: string | number | undefined;
105
- fallbackLocale?: string | undefined;
81
+ id?: string | undefined;
106
82
  where?: string | undefined;
107
83
  }>;
108
84
  };
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgavB,CAAA"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkXvB,CAAA"}
@@ -3,13 +3,8 @@ export const toolSchemas = {
3
3
  findResources: {
4
4
  description: 'Find documents in a collection by ID or where clause using Find or FindByID.',
5
5
  parameters: z.object({
6
- id: z.union([
7
- z.string(),
8
- z.number()
9
- ]).optional().describe('Optional: specific document ID to retrieve. If not provided, returns all documents'),
10
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
6
+ id: z.string().optional().describe('Optional: specific document ID to retrieve. If not provided, returns all documents'),
11
7
  limit: z.number().int().min(1, 'Limit must be at least 1').max(100, 'Limit cannot exceed 100').optional().default(10).describe('Maximum number of documents to return (default: 10, max: 100)'),
12
- locale: z.string().optional().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields'),
13
8
  page: z.number().int().min(1, 'Page must be at least 1').optional().default(1).describe('Page number for pagination (default: 1)'),
14
9
  sort: z.string().optional().describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)'),
15
10
  where: z.string().optional().describe('Optional JSON string for where clause filtering (e.g., \'{"title": {"contains": "test"}}\')')
@@ -19,24 +14,17 @@ export const toolSchemas = {
19
14
  description: 'Create a document in a collection.',
20
15
  parameters: z.object({
21
16
  data: z.string().describe('JSON string containing the data for the new document'),
22
- draft: z.boolean().optional().default(false).describe('Whether to create the document as a draft'),
23
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
24
- locale: z.string().optional().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale')
17
+ draft: z.boolean().optional().default(false).describe('Whether to create the document as a draft')
25
18
  })
26
19
  },
27
20
  updateResource: {
28
21
  description: 'Update documents in a collection by ID or where clause.',
29
22
  parameters: z.object({
30
- id: z.union([
31
- z.string(),
32
- z.number()
33
- ]).optional().describe('Optional: specific document ID to update'),
23
+ id: z.string().optional().describe('Optional: specific document ID to update'),
34
24
  data: z.string().describe('JSON string containing the data to update'),
35
25
  depth: z.number().int().min(0).max(10).optional().default(0).describe('Depth of population for relationships'),
36
26
  draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),
37
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
38
27
  filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),
39
- locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
40
28
  overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
41
29
  overwriteExistingFiles: z.boolean().optional().default(false).describe('Whether to overwrite existing files'),
42
30
  where: z.string().optional().describe('Optional: JSON string for where clause to update multiple documents')
@@ -45,13 +33,8 @@ export const toolSchemas = {
45
33
  deleteResource: {
46
34
  description: 'Delete documents in a collection by ID or where clause.',
47
35
  parameters: z.object({
48
- id: z.union([
49
- z.string(),
50
- z.number()
51
- ]).optional().describe('Optional: specific document ID to delete'),
36
+ id: z.string().optional().describe('Optional: specific document ID to delete'),
52
37
  depth: z.number().int().min(0).max(10).optional().default(0).describe('Depth of population for relationships in response'),
53
- fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
54
- locale: z.string().optional().describe('Optional: locale code for the operation (e.g., "en", "es"). Defaults to the default locale'),
55
38
  where: z.string().optional().describe('Optional: JSON string for where clause to delete multiple documents')
56
39
  })
57
40
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n ),\n page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code for the operation (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n generalConfig: z.any().optional().describe('General configuration updates'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n ),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n password: z.string().describe('The new password for the user'),\n token: z.string().describe('The password reset token sent to the user email'),\n }),\n },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findResources","description","parameters","object","id","union","string","number","optional","describe","fallbackLocale","limit","int","min","max","default","locale","page","sort","where","createResource","data","draft","boolean","updateResource","depth","filePath","overrideLock","overwriteExistingFiles","deleteResource","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","generalConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","unlock","createJob","inputSchema","record","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,eAAe;QACbC,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,IAAIN,EACDO,KAAK,CAAC;gBAACP,EAAEQ,MAAM;gBAAIR,EAAES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QAAQ,CAAC;QACd;IACF;IAEA2E,QAAQ;QACNnF,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBkF,OAAOvF,EACJS,MAAM,GACNK,GAAG,GACHC,GAAG,CAAC,GACJL,QAAQ,GACRC,QAAQ,CAAC;YACZ6E,OAAOxF,EAAE2E,MAAM,CAAC3E,EAAEqC,GAAG,IAAI1B,QAAQ,CAAC;YAClCoE,SAAS/E,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;YAC7B8E,UAAUzF,EACPS,MAAM,GACNK,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJN,QAAQ,GACRC,QAAQ,CAAC;YACZ+E,OAAO1F,EACJQ,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .string()\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z.string().optional().describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z.string().optional().describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n generalConfig: z.any().optional().describe('General configuration updates'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n ),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n password: z.string().describe('The new password for the user'),\n token: z.string().describe('The password reset token sent to the user email'),\n }),\n },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findResources","description","parameters","object","id","string","optional","describe","limit","number","int","min","max","default","page","sort","where","createResource","data","draft","boolean","updateResource","depth","filePath","overrideLock","overwriteExistingFiles","deleteResource","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","generalConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","unlock","createJob","inputSchema","record","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,eAAe;QACbC,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,IAAIN,EACDO,MAAM,GACNC,QAAQ,GACRC,QAAQ,CACP;YAEJC,OAAOV,EACJW,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GAAG,4BACPC,GAAG,CAAC,KAAK,2BACTN,QAAQ,GACRO,OAAO,CAAC,IACRN,QAAQ,CAAC;YACZO,MAAMhB,EACHW,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GAAG,2BACPL,QAAQ,GACRO,OAAO,CAAC,GACRN,QAAQ,CAAC;YACZQ,MAAMjB,EACHO,MAAM,GACNC,QAAQ,GACRC,QAAQ,CAAC;YACZS,OAAOlB,EACJO,MAAM,GACNC,QAAQ,GACRC,QAAQ,CACP;QAEN;IACF;IAEAU,gBAAgB;QACdhB,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBe,MAAMpB,EAAEO,MAAM,GAAGE,QAAQ,CAAC;YAC1BY,OAAOrB,EACJsB,OAAO,GACPd,QAAQ,GACRO,OAAO,CAAC,OACRN,QAAQ,CAAC;QACd;IACF;IAEAc,gBAAgB;QACdpB,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,IAAIN,EAAEO,MAAM,GAAGC,QAAQ,GAAGC,QAAQ,CAAC;YACnCW,MAAMpB,EAAEO,MAAM,GAAGE,QAAQ,CAAC;YAC1Be,OAAOxB,EACJW,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJN,QAAQ,GACRO,OAAO,CAAC,GACRN,QAAQ,CAAC;YACZY,OAAOrB,EAAEsB,OAAO,GAAGd,QAAQ,GAAGO,OAAO,CAAC,OAAON,QAAQ,CAA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JO,MAAM,GACNC,QAAQ,GACRC,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "3.65.0-canary.7",
3
+ "version": "3.65.0-internal.5b33fe0",
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.65.0-canary.7"
48
+ "payload": "3.65.0-internal.5b33fe0"
49
49
  },
50
50
  "peerDependencies": {
51
- "payload": "3.65.0-canary.7"
51
+ "payload": "3.65.0-internal.5b33fe0"
52
52
  },
53
53
  "homepage:": "https://payloadcms.com",
54
54
  "scripts": {
@@ -2,8 +2,6 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
2
  import type { JSONSchema4 } from 'json-schema'
3
3
  import type { PayloadRequest, TypedUser } from 'payload'
4
4
 
5
- import { z } from 'zod'
6
-
7
5
  import type { PluginMCPServerConfig } from '../../../types.js'
8
6
 
9
7
  import { toCamelCase } from '../../../utils/camelCase.js'
@@ -20,9 +18,6 @@ export const createResourceTool = (
20
18
  ) => {
21
19
  const tool = async (
22
20
  data: string,
23
- draft: boolean,
24
- locale?: string,
25
- fallbackLocale?: string,
26
21
  ): Promise<{
27
22
  content: Array<{
28
23
  text: string
@@ -32,9 +27,7 @@ export const createResourceTool = (
32
27
  const payload = req.payload
33
28
 
34
29
  if (verboseLogs) {
35
- payload.logger.info(
36
- `[payload-mcp] Creating resource in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,
37
- )
30
+ payload.logger.info(`[payload-mcp] Creating resource in collection: ${collectionSlug}`)
38
31
  }
39
32
 
40
33
  try {
@@ -58,12 +51,9 @@ export const createResourceTool = (
58
51
  const result = await payload.create({
59
52
  collection: collectionSlug,
60
53
  data: parsedData,
61
- draft,
62
54
  overrideAccess: false,
63
55
  req,
64
56
  user,
65
- ...(locale && { locale }),
66
- ...(fallbackLocale && { fallbackLocale }),
67
57
  })
68
58
 
69
59
  if (verboseLogs) {
@@ -119,39 +109,13 @@ ${JSON.stringify(result, null, 2)}
119
109
  if (collections?.[collectionSlug]?.enabled) {
120
110
  const convertedFields = convertCollectionSchemaToZod(schema)
121
111
 
122
- // Create a new schema that combines the converted fields with create-specific parameters
123
- const createResourceSchema = z.object({
124
- ...convertedFields.shape,
125
- draft: z
126
- .boolean()
127
- .optional()
128
- .default(false)
129
- .describe('Whether to create the document as a draft'),
130
- fallbackLocale: z
131
- .string()
132
- .optional()
133
- .describe('Optional: fallback locale code to use when requested locale is not available'),
134
- locale: z
135
- .string()
136
- .optional()
137
- .describe(
138
- 'Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale',
139
- ),
140
- })
141
-
142
112
  server.tool(
143
113
  `create${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,
144
114
  `${collections?.[collectionSlug]?.description || toolSchemas.createResource.description.trim()}`,
145
- createResourceSchema.shape,
115
+ convertedFields.shape,
146
116
  async (params: Record<string, unknown>) => {
147
- const { draft, fallbackLocale, locale, ...fieldData } = params
148
- const data = JSON.stringify(fieldData)
149
- return await tool(
150
- data,
151
- draft as boolean,
152
- locale as string | undefined,
153
- fallbackLocale as string | undefined,
154
- )
117
+ const data = JSON.stringify(params)
118
+ return await tool(data)
155
119
  },
156
120
  )
157
121
  }
@@ -15,11 +15,9 @@ export const deleteResourceTool = (
15
15
  collections: PluginMCPServerConfig['collections'],
16
16
  ) => {
17
17
  const tool = async (
18
- id?: number | string,
18
+ id?: string,
19
19
  where?: string,
20
20
  depth: number = 0,
21
- locale?: string,
22
- fallbackLocale?: string,
23
21
  ): Promise<{
24
22
  content: Array<{
25
23
  text: string
@@ -30,7 +28,7 @@ export const deleteResourceTool = (
30
28
 
31
29
  if (verboseLogs) {
32
30
  payload.logger.info(
33
- `[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`,
31
+ `[payload-mcp] Deleting resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}`,
34
32
  )
35
33
  }
36
34
 
@@ -82,8 +80,6 @@ export const deleteResourceTool = (
82
80
  overrideAccess: false,
83
81
  req,
84
82
  user,
85
- ...(locale && { locale }),
86
- ...(fallbackLocale && { fallbackLocale }),
87
83
  }
88
84
 
89
85
  // Delete by ID or where clause
@@ -208,8 +204,8 @@ ${JSON.stringify(errors, null, 2)}
208
204
  `delete${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,
209
205
  `${collections?.[collectionSlug]?.description || toolSchemas.deleteResource.description.trim()}`,
210
206
  toolSchemas.deleteResource.parameters.shape,
211
- async ({ id, depth, fallbackLocale, locale, where }) => {
212
- return await tool(id, where, depth, locale, fallbackLocale)
207
+ async ({ id, depth, where }) => {
208
+ return await tool(id, where, depth)
213
209
  },
214
210
  )
215
211
  }
@@ -15,13 +15,11 @@ export const findResourceTool = (
15
15
  collections: PluginMCPServerConfig['collections'],
16
16
  ) => {
17
17
  const tool = async (
18
- id?: number | string,
18
+ id?: string,
19
19
  limit: number = 10,
20
20
  page: number = 1,
21
21
  sort?: string,
22
22
  where?: string,
23
- locale?: string,
24
- fallbackLocale?: string,
25
23
  ): Promise<{
26
24
  content: Array<{
27
25
  text: string
@@ -32,7 +30,7 @@ export const findResourceTool = (
32
30
 
33
31
  if (verboseLogs) {
34
32
  payload.logger.info(
35
- `[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,
33
+ `[payload-mcp] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}`,
36
34
  )
37
35
  }
38
36
 
@@ -69,8 +67,6 @@ export const findResourceTool = (
69
67
  overrideAccess: false,
70
68
  req,
71
69
  user,
72
- ...(locale && { locale }),
73
- ...(fallbackLocale && { fallbackLocale }),
74
70
  })
75
71
 
76
72
  if (verboseLogs) {
@@ -124,8 +120,6 @@ ${JSON.stringify(doc, null, 2)}`,
124
120
  page,
125
121
  req,
126
122
  user,
127
- ...(locale && { locale }),
128
- ...(fallbackLocale && { fallbackLocale }),
129
123
  }
130
124
 
131
125
  if (sort) {
@@ -196,8 +190,8 @@ Page: ${result.page} of ${result.totalPages}
196
190
  `find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,
197
191
  `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`,
198
192
  toolSchemas.findResources.parameters.shape,
199
- async ({ id, fallbackLocale, limit, locale, page, sort, where }) => {
200
- return await tool(id, limit, page, sort, where, locale, fallbackLocale)
193
+ async ({ id, limit, page, sort, where }) => {
194
+ return await tool(id, limit, page, sort, where)
201
195
  },
202
196
  )
203
197
  }
@@ -20,15 +20,13 @@ export const updateResourceTool = (
20
20
  ) => {
21
21
  const tool = async (
22
22
  data: string,
23
- id?: number | string,
23
+ id?: string,
24
24
  where?: string,
25
25
  draft: boolean = false,
26
26
  depth: number = 0,
27
27
  overrideLock: boolean = true,
28
28
  filePath?: string,
29
29
  overwriteExistingFiles: boolean = false,
30
- locale?: string,
31
- fallbackLocale?: string,
32
30
  ): Promise<{
33
31
  content: Array<{
34
32
  text: string
@@ -39,7 +37,7 @@ export const updateResourceTool = (
39
37
 
40
38
  if (verboseLogs) {
41
39
  payload.logger.info(
42
- `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,
40
+ `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}`,
43
41
  )
44
42
  }
45
43
 
@@ -122,8 +120,6 @@ export const updateResourceTool = (
122
120
  user,
123
121
  ...(filePath && { filePath }),
124
122
  ...(overwriteExistingFiles && { overwriteExistingFiles }),
125
- ...(locale && { locale }),
126
- ...(fallbackLocale && { fallbackLocale }),
127
123
  }
128
124
 
129
125
  if (verboseLogs) {
@@ -172,8 +168,6 @@ ${JSON.stringify(result, null, 2)}
172
168
  where: whereClause,
173
169
  ...(filePath && { filePath }),
174
170
  ...(overwriteExistingFiles && { overwriteExistingFiles }),
175
- ...(locale && { locale }),
176
- ...(fallbackLocale && { fallbackLocale }),
177
171
  }
178
172
 
179
173
  if (verboseLogs) {
@@ -261,10 +255,9 @@ ${JSON.stringify(errors, null, 2)}
261
255
  const convertedFields = convertCollectionSchemaToZod(schema)
262
256
 
263
257
  // Create a new schema that combines the converted fields with update-specific parameters
264
- // Use .partial() to make all fields optional for partial updates
265
258
  const updateResourceSchema = z.object({
266
- ...convertedFields.partial().shape,
267
- id: z.union([z.string(), z.number()]).optional().describe('The ID of the document to update'),
259
+ ...convertedFields.shape,
260
+ id: z.string().optional().describe('The ID of the document to update'),
268
261
  depth: z
269
262
  .number()
270
263
  .optional()
@@ -275,17 +268,7 @@ ${JSON.stringify(errors, null, 2)}
275
268
  .optional()
276
269
  .default(false)
277
270
  .describe('Whether to update the document as a draft'),
278
- fallbackLocale: z
279
- .string()
280
- .optional()
281
- .describe('Optional: fallback locale code to use when requested locale is not available'),
282
271
  filePath: z.string().optional().describe('File path for file uploads'),
283
- locale: z
284
- .string()
285
- .optional()
286
- .describe(
287
- 'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
288
- ),
289
272
  overrideLock: z
290
273
  .boolean()
291
274
  .optional()
@@ -311,9 +294,7 @@ ${JSON.stringify(errors, null, 2)}
311
294
  id,
312
295
  depth,
313
296
  draft,
314
- fallbackLocale,
315
297
  filePath,
316
- locale,
317
298
  overrideLock,
318
299
  overwriteExistingFiles,
319
300
  where,
@@ -323,15 +304,13 @@ ${JSON.stringify(errors, null, 2)}
323
304
  const data = JSON.stringify(fieldData)
324
305
  return await tool(
325
306
  data,
326
- id as number | string | undefined,
307
+ id as string | undefined,
327
308
  where as string | undefined,
328
309
  draft as boolean,
329
310
  depth as number,
330
311
  overrideLock as boolean,
331
312
  filePath as string | undefined,
332
313
  overwriteExistingFiles as boolean,
333
- locale as string | undefined,
334
- fallbackLocale as string | undefined,
335
314
  )
336
315
  },
337
316
  )
@@ -5,15 +5,11 @@ export const toolSchemas = {
5
5
  description: 'Find documents in a collection by ID or where clause using Find or FindByID.',
6
6
  parameters: z.object({
7
7
  id: z
8
- .union([z.string(), z.number()])
8
+ .string()
9
9
  .optional()
10
10
  .describe(
11
11
  'Optional: specific document ID to retrieve. If not provided, returns all documents',
12
12
  ),
13
- fallbackLocale: z
14
- .string()
15
- .optional()
16
- .describe('Optional: fallback locale code to use when requested locale is not available'),
17
13
  limit: z
18
14
  .number()
19
15
  .int()
@@ -22,12 +18,6 @@ export const toolSchemas = {
22
18
  .optional()
23
19
  .default(10)
24
20
  .describe('Maximum number of documents to return (default: 10, max: 100)'),
25
- locale: z
26
- .string()
27
- .optional()
28
- .describe(
29
- 'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
30
- ),
31
21
  page: z
32
22
  .number()
33
23
  .int()
@@ -57,26 +47,13 @@ export const toolSchemas = {
57
47
  .optional()
58
48
  .default(false)
59
49
  .describe('Whether to create the document as a draft'),
60
- fallbackLocale: z
61
- .string()
62
- .optional()
63
- .describe('Optional: fallback locale code to use when requested locale is not available'),
64
- locale: z
65
- .string()
66
- .optional()
67
- .describe(
68
- 'Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale',
69
- ),
70
50
  }),
71
51
  },
72
52
 
73
53
  updateResource: {
74
54
  description: 'Update documents in a collection by ID or where clause.',
75
55
  parameters: z.object({
76
- id: z
77
- .union([z.string(), z.number()])
78
- .optional()
79
- .describe('Optional: specific document ID to update'),
56
+ id: z.string().optional().describe('Optional: specific document ID to update'),
80
57
  data: z.string().describe('JSON string containing the data to update'),
81
58
  depth: z
82
59
  .number()
@@ -87,17 +64,7 @@ export const toolSchemas = {
87
64
  .default(0)
88
65
  .describe('Depth of population for relationships'),
89
66
  draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),
90
- fallbackLocale: z
91
- .string()
92
- .optional()
93
- .describe('Optional: fallback locale code to use when requested locale is not available'),
94
67
  filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),
95
- locale: z
96
- .string()
97
- .optional()
98
- .describe(
99
- 'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
100
- ),
101
68
  overrideLock: z
102
69
  .boolean()
103
70
  .optional()
@@ -118,10 +85,7 @@ export const toolSchemas = {
118
85
  deleteResource: {
119
86
  description: 'Delete documents in a collection by ID or where clause.',
120
87
  parameters: z.object({
121
- id: z
122
- .union([z.string(), z.number()])
123
- .optional()
124
- .describe('Optional: specific document ID to delete'),
88
+ id: z.string().optional().describe('Optional: specific document ID to delete'),
125
89
  depth: z
126
90
  .number()
127
91
  .int()
@@ -130,16 +94,6 @@ export const toolSchemas = {
130
94
  .optional()
131
95
  .default(0)
132
96
  .describe('Depth of population for relationships in response'),
133
- fallbackLocale: z
134
- .string()
135
- .optional()
136
- .describe('Optional: fallback locale code to use when requested locale is not available'),
137
- locale: z
138
- .string()
139
- .optional()
140
- .describe(
141
- 'Optional: locale code for the operation (e.g., "en", "es"). Defaults to the default locale',
142
- ),
143
97
  where: z
144
98
  .string()
145
99
  .optional()