@payloadcms/plugin-mcp 4.0.0-internal.811e0a4 → 4.0.0-internal.8ba6b5b

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 (105) hide show
  1. package/dist/endpoint/access.d.ts +2 -7
  2. package/dist/endpoint/access.d.ts.map +1 -1
  3. package/dist/endpoint/access.js +4 -11
  4. package/dist/endpoint/access.js.map +1 -1
  5. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
  6. package/dist/mcp/builtin/collections/countTool.js +1 -2
  7. package/dist/mcp/builtin/collections/countTool.js.map +1 -1
  8. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
  9. package/dist/mcp/builtin/collections/countVersionsTool.js +1 -2
  10. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
  11. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  12. package/dist/mcp/builtin/collections/createTool.js +1 -2
  13. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  14. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  15. package/dist/mcp/builtin/collections/deleteTool.js +1 -2
  16. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  17. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
  18. package/dist/mcp/builtin/collections/duplicateTool.js +1 -2
  19. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
  20. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
  21. package/dist/mcp/builtin/collections/findDistinctTool.js +1 -2
  22. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
  23. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  24. package/dist/mcp/builtin/collections/findTool.js +2 -3
  25. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  26. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
  27. package/dist/mcp/builtin/collections/findVersionByIDTool.js +1 -2
  28. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
  29. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
  30. package/dist/mcp/builtin/collections/findVersionsTool.js +1 -2
  31. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
  32. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  33. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +21 -3
  34. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  35. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
  36. package/dist/mcp/builtin/collections/restoreVersionTool.js +1 -2
  37. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
  38. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  39. package/dist/mcp/builtin/collections/updateTool.js +2 -3
  40. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  41. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  42. package/dist/mcp/builtin/getConfigInfoTool.js +2 -5
  43. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  44. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
  45. package/dist/mcp/builtin/globals/countVersionsTool.js +1 -2
  46. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
  47. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  48. package/dist/mcp/builtin/globals/findTool.js +2 -2
  49. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  50. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
  51. package/dist/mcp/builtin/globals/findVersionByIDTool.js +1 -2
  52. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
  53. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
  54. package/dist/mcp/builtin/globals/findVersionsTool.js +1 -2
  55. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
  56. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  57. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +21 -3
  58. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  59. package/dist/mcp/builtin/globals/restoreVersionTool.js +1 -2
  60. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
  61. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  62. package/dist/mcp/builtin/globals/updateTool.js +2 -2
  63. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  64. package/dist/types.d.ts +44 -7
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js +2 -4
  67. package/dist/types.js.map +1 -1
  68. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
  69. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
  70. package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
  71. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
  72. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
  73. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
  74. package/dist/utils/schemaConversion/getEntityInputSchema.js +40 -6
  75. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
  76. package/package.json +3 -3
  77. package/src/endpoint/access.ts +3 -10
  78. package/src/mcp/builtin/collections/countTool.ts +1 -2
  79. package/src/mcp/builtin/collections/countVersionsTool.ts +2 -6
  80. package/src/mcp/builtin/collections/createTool.ts +1 -2
  81. package/src/mcp/builtin/collections/deleteTool.ts +1 -2
  82. package/src/mcp/builtin/collections/duplicateTool.ts +1 -2
  83. package/src/mcp/builtin/collections/findDistinctTool.ts +3 -3
  84. package/src/mcp/builtin/collections/findTool.ts +2 -3
  85. package/src/mcp/builtin/collections/findVersionByIDTool.ts +1 -2
  86. package/src/mcp/builtin/collections/findVersionsTool.ts +1 -2
  87. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +25 -8
  88. package/src/mcp/builtin/collections/restoreVersionTool.ts +1 -2
  89. package/src/mcp/builtin/collections/updateTool.ts +2 -3
  90. package/src/mcp/builtin/getConfigInfoTool.ts +2 -4
  91. package/src/mcp/builtin/globals/countVersionsTool.ts +2 -6
  92. package/src/mcp/builtin/globals/findTool.ts +2 -2
  93. package/src/mcp/builtin/globals/findVersionByIDTool.ts +1 -2
  94. package/src/mcp/builtin/globals/findVersionsTool.ts +1 -2
  95. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +25 -3
  96. package/src/mcp/builtin/globals/restoreVersionTool.ts +3 -3
  97. package/src/mcp/builtin/globals/updateTool.ts +2 -2
  98. package/src/types.ts +43 -7
  99. package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
  100. package/src/utils/schemaConversion/getEntityInputSchema.ts +47 -13
  101. package/dist/utils/localAPIDefaults.d.ts +0 -20
  102. package/dist/utils/localAPIDefaults.d.ts.map +0 -1
  103. package/dist/utils/localAPIDefaults.js +0 -19
  104. package/dist/utils/localAPIDefaults.js.map +0 -1
  105. package/src/utils/localAPIDefaults.ts +0 -22
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find a specific global version in any version-enabled global by passing the global slug and version ID.'\n\nexport const findGlobalVersionByIDTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Version By ID',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to retrieve'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in the global version document')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\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 .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the returned global version document')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields } = input\n\n logger.info(`Finding version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.findGlobalVersionByID({\n id,\n slug: globalSlug,\n depth,\n req,\n ...localAPIDefaults(authorizedMCP),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" from global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","localAPIDefaults","DEFAULT_DESCRIPTION","findGlobalVersionByIDTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","select","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersionByID","slug","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,gBAAgB,QAAQ,qCAAoC;AAErE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,4BAA4BJ,iBAAiB;IACxDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOrB,EAAEsB,MAAM,CAAC;QACdC,IAAIvB,EAAEwB,MAAM,GAAGC,QAAQ,CAAC;QACxBC,OAAO1B,EACJ2B,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJL,QAAQ,CAAC,iFACTM,QAAQ,GACRC,OAAO,CAAC;QACXC,gBAAgBjC,EACbwB,MAAM,GACNC,QAAQ,CAAC,gFACTM,QAAQ;QACXG,QAAQlC,EACLwB,MAAM,GACNC,QAAQ,CACP,wHAEDM,QAAQ;QACXI,UAAUnC,EACPoC,MAAM,CAACpC,EAAEwB,MAAM,IAAIxB,EAAEqC,OAAO,IAC5BZ,QAAQ,CACP,8FAEDM,QAAQ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AAO,GAAG;QAC9Df,OAAOY,KAAK,CAAC,CAAC,sBAAsB,EAAElC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAE8C,cAAc;QACpF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,2BAA2B,EAAE9B,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAE8C,cAAc;gBACzF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find a specific global version in any version-enabled global by passing the global slug and version ID.'\n\nexport const findGlobalVersionByIDTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Version By ID',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to retrieve'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in the global version document')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\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 .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the returned global version document')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields } = input\n\n logger.info(`Finding version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.findGlobalVersionByID({\n id,\n slug: globalSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" from global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionByIDTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","select","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersionByID","slug","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,Q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BAA4B,EAAElC,WAAW,UAAU,EAAEW,IAAI;IAEtE,IAAI;QACF,MAAMwB,SAAS,MAAMH,QAAQI,qBAAqB,CAAC;YACjDzB;YACA0B,MAAMrC;YACNc;YACAwB,gBAAgBR,cAAcQ,cAAc;YAC5CP;YACA,GAAIV,iBAAiB;gBAAEA;YAAe,IAAI,CAAC,CAAC;YAC5C,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,WAAW;gBAAEA,UAAUA;YAAyB,IAAI,CAAC,CAAC;YAC1D,GAAIG,SAAS;gBAAEA,QAAQA;YAAqB,IAAI,CAAC,CAAC;YAClD,GAAIC,qBAAqBY,YAAY;gBAAEZ;YAAiB,IAAI,CAAC,CAAC;QAChE;QAEA,OAAO;YACLa,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAE/B,GAAG,eAAe,EAAEX,WAAW,gBAAgB,EAAE2C,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBACrG;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DhB,OAAOa,KAAK,CAAC,CAAC,sBAAsB,EAAEnC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAE+C,cAAc;QACpF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,2BAA2B,EAAE/B,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAE+C,cAAc;gBACzF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,sBAAsB,wCAsIjC,CAAA"}
1
+ {"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,wCAsIjC,CAAA"}
@@ -2,7 +2,6 @@ import { z } from 'zod';
2
2
  import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
- import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
6
5
  import { whereSchema } from '../../../utils/whereSchema.js';
7
6
  const DEFAULT_DESCRIPTION = 'Find global versions in any version-enabled global by passing the global slug and optional where clause.';
8
7
  export const findGlobalVersionsTool = defineGlobalTool({
@@ -40,9 +39,9 @@ export const findGlobalVersionsTool = defineGlobalTool({
40
39
  slug: globalSlug,
41
40
  depth,
42
41
  limit,
42
+ overrideAccess: authorizedMCP.overrideAccess,
43
43
  page,
44
44
  req,
45
- ...localAPIDefaults(authorizedMCP),
46
45
  ...fallbackLocale ? {
47
46
  fallbackLocale
48
47
  } : {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const findGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in global version documents')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .describe('Maximum number of versions to return (default: 10, max: 100)')\n .optional()\n .default(10),\n locale: z\n .string()\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 .optional(),\n page: z\n .number()\n .int()\n .min(1)\n .describe('Page number for pagination (default: 1)')\n .optional()\n .default(1),\n pagination: z\n .boolean()\n .describe('Optional: set to false to skip the count query overhead')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in returned global version documents')\n .optional(),\n sort: z\n .string()\n .describe('Field to sort by (e.g., \"-updatedAt\", \"-version.updatedAt\" for descending)')\n .optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering versions. Version document fields are usually under \"version\". Example: {\"version.siteName\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const {\n depth,\n fallbackLocale,\n limit,\n locale,\n page,\n pagination,\n populate,\n select,\n showHiddenFields,\n sort,\n where,\n } = input\n\n logger.info(`Finding versions for global: ${globalSlug}, limit: ${limit}, page: ${page}`)\n\n try {\n const result = await payload.findGlobalVersions({\n slug: globalSlug,\n depth,\n limit,\n page,\n req,\n ...localAPIDefaults(authorizedMCP),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(pagination !== undefined ? { pagination } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n ...(sort ? { sort } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Versions for global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding versions for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding versions for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","localAPIDefaults","whereSchema","DEFAULT_DESCRIPTION","findGlobalVersionsTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","depth","number","int","min","max","describe","optional","default","fallbackLocale","string","limit","locale","page","pagination","boolean","populate","record","unknown","select","showHiddenFields","sort","where","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersions","slug","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,yBAAyBL,iBAAiB;IACrDM,QAAQ,CAACC,OACPR,cAAcQ,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,O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,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const findGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in global version documents')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .describe('Maximum number of versions to return (default: 10, max: 100)')\n .optional()\n .default(10),\n locale: z\n .string()\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 .optional(),\n page: z\n .number()\n .int()\n .min(1)\n .describe('Page number for pagination (default: 1)')\n .optional()\n .default(1),\n pagination: z\n .boolean()\n .describe('Optional: set to false to skip the count query overhead')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in returned global version documents')\n .optional(),\n sort: z\n .string()\n .describe('Field to sort by (e.g., \"-updatedAt\", \"-version.updatedAt\" for descending)')\n .optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering versions. Version document fields are usually under \"version\". Example: {\"version.siteName\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const {\n depth,\n fallbackLocale,\n limit,\n locale,\n page,\n pagination,\n populate,\n select,\n showHiddenFields,\n sort,\n where,\n } = input\n\n logger.info(`Finding versions for global: ${globalSlug}, limit: ${limit}, page: ${page}`)\n\n try {\n const result = await payload.findGlobalVersions({\n slug: globalSlug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(pagination !== undefined ? { pagination } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n ...(sort ? { sort } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Versions for global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding versions for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding versions for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","whereSchema","DEFAULT_DESCRIPTION","findGlobalVersionsTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","depth","number","int","min","max","describe","optional","default","fallbackLocale","string","limit","locale","page","pagination","boolean","populate","record","unknown","select","showHiddenFields","sort","where","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersions","slug","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,yBAAyBJ,iBAAiB;IACrDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOrB,EAAEsB,MAAM,CAAC;QACdC,OAAOvB,EACJwB,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,CAAC,8EACTC,QAAQ,GACRC,OAAO,CAAC;QACXC,gBAAgB/B,EACbgC,MAAM,GACNJ,QAAQ,CAAC,gFACTC,QAAQ;QACXI,OAAOjC,EACJwB,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,KACJC,QAAQ,CAAC,gEACTC,QAAQ,GACRC,OAAO,CAAC;QACXI,QAAQlC,EACLgC,MAAM,GACNJ,QAAQ,CACP,wHAEDC,QAAQ;QACXM,MAAMnC,EACHwB,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJE,QAAQ,CAAC,2CACTC,QAAQ,GACRC,OAAO,CAAC;QACXM,YAAYpC,EACTqC,OAAO,GACPT,QAAQ,CAAC,2DACTC,QAAQ;QACXS,UAAUtC,EACPuC,MAAM,CAACvC,EAAEgC,MAAM,IAAIhC,EAAEwC,OAAO,IA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,CAAC,CAAC;YAC9D,GAAIC,OAAO;gBAAEA;YAAK,IAAI,CAAC,CAAC;YACxB,GAAIC,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;QAEA,OAAO;YACLY,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,qBAAqB,EAAE9C,WAAW,gBAAgB,EAAE+C,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBAC7F;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DhB,OAAOa,KAAK,CAAC,CAAC,kCAAkC,EAAElD,WAAW,EAAE,EAAEmD,cAAc;QAC/E,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,uCAAuC,EAAE9C,WAAW,KAAK,EAAEmD,cAAc;gBAClF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,wCAoC9B,CAAA"}
1
+ {"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,wCAwD9B,CAAA"}
@@ -1,10 +1,11 @@
1
+ import { getAccessResults } from 'payload';
1
2
  import { defaultAccess } from '../../../defaultAccess.js';
2
3
  import { defineGlobalTool } from '../../../defineTool.js';
3
4
  import { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js';
4
5
  export const getGlobalSchemaTool = defineGlobalTool({
5
6
  access: (args)=>{
6
7
  const permissions = args.permissions?.globals?.[args.globalSlug];
7
- return defaultAccess(args) && Boolean(permissions?.read || permissions?.update);
8
+ return defaultAccess(args) && Boolean(permissions?.update);
8
9
  },
9
10
  annotations: {
10
11
  destructiveHint: false,
@@ -14,10 +15,27 @@ export const getGlobalSchemaTool = defineGlobalTool({
14
15
  title: 'Get Global Schema'
15
16
  },
16
17
  description: 'Get the input schema for updating a global.'
17
- }).handler(({ globalSlug, req })=>{
18
+ }).handler(async ({ authorizedMCP, globalSlug, req })=>{
19
+ const permissions = authorizedMCP.overrideAccess ? null : (await getAccessResults({
20
+ req
21
+ })).globals?.[globalSlug];
22
+ if (!authorizedMCP.overrideAccess && !permissions?.update) {
23
+ return {
24
+ content: [
25
+ {
26
+ type: 'text',
27
+ text: `Error: MCP access to "getGlobalSchema" is not enabled for global "${globalSlug}"`
28
+ }
29
+ ],
30
+ isError: true
31
+ };
32
+ }
18
33
  const inputSchema = getGlobalInputSchema({
19
34
  globalSlug,
20
- req
35
+ req,
36
+ ...permissions ? {
37
+ permissions
38
+ } : {}
21
39
  });
22
40
  if (!inputSchema) {
23
41
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"sourcesContent":["import { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getGlobalSchemaTool = defineGlobalTool({\n access: (args) => {\n const permissions = args.permissions?.globals?.[args.globalSlug]\n\n return defaultAccess(args) && Boolean(permissions?.read || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Global Schema',\n },\n description: 'Get the input schema for updating a global.',\n}).handler(({ globalSlug, req }) => {\n const inputSchema = getGlobalInputSchema({ globalSlug, req })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Global \"${globalSlug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n globalSlug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["defaultAccess","defineGlobalTool","getGlobalInputSchema","getGlobalSchemaTool","access","args","permissions","globals","globalSlug","Boolean","read","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","req","inputSchema","content","type","text","isError","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,oBAAoB,QAAQ,0DAAyD;AAE9F,OAAO,MAAMC,sBAAsBF,iBAAiB;IAClDG,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,SAAS,CAACF,KAAKG,UAAU,CAAC;QAEhE,OAAOR,cAAcK,SAASI,QAAQH,aAAaI,QAAQJ,aAAaK;IAC1E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,CAAC,EAAEX,UAAU,EAAEY,GAAG,EAAE;IAC7B,MAAMC,cAAcnB,qBAAqB;QAAEM;QAAYY;IAAI;IAE3D,IAAI,CAACC,aAAa;QAChB,OAAO;YACLC,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,eAAe,EAAEhB,WAAW,WAAW,CAAC;gBAAC;aAAE;YAC5EiB,SAAS;QACX;IACF;IAEA,OAAO;QACLH,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,mBAAmB,EAAEhB,WAAW,gBAAgB,EAAEkB,KAAKC,SAAS,CAACN,aAAa,QAAQ,CAAC;YAChG;SACD;QACDO,mBAAmB;YACjBpB;YACAqB,QAAQR;QACV;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"sourcesContent":["import { getAccessResults } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getGlobalSchemaTool = defineGlobalTool({\n access: (args) => {\n const permissions = args.permissions?.globals?.[args.globalSlug]\n\n return defaultAccess(args) && Boolean(permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Global Schema',\n },\n description: 'Get the input schema for updating a global.',\n}).handler(async ({ authorizedMCP, globalSlug, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).globals?.[globalSlug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getGlobalSchema\" is not enabled for global \"${globalSlug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getGlobalInputSchema({\n globalSlug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Global \"${globalSlug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n globalSlug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["getAccessResults","defaultAccess","defineGlobalTool","getGlobalInputSchema","getGlobalSchemaTool","access","args","permissions","globals","globalSlug","Boolean","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,UAAS;AAE1C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,o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
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
- import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
6
5
  const DEFAULT_DESCRIPTION = 'Restore a global from a previous version in any version-enabled global.';
7
6
  export const restoreGlobalVersionTool = defineGlobalTool({
8
7
  access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),
@@ -34,8 +33,8 @@ export const restoreGlobalVersionTool = defineGlobalTool({
34
33
  id,
35
34
  slug: globalSlug,
36
35
  depth,
36
+ overrideAccess: authorizedMCP.overrideAccess,
37
37
  req,
38
- ...localAPIDefaults(authorizedMCP),
39
38
  ...fallbackLocale ? {
40
39
  fallbackLocale
41
40
  } : {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/restoreVersionTool.ts"],"sourcesContent":["import type { PopulateType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\n\nconst DEFAULT_DESCRIPTION = 'Restore a global from a previous version in any version-enabled global.'\n\nexport const restoreGlobalVersionTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Restore Global Version',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to restore'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe('Optional: locale code to restore in (e.g., \"en\", \"es\")')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the restored global response')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, showHiddenFields } = input\n\n logger.info(`Restoring version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.restoreGlobalVersion({\n id,\n slug: globalSlug,\n depth,\n req,\n ...localAPIDefaults(authorizedMCP),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n const resultObject = result as Record<string, unknown>\n const restoredGlobal =\n resultObject.version && typeof resultObject.version === 'object'\n ? (resultObject.version as Record<string, unknown>)\n : resultObject\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" restored successfully for global \"${globalSlug}\"!\\nRestored global:\\n\\`\\`\\`json\\n${JSON.stringify(restoredGlobal)}\\n\\`\\`\\``,\n },\n ],\n doc: restoredGlobal,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error restoring version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error restoring version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","localAPIDefaults","DEFAULT_DESCRIPTION","restoreGlobalVersionTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","restoreGlobalVersion","slug","undefined","resultObject","restoredGlobal","version","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,gBAAgB,QAAQ,qCAAoC;AAErE,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,2BAA2BJ,iBAAiB;IACvDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOrB,EAAEsB,MAAM,CAAC;QACdC,IAAIvB,EAAEwB,MAAM,GAAGC,QAAQ,CAAC;QACxBC,OAAO1B,EACJ2B,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJL,QAAQ,CAAC,8DACTM,QAAQ,GACRC,OAAO,CAAC;QACXC,gBAAgBjC,EACbwB,MAAM,GACNC,QAAQ,CAAC,gFACTM,QAAQ;QACXG,QAAQlC,EACLwB,MAAM,GACNC,QAAQ,CAAC,0DACTM,QAAQ;QACXI,UAAUnC,EACPoC,MAAM,CAACpC,EAAEwB,MAAM,IAAIxB,EAAEqC,OAAO,IAC5BZ,QAAQ,CACP,8FAEDM,QAAQ;QACXO,kBAAkBtC,EACfuC,OAAO,GACPd,QAAQ,CAAC,mEACTM,QAAQ;IACb;AACF,GAAGS,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAE7B,UAAU,EAAES,KAAK,EAAEqB,GAAG,EAAE;IACzD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAASzC,UAAU;QAAEwC;IAAQ;IACnC,MAAM,EAAEpB,EAAE,EAAEG,KAAK,EAAEO,cAAc,EAAEC,MAAM,EAAEC,QAAQ,EAAEG,gBAAgB,EAAE,GAAGjB;IAE1EuB,OAAOC,IAAI,CAAC,CAAC,8BAA8B,EAAEjC,WAAW,UAAU,EAAEW,IAAI;IAExE,IAAI;QACF,MAAMuB,SAAS,MAAMH,QAAQI,oBAAoB,CAAC;YAChDxB;YACAyB,MAAMpC;YACNc;YACAgB;YACA,GAAGtC,iBAAiBqC,cAAc;YAClC,GAAIR,iBAAiB;gBAAEA;YAAe,IAAI,CAAC,CAAC;YAC5C,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,WAAW;gBAAEA,UAAUA;YAAyB,IAAI,CAAC,CAAC;YAC1D,GAAIG,qBAAqBW,YAAY;gBAAEX;YAAiB,IAAI,CAAC,CAAC;QAChE;QACA,MAAMY,eAAeJ;QACrB,MAAMK,iBACJD,aAAaE,OAAO,IAAI,OAAOF,aAAaE,OAAO,KAAK,WACnDF,aAAaE,OAAO,GACrBF;QAEN,OAAO;YACLG,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAEhC,GAAG,oCAAoC,EAAEX,WAAW,kCAAkC,EAAE4C,KAAKC,SAAS,CAACN,gBAAgB,QAAQ,CAAC;gBACpJ;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DlB,OAAOe,KAAK,CAAC,CAAC,wBAAwB,EAAEpC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAEgD,cAAc;QACtF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6BAA6B,EAAEhC,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAEgD,cAAc;gBAC3F;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/restoreVersionTool.ts"],"sourcesContent":["import type { PopulateType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Restore a global from a previous version in any version-enabled global.'\n\nexport const restoreGlobalVersionTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Restore Global Version',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to restore'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe('Optional: locale code to restore in (e.g., \"en\", \"es\")')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the restored global response')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, showHiddenFields } = input\n\n logger.info(`Restoring version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.restoreGlobalVersion({\n id,\n slug: globalSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n const resultObject = result as Record<string, unknown>\n const restoredGlobal =\n resultObject.version && typeof resultObject.version === 'object'\n ? (resultObject.version as Record<string, unknown>)\n : resultObject\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" restored successfully for global \"${globalSlug}\"!\\nRestored global:\\n\\`\\`\\`json\\n${JSON.stringify(restoredGlobal)}\\n\\`\\`\\``,\n },\n ],\n doc: restoredGlobal,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error restoring version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error restoring version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","restoreGlobalVersionTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","restoreGlobalVersion","slug","overrideAccess","undefined","resultObject","restoredGlobal","version","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,2BAA2BH,iBAAiB;IACvDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB,EAAEqB,MAAM,CAAC;QACdC,IAAItB,EAAEuB,MAAM,GAAGC,QAAQ,CAAC;QACxBC,OAAOzB,EACJ0B,MAAM,GACNC,GAAG,GACHC,GAAG,CAA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AS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAEjC,GAAG,oCAAoC,EAAEX,WAAW,kCAAkC,EAAE6C,KAAKC,SAAS,CAACN,gBAAgB,QAAQ,CAAC;gBACpJ;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DnB,OAAOgB,KAAK,CAAC,CAAC,wBAAwB,EAAErC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAEiD,cAAc;QACtF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6BAA6B,EAAEjC,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAEiD,cAAc;gBAC3F;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,gBAAgB,wCAiG3B,CAAA"}
1
+ {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,gBAAgB,wCAkG3B,CAAA"}
@@ -3,7 +3,6 @@ import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
5
  import { getGlobalVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
6
- import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
7
6
  import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
8
7
  import { validateGlobalData } from '../validateEntityData.js';
9
8
  const DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.';
@@ -49,7 +48,8 @@ export const updateGlobalTool = defineGlobalTool({
49
48
  data: parsedData,
50
49
  depth,
51
50
  draft,
52
- ...localAPIDefaults(authorizedMCP)
51
+ overrideAccess: authorizedMCP.overrideAccess,
52
+ req
53
53
  };
54
54
  if (locale) {
55
55
  updateOptions.locale = locale;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getGlobalVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateGlobalData } from '../validateEntityData.js'\n\nconst DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.'\n\nexport const updateGlobalTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z.record(z.string(), z.unknown()).describe('The global fields to update'),\n depth: z\n .number()\n .describe('Optional: Depth of relationships to populate')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Optional: Whether to save as draft (default: false)')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"siteName\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Updating global: ${globalSlug}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, globalSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateGlobalData({ data: inputData, globalSlug, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const updateOptions: Parameters<typeof payload.updateGlobal>[0] = {\n slug: globalSlug,\n data: parsedData,\n depth,\n draft,\n ...localAPIDefaults(authorizedMCP),\n }\n\n if (locale) {\n updateOptions.locale = locale\n }\n if (fallbackLocale) {\n updateOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n updateOptions.select = select as SelectType\n }\n\n const result = await payload.updateGlobal(updateOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${globalSlug}\" updated successfully!\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating global ${globalSlug}: ${errorMessage}`)\n return {\n content: [{ type: 'text', text: `Error updating global \"${globalSlug}\": ${errorMessage}` }],\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","getGlobalVirtualFieldNames","stripVirtualFields","localAPIDefaults","transformPointDataToPayload","validateGlobalData","DEFAULT_DESCRIPTION","updateGlobalTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","optional","default","draft","boolean","fallbackLocale","locale","select","handler","authorizedMCP","req","payload","logger","info","virtualFieldNames","config","inputData","validationError","parsedData","updateOptions","slug","result","updateGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;A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AAc;gBAAC;aAAE;QAC7F;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getGlobalVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateGlobalData } from '../validateEntityData.js'\n\nconst DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.'\n\nexport const updateGlobalTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z.record(z.string(), z.unknown()).describe('The global fields to update'),\n depth: z\n .number()\n .describe('Optional: Depth of relationships to populate')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Optional: Whether to save as draft (default: false)')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"siteName\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Updating global: ${globalSlug}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, globalSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateGlobalData({ data: inputData, globalSlug, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const updateOptions: Parameters<typeof payload.updateGlobal>[0] = {\n slug: globalSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n }\n\n if (locale) {\n updateOptions.locale = locale\n }\n if (fallbackLocale) {\n updateOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n updateOptions.select = select as SelectType\n }\n\n const result = await payload.updateGlobal(updateOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${globalSlug}\" updated successfully!\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating global ${globalSlug}: ${errorMessage}`)\n return {\n content: [{ type: 'text', text: `Error updating global \"${globalSlug}\": ${errorMessage}` }],\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","getGlobalVirtualFieldNames","stripVirtualFields","transformPointDataToPayload","validateGlobalData","DEFAULT_DESCRIPTION","updateGlobalTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","optional","default","draft","boolean","fallbackLocale","locale","select","handler","authorizedMCP","req","payload","logger","info","virtualFieldNames","config","inputData","validationError","parsedData","updateOptions","slug","overrideAccess","result","updateGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,0BAA0B,EAC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SAAS,EAAEoB,QAAQG,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;IAGzF,IAAI;QACF,MAAMQ,oBAAoB1C,2BAA2BuC,QAAQI,MAAM,EAAEhC;QACrE,MAAMiC,YAAY3C,mBAAmBqB,MAAMoB;QAC3C,MAAMG,kBAAkB1C,mBAAmB;YAAEmB,MAAMsB;YAAWjC;YAAY2B;QAAI;QAE9E,IAAIO,iBAAiB;YACnB,OAAOA;QACT;QAEA,MAAMC,aAAa5C,4BAA4B0C;QAE/C,MAAMG,gBAA4D;YAChEC,MAAMrC;YACNW,MAAMwB;YACNnB;YACAI;YACAkB,gBAAgBZ,cAAcY,cAAc;YAC5CX;QACF;QAEA,IAAIJ,QAAQ;YACVa,cAAcb,MAAM,GAAGA;QACzB;QACA,IAAID,gBAAgB;YAClBc,cAAcd,cAAc,GAAGA;QACjC;QACA,IAAIE,QAAQ;YACVY,cAAcZ,MAAM,GAAGA;QACzB;QAEA,MAAMe,SAAS,MAAMX,QAAQY,YAAY,CAACJ;QAE1C,OAAO;YACLK,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAE3C,WAAW,qCAAqC,EAAE4C,KAAKC,SAAS,CAACN,QAAQ,QAAQ,CAAC;gBACrG;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,sBAAsB,EAAE/C,WAAW,EAAE,EAAEgD,cAAc;QACnE,OAAO;YACLP,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,uBAAuB,EAAE3C,WAAW,GAAG,EAAEgD,cAAc;gBAAC;aAAE;QAC7F;IACF;AACF,GAAE"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from '@modelcontextprotocol/server';
2
- import type { AuthCollectionSlug, CollectionSlug, GlobalSlug, MaybePromise, PayloadRequest, SanitizedPermissions, User } from 'payload';
2
+ import type { AuthCollectionSlug, CollectionSlug, GlobalSlug, MaybePromise, PayloadRequest, SanitizedPermissions } from 'payload';
3
3
  import type { GetAuthorizedMCPArgs } from './endpoint/access.js';
4
4
  import type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName } from './mcp/builtinTools.js';
5
5
  export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName };
@@ -55,6 +55,11 @@ export type GlobalToolHandlerArgs<TSchema = undefined> = {
55
55
  globalSlug: GlobalSlug;
56
56
  } & ToolHandlerArgs<TSchema>;
57
57
  export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
58
+ /**
59
+ * Runs while authorizing each MCP request, before the tool is advertised or called. Return
60
+ * `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`
61
+ * is enabled.
62
+ */
58
63
  access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
59
64
  annotations?: ToolAnnotations;
60
65
  description: string;
@@ -66,11 +71,23 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
66
71
  overrideResponse?: MCPResponseOverride;
67
72
  };
68
73
  export type CollectionTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
74
+ /**
75
+ * Runs while authorizing each MCP request for this collection. Return `false` to reject calls
76
+ * to this tool for the collection. The shared tool is not advertised when no collections allow
77
+ * it, but can remain advertised when it is available for another collection. This is skipped
78
+ * when `overrideAccess` is enabled.
79
+ */
69
80
  access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
70
81
  handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
71
82
  input?: TSchema;
72
83
  } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>;
73
84
  export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
85
+ /**
86
+ * Runs while authorizing each MCP request for this global. Return `false` to reject calls to
87
+ * this tool for the global. The shared tool is not advertised when no globals allow it, but
88
+ * can remain advertised when it is available for another global. This is skipped when
89
+ * `overrideAccess` is enabled.
90
+ */
74
91
  access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
75
92
  handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
76
93
  input?: TSchema;
@@ -81,6 +98,10 @@ export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSc
81
98
  * required handler) from being silently accepted at a built-in key slot.
82
99
  */
83
100
  export type MCPBuiltInCollectionToolOverride = {
101
+ /**
102
+ * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
103
+ * this collection. This is skipped when `overrideAccess` is enabled.
104
+ */
84
105
  access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
85
106
  annotations?: ToolAnnotations;
86
107
  description?: string;
@@ -88,6 +109,10 @@ export type MCPBuiltInCollectionToolOverride = {
88
109
  overrideResponse?: MCPResponseOverride;
89
110
  };
90
111
  export type MCPBuiltInGlobalToolOverride = {
112
+ /**
113
+ * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
114
+ * this global. This is skipped when `overrideAccess` is enabled.
115
+ */
91
116
  access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
92
117
  annotations?: ToolAnnotations;
93
118
  description?: string;
@@ -122,6 +147,11 @@ export type PromptHandlerArgs<TSchema = undefined> = {
122
147
  serverContext: ServerContext;
123
148
  };
124
149
  export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
150
+ /**
151
+ * Runs while authorizing each MCP request, before the prompt is advertised or used. Return
152
+ * `false` to make the prompt unavailable for that request. This is skipped when
153
+ * `overrideAccess` is enabled.
154
+ */
125
155
  access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
126
156
  argsSchema: TSchema;
127
157
  description: string;
@@ -144,6 +174,11 @@ export type ResourceHandlerArgs = {
144
174
  uri: URL;
145
175
  };
146
176
  export type Resource = {
177
+ /**
178
+ * Runs while authorizing each MCP request, before the resource is advertised or read. Return
179
+ * `false` to make the resource unavailable for that request. This is skipped when
180
+ * `overrideAccess` is enabled.
181
+ */
147
182
  access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
148
183
  description: string;
149
184
  handler: (args: ResourceHandlerArgs) => MaybePromise<{
@@ -191,7 +226,12 @@ export type MCPPluginConfig = {
191
226
  serverOptions?: MCPServerOptions;
192
227
  verboseLogs?: boolean;
193
228
  };
194
- /** Replace the default MCP authorization resolver. */
229
+ /**
230
+ * Replace the default MCP authorization resolver.
231
+ *
232
+ * This hook replaces the default authentication flow. It must set `req.user` to the
233
+ * authenticated Payload user, or to `null` for an anonymous caller, before returning.
234
+ */
195
235
  overrideGetAuthorizedMCP?: (args: {
196
236
  pluginConfig: SanitizedMCPPluginConfig;
197
237
  } & GetAuthorizedMCPArgs) => MaybePromise<AuthorizedMCP>;
@@ -241,14 +281,11 @@ export type MCPItem = ({
241
281
  type: 'tool';
242
282
  } & MCPItemBase) | CollectionMCPItem | GlobalMCPItem;
243
283
  /**
244
- * The caller's identity + the MCP items authorized for this request. Disabled
245
- * items and items blocked by access callbacks or Payload operation access are
246
- * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
247
- * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
284
+ * The MCP items and access mode authorized for this request. The authenticated user is available
285
+ * as `req.user`.
248
286
  */
249
287
  export type AuthorizedMCP = {
250
288
  items: MCPItem[];
251
289
  overrideAccess: boolean;
252
- user: null | User;
253
290
  };
254
291
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,s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IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,WAAW,CAAC,GAChB,CAAC;IACC,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,WAAW,CAAC,GAChB,iBAAiB,GACjB,aAAa,CAAA;AAEjB;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;CACxB,CAAA"}
package/dist/types.js CHANGED
@@ -1,8 +1,6 @@
1
1
  /**
2
- * The caller's identity + the MCP items authorized for this request. Disabled
3
- * items and items blocked by access callbacks or Payload operation access are
4
- * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
5
- * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
2
+ * The MCP items and access mode authorized for this request. The authenticated user is available
3
+ * as `req.user`.
6
4
  */ export { };
7
5
 
8
6
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionSlug,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n SanitizedPermissions,\n User,\n} from 'payload'\n\nimport type { GetAuthorizedMCPArgs } from './endpoint/access.js'\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */\nexport type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).\n * Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\nexport type MCPAfterToolCallHook = (args: {\n input: unknown\n req: PayloadRequest\n response: MCPToolResponse\n toolName: string\n}) => MaybePromise<MCPToolResponse>\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type MCPAccessArgs = {\n permissions?: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type CollectionMCPAccessArgs = {\n collectionSlug: CollectionSlug\n} & MCPAccessArgs\n\nexport type GlobalMCPAccessArgs = {\n globalSlug: GlobalSlug\n} & MCPAccessArgs\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInCollectionToolOverride = {\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP endpoint registration. */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n hooks?: {\n /** Transform a tool response after its handler returns */\n afterToolCall?: MCPAfterToolCallHook[]\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /** Replace the default MCP authorization resolver. */\n overrideGetAuthorizedMCP?: (\n args: {\n pluginConfig: SanitizedMCPPluginConfig\n } & GetAuthorizedMCPArgs,\n ) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * One MCP primitive plus the metadata needed for config-driven filtering and\n * registration.\n *\n * - `configKey`: the config identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable display text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The caller's identity + the MCP items authorized for this request. Disabled\n * items and items blocked by access callbacks or Payload operation access are\n * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so\n * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | User\n}\n"],"names":[],"mappings":"AAyTA;;;;;CAKC,GACD,WAIC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionSlug,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n SanitizedPermissions,\n} from 'payload'\n\nimport type { GetAuthorizedMCPArgs } from './endpoint/access.js'\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */\nexport type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).\n * Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\nexport type MCPAfterToolCallHook = (args: {\n input: unknown\n req: PayloadRequest\n response: MCPToolResponse\n toolName: string\n}) => MaybePromise<MCPToolResponse>\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type MCPAccessArgs = {\n permissions?: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type CollectionMCPAccessArgs = {\n collectionSlug: CollectionSlug\n} & MCPAccessArgs\n\nexport type GlobalMCPAccessArgs = {\n globalSlug: GlobalSlug\n} & MCPAccessArgs\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n /**\n * Runs while authorizing each MCP request, before the tool is advertised or called. Return\n * `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`\n * is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n /**\n * Runs while authorizing each MCP request for this collection. Return `false` to reject calls\n * to this tool for the collection. The shared tool is not advertised when no collections allow\n * it, but can remain advertised when it is available for another collection. This is skipped\n * when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n /**\n * Runs while authorizing each MCP request for this global. Return `false` to reject calls to\n * this tool for the global. The shared tool is not advertised when no globals allow it, but\n * can remain advertised when it is available for another global. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInCollectionToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this collection. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\n /**\n * Replaces the built-in tool's access check. Return `false` to make the tool unavailable for\n * this global. This is skipped when `overrideAccess` is enabled.\n */\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n /**\n * Runs while authorizing each MCP request, before the prompt is advertised or used. Return\n * `false` to make the prompt unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n /**\n * Runs while authorizing each MCP request, before the resource is advertised or read. Return\n * `false` to make the resource unavailable for that request. This is skipped when\n * `overrideAccess` is enabled.\n */\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP endpoint registration. */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n hooks?: {\n /** Transform a tool response after its handler returns */\n afterToolCall?: MCPAfterToolCallHook[]\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /**\n * Replace the default MCP authorization resolver.\n *\n * This hook replaces the default authentication flow. It must set `req.user` to the\n * authenticated Payload user, or to `null` for an anonymous caller, before returning.\n */\n overrideGetAuthorizedMCP?: (\n args: {\n pluginConfig: SanitizedMCPPluginConfig\n } & GetAuthorizedMCPArgs,\n ) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * One MCP primitive plus the metadata needed for config-driven filtering and\n * registration.\n *\n * - `configKey`: the config identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable display text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The MCP items and access mode authorized for this request. The authenticated user is available\n * as `req.user`.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n}\n"],"names":[],"mappings":"AAgWA;;;CAGC,GACD,WAGC"}
@@ -0,0 +1,28 @@
1
+ import type { FlattenedBlock, FlattenedField, Operation, SanitizedDocumentPermissions } from 'payload';
2
+ type FieldOperation = Exclude<Operation, 'delete'>;
3
+ type AllowedFieldOperations = Record<FieldOperation, boolean>;
4
+ /**
5
+ * Filters fields using the access results in `permissions`. `shouldExcludeField` receives the
6
+ * operations allowed by the entity, field, and its parents and decides whether to remove the
7
+ * field.
8
+ *
9
+ * Arrays, groups, named tabs, and blocks are filtered recursively. Rows and unnamed tabs are
10
+ * flattened by Payload, so their children are filtered at the containing level.
11
+ *
12
+ * @example Include fields writable through any collection operation the user can perform.
13
+ * ```ts
14
+ * filterFieldsByAccess({
15
+ * fields,
16
+ * permissions: collectionPermissions,
17
+ * shouldExcludeField: ({ create, update }) => !create && !update,
18
+ * })
19
+ * ```
20
+ */
21
+ export declare const filterFieldsByAccess: ({ blocks, fields, permissions, shouldExcludeField, }: {
22
+ blocks?: FlattenedBlock[];
23
+ fields: FlattenedField[];
24
+ permissions: SanitizedDocumentPermissions;
25
+ shouldExcludeField: (allowedOperations: AllowedFieldOperations) => boolean;
26
+ }) => FlattenedField[];
27
+ export {};
28
+ //# sourceMappingURL=filterFieldsByAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterFieldsByAccess.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/filterFieldsByAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,SAAS,EACT,4BAA4B,EAE7B,MAAM,SAAS,CAAA;AAEhB,KAAK,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAClD,KAAK,sBAAsB,GAAG,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,GAAI,sDAKlC;IACD,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;IACzB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,WAAW,EAAE,4BAA4B,CAAA;IACzC,kBAAkB,EAAE,CAAC,iBAAiB,EAAE,sBAAsB,KAAK,OAAO,CAAA;CAC3E,KAAG,cAAc,EAoFjB,CAAA"}