@payloadcms/plugin-mcp 3.77.0-canary.7 → 3.77.0-internal-debug.98d2e4d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/mcp/getMcpHandler.d.ts.map +1 -1
  2. package/dist/mcp/getMcpHandler.js +8 -4
  3. package/dist/mcp/getMcpHandler.js.map +1 -1
  4. package/dist/mcp/tools/auth/auth.d.ts.map +1 -1
  5. package/dist/mcp/tools/auth/auth.js +4 -1
  6. package/dist/mcp/tools/auth/auth.js.map +1 -1
  7. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +1 -1
  8. package/dist/mcp/tools/auth/forgotPassword.js +4 -1
  9. package/dist/mcp/tools/auth/forgotPassword.js.map +1 -1
  10. package/dist/mcp/tools/auth/login.d.ts.map +1 -1
  11. package/dist/mcp/tools/auth/login.js +4 -1
  12. package/dist/mcp/tools/auth/login.js.map +1 -1
  13. package/dist/mcp/tools/auth/resetPassword.d.ts.map +1 -1
  14. package/dist/mcp/tools/auth/resetPassword.js +4 -1
  15. package/dist/mcp/tools/auth/resetPassword.js.map +1 -1
  16. package/dist/mcp/tools/auth/unlock.d.ts.map +1 -1
  17. package/dist/mcp/tools/auth/unlock.js +4 -1
  18. package/dist/mcp/tools/auth/unlock.js.map +1 -1
  19. package/dist/mcp/tools/auth/verify.d.ts.map +1 -1
  20. package/dist/mcp/tools/auth/verify.js +4 -1
  21. package/dist/mcp/tools/auth/verify.js.map +1 -1
  22. package/dist/mcp/tools/collection/create.d.ts.map +1 -1
  23. package/dist/mcp/tools/collection/create.js +4 -1
  24. package/dist/mcp/tools/collection/create.js.map +1 -1
  25. package/dist/mcp/tools/collection/delete.d.ts.map +1 -1
  26. package/dist/mcp/tools/collection/delete.js +4 -1
  27. package/dist/mcp/tools/collection/delete.js.map +1 -1
  28. package/dist/mcp/tools/collection/find.d.ts.map +1 -1
  29. package/dist/mcp/tools/collection/find.js +4 -1
  30. package/dist/mcp/tools/collection/find.js.map +1 -1
  31. package/dist/mcp/tools/collection/update.d.ts.map +1 -1
  32. package/dist/mcp/tools/collection/update.js +4 -1
  33. package/dist/mcp/tools/collection/update.js.map +1 -1
  34. package/dist/mcp/tools/config/find.d.ts.map +1 -1
  35. package/dist/mcp/tools/config/find.js +4 -1
  36. package/dist/mcp/tools/config/find.js.map +1 -1
  37. package/dist/mcp/tools/config/update.d.ts.map +1 -1
  38. package/dist/mcp/tools/config/update.js +4 -1
  39. package/dist/mcp/tools/config/update.js.map +1 -1
  40. package/dist/mcp/tools/global/find.d.ts.map +1 -1
  41. package/dist/mcp/tools/global/find.js +4 -1
  42. package/dist/mcp/tools/global/find.js.map +1 -1
  43. package/dist/mcp/tools/global/update.d.ts.map +1 -1
  44. package/dist/mcp/tools/global/update.js +5 -2
  45. package/dist/mcp/tools/global/update.js.map +1 -1
  46. package/dist/mcp/tools/job/create.d.ts.map +1 -1
  47. package/dist/mcp/tools/job/create.js +4 -1
  48. package/dist/mcp/tools/job/create.js.map +1 -1
  49. package/dist/mcp/tools/job/run.d.ts.map +1 -1
  50. package/dist/mcp/tools/job/run.js +4 -1
  51. package/dist/mcp/tools/job/run.js.map +1 -1
  52. package/dist/mcp/tools/job/update.d.ts.map +1 -1
  53. package/dist/mcp/tools/job/update.js +4 -1
  54. package/dist/mcp/tools/job/update.js.map +1 -1
  55. package/dist/mcp/tools/resource/create.d.ts.map +1 -1
  56. package/dist/mcp/tools/resource/create.js +5 -2
  57. package/dist/mcp/tools/resource/create.js.map +1 -1
  58. package/dist/mcp/tools/resource/delete.d.ts.map +1 -1
  59. package/dist/mcp/tools/resource/delete.js +4 -1
  60. package/dist/mcp/tools/resource/delete.js.map +1 -1
  61. package/dist/mcp/tools/resource/find.d.ts.map +1 -1
  62. package/dist/mcp/tools/resource/find.js +4 -1
  63. package/dist/mcp/tools/resource/find.js.map +1 -1
  64. package/dist/mcp/tools/resource/update.d.ts.map +1 -1
  65. package/dist/mcp/tools/resource/update.js +5 -2
  66. package/dist/mcp/tools/resource/update.js.map +1 -1
  67. package/dist/types.d.ts +11 -1
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/types.js.map +1 -1
  70. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +1 -0
  71. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +34 -0
  72. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +1 -0
  73. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +8 -0
  74. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -0
  75. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +18 -0
  76. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -0
  77. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +20 -0
  78. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +1 -0
  79. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +53 -0
  80. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +1 -0
  81. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +1 -0
  82. package/dist/utils/schemaConversion/transformPointFields.js.map +1 -0
  83. package/package.json +5 -5
  84. package/src/mcp/getMcpHandler.ts +9 -6
  85. package/src/mcp/tools/auth/auth.ts +5 -3
  86. package/src/mcp/tools/auth/forgotPassword.ts +5 -3
  87. package/src/mcp/tools/auth/login.ts +5 -3
  88. package/src/mcp/tools/auth/resetPassword.ts +5 -3
  89. package/src/mcp/tools/auth/unlock.ts +5 -3
  90. package/src/mcp/tools/auth/verify.ts +5 -3
  91. package/src/mcp/tools/collection/create.ts +5 -3
  92. package/src/mcp/tools/collection/delete.ts +5 -3
  93. package/src/mcp/tools/collection/find.ts +5 -3
  94. package/src/mcp/tools/collection/update.ts +5 -3
  95. package/src/mcp/tools/config/find.ts +5 -3
  96. package/src/mcp/tools/config/update.ts +5 -3
  97. package/src/mcp/tools/global/find.ts +5 -3
  98. package/src/mcp/tools/global/update.ts +6 -4
  99. package/src/mcp/tools/job/create.ts +5 -3
  100. package/src/mcp/tools/job/run.ts +5 -3
  101. package/src/mcp/tools/job/update.ts +6 -3
  102. package/src/mcp/tools/resource/create.ts +6 -4
  103. package/src/mcp/tools/resource/delete.ts +5 -3
  104. package/src/mcp/tools/resource/find.ts +5 -3
  105. package/src/mcp/tools/resource/update.ts +6 -4
  106. package/src/types.ts +11 -2
  107. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +41 -0
  108. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +21 -0
  109. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +65 -0
  110. package/dist/utils/convertCollectionSchemaToZod.d.ts.map +0 -1
  111. package/dist/utils/convertCollectionSchemaToZod.js +0 -80
  112. package/dist/utils/convertCollectionSchemaToZod.js.map +0 -1
  113. package/dist/utils/transformPointFields.d.ts.map +0 -1
  114. package/dist/utils/transformPointFields.js.map +0 -1
  115. package/src/utils/convertCollectionSchemaToZod.ts +0 -95
  116. /package/dist/utils/{convertCollectionSchemaToZod.d.ts → schemaConversion/convertCollectionSchemaToZod.d.ts} +0 -0
  117. /package/dist/utils/{transformPointFields.d.ts → schemaConversion/transformPointFields.d.ts} +0 -0
  118. /package/dist/utils/{transformPointFields.js → schemaConversion/transformPointFields.js} +0 -0
  119. /package/src/utils/{transformPointFields.ts → schemaConversion/transformPointFields.ts} +0 -0
@@ -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, SelectType, 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 { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.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 select?: 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\n // Transform point fields from object format to tuple array\n parsedData = transformPointDataToPayload(parsedData)\n\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 let selectClause: SelectType | undefined\n if (select) {\n try {\n selectClause = JSON.parse(select) as SelectType\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid select clause JSON: ${select}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in select 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 ...(selectClause && { select: selectClause }),\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 ...(selectClause && { select: selectClause }),\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 select: z\n .string()\n .optional()\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response (JSON), e.g., \\'{\"title\": \"My Post\"}\\'',\n ),\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 select,\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 select as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","transformPointDataToPayload","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","locale","fallbackLocale","select","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","selectClause","warn","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,2BAA2B,QAAQ,gDAA+C;AAC3F,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,EACvCC,QACAC,gBACAC;QAOA,MAAMC,UAAUlB,IAAIkB,OAAO;QAE3B,IAAIhB,aAAa;YACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,+CAA+C,EAAEjB,iBAAiBK,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,qBAAqB,SAAS,EAAEE,QAAQK,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;QAE7K;QAEA,IAAI;YACF,sBAAsB;YACtB,IAAIM;YACJ,IAAI;gBACFA,aAAaC,KAAKC,KAAK,CAAChB;gBAExB,2DAA2D;gBAC3Dc,aAAazB,4BAA4ByB;gBAEzC,IAAInB,aAAa;oBACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,8BAA8B,EAAEjB,eAAe,EAAE,EAAEmB,KAAKE,SAAS,CAACH,aAAa;gBAEpF;YACF,EAAE,OAAOI,aAAa;gBACpBP,QAAQC,MAAM,CAACO,KAAK,CAAC,CAAC,0CAA0C,EAAEnB,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,GACRE,OAAO,CAAC,OACRD,QAAQ,CAAC;YACZzC,QAAQxB,EACL8D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJjD,OAAOhB,EACJ8D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEA3D,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAe0D,MAAM,CAAC,GAAGC,WAAW,KAAKpE,YAAYS,gBAAgB4D,KAAK,CAAC,IAAI,EACxF,GAAG3D,aAAa,CAACD,eAAe,EAAE6D,eAAenE,YAAYoE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGhB,qBAAqBG,KAAK,EAC1B,OAAOc;YACL,MAAM,EACJ3D,EAAE,EACFG,KAAK,EACLD,KAAK,EACLM,cAAc,EACdH,QAAQ,EACRE,MAAM,EACNH,YAAY,EACZE,sBAAsB,EACtBG,MAAM,EACNR,KAAK,EACL,GAAG2D,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAM5D,OAAOe,KAAKE,SAAS,CAAC4C;YAC5B,OAAO,MAAM9D,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC,wBACAC,QACAC,gBACAC;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, SelectType, 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/schemaConversion/convertCollectionSchemaToZod.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.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 select?: 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\n // Transform point fields from object format to tuple array\n parsedData = transformPointDataToPayload(parsedData)\n\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 let selectClause: SelectType | undefined\n if (select) {\n try {\n selectClause = JSON.parse(select) as SelectType\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid select clause JSON: ${select}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in select 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 ...(selectClause && { select: selectClause }),\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 ...(selectClause && { select: selectClause }),\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 select: z\n .string()\n .optional()\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response (JSON), e.g., \\'{\"title\": \"My Post\"}\\'',\n ),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.registerTool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n {\n description: `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n inputSchema: updateResourceSchema.shape,\n },\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 select,\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 select as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","transformPointDataToPayload","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","locale","fallbackLocale","select","payload","logger","info","parsedData","JSON","parse","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","selectClause","warn","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","registerTool","charAt","toUpperCase","slice","description","updateResource","trim","inputSchema","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,4BAA4B,QAAQ,kEAAiE;AAC9G,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,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,EACvCC,QACAC,gBACAC;QAOA,MAAMC,UAAUlB,IAAIkB,OAAO;QAE3B,IAAIhB,aAAa;YACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,+CAA+C,EAAEjB,iBAAiBK,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,qBAAqB,SAAS,EAAEE,QAAQK,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;QAE7K;QAEA,IAAI;YACF,sBAAsB;YACtB,IAAIM;YACJ,IAAI;gBACFA,aAAaC,KAAKC,KAAK,CAAChB;gBAExB,2DAA2D;gBAC3Dc,aAAazB,4BAA4ByB;gBAEzC,IAAInB,aAAa;oBACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,8BAA8B,EAAEjB,eAAe,EAAE,EAAEmB,KAAKE,SAAS,CAACH,aAAa;gBAEpF;YACF,EAAE,OAAOI,aAAa;gBACpBP,QAAQC,MAAM,CAACO,KAAK,CAAC,CAAC,0CAA0C,EAAEnB,MAAM;gBACxE,MAAMoB,WAAW;oBACfC,SAAS;wBAAC;4BAAEC,MAAM;4BAAiBC,MAAM;wBAAoC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,QAAQ,CACP;YAEJjD,OAAOhB,EACJ8D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEA3D,OAAO8D,YAAY,CACjB,CAAC,MAAM,EAAE1D,eAAe2D,MAAM,CAAC,GAAGC,WAAW,KAAKrE,YAAYS,gBAAgB6D,KAAK,CAAC,IAAI,EACxF;YACEC,aAAa,GAAG7D,aAAa,CAACD,eAAe,EAAE8D,eAAepE,YAAYqE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI;YAC7GC,aAAalB,qBAAqBG,KAAK;QACzC,GACA,OAAOgB;YACL,MAAM,EACJ7D,EAAE,EACFG,KAAK,EACLD,KAAK,EACLM,cAAc,EACdH,QAAQ,EACRE,MAAM,EACNH,YAAY,EACZE,sBAAsB,EACtBG,MAAM,EACNR,KAAK,EACL,GAAG6D,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAM9D,OAAOe,KAAKE,SAAS,CAAC8C;YAC5B,OAAO,MAAMhE,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC,wBACAC,QACAC,gBACAC;QAEJ;IAEJ;AACF,EAAC"}
package/dist/types.d.ts CHANGED
@@ -288,16 +288,26 @@ export type MCPHandlerOptions = {
288
288
  * @default /api
289
289
  */
290
290
  basePath?: string;
291
+ /**
292
+ * If true, disables the SSE endpoint. Only Streamable HTTP will be available.
293
+ * @default true
294
+ */
295
+ disableSse?: boolean;
291
296
  /**
292
297
  * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.
293
298
  * @default 60
294
299
  */
295
300
  maxDuration?: number;
301
+ /**
302
+ * Callback function that receives MCP events.
303
+ * This can be used to track analytics, debug issues, or implement custom behaviors.
304
+ */
305
+ onEvent?: (event: unknown) => void;
296
306
  /**
297
307
  * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.
298
308
  * @default process.env.REDIS_URL
299
- * INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns
300
309
  */
310
+ redisUrl?: string;
301
311
  /**
302
312
  * Set verbose logging.
303
313
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAE/E,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CACnB,MAAM,CACJ,cAAc,EACd;QACE;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB;;WAEG;QACH,OAAO,EACH;YACE,MAAM,CAAC,EAAE,OAAO,CAAA;YAChB,MAAM,CAAC,EAAE,OAAO,CAAA;YAChB,IAAI,CAAC,EAAE,OAAO,CAAA;YACd,MAAM,CAAC,EAAE,OAAO,CAAA;SACjB,GACD,OAAO,CAAA;QAEX;;WAEG;QACH,gBAAgB,CAAC,EAAE,CACjB,QAAQ,EAAE;YACR,OAAO,EAAE,KAAK,CAAC;gBACb,IAAI,EAAE,MAAM,CAAA;gBACZ,IAAI,EAAE,MAAM,CAAA;aACb,CAAC,CAAA;SACH,EACD,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,cAAc,KAChB;YACH,OAAO,EAAE,KAAK,CAAC;gBACb,IAAI,EAAE,MAAM,CAAA;gBACZ,IAAI,EAAE,MAAM,CAAA;aACb,CAAC,CAAA;SACH,CAAA;KACF,CACF,CACF,CAAA;IACD;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb;;WAEG;QACH,KAAK,EAAE;YACL;;eAEG;YACH,IAAI,CAAC,EAAE;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,OAAO,CAAA;QACjB,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAA;IACD,SAAS,CAAC,EAAE;QACV,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n GlobalSlug,\n PayloadRequest,\n TypedUser,\n} from 'payload'\nimport type { z } from 'zod'\n\nimport { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport type PluginMCPServerConfig = {\n /**\n * Set the collections that should be available as resources via MCP.\n */\n collections?: Partial<\n Record<\n CollectionSlug,\n {\n /**\n * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.\n */\n enabled:\n | {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * Disable the MCP plugin.\n */\n disabled?: boolean\n /**\n * Experimental features\n * **These features are for experimental purposes -- They are Disabled in Production by Default**\n */\n experimental?: {\n /**\n * These are MCP tools that can be used by a client to modify Payload.\n */\n tools: {\n /**\n * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.\n */\n auth?: {\n /**\n * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.\n */\n collections?: {\n /**\n * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.\n */\n collectionsDirPath: string\n /**\n * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.\n */\n config?: {\n /**\n * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.\n */\n configFilePath: string\n /**\n * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.\n */\n jobs?: {\n /**\n * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.\n * @default false\n */\n enabled: boolean\n /**\n * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.\n */\n jobsDirPath: string\n }\n }\n }\n /**\n * Set the globals that should be available as resources via MCP.\n * Globals are singleton configuration objects (e.g., site settings, navigation).\n * Note: Globals only support find and update operations.\n */\n globals?: Partial<\n Record<\n GlobalSlug,\n {\n /**\n * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.\n * Note: Globals only support find and update operations as they are singletons.\n */\n enabled:\n | {\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * MCP Server options.\n */\n mcp?: {\n handlerOptions?: MCPHandlerOptions\n /**\n * Add custom MCP Prompts.\n */\n prompts?: {\n /**\n * Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.\n */\n argsSchema: z.ZodRawShape\n /**\n * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.\n */\n description: string\n /**\n * Set the handler of the prompt. This is the function that will be called when the prompt is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }\n | Promise<{\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }>\n /**\n * Set the function name of the prompt.\n */\n name: string\n /**\n * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.\n */\n title: string\n }[]\n\n /**\n * Add custom MCP Resource.\n */\n resources?: {\n /**\n * Set the description of the resource. This is used by MCP clients to determine when to use the resource.\n * example: 'Data is a resource that contains special data.'\n */\n description: string\n /**\n * Set the handler of the resource. This is the function that will be called when the resource is used.\n * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).\n */\n handler: (...args: any[]) =>\n | {\n contents: Array<{\n text: string\n uri: string\n }>\n }\n | Promise<{\n contents: Array<{\n text: string\n uri: string\n }>\n }>\n /**\n * Set the mime type of the resource.\n * example: 'text/plain'\n */\n mimeType: string\n /**\n * Set the function name of the resource.\n * example: 'data'\n */\n name: string\n /**\n * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.\n * example: 'Data'\n */\n title: string\n /**\n * Set the uri of the resource.\n * example: 'data://app'\n */\n uri: ResourceTemplate | string\n }[]\n serverOptions?: MCPServerOptions\n /**\n * Add custom MCP Tools.\n */\n tools?: {\n /**\n * Set the description of the tool. This is used by MCP clients to determine when to use the tool.\n */\n description: string\n /**\n * Set the handler of the tool. This is the function that will be called when the tool is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }\n | Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }>\n /**\n * Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.\n */\n name: string\n /**\n * Set the parameters of the tool. This is the parameters that will be passed to the tool.\n */\n parameters: z.ZodRawShape\n }[]\n }\n\n /**\n * Override the API key collection.\n * This allows you to add fields to the API key collection or modify the collection in any way you want.\n * @param collection - The API key collection.\n * @returns The modified API key collection.\n */\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n\n /**\n * Override the authentication method.\n * This allows you to use a custom authentication method instead of the default API key authentication.\n * @param req - The request object.\n * @returns The MCP access settings.\n */\n overrideAuth?: (\n req: PayloadRequest,\n getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,\n ) => MCPAccessSettings | Promise<MCPAccessSettings>\n\n /**\n * Set the users collection that API keys should be associated with.\n */\n userCollection?: CollectionSlug\n}\n\n/**\n * MCP Handler options.\n */\nexport type MCPHandlerOptions = {\n /**\n * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.\n * @default /api\n */\n basePath?: string\n /**\n * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.\n * @default 60\n */\n maxDuration?: number\n /**\n * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.\n * @default process.env.REDIS_URL\n * INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns\n */\n // redisUrl?: string\n /**\n * Set verbose logging.\n * @default false\n */\n verboseLogs?: boolean\n}\n\n/**\n * MCP Server options.\n */\nexport type MCPServerOptions = {\n /**\n * Set the server info of the MCP server.\n */\n serverInfo?: {\n /**\n * Set the name of the MCP server.\n * @default 'Payload MCP Server'\n */\n name: string\n /**\n * Set the version of the MCP server.\n * @default '1.0.0'\n */\n version: string\n }\n}\n\nexport type MCPAccessSettings = {\n auth?: {\n auth?: boolean\n forgotPassword?: boolean\n login?: boolean\n resetPassword?: boolean\n unlock?: boolean\n verify?: boolean\n }\n collections?: {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n config?: {\n find?: boolean\n update?: boolean\n }\n custom?: Record<string, boolean>\n globals?: {\n find?: boolean\n update?: boolean\n }\n jobs?: {\n create?: boolean\n run?: boolean\n update?: boolean\n }\n 'payload-mcp-prompt'?: Record<string, boolean>\n 'payload-mcp-resource'?: Record<string, boolean>\n 'payload-mcp-tool'?: Record<string, boolean>\n user: TypedUser\n} & Record<string, unknown>\n\nexport type EntityConfig = PluginMCPServerConfig['collections'] | PluginMCPServerConfig['globals']\n\nexport type FieldDefinition = {\n description?: string\n name: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type: string\n}\n\nexport type FieldModification = {\n changes: {\n description?: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type?: string\n }\n fieldName: string\n}\n\nexport type CollectionConfigUpdates = {\n access?: {\n create?: string\n delete?: string\n read?: string\n update?: string\n }\n description?: string\n slug?: string\n timestamps?: boolean\n versioning?: boolean\n}\n\nexport type AdminConfig = {\n avatar?: string\n css?: string\n dateFormat?: string\n inactivityRoute?: string\n livePreview?: {\n breakpoints?: Array<{\n height: number\n label: string\n name: string\n width: number\n }>\n }\n logoutRoute?: string\n meta?: {\n favicon?: string\n ogImage?: string\n titleSuffix?: string\n }\n user?: string\n}\n\nexport type DatabaseConfig = {\n connectOptions?: string\n type?: 'mongodb' | 'postgres'\n url?: string\n}\n\nexport type PluginUpdates = {\n add?: string[]\n remove?: string[]\n}\n\nexport type GeneralConfig = {\n cookiePrefix?: string\n cors?: string\n csrf?: string\n graphQL?: {\n disable?: boolean\n schemaOutputFile?: string\n }\n rateLimit?: {\n max?: number\n skip?: string\n window?: number\n }\n secret?: string\n serverURL?: string\n typescript?: {\n declare?: boolean\n outputFile?: string\n }\n}\n\nexport interface SchemaField {\n description?: string\n name: string\n options?: string[]\n required?: boolean\n type: string\n}\n\nexport interface TaskSequenceItem {\n description?: string\n retries?: number\n taskId: string\n taskSlug: string\n timeout?: number\n}\n\nexport interface JobConfigUpdate {\n description?: string\n queue?: string\n retries?: number\n timeout?: number\n}\n"],"names":[],"mappings":"AA2gBA,WAKC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n GlobalSlug,\n PayloadRequest,\n TypedUser,\n} from 'payload'\nimport type { z } from 'zod'\n\nimport { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport type PluginMCPServerConfig = {\n /**\n * Set the collections that should be available as resources via MCP.\n */\n collections?: Partial<\n Record<\n CollectionSlug,\n {\n /**\n * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.\n */\n enabled:\n | {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * Disable the MCP plugin.\n */\n disabled?: boolean\n /**\n * Experimental features\n * **These features are for experimental purposes -- They are Disabled in Production by Default**\n */\n experimental?: {\n /**\n * These are MCP tools that can be used by a client to modify Payload.\n */\n tools: {\n /**\n * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.\n */\n auth?: {\n /**\n * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.\n */\n collections?: {\n /**\n * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.\n */\n collectionsDirPath: string\n /**\n * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.\n */\n config?: {\n /**\n * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.\n */\n configFilePath: string\n /**\n * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.\n */\n jobs?: {\n /**\n * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.\n * @default false\n */\n enabled: boolean\n /**\n * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.\n */\n jobsDirPath: string\n }\n }\n }\n /**\n * Set the globals that should be available as resources via MCP.\n * Globals are singleton configuration objects (e.g., site settings, navigation).\n * Note: Globals only support find and update operations.\n */\n globals?: Partial<\n Record<\n GlobalSlug,\n {\n /**\n * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.\n * Note: Globals only support find and update operations as they are singletons.\n */\n enabled:\n | {\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * MCP Server options.\n */\n mcp?: {\n handlerOptions?: MCPHandlerOptions\n /**\n * Add custom MCP Prompts.\n */\n prompts?: {\n /**\n * Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.\n */\n argsSchema: z.ZodRawShape\n /**\n * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.\n */\n description: string\n /**\n * Set the handler of the prompt. This is the function that will be called when the prompt is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }\n | Promise<{\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }>\n /**\n * Set the function name of the prompt.\n */\n name: string\n /**\n * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.\n */\n title: string\n }[]\n\n /**\n * Add custom MCP Resource.\n */\n resources?: {\n /**\n * Set the description of the resource. This is used by MCP clients to determine when to use the resource.\n * example: 'Data is a resource that contains special data.'\n */\n description: string\n /**\n * Set the handler of the resource. This is the function that will be called when the resource is used.\n * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).\n */\n handler: (...args: any[]) =>\n | {\n contents: Array<{\n text: string\n uri: string\n }>\n }\n | Promise<{\n contents: Array<{\n text: string\n uri: string\n }>\n }>\n /**\n * Set the mime type of the resource.\n * example: 'text/plain'\n */\n mimeType: string\n /**\n * Set the function name of the resource.\n * example: 'data'\n */\n name: string\n /**\n * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.\n * example: 'Data'\n */\n title: string\n /**\n * Set the uri of the resource.\n * example: 'data://app'\n */\n uri: ResourceTemplate | string\n }[]\n serverOptions?: MCPServerOptions\n /**\n * Add custom MCP Tools.\n */\n tools?: {\n /**\n * Set the description of the tool. This is used by MCP clients to determine when to use the tool.\n */\n description: string\n /**\n * Set the handler of the tool. This is the function that will be called when the tool is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }\n | Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }>\n /**\n * Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.\n */\n name: string\n /**\n * Set the parameters of the tool. This is the parameters that will be passed to the tool.\n */\n parameters: z.ZodRawShape\n }[]\n }\n\n /**\n * Override the API key collection.\n * This allows you to add fields to the API key collection or modify the collection in any way you want.\n * @param collection - The API key collection.\n * @returns The modified API key collection.\n */\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n\n /**\n * Override the authentication method.\n * This allows you to use a custom authentication method instead of the default API key authentication.\n * @param req - The request object.\n * @returns The MCP access settings.\n */\n overrideAuth?: (\n req: PayloadRequest,\n getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,\n ) => MCPAccessSettings | Promise<MCPAccessSettings>\n\n /**\n * Set the users collection that API keys should be associated with.\n */\n userCollection?: CollectionSlug\n}\n\n/**\n * MCP Handler options.\n */\nexport type MCPHandlerOptions = {\n /**\n * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.\n * @default /api\n */\n basePath?: string\n /**\n * If true, disables the SSE endpoint. Only Streamable HTTP will be available.\n * @default true\n */\n disableSse?: boolean\n /**\n * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.\n * @default 60\n */\n maxDuration?: number\n /**\n * Callback function that receives MCP events.\n * This can be used to track analytics, debug issues, or implement custom behaviors.\n */\n onEvent?: (event: unknown) => void\n /**\n * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.\n * @default process.env.REDIS_URL\n */\n redisUrl?: string\n /**\n * Set verbose logging.\n * @default false\n */\n verboseLogs?: boolean\n}\n\n/**\n * MCP Server options.\n */\nexport type MCPServerOptions = {\n /**\n * Set the server info of the MCP server.\n */\n serverInfo?: {\n /**\n * Set the name of the MCP server.\n * @default 'Payload MCP Server'\n */\n name: string\n /**\n * Set the version of the MCP server.\n * @default '1.0.0'\n */\n version: string\n }\n}\n\nexport type MCPAccessSettings = {\n auth?: {\n auth?: boolean\n forgotPassword?: boolean\n login?: boolean\n resetPassword?: boolean\n unlock?: boolean\n verify?: boolean\n }\n collections?: {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n config?: {\n find?: boolean\n update?: boolean\n }\n custom?: Record<string, boolean>\n globals?: {\n find?: boolean\n update?: boolean\n }\n jobs?: {\n create?: boolean\n run?: boolean\n update?: boolean\n }\n 'payload-mcp-prompt'?: Record<string, boolean>\n 'payload-mcp-resource'?: Record<string, boolean>\n 'payload-mcp-tool'?: Record<string, boolean>\n user: TypedUser\n} & Record<string, unknown>\n\nexport type EntityConfig = PluginMCPServerConfig['collections'] | PluginMCPServerConfig['globals']\n\nexport type FieldDefinition = {\n description?: string\n name: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type: string\n}\n\nexport type FieldModification = {\n changes: {\n description?: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type?: string\n }\n fieldName: string\n}\n\nexport type CollectionConfigUpdates = {\n access?: {\n create?: string\n delete?: string\n read?: string\n update?: string\n }\n description?: string\n slug?: string\n timestamps?: boolean\n versioning?: boolean\n}\n\nexport type AdminConfig = {\n avatar?: string\n css?: string\n dateFormat?: string\n inactivityRoute?: string\n livePreview?: {\n breakpoints?: Array<{\n height: number\n label: string\n name: string\n width: number\n }>\n }\n logoutRoute?: string\n meta?: {\n favicon?: string\n ogImage?: string\n titleSuffix?: string\n }\n user?: string\n}\n\nexport type DatabaseConfig = {\n connectOptions?: string\n type?: 'mongodb' | 'postgres'\n url?: string\n}\n\nexport type PluginUpdates = {\n add?: string[]\n remove?: string[]\n}\n\nexport type GeneralConfig = {\n cookiePrefix?: string\n cors?: string\n csrf?: string\n graphQL?: {\n disable?: boolean\n schemaOutputFile?: string\n }\n rateLimit?: {\n max?: number\n skip?: string\n window?: number\n }\n secret?: string\n serverURL?: string\n typescript?: {\n declare?: boolean\n outputFile?: string\n }\n}\n\nexport interface SchemaField {\n description?: string\n name: string\n options?: string[]\n required?: boolean\n type: string\n}\n\nexport interface TaskSequenceItem {\n description?: string\n retries?: number\n taskId: string\n taskSlug: string\n timeout?: number\n}\n\nexport interface JobConfigUpdate {\n description?: string\n queue?: string\n retries?: number\n timeout?: number\n}\n"],"names":[],"mappings":"AAohBA,WAKC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertCollectionSchemaToZod.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAU9C,eAAO,MAAM,4BAA4B,WAAY,WAAW,QA8B/D,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { jsonSchemaToZod } from 'json-schema-to-zod';
2
+ import * as ts from 'typescript';
3
+ import { z } from 'zod';
4
+ import { sanitizeJsonSchema } from './sanitizeJsonSchema.js';
5
+ import { simplifyRelationshipFields } from './simplifyRelationshipFields.js';
6
+ import { transformPointFieldsForMCP } from './transformPointFields.js';
7
+ export const convertCollectionSchemaToZod = (schema)=>{
8
+ // Clone to avoid mutating the original schema (used elsewhere for tool listing)
9
+ const schemaClone = JSON.parse(JSON.stringify(schema));
10
+ const sanitized = sanitizeJsonSchema(schemaClone);
11
+ const pointTransformed = transformPointFieldsForMCP(sanitized);
12
+ const simplifiedSchema = simplifyRelationshipFields(pointTransformed);
13
+ const zodSchemaAsString = jsonSchemaToZod(simplifiedSchema);
14
+ // Transpile TypeScript to JavaScript
15
+ const transpileResult = ts.transpileModule(zodSchemaAsString, {
16
+ compilerOptions: {
17
+ module: ts.ModuleKind.CommonJS,
18
+ removeComments: true,
19
+ strict: false,
20
+ target: ts.ScriptTarget.ES2018
21
+ }
22
+ });
23
+ /**
24
+ * This Function evaluation is safe because:
25
+ * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer
26
+ * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code
27
+ * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic
28
+ * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing
29
+ * 5. No user input or external data is involved in the schema generation process
30
+ */ // eslint-disable-next-line @typescript-eslint/no-implied-eval
31
+ return new Function('z', `return ${transpileResult.outputText}`)(z);
32
+ };
33
+
34
+ //# sourceMappingURL=convertCollectionSchemaToZod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { jsonSchemaToZod } from 'json-schema-to-zod'\nimport * as ts from 'typescript'\nimport { z } from 'zod'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\nexport const convertCollectionSchemaToZod = (schema: JSONSchema4) => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const simplifiedSchema = simplifyRelationshipFields(pointTransformed)\n\n const zodSchemaAsString = jsonSchemaToZod(simplifiedSchema)\n\n // Transpile TypeScript to JavaScript\n const transpileResult = ts.transpileModule(zodSchemaAsString, {\n compilerOptions: {\n module: ts.ModuleKind.CommonJS,\n removeComments: true,\n strict: false,\n target: ts.ScriptTarget.ES2018,\n },\n })\n\n /**\n * This Function evaluation is safe because:\n * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer\n * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code\n * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic\n * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing\n * 5. No user input or external data is involved in the schema generation process\n */\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n return new Function('z', `return ${transpileResult.outputText}`)(z)\n}\n"],"names":["jsonSchemaToZod","ts","z","sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","convertCollectionSchemaToZod","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","simplifiedSchema","zodSchemaAsString","transpileResult","transpileModule","compilerOptions","module","ModuleKind","CommonJS","removeComments","strict","target","ScriptTarget","ES2018","Function","outputText"],"mappings":"AAEA,SAASA,eAAe,QAAQ,qBAAoB;AACpD,YAAYC,QAAQ,aAAY;AAChC,SAASC,CAAC,QAAQ,MAAK;AAEvB,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE,OAAO,MAAMC,+BAA+B,CAACC;IAC3C,gFAAgF;IAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAE9C,MAAMK,YAAYT,mBAAmBK;IACrC,MAAMK,mBAAmBR,2BAA2BO;IACpD,MAAME,mBAAmBV,2BAA2BS;IAEpD,MAAME,oBAAoBf,gBAAgBc;IAE1C,qCAAqC;IACrC,MAAME,kBAAkBf,GAAGgB,eAAe,CAACF,mBAAmB;QAC5DG,iBAAiB;YACfC,QAAQlB,GAAGmB,UAAU,CAACC,QAAQ;YAC9BC,gBAAgB;YAChBC,QAAQ;YACRC,QAAQvB,GAAGwB,YAAY,CAACC,MAAM;QAChC;IACF;IAEA;;;;;;;GAOC,GACD,8DAA8D;IAC9D,OAAO,IAAIC,SAAS,KAAK,CAAC,OAAO,EAAEX,gBAAgBY,UAAU,EAAE,EAAE1B;AACnE,EAAC"}
@@ -0,0 +1,8 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ /**
3
+ * Removes internal Payload properties (id, createdAt, updatedAt) from a
4
+ * JSON Schema so they don't appear in the generated Zod validation schema.
5
+ * Also strips `id` from the `required` array when present.
6
+ */
7
+ export declare function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4;
8
+ //# sourceMappingURL=sanitizeJsonSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAanE"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Removes internal Payload properties (id, createdAt, updatedAt) from a
3
+ * JSON Schema so they don't appear in the generated Zod validation schema.
4
+ * Also strips `id` from the `required` array when present.
5
+ */ export function sanitizeJsonSchema(schema) {
6
+ delete schema?.properties?.id;
7
+ delete schema?.properties?.createdAt;
8
+ delete schema?.properties?.updatedAt;
9
+ if (Array.isArray(schema.required)) {
10
+ schema.required = schema.required.filter((field)=>field !== 'id');
11
+ if (schema.required.length === 0) {
12
+ delete schema.required;
13
+ }
14
+ }
15
+ return schema;
16
+ }
17
+
18
+ //# sourceMappingURL=sanitizeJsonSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n */\nexport function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4 {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n return schema\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,mBAAmBC,MAAmB;IACpD,OAAOA,QAAQC,YAAYC;IAC3B,OAAOF,QAAQC,YAAYE;IAC3B,OAAOH,QAAQC,YAAYG;IAE3B,IAAIC,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAUA,UAAU;QAC9D,IAAIT,OAAOO,QAAQ,CAACG,MAAM,KAAK,GAAG;YAChC,OAAOV,OAAOO,QAAQ;QACxB;IACF;IAEA,OAAOP;AACT"}
@@ -0,0 +1,20 @@
1
+ import type { JSONSchema4 } from 'json-schema';
2
+ /**
3
+ * Recursively processes JSON schema properties to simplify relationship fields
4
+ * and convert `oneOf` constructs into MCP-friendly schemas.
5
+ *
6
+ * For create/update validation we only need to accept IDs (string/number),
7
+ * not populated objects. `$ref` options pointing to full entity definitions
8
+ * are removed entirely from `oneOf` unions. When a single option remains the
9
+ * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
10
+ *
11
+ * This matters because `json-schema-to-zod` converts `oneOf` into a strict
12
+ * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
13
+ * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
14
+ * tool input schema. `anyOf` instead produces a clean `z.union([...])`.
15
+ *
16
+ * NOTE: This function must operate on a cloned schema to avoid mutating
17
+ * the original JSON schema used for tool listing.
18
+ */
19
+ export declare function simplifyRelationshipFields(schema: JSONSchema4): JSONSchema4;
20
+ //# sourceMappingURL=simplifyRelationshipFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simplifyRelationshipFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA6C3E"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Recursively processes JSON schema properties to simplify relationship fields
3
+ * and convert `oneOf` constructs into MCP-friendly schemas.
4
+ *
5
+ * For create/update validation we only need to accept IDs (string/number),
6
+ * not populated objects. `$ref` options pointing to full entity definitions
7
+ * are removed entirely from `oneOf` unions. When a single option remains the
8
+ * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
9
+ *
10
+ * This matters because `json-schema-to-zod` converts `oneOf` into a strict
11
+ * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
12
+ * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
13
+ * tool input schema. `anyOf` instead produces a clean `z.union([...])`.
14
+ *
15
+ * NOTE: This function must operate on a cloned schema to avoid mutating
16
+ * the original JSON schema used for tool listing.
17
+ */ export function simplifyRelationshipFields(schema) {
18
+ if (!schema || typeof schema !== 'object') {
19
+ return schema;
20
+ }
21
+ const processed = {
22
+ ...schema
23
+ };
24
+ if (Array.isArray(processed.oneOf)) {
25
+ const hasRef = processed.oneOf.some((option)=>option && typeof option === 'object' && '$ref' in option);
26
+ if (hasRef) {
27
+ const nonRefOptions = processed.oneOf.filter((option)=>!(option && typeof option === 'object' && '$ref' in option)).map((option)=>simplifyRelationshipFields(option));
28
+ if (nonRefOptions.length === 1) {
29
+ const single = nonRefOptions[0];
30
+ delete processed.oneOf;
31
+ Object.assign(processed, single);
32
+ } else if (nonRefOptions.length > 1) {
33
+ delete processed.oneOf;
34
+ processed.anyOf = nonRefOptions;
35
+ }
36
+ } else {
37
+ processed.anyOf = processed.oneOf.map((option)=>simplifyRelationshipFields(option));
38
+ delete processed.oneOf;
39
+ }
40
+ }
41
+ if (processed.properties && typeof processed.properties === 'object') {
42
+ processed.properties = Object.fromEntries(Object.entries(processed.properties).map(([key, value])=>[
43
+ key,
44
+ simplifyRelationshipFields(value)
45
+ ]));
46
+ }
47
+ if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
48
+ processed.items = simplifyRelationshipFields(processed.items);
49
+ }
50
+ return processed;
51
+ }
52
+
53
+ //# sourceMappingURL=simplifyRelationshipFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/**\n * Recursively processes JSON schema properties to simplify relationship fields\n * and convert `oneOf` constructs into MCP-friendly schemas.\n *\n * For create/update validation we only need to accept IDs (string/number),\n * not populated objects. `$ref` options pointing to full entity definitions\n * are removed entirely from `oneOf` unions. When a single option remains the\n * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.\n *\n * This matters because `json-schema-to-zod` converts `oneOf` into a strict\n * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing\n * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP\n * tool input schema. `anyOf` instead produces a clean `z.union([...])`.\n *\n * NOTE: This function must operate on a cloned schema to avoid mutating\n * the original JSON schema used for tool listing.\n */\nexport function simplifyRelationshipFields(schema: JSONSchema4): JSONSchema4 {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const processed = { ...schema }\n\n if (Array.isArray(processed.oneOf)) {\n const hasRef = processed.oneOf.some(\n (option) => option && typeof option === 'object' && '$ref' in option,\n )\n\n if (hasRef) {\n const nonRefOptions = processed.oneOf\n .filter((option) => !(option && typeof option === 'object' && '$ref' in option))\n .map((option) => simplifyRelationshipFields(option))\n\n if (nonRefOptions.length === 1) {\n const single = nonRefOptions[0]!\n delete processed.oneOf\n Object.assign(processed, single)\n } else if (nonRefOptions.length > 1) {\n delete processed.oneOf\n processed.anyOf = nonRefOptions\n }\n } else {\n processed.anyOf = processed.oneOf.map((option) => simplifyRelationshipFields(option))\n delete processed.oneOf\n }\n }\n\n if (processed.properties && typeof processed.properties === 'object') {\n processed.properties = Object.fromEntries(\n Object.entries(processed.properties).map(([key, value]) => [\n key,\n simplifyRelationshipFields(value),\n ]),\n )\n }\n\n if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {\n processed.items = simplifyRelationshipFields(processed.items)\n }\n\n return processed\n}\n"],"names":["simplifyRelationshipFields","schema","processed","Array","isArray","oneOf","hasRef","some","option","nonRefOptions","filter","map","length","single","Object","assign","anyOf","properties","fromEntries","entries","key","value","items"],"mappings":"AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASA,2BAA2BC,MAAmB;IAC5D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,YAAY;QAAE,GAAGD,MAAM;IAAC;IAE9B,IAAIE,MAAMC,OAAO,CAACF,UAAUG,KAAK,GAAG;QAClC,MAAMC,SAASJ,UAAUG,KAAK,CAACE,IAAI,CACjC,CAACC,SAAWA,UAAU,OAAOA,WAAW,YAAY,UAAUA;QAGhE,IAAIF,QAAQ;YACV,MAAMG,gBAAgBP,UAAUG,KAAK,CAClCK,MAAM,CAAC,CAACF,SAAW,CAAEA,CAAAA,UAAU,OAAOA,WAAW,YAAY,UAAUA,MAAK,GAC5EG,GAAG,CAAC,CAACH,SAAWR,2BAA2BQ;YAE9C,IAAIC,cAAcG,MAAM,KAAK,GAAG;gBAC9B,MAAMC,SAASJ,aAAa,CAAC,EAAE;gBAC/B,OAAOP,UAAUG,KAAK;gBACtBS,OAAOC,MAAM,CAACb,WAAWW;YAC3B,OAAO,IAAIJ,cAAcG,MAAM,GAAG,GAAG;gBACnC,OAAOV,UAAUG,KAAK;gBACtBH,UAAUc,KAAK,GAAGP;YACpB;QACF,OAAO;YACLP,UAAUc,KAAK,GAAGd,UAAUG,KAAK,CAACM,GAAG,CAAC,CAACH,SAAWR,2BAA2BQ;YAC7E,OAAON,UAAUG,KAAK;QACxB;IACF;IAEA,IAAIH,UAAUe,UAAU,IAAI,OAAOf,UAAUe,UAAU,KAAK,UAAU;QACpEf,UAAUe,UAAU,GAAGH,OAAOI,WAAW,CACvCJ,OAAOK,OAAO,CAACjB,UAAUe,UAAU,EAAEN,GAAG,CAAC,CAAC,CAACS,KAAKC,MAAM,GAAK;gBACzDD;gBACApB,2BAA2BqB;aAC5B;IAEL;IAEA,IAAInB,UAAUoB,KAAK,IAAI,OAAOpB,UAAUoB,KAAK,KAAK,YAAY,CAACnB,MAAMC,OAAO,CAACF,UAAUoB,KAAK,GAAG;QAC7FpB,UAAUoB,KAAK,GAAGtB,2BAA2BE,UAAUoB,KAAK;IAC9D;IAEA,OAAOpB;AACT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformPointFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAoD3E"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nexport function transformPointFieldsForMCP(schema: JSONSchema4): JSONSchema4 {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const transformed = { ...schema }\n\n if (transformed.properties && typeof transformed.properties === 'object') {\n transformed.properties = Object.fromEntries(\n Object.entries(transformed.properties).map(([key, value]) => {\n const isArrayType =\n value.type === 'array' || (Array.isArray(value.type) && value.type.includes('array'))\n\n if (\n value &&\n typeof value === 'object' &&\n isArrayType &&\n Array.isArray(value.items) &&\n value.items.length === 2 &&\n value.items.every((item: JSONSchema4) => item?.type === 'number')\n ) {\n // Transform to object format\n const isNullable = Array.isArray(value.type) && value.type.includes('null')\n\n return [\n key,\n {\n type: isNullable ? ['object', 'null'] : 'object',\n description: value.description || 'Geographic coordinates (longitude, latitude)',\n properties: {\n latitude: { type: 'number', description: 'Latitude coordinate' },\n longitude: { type: 'number', description: 'Longitude coordinate' },\n },\n required: ['longitude', 'latitude'],\n },\n ]\n }\n\n return [key, transformPointFieldsForMCP(value)]\n }),\n )\n }\n\n if (\n transformed.items &&\n typeof transformed.items === 'object' &&\n !Array.isArray(transformed.items)\n ) {\n transformed.items = transformPointFieldsForMCP(transformed.items)\n }\n\n return transformed\n}\n"],"names":["transformPointFieldsForMCP","schema","transformed","properties","Object","fromEntries","entries","map","key","value","isArrayType","type","Array","isArray","includes","items","length","every","item","isNullable","description","latitude","longitude","required"],"mappings":"AAEA,OAAO,SAASA,2BAA2BC,MAAmB;IAC5D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,cAAc;QAAE,GAAGD,MAAM;IAA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7",
3
+ "version": "3.77.0-internal-debug.98d2e4d",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
6
  "plugin",
@@ -37,18 +37,18 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@modelcontextprotocol/sdk": "~1.24.0",
40
+ "@modelcontextprotocol/sdk": "1.25.2",
41
41
  "@types/json-schema": "7.0.15",
42
- "@vercel/mcp-adapter": "^1.0.0",
43
42
  "json-schema-to-zod": "2.6.1",
43
+ "mcp-handler": "^1.0.7",
44
44
  "zod": "^3.25.50"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@payloadcms/eslint-config": "3.28.0",
48
- "payload": "3.77.0-canary.7"
48
+ "payload": "3.77.0-internal-debug.98d2e4d"
49
49
  },
50
50
  "peerDependencies": {
51
- "payload": "3.77.0-canary.7"
51
+ "payload": "3.77.0-internal-debug.98d2e4d"
52
52
  },
53
53
  "homepage:": "https://payloadcms.com",
54
54
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import type { JSONSchema4 } from 'json-schema'
2
2
 
3
- import { createMcpHandler } from '@vercel/mcp-adapter'
3
+ import { createMcpHandler } from 'mcp-handler'
4
4
  import { join } from 'path'
5
5
  import { APIError, configToJSONSchema, type PayloadRequest, type TypedUser } from 'payload'
6
6
 
@@ -260,10 +260,12 @@ export const getMCPHandler = (
260
260
  isToolEnabled,
261
261
  tool.name,
262
262
  () =>
263
- server.tool(
263
+ server.registerTool(
264
264
  tool.name,
265
- tool.description,
266
- tool.parameters,
265
+ {
266
+ description: tool.description,
267
+ inputSchema: tool.parameters,
268
+ },
267
269
  payloadToolHandler(tool.handler),
268
270
  ),
269
271
  payload,
@@ -507,9 +509,10 @@ export const getMCPHandler = (
507
509
  },
508
510
  {
509
511
  basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',
512
+ disableSse: MCPHandlerOptions.disableSse ?? true,
510
513
  maxDuration: MCPHandlerOptions.maxDuration || 60,
511
- // INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns
512
- // redisUrl: MCPHandlerOptions.redisUrl || process.env.REDIS_URL,
514
+ onEvent: MCPHandlerOptions.onEvent,
515
+ redisUrl: MCPHandlerOptions.redisUrl,
513
516
  verboseLogs: useVerboseLogs,
514
517
  },
515
518
  )
@@ -58,10 +58,12 @@ export const authTool = (server: McpServer, req: PayloadRequest, verboseLogs: bo
58
58
  }
59
59
  }
60
60
 
61
- server.tool(
61
+ server.registerTool(
62
62
  'auth',
63
- toolSchemas.auth.description,
64
- toolSchemas.auth.parameters.shape,
63
+ {
64
+ description: toolSchemas.auth.description,
65
+ inputSchema: toolSchemas.auth.parameters.shape,
66
+ },
65
67
  async ({ headers }) => {
66
68
  return await tool(headers)
67
69
  },
@@ -57,10 +57,12 @@ export const forgotPasswordTool = (
57
57
  }
58
58
  }
59
59
 
60
- server.tool(
60
+ server.registerTool(
61
61
  'forgotPassword',
62
- toolSchemas.forgotPassword.description,
63
- toolSchemas.forgotPassword.parameters.shape,
62
+ {
63
+ description: toolSchemas.forgotPassword.description,
64
+ inputSchema: toolSchemas.forgotPassword.parameters.shape,
65
+ },
64
66
  async ({ collection, disableEmail, email }) => {
65
67
  return await tool(collection, email, disableEmail)
66
68
  },
@@ -59,10 +59,12 @@ export const loginTool = (server: McpServer, req: PayloadRequest, verboseLogs: b
59
59
  }
60
60
  }
61
61
 
62
- server.tool(
62
+ server.registerTool(
63
63
  'login',
64
- toolSchemas.login.description,
65
- toolSchemas.login.parameters.shape,
64
+ {
65
+ description: toolSchemas.login.description,
66
+ inputSchema: toolSchemas.login.parameters.shape,
67
+ },
66
68
  async ({ collection, depth, email, overrideAccess, password, showHiddenFields }) => {
67
69
  return await tool(collection, email, password, depth, overrideAccess, showHiddenFields)
68
70
  },
@@ -48,10 +48,12 @@ export const resetPasswordTool = (server: McpServer, req: PayloadRequest, verbos
48
48
  }
49
49
  }
50
50
 
51
- server.tool(
51
+ server.registerTool(
52
52
  'resetPassword',
53
- toolSchemas.resetPassword.description,
54
- toolSchemas.resetPassword.parameters.shape,
53
+ {
54
+ description: toolSchemas.resetPassword.description,
55
+ inputSchema: toolSchemas.resetPassword.parameters.shape,
56
+ },
55
57
  async ({ collection, password, token }) => {
56
58
  return await tool(collection, token, password)
57
59
  },
@@ -51,10 +51,12 @@ export const unlockTool = (server: McpServer, req: PayloadRequest, verboseLogs:
51
51
  }
52
52
  }
53
53
 
54
- server.tool(
54
+ server.registerTool(
55
55
  'unlock',
56
- toolSchemas.unlock.description,
57
- toolSchemas.unlock.parameters.shape,
56
+ {
57
+ description: toolSchemas.unlock.description,
58
+ inputSchema: toolSchemas.unlock.parameters.shape,
59
+ },
58
60
  async ({ collection, email }) => {
59
61
  return await tool(collection, email)
60
62
  },
@@ -44,10 +44,12 @@ export const verifyTool = (server: McpServer, req: PayloadRequest, verboseLogs:
44
44
  }
45
45
  }
46
46
 
47
- server.tool(
47
+ server.registerTool(
48
48
  'verify',
49
- toolSchemas.verify.description,
50
- toolSchemas.verify.parameters.shape,
49
+ {
50
+ description: toolSchemas.verify.description,
51
+ inputSchema: toolSchemas.verify.parameters.shape,
52
+ },
51
53
  async ({ collection, token }) => {
52
54
  return await tool(collection, token)
53
55
  },