@payloadcms/plugin-mcp 4.0.0-canary.1 → 4.0.0-canary.10

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 (222) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +7 -0
  3. package/dist/defaultAccess.d.ts +3 -0
  4. package/dist/defaultAccess.d.ts.map +1 -0
  5. package/dist/defaultAccess.js +3 -0
  6. package/dist/defaultAccess.js.map +1 -0
  7. package/dist/defineTool.d.ts +8 -8
  8. package/dist/defineTool.d.ts.map +1 -1
  9. package/dist/endpoint/access.d.ts +12 -5
  10. package/dist/endpoint/access.d.ts.map +1 -1
  11. package/dist/endpoint/access.js +75 -88
  12. package/dist/endpoint/access.js.map +1 -1
  13. package/dist/endpoint/index.d.ts +1 -1
  14. package/dist/endpoint/index.d.ts.map +1 -1
  15. package/dist/endpoint/index.js +68 -17
  16. package/dist/endpoint/index.js.map +1 -1
  17. package/dist/exports/client.d.ts +1 -1
  18. package/dist/exports/client.d.ts.map +1 -1
  19. package/dist/exports/client.js +1 -1
  20. package/dist/exports/client.js.map +1 -1
  21. package/dist/exports/internal.d.ts +2 -0
  22. package/dist/exports/internal.d.ts.map +1 -0
  23. package/dist/exports/internal.js +3 -0
  24. package/dist/exports/internal.js.map +1 -0
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +15 -20
  28. package/dist/index.js.map +1 -1
  29. package/dist/mcp/buildMcpServer.d.ts +4 -4
  30. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  31. package/dist/mcp/buildMcpServer.js +34 -10
  32. package/dist/mcp/buildMcpServer.js.map +1 -1
  33. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  34. package/dist/mcp/builtin/collections/authTools.js +44 -6
  35. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  36. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  37. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  38. package/dist/mcp/builtin/collections/countTool.js +68 -0
  39. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  40. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  41. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  42. package/dist/mcp/builtin/collections/countVersionsTool.js +64 -0
  43. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  44. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  45. package/dist/mcp/builtin/collections/createTool.js +26 -24
  46. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  47. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  48. package/dist/mcp/builtin/collections/deleteTool.js +10 -2
  49. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  50. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  51. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  52. package/dist/mcp/builtin/collections/duplicateTool.js +96 -0
  53. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  54. package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
  55. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  56. package/dist/mcp/builtin/collections/fileInput.js +100 -0
  57. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  58. package/dist/mcp/builtin/collections/fileInput.spec.js +72 -0
  59. package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
  60. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  61. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  62. package/dist/mcp/builtin/collections/findDistinctTool.js +92 -0
  63. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  64. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  65. package/dist/mcp/builtin/collections/findTool.js +46 -26
  66. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  67. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  68. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  69. package/dist/mcp/builtin/collections/findVersionByIDTool.js +83 -0
  70. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  71. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  72. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  73. package/dist/mcp/builtin/collections/findVersionsTool.js +98 -0
  74. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  75. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  76. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  77. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
  78. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  79. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +55 -4
  80. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  81. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  82. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  83. package/dist/mcp/builtin/collections/restoreVersionTool.js +81 -0
  84. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  85. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  86. package/dist/mcp/builtin/collections/updateTool.js +37 -32
  87. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  88. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  89. package/dist/mcp/builtin/getConfigInfoTool.js +27 -8
  90. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  91. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  92. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  93. package/dist/mcp/builtin/globals/countVersionsTool.js +64 -0
  94. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  95. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  96. package/dist/mcp/builtin/globals/findTool.js +19 -22
  97. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  98. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  99. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  100. package/dist/mcp/builtin/globals/findVersionByIDTool.js +79 -0
  101. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  102. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  103. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  104. package/dist/mcp/builtin/globals/findVersionsTool.js +94 -0
  105. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  106. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  107. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +32 -2
  108. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  109. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  110. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  111. package/dist/mcp/builtin/globals/restoreVersionTool.js +77 -0
  112. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  113. package/dist/mcp/builtin/globals/updateTool.js +14 -21
  114. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  115. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
  116. package/dist/mcp/builtin/validateEntityData.js +1 -1
  117. package/dist/mcp/builtin/validateEntityData.js.map +1 -1
  118. package/dist/mcp/builtinTools.d.ts +69 -12
  119. package/dist/mcp/builtinTools.d.ts.map +1 -1
  120. package/dist/mcp/builtinTools.js +66 -10
  121. package/dist/mcp/builtinTools.js.map +1 -1
  122. package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
  123. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  124. package/dist/mcp/sanitizeMCPConfig.js +69 -27
  125. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  126. package/dist/stdio.d.ts +3 -3
  127. package/dist/stdio.d.ts.map +1 -1
  128. package/dist/stdio.js +82 -45
  129. package/dist/stdio.js.map +1 -1
  130. package/dist/types.d.ts +100 -87
  131. package/dist/types.d.ts.map +1 -1
  132. package/dist/types.js +2 -4
  133. package/dist/types.js.map +1 -1
  134. package/dist/utils/camelCase.d.ts.map +1 -1
  135. package/dist/utils/getPluginConfig.d.ts +1 -1
  136. package/dist/utils/getPluginConfig.js +1 -1
  137. package/dist/utils/getPluginConfig.js.map +1 -1
  138. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  139. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
  140. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
  141. package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
  142. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
  143. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
  144. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
  145. package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
  146. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
  147. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
  148. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
  149. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
  150. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
  151. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
  152. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
  153. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  154. package/package.json +10 -15
  155. package/src/defaultAccess.ts +3 -0
  156. package/src/endpoint/access.ts +81 -101
  157. package/src/endpoint/index.ts +58 -16
  158. package/src/exports/client.ts +2 -1
  159. package/src/exports/internal.ts +1 -0
  160. package/src/index.ts +12 -20
  161. package/src/mcp/buildMcpServer.ts +48 -21
  162. package/src/mcp/builtin/collections/authTools.ts +45 -9
  163. package/src/mcp/builtin/collections/countTool.ts +73 -0
  164. package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
  165. package/src/mcp/builtin/collections/createTool.ts +27 -18
  166. package/src/mcp/builtin/collections/deleteTool.ts +11 -2
  167. package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
  168. package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
  169. package/src/mcp/builtin/collections/fileInput.ts +139 -0
  170. package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
  171. package/src/mcp/builtin/collections/findTool.ts +59 -20
  172. package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
  173. package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
  174. package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
  175. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +51 -3
  176. package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
  177. package/src/mcp/builtin/collections/updateTool.ts +39 -23
  178. package/src/mcp/builtin/getConfigInfoTool.ts +27 -4
  179. package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
  180. package/src/mcp/builtin/globals/findTool.ts +27 -18
  181. package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
  182. package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
  183. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +37 -2
  184. package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
  185. package/src/mcp/builtin/globals/updateTool.ts +16 -16
  186. package/src/mcp/builtin/validateEntityData.ts +1 -1
  187. package/src/mcp/builtinTools.ts +72 -16
  188. package/src/mcp/sanitizeMCPConfig.ts +48 -30
  189. package/src/stdio.ts +77 -45
  190. package/src/types.ts +108 -90
  191. package/src/utils/getPluginConfig.ts +1 -1
  192. package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
  193. package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
  194. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
  195. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
  196. package/dist/collection/getAccessField.d.ts +0 -12
  197. package/dist/collection/getAccessField.d.ts.map +0 -1
  198. package/dist/collection/getAccessField.js +0 -57
  199. package/dist/collection/getAccessField.js.map +0 -1
  200. package/dist/collection/index.d.ts +0 -6
  201. package/dist/collection/index.d.ts.map +0 -1
  202. package/dist/collection/index.js +0 -60
  203. package/dist/collection/index.js.map +0 -1
  204. package/dist/components/AccessField/index.client.d.ts +0 -10
  205. package/dist/components/AccessField/index.client.d.ts.map +0 -1
  206. package/dist/components/AccessField/index.client.js +0 -305
  207. package/dist/components/AccessField/index.client.js.map +0 -1
  208. package/dist/components/AccessField/index.css +0 -93
  209. package/dist/utils/localAPIDefaults.d.ts +0 -20
  210. package/dist/utils/localAPIDefaults.d.ts.map +0 -1
  211. package/dist/utils/localAPIDefaults.js +0 -19
  212. package/dist/utils/localAPIDefaults.js.map +0 -1
  213. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  214. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  215. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  216. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  217. package/src/collection/getAccessField.ts +0 -64
  218. package/src/collection/index.ts +0 -64
  219. package/src/components/AccessField/index.client.tsx +0 -347
  220. package/src/components/AccessField/index.css +0 -93
  221. package/src/utils/localAPIDefaults.ts +0 -22
  222. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,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+1,4 @@
1
- import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server';
1
+ import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker';
2
2
  import { getCollectionInputSchema, getGlobalInputSchema } from '../../utils/schemaConversion/getEntityInputSchema.js';
3
3
  /**
4
4
  * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mcp/builtin/validateEntityData.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server'\n\nimport type { JsonSchemaType, MCPToolResponse } from '../../types.js'\n\nimport {\n getCollectionInputSchema,\n getGlobalInputSchema,\n} from '../../utils/schemaConversion/getEntityInputSchema.js'\n\n/**\n * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.\n */\nconst validator = new CfWorkerJsonSchemaValidator({ shortcircuit: true })\n\ntype EntityValidator = {\n schema: JsonSchemaType\n validate: ReturnType<(typeof validator)['getValidator']>\n}\n\n/**\n * - Caches each entity's schema and validator, so both are only built on the first request.\n * - Keyed by payload config, then by entity type, slug, partial and language.\n */\nconst validatorCache = new WeakMap<SanitizedConfig, Map<string, EntityValidator>>()\n\nexport const validateCollectionData = ({\n collectionSlug,\n data,\n partial,\n req,\n}: {\n collectionSlug: CollectionSlug\n data: Record<string, unknown>\n partial?: boolean\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: collectionSlug,\n buildSchema: () => getCollectionInputSchema({ collectionSlug, req }),\n data,\n entity: 'collection',\n partial,\n req,\n })\n\nexport const validateGlobalData = ({\n data,\n globalSlug,\n req,\n}: {\n data: Record<string, unknown>\n globalSlug: GlobalSlug\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: globalSlug,\n buildSchema: () => getGlobalInputSchema({ globalSlug, req }),\n data,\n entity: 'global',\n partial: true,\n req,\n })\n\nconst validateData = ({\n slug,\n buildSchema,\n data,\n entity,\n partial,\n req,\n}: {\n buildSchema: () => JsonSchemaType | null\n data: Record<string, unknown>\n entity: 'collection' | 'global'\n partial?: boolean\n req: PayloadRequest\n slug: string\n}): MCPToolResponse | null => {\n let cache = validatorCache.get(req.payload.config)\n if (!cache) {\n cache = new Map()\n validatorCache.set(req.payload.config, cache)\n }\n\n const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`\n let entityValidator = cache.get(cacheKey)\n\n if (!entityValidator) {\n const schema = buildSchema()\n\n if (!schema) {\n return null\n }\n\n entityValidator = {\n schema,\n validate: validator.getValidator(partial ? withoutRequired(schema) : schema),\n }\n cache.set(cacheKey, entityValidator)\n }\n\n const result = entityValidator.validate(data)\n\n if (result.valid) {\n return null\n }\n\n const { schema } = entityValidator\n\n return {\n content: [\n {\n type: 'text',\n text: `Invalid data for ${entity} \"${slug}\": ${result.errorMessage}\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(schema)}\\n\\`\\`\\``,\n },\n ],\n isError: true,\n structuredContent: {\n [`${entity}Slug`]: slug,\n errors: [{ message: result.errorMessage }],\n schema,\n },\n }\n}\n\n/** Updates are partial — drop the schema's top-level `required` before validating. */\nconst withoutRequired = (schema: JsonSchemaType): JsonSchemaType => {\n const { required: _required, ...rest } = schema\n return rest\n}\n"],"names":["CfWorkerJsonSchemaValidator","getCollectionInputSchema","getGlobalInputSchema","validator","shortcircuit","validatorCache","WeakMap","validateCollectionData","collectionSlug","data","partial","req","validateData","slug","buildSchema","entity","validateGlobalData","globalSlug","cache","get","payload","config","Map","set","cacheKey","i18n","language","entityValidator","schema","validate","getValidator","withoutRequired","result","valid","content","type","text","errorMessage","JSON","stringify","isError","structuredContent","errors","message","required","_required","rest"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,+BAA8B;AAI1E,SACEC,wBAAwB,EACxBC,oBAAoB,QACf,uDAAsD;AAE7D;;CAE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,IAAIuB,OAAOC,KAAK,EAAE;QAChB,OAAO;IACT;IAEA,MAAM,EAAEL,MAAM,EAAE,GAAGD;IAEnB,OAAO;QACLO,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,iBAAiB,EAAErB,OAAO,EAAE,EAAEF,KAAK,GAAG,EAAEmB,OAAOK,YAAY,CAAC,2CAA2C,EAAEC,KAAKC,SAAS,CAACX,QAAQ,QAAQ,CAAC;YAClJ;SACD;QACDY,SAAS;QACTC,mBAAmB;YACjB,CAAC,GAAG1B,OAAO,IAAI,CAAC,CAAC,EAAEF;YACnB6B,QAAQ;gBAAC;oBAAEC,SAASX,OAAOK,YAAY;gBAAC;aAAE;YAC1CT;QACF;IACF;AACF;AAEA,oFAAoF,GACpF,MAAMG,kBAAkB,CAACH;IACvB,MAAM,EAAEgB,UAAUC,SAAS,EAAE,GAAGC,MAAM,GAAGlB;IACzC,OAAOkB;AACT"}
1
+ {"version":3,"sources":["../../../src/mcp/builtin/validateEntityData.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker'\n\nimport type { JsonSchemaType, MCPToolResponse } from '../../types.js'\n\nimport {\n getCollectionInputSchema,\n getGlobalInputSchema,\n} from '../../utils/schemaConversion/getEntityInputSchema.js'\n\n/**\n * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.\n */\nconst validator = new CfWorkerJsonSchemaValidator({ shortcircuit: true })\n\ntype EntityValidator = {\n schema: JsonSchemaType\n validate: ReturnType<(typeof validator)['getValidator']>\n}\n\n/**\n * - Caches each entity's schema and validator, so both are only built on the first request.\n * - Keyed by payload config, then by entity type, slug, partial and language.\n */\nconst validatorCache = new WeakMap<SanitizedConfig, Map<string, EntityValidator>>()\n\nexport const validateCollectionData = ({\n collectionSlug,\n data,\n partial,\n req,\n}: {\n collectionSlug: CollectionSlug\n data: Record<string, unknown>\n partial?: boolean\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: collectionSlug,\n buildSchema: () => getCollectionInputSchema({ collectionSlug, req }),\n data,\n entity: 'collection',\n partial,\n req,\n })\n\nexport const validateGlobalData = ({\n data,\n globalSlug,\n req,\n}: {\n data: Record<string, unknown>\n globalSlug: GlobalSlug\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: globalSlug,\n buildSchema: () => getGlobalInputSchema({ globalSlug, req }),\n data,\n entity: 'global',\n partial: true,\n req,\n })\n\nconst validateData = ({\n slug,\n buildSchema,\n data,\n entity,\n partial,\n req,\n}: {\n buildSchema: () => JsonSchemaType | null\n data: Record<string, unknown>\n entity: 'collection' | 'global'\n partial?: boolean\n req: PayloadRequest\n slug: string\n}): MCPToolResponse | null => {\n let cache = validatorCache.get(req.payload.config)\n if (!cache) {\n cache = new Map()\n validatorCache.set(req.payload.config, cache)\n }\n\n const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`\n let entityValidator = cache.get(cacheKey)\n\n if (!entityValidator) {\n const schema = buildSchema()\n\n if (!schema) {\n return null\n }\n\n entityValidator = {\n schema,\n validate: validator.getValidator(partial ? withoutRequired(schema) : schema),\n }\n cache.set(cacheKey, entityValidator)\n }\n\n const result = entityValidator.validate(data)\n\n if (result.valid) {\n return null\n }\n\n const { schema } = entityValidator\n\n return {\n content: [\n {\n type: 'text',\n text: `Invalid data for ${entity} \"${slug}\": ${result.errorMessage}\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(schema)}\\n\\`\\`\\``,\n },\n ],\n isError: true,\n structuredContent: {\n [`${entity}Slug`]: slug,\n errors: [{ message: result.errorMessage }],\n schema,\n },\n }\n}\n\n/** Updates are partial — drop the schema's top-level `required` before validating. */\nconst withoutRequired = (schema: JsonSchemaType): JsonSchemaType => {\n const { required: _required, ...rest } = schema\n return rest\n}\n"],"names":["CfWorkerJsonSchemaValidator","getCollectionInputSchema","getGlobalInputSchema","validator","shortcircuit","validatorCache","WeakMap","validateCollectionData","collectionSlug","data","partial","req","validateData","slug","buildSchema","entity","validateGlobalData","globalSlug","cache","get","payload","config","Map","set","cacheKey","i18n","language","entityValidator","schema","validate","getValidator","withoutRequired","result","valid","content","type","text","errorMessage","JSON","stringify","isError","structuredContent","errors","message","required","_required","rest"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,oDAAmD;AAI/F,SACEC,wBAAwB,EACxBC,oBAAoB,QACf,uDAAsD;AAE7D;;CAEC,GACD,MAAMC,YAAY,IAAIH,4BAA4B;IAAEI,cAAc;AAAK;AAOvE;;;CAGC,GACD,MAAMC,iBAAiB,IAAIC;AAE3B,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,cAAc,EACdC,IAAI,EACJC,OAAO,EACPC,GAAG,EAMJ,GACCC,aAAa;QACXC,MAAML;QACNM,aAAa,IAAMb,yBAAyB;gBAAEO;gBAAgBG;YAAI;QAClEF;QACAM,QAAQ;QACRL;QACAC;IACF,GAAE;AAEJ,OAAO,MAAMK,qBAAqB,CAAC,EACjCP,IAAI,EACJQ,UAAU,EACVN,GAAG,EAKJ,GACCC,aAAa;QACXC,MAAMI;QACNH,aAAa,IAAMZ,qBAAqB;gBAAEe;gBAAYN;YAAI;QAC1DF;QACAM,QAAQ;QACRL,SAAS;QACTC;IACF,GAAE;AAEJ,MAAMC,eAAe,CAAC,EACpBC,IAAI,EACJC,WAAW,EACXL,IAAI,EACJM,MAAM,EACNL,OAAO,EACPC,GAAG,EAQJ;IACC,IAAIO,QAAQb,eAAec,GAAG,CAACR,IAAIS,OAAO,CAACC,MAAM;IACjD,IAAI,CAACH,OAAO;QACVA,QAAQ,IAAII;QACZjB,eAAekB,GAAG,CAACZ,IAAIS,OAAO,CAACC,MAAM,EAAEH;IACzC;IAEA,MAAMM,WAAW,GAAGT,OAAO,CAAC,EAAEF,KAAK,CAAC,EAAEH,UAAU,YAAY,OAAO,CAAC,EAAEC,IAAIc,IAAI,CAACC,QAAQ,EAAE;IACzF,IAAIC,kBAAkBT,MAAMC,GAAG,CAACK;IAEhC,IAAI,CAACG,iBAAiB;QACpB,MAAMC,SAASd;QAEf,IAAI,CAACc,QAAQ;YACX,OAAO;QACT;QAEAD,kBAAkB;YAChBC;YACAC,UAAU1B,UAAU2B,YAAY,CAACpB,UAAUqB,gBAAgBH,UAAUA;QACvE;QACAV,MAAMK,GAAG,CAACC,UAAUG;IACtB;IAEA,MAAMK,SAASL,gBAAgBE,QAAQ,CAACpB;IAExC,IAAIuB,OAAOC,KAAK,EAAE;QAChB,OAAO;IACT;IAEA,MAAM,EAAEL,MAAM,EAAE,GAAGD;IAEnB,OAAO;QACLO,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,iBAAiB,EAAErB,OAAO,EAAE,EAAEF,KAAK,GAAG,EAAEmB,OAAOK,YAAY,CAAC,2CAA2C,EAAEC,KAAKC,SAAS,CAACX,QAAQ,QAAQ,CAAC;YAClJ;SACD;QACDY,SAAS;QACTC,mBAAmB;YACjB,CAAC,GAAG1B,OAAO,IAAI,CAAC,CAAC,EAAEF;YACnB6B,QAAQ;gBAAC;oBAAEC,SAASX,OAAOK,YAAY;gBAAC;aAAE;YAC1CT;QACF;IACF;AACF;AAEA,oFAAoF,GACpF,MAAMG,kBAAkB,CAACH;IACvB,MAAM,EAAEgB,UAAUC,SAAS,EAAE,GAAGC,MAAM,GAAGlB;IACzC,OAAOkB;AACT"}
@@ -1,7 +1,17 @@
1
1
  import type { CollectionTool, GlobalTool, Tool } from '../types.js';
2
+ type CollectionBuiltin = {
3
+ mcpName: string;
4
+ requiresDuplicateEnabled?: boolean;
5
+ requiresVersions?: boolean;
6
+ tool: CollectionTool;
7
+ };
8
+ type GlobalBuiltin = {
9
+ mcpName: string;
10
+ requiresVersions?: boolean;
11
+ tool: GlobalTool;
12
+ };
2
13
  export declare const TOOL_BUILTINS: {
3
14
  getConfigInfo: {
4
- label: string;
5
15
  mcpName: string;
6
16
  tool: Tool;
7
17
  };
@@ -12,6 +22,15 @@ export declare const TOOL_BUILTINS: {
12
22
  * automatically.
13
23
  */
14
24
  export declare const COLLECTION_BUILTINS: {
25
+ count: {
26
+ mcpName: string;
27
+ tool: CollectionTool;
28
+ };
29
+ countVersions: {
30
+ mcpName: string;
31
+ requiresVersions: true;
32
+ tool: CollectionTool;
33
+ };
15
34
  create: {
16
35
  mcpName: string;
17
36
  tool: CollectionTool;
@@ -20,52 +39,69 @@ export declare const COLLECTION_BUILTINS: {
20
39
  mcpName: string;
21
40
  tool: CollectionTool;
22
41
  };
42
+ duplicate: {
43
+ mcpName: string;
44
+ requiresDuplicateEnabled: true;
45
+ tool: CollectionTool;
46
+ };
23
47
  find: {
24
48
  mcpName: string;
25
49
  tool: CollectionTool;
26
50
  };
51
+ findDistinct: {
52
+ mcpName: string;
53
+ tool: CollectionTool;
54
+ };
55
+ findVersionByID: {
56
+ mcpName: string;
57
+ requiresVersions: true;
58
+ tool: CollectionTool;
59
+ };
60
+ findVersions: {
61
+ mcpName: string;
62
+ requiresVersions: true;
63
+ tool: CollectionTool;
64
+ };
27
65
  getCollectionSchema: {
28
66
  mcpName: string;
29
67
  tool: CollectionTool;
30
68
  };
69
+ restoreVersion: {
70
+ mcpName: string;
71
+ requiresVersions: true;
72
+ tool: CollectionTool;
73
+ };
31
74
  update: {
32
75
  mcpName: string;
33
76
  tool: CollectionTool;
34
77
  };
35
78
  };
36
79
  /**
37
- * The static auth tools surfaced under auth-enabled collections. Each entry
38
- * carries the admin-UI label alongside the tool. Keys are the source of truth
39
- * for `MCPCollectionAuthToolName`.
80
+ * The static auth tools surfaced under auth-enabled collections. Keys are the
81
+ * source of truth for `MCPCollectionAuthToolName`.
40
82
  */
41
83
  export declare const COLLECTION_AUTH_BUILTINS: {
42
84
  auth: {
43
- label: string;
44
85
  mcpName: string;
45
86
  tool: CollectionTool;
46
87
  };
47
88
  forgotPassword: {
48
- label: string;
49
89
  mcpName: string;
50
90
  tool: CollectionTool;
51
91
  };
52
92
  login: {
53
- label: string;
54
93
  mcpName: string;
55
94
  tool: CollectionTool;
56
95
  };
57
96
  resetPassword: {
58
- label: string;
59
97
  mcpName: string;
60
98
  tool: CollectionTool;
61
99
  };
62
100
  unlock: {
63
- label: string;
64
101
  mcpName: string;
65
102
  tool: CollectionTool;
66
103
  };
67
104
  verify: {
68
- label: string;
69
105
  mcpName: string;
70
106
  tool: CollectionTool;
71
107
  };
@@ -75,14 +111,34 @@ export declare const COLLECTION_AUTH_BUILTINS: {
75
111
  * `MCPGlobalBuiltinName`.
76
112
  */
77
113
  export declare const GLOBAL_BUILTINS: {
114
+ countGlobalVersions: {
115
+ mcpName: string;
116
+ requiresVersions: true;
117
+ tool: GlobalTool;
118
+ };
78
119
  find: {
79
120
  mcpName: string;
80
121
  tool: GlobalTool;
81
122
  };
123
+ findGlobalVersionByID: {
124
+ mcpName: string;
125
+ requiresVersions: true;
126
+ tool: GlobalTool;
127
+ };
128
+ findGlobalVersions: {
129
+ mcpName: string;
130
+ requiresVersions: true;
131
+ tool: GlobalTool;
132
+ };
82
133
  getGlobalSchema: {
83
134
  mcpName: string;
84
135
  tool: GlobalTool;
85
136
  };
137
+ restoreGlobalVersion: {
138
+ mcpName: string;
139
+ requiresVersions: true;
140
+ tool: GlobalTool;
141
+ };
86
142
  update: {
87
143
  mcpName: string;
88
144
  tool: GlobalTool;
@@ -99,7 +155,8 @@ export type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS;
99
155
  * defeats the narrow type lookups on `MCPCollectionToolsMap`.
100
156
  */
101
157
  export declare const TOOL_BUILTIN_ENTRIES: Array<[MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]>;
102
- export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, (typeof COLLECTION_BUILTINS)[MCPCollectionBuiltinName]]>;
158
+ export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, CollectionBuiltin]>;
103
159
  export declare const COLLECTION_AUTH_BUILTIN_ENTRIES: Array<[MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]>;
104
- export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, (typeof GLOBAL_BUILTINS)[MCPGlobalBuiltinName]]>;
160
+ export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, GlobalBuiltin]>;
161
+ export {};
105
162
  //# sourceMappingURL=builtinTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAoBnE,eAAO,MAAM,aAAa;;;;;;CAEgD,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;CAMqC,CAAA;AAErE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAe+C,CAAA;AAEpF;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAIqC,CAAA;AAEjE,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AAEvE,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,eAAe,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,aAAa,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAoC,KAAK,CACxE,CAAC,sBAAsB,EAAE,CAAC,OAAO,aAAa,EAAE,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAw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G,OAAO;QAAW,IAAI;;;QAE7B,OAAO;QACP,IAAI;;;QAEI,OAAO;QAAY,IAAI;;;QACvB,OAAO;QAAY,IAAI;;CACkC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;QAMlB,OAAO;QAAgB,IAAI;;;;;;;;;;;;;QAWhB,OAAO;QAAqB,IAAI;;;;;;;;QAMzC,OAAO;QAAkB,IAAI;;CACA,CAAA;AAEzC,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AAEvE,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,eAAe,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,aAAa,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAoC,KAAK,CACxE,CAAC,sBAAsB,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAC9C,CAAA;AAED,eAAO,MAAM,+BAA+B,EAA+C,KAAK,CAC9F,CAAC,yBAAyB,EAAE,CAAC,OAAO,wBAAwB,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAC1F,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAsC,KAAK,CAC5E,CAAC,oBAAoB,EAAE,aAAa,CAAC,CACtC,CAAA"}
@@ -1,16 +1,26 @@
1
1
  import { authCollectionTool, forgotPasswordCollectionTool, loginCollectionTool, resetPasswordCollectionTool, unlockCollectionTool, verifyCollectionTool } from './builtin/collections/authTools.js';
2
+ import { countDocumentsTool } from './builtin/collections/countTool.js';
3
+ import { countVersionsTool } from './builtin/collections/countVersionsTool.js';
2
4
  import { createDocumentTool } from './builtin/collections/createTool.js';
3
5
  import { deleteDocumentsTool } from './builtin/collections/deleteTool.js';
6
+ import { duplicateDocumentTool } from './builtin/collections/duplicateTool.js';
7
+ import { findDistinctTool } from './builtin/collections/findDistinctTool.js';
4
8
  import { findDocumentsTool } from './builtin/collections/findTool.js';
9
+ import { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js';
10
+ import { findVersionsTool } from './builtin/collections/findVersionsTool.js';
5
11
  import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js';
12
+ import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js';
6
13
  import { updateDocumentTool } from './builtin/collections/updateTool.js';
7
14
  import { getConfigInfoTool } from './builtin/getConfigInfoTool.js';
15
+ import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js';
8
16
  import { findGlobalTool } from './builtin/globals/findTool.js';
17
+ import { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js';
18
+ import { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js';
9
19
  import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js';
20
+ import { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js';
10
21
  import { updateGlobalTool } from './builtin/globals/updateTool.js';
11
22
  export const TOOL_BUILTINS = {
12
23
  getConfigInfo: {
13
- label: 'Config Info',
14
24
  mcpName: 'getConfigInfo',
15
25
  tool: getConfigInfoTool
16
26
  }
@@ -20,6 +30,15 @@ export const TOOL_BUILTINS = {
20
30
  * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
21
31
  * automatically.
22
32
  */ export const COLLECTION_BUILTINS = {
33
+ count: {
34
+ mcpName: 'countDocuments',
35
+ tool: countDocumentsTool
36
+ },
37
+ countVersions: {
38
+ mcpName: 'countVersions',
39
+ requiresVersions: true,
40
+ tool: countVersionsTool
41
+ },
23
42
  create: {
24
43
  mcpName: 'createDocument',
25
44
  tool: createDocumentTool
@@ -28,51 +47,68 @@ export const TOOL_BUILTINS = {
28
47
  mcpName: 'deleteDocuments',
29
48
  tool: deleteDocumentsTool
30
49
  },
50
+ duplicate: {
51
+ mcpName: 'duplicateDocument',
52
+ requiresDuplicateEnabled: true,
53
+ tool: duplicateDocumentTool
54
+ },
31
55
  find: {
32
56
  mcpName: 'findDocuments',
33
57
  tool: findDocumentsTool
34
58
  },
59
+ findDistinct: {
60
+ mcpName: 'findDistinct',
61
+ tool: findDistinctTool
62
+ },
63
+ findVersionByID: {
64
+ mcpName: 'findVersionByID',
65
+ requiresVersions: true,
66
+ tool: findVersionByIDTool
67
+ },
68
+ findVersions: {
69
+ mcpName: 'findVersions',
70
+ requiresVersions: true,
71
+ tool: findVersionsTool
72
+ },
35
73
  getCollectionSchema: {
36
74
  mcpName: 'getCollectionSchema',
37
75
  tool: getCollectionSchemaTool
38
76
  },
77
+ restoreVersion: {
78
+ mcpName: 'restoreVersion',
79
+ requiresVersions: true,
80
+ tool: restoreVersionTool
81
+ },
39
82
  update: {
40
83
  mcpName: 'updateDocument',
41
84
  tool: updateDocumentTool
42
85
  }
43
86
  };
44
87
  /**
45
- * The static auth tools surfaced under auth-enabled collections. Each entry
46
- * carries the admin-UI label alongside the tool. Keys are the source of truth
47
- * for `MCPCollectionAuthToolName`.
88
+ * The static auth tools surfaced under auth-enabled collections. Keys are the
89
+ * source of truth for `MCPCollectionAuthToolName`.
48
90
  */ export const COLLECTION_AUTH_BUILTINS = {
49
91
  auth: {
50
- label: 'Check Auth Status',
51
92
  mcpName: 'auth',
52
93
  tool: authCollectionTool
53
94
  },
54
95
  forgotPassword: {
55
- label: 'Forgot Password',
56
96
  mcpName: 'forgotPassword',
57
97
  tool: forgotPasswordCollectionTool
58
98
  },
59
99
  login: {
60
- label: 'User Login',
61
100
  mcpName: 'login',
62
101
  tool: loginCollectionTool
63
102
  },
64
103
  resetPassword: {
65
- label: 'Reset Password',
66
104
  mcpName: 'resetPassword',
67
105
  tool: resetPasswordCollectionTool
68
106
  },
69
107
  unlock: {
70
- label: 'Unlock Account',
71
108
  mcpName: 'unlock',
72
109
  tool: unlockCollectionTool
73
110
  },
74
111
  verify: {
75
- label: 'Email Verification',
76
112
  mcpName: 'verify',
77
113
  tool: verifyCollectionTool
78
114
  }
@@ -81,14 +117,34 @@ export const TOOL_BUILTINS = {
81
117
  * The static built-in global tools. Keys are the source of truth for
82
118
  * `MCPGlobalBuiltinName`.
83
119
  */ export const GLOBAL_BUILTINS = {
120
+ countGlobalVersions: {
121
+ mcpName: 'countGlobalVersions',
122
+ requiresVersions: true,
123
+ tool: countGlobalVersionsTool
124
+ },
84
125
  find: {
85
126
  mcpName: 'findGlobal',
86
127
  tool: findGlobalTool
87
128
  },
129
+ findGlobalVersionByID: {
130
+ mcpName: 'findGlobalVersionByID',
131
+ requiresVersions: true,
132
+ tool: findGlobalVersionByIDTool
133
+ },
134
+ findGlobalVersions: {
135
+ mcpName: 'findGlobalVersions',
136
+ requiresVersions: true,
137
+ tool: findGlobalVersionsTool
138
+ },
88
139
  getGlobalSchema: {
89
140
  mcpName: 'getGlobalSchema',
90
141
  tool: getGlobalSchemaTool
91
142
  },
143
+ restoreGlobalVersion: {
144
+ mcpName: 'restoreGlobalVersion',
145
+ requiresVersions: true,
146
+ tool: restoreGlobalVersionTool
147
+ },
92
148
  update: {
93
149
  mcpName: 'updateGlobal',
94
150
  tool: updateGlobalTool
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/builtinTools.ts"],"sourcesContent":["import type { CollectionTool, GlobalTool, Tool } from '../types.js'\n\nimport {\n authCollectionTool,\n forgotPasswordCollectionTool,\n loginCollectionTool,\n resetPasswordCollectionTool,\n unlockCollectionTool,\n verifyCollectionTool,\n} from './builtin/collections/authTools.js'\nimport { createDocumentTool } from './builtin/collections/createTool.js'\nimport { deleteDocumentsTool } from './builtin/collections/deleteTool.js'\nimport { findDocumentsTool } from './builtin/collections/findTool.js'\nimport { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'\nimport { updateDocumentTool } from './builtin/collections/updateTool.js'\nimport { getConfigInfoTool } from './builtin/getConfigInfoTool.js'\nimport { findGlobalTool } from './builtin/globals/findTool.js'\nimport { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'\nimport { updateGlobalTool } from './builtin/globals/updateTool.js'\n\nexport const TOOL_BUILTINS = {\n getConfigInfo: { label: 'Config Info', mcpName: 'getConfigInfo', tool: getConfigInfoTool },\n} satisfies Record<string, { label: string; mcpName: string; tool: Tool }>\n\n/**\n * The static built-in collection CRUD tools. Keys here are the source of truth\n * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type\n * automatically.\n */\nexport const COLLECTION_BUILTINS = {\n create: { mcpName: 'createDocument', tool: createDocumentTool },\n delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },\n find: { mcpName: 'findDocuments', tool: findDocumentsTool },\n getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },\n update: { mcpName: 'updateDocument', tool: updateDocumentTool },\n} satisfies Record<string, { mcpName: string; tool: CollectionTool }>\n\n/**\n * The static auth tools surfaced under auth-enabled collections. Each entry\n * carries the admin-UI label alongside the tool. Keys are the source of truth\n * for `MCPCollectionAuthToolName`.\n */\nexport const COLLECTION_AUTH_BUILTINS = {\n auth: { label: 'Check Auth Status', mcpName: 'auth', tool: authCollectionTool },\n forgotPassword: {\n label: 'Forgot Password',\n mcpName: 'forgotPassword',\n tool: forgotPasswordCollectionTool,\n },\n login: { label: 'User Login', mcpName: 'login', tool: loginCollectionTool },\n resetPassword: {\n label: 'Reset Password',\n mcpName: 'resetPassword',\n tool: resetPasswordCollectionTool,\n },\n unlock: { label: 'Unlock Account', mcpName: 'unlock', tool: unlockCollectionTool },\n verify: { label: 'Email Verification', mcpName: 'verify', tool: verifyCollectionTool },\n} satisfies Record<string, { label: string; mcpName: string; tool: CollectionTool }>\n\n/**\n * The static built-in global tools. Keys are the source of truth for\n * `MCPGlobalBuiltinName`.\n */\nexport const GLOBAL_BUILTINS = {\n find: { mcpName: 'findGlobal', tool: findGlobalTool },\n getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },\n update: { mcpName: 'updateGlobal', tool: updateGlobalTool },\n} satisfies Record<string, { mcpName: string; tool: GlobalTool }>\n\nexport type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS\n\nexport type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS\n\nexport type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS\n\nexport type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS\n\n/**\n * Pre-typed `Object.entries` for each registry. The cast from `string` to the\n * literal key union lives here once so consumers can iterate without their own\n * cast — TypeScript's `Object.entries` always widens keys to `string`, which\n * defeats the narrow type lookups on `MCPCollectionToolsMap`.\n */\nexport const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS) as Array<\n [MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]\n>\n\nexport const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<\n [MCPCollectionBuiltinName, (typeof COLLECTION_BUILTINS)[MCPCollectionBuiltinName]]\n>\n\nexport const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<\n [MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]\n>\n\nexport const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<\n [MCPGlobalBuiltinName, (typeof GLOBAL_BUILTINS)[MCPGlobalBuiltinName]]\n>\n"],"names":["authCollectionTool","forgotPasswordCollectionTool","loginCollectionTool","resetPasswordCollectionTool","unlockCollectionTool","verifyCollectionTool","createDocumentTool","deleteDocumentsTool","findDocumentsTool","getCollectionSchemaTool","updateDocumentTool","getConfigInfoTool","findGlobalTool","getGlobalSchemaTool","updateGlobalTool","TOOL_BUILTINS","getConfigInfo","label","mcpName","tool","COLLECTION_BUILTINS","create","delete","find","getCollectionSchema","update","COLLECTION_AUTH_BUILTINS","auth","forgotPassword","login","resetPassword","unlock","verify","GLOBAL_BUILTINS","getGlobalSchema","TOOL_BUILTIN_ENTRIES","Object","entries","COLLECTION_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTIN_ENTRIES","GLOBAL_BUILTIN_ENTRIES"],"mappings":"AAEA,SACEA,kBAAkB,EAClBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,2BAA2B,EAC3BC,oBAAoB,EACpBC,oBAAoB,QACf,qCAAoC;AAC3C,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,mBAAmB,QAAQ,2CAA0C;AAC9E,SAASC,gBAAgB,QAAQ,kCAAiC;AAElE,OAAO,MAAMC,gBAAgB;IAC3BC,eAAe;QAAEC,OAAO;QAAeC,SAAS;QAAiBC,MAAMR;IAAkB;AAC3F,EAA0E;AAE1E;;;;CAIC,GACD,OAAO,MAAMS,sBAAsB;IACjCC,QAAQ;QAAEH,SAAS;QAAkBC,MAAMb;IAAmB;IAC9DgB,QAAQ;QAAEJ,SAAS;QAAmBC,MAAMZ;IAAoB;IAChEgB,MAAM;QAAEL,SAAS;QAAiBC,MAAMX;IAAkB;IAC1DgB,qBAAqB;QAAEN,SAAS;QAAuBC,MAAMV;IAAwB;IACrFgB,QAAQ;QAAEP,SAAS;QAAkBC,MAAMT;IAAmB;AAChE,EAAqE;AAErE;;;;CAIC,GACD,OAAO,MAAMgB,2BAA2B;IACtCC,MAAM;QAAEV,OAAO;QAAqBC,SAAS;QAAQC,MAAMnB;IAAmB;IAC9E4B,gBAAgB;QACdX,OAAO;QACPC,SAAS;QACTC,MAAMlB;IACR;IACA4B,OAAO;QAAEZ,OAAO;QAAcC,SAAS;QAASC,MAAMjB;IAAoB;IAC1E4B,eAAe;QACbb,OAAO;QACPC,SAAS;QACTC,MAAMhB;IACR;IACA4B,QAAQ;QAAEd,OAAO;QAAkBC,SAAS;QAAUC,MAAMf;IAAqB;IACjF4B,QAAQ;QAAEf,OAAO;QAAsBC,SAAS;QAAUC,MAAMd;IAAqB;AACvF,EAAoF;AAEpF;;;CAGC,GACD,OAAO,MAAM4B,kBAAkB;IAC7BV,MAAM;QAAEL,SAAS;QAAcC,MAAMP;IAAe;IACpDsB,iBAAiB;QAAEhB,SAAS;QAAmBC,MAAMN;IAAoB;IACzEY,QAAQ;QAAEP,SAAS;QAAgBC,MAAML;IAAiB;AAC5D,EAAiE;AAUjE;;;;;CAKC,GACD,OAAO,MAAMqB,uBAAuBC,OAAOC,OAAO,CAACtB,eAElD;AAED,OAAO,MAAMuB,6BAA6BF,OAAOC,OAAO,CAACjB,qBAExD;AAED,OAAO,MAAMmB,kCAAkCH,OAAOC,OAAO,CAACX,0BAE7D;AAED,OAAO,MAAMc,yBAAyBJ,OAAOC,OAAO,CAACJ,iBAEpD"}
1
+ {"version":3,"sources":["../../src/mcp/builtinTools.ts"],"sourcesContent":["import type { CollectionTool, GlobalTool, Tool } from '../types.js'\n\nimport {\n authCollectionTool,\n forgotPasswordCollectionTool,\n loginCollectionTool,\n resetPasswordCollectionTool,\n unlockCollectionTool,\n verifyCollectionTool,\n} from './builtin/collections/authTools.js'\nimport { countDocumentsTool } from './builtin/collections/countTool.js'\nimport { countVersionsTool } from './builtin/collections/countVersionsTool.js'\nimport { createDocumentTool } from './builtin/collections/createTool.js'\nimport { deleteDocumentsTool } from './builtin/collections/deleteTool.js'\nimport { duplicateDocumentTool } from './builtin/collections/duplicateTool.js'\nimport { findDistinctTool } from './builtin/collections/findDistinctTool.js'\nimport { findDocumentsTool } from './builtin/collections/findTool.js'\nimport { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js'\nimport { findVersionsTool } from './builtin/collections/findVersionsTool.js'\nimport { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'\nimport { restoreVersionTool } from './builtin/collections/restoreVersionTool.js'\nimport { updateDocumentTool } from './builtin/collections/updateTool.js'\nimport { getConfigInfoTool } from './builtin/getConfigInfoTool.js'\nimport { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js'\nimport { findGlobalTool } from './builtin/globals/findTool.js'\nimport { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js'\nimport { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js'\nimport { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'\nimport { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js'\nimport { updateGlobalTool } from './builtin/globals/updateTool.js'\n\ntype CollectionBuiltin = {\n mcpName: string\n requiresDuplicateEnabled?: boolean\n requiresVersions?: boolean\n tool: CollectionTool\n}\n\ntype GlobalBuiltin = {\n mcpName: string\n requiresVersions?: boolean\n tool: GlobalTool\n}\n\nexport const TOOL_BUILTINS = {\n getConfigInfo: { mcpName: 'getConfigInfo', tool: getConfigInfoTool },\n} satisfies Record<string, { mcpName: string; tool: Tool }>\n\n/**\n * The static built-in collection CRUD tools. Keys here are the source of truth\n * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type\n * automatically.\n */\nexport const COLLECTION_BUILTINS = {\n count: { mcpName: 'countDocuments', tool: countDocumentsTool },\n countVersions: { mcpName: 'countVersions', requiresVersions: true, tool: countVersionsTool },\n create: { mcpName: 'createDocument', tool: createDocumentTool },\n delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },\n duplicate: {\n mcpName: 'duplicateDocument',\n requiresDuplicateEnabled: true,\n tool: duplicateDocumentTool,\n },\n find: { mcpName: 'findDocuments', tool: findDocumentsTool },\n findDistinct: { mcpName: 'findDistinct', tool: findDistinctTool },\n findVersionByID: {\n mcpName: 'findVersionByID',\n requiresVersions: true,\n tool: findVersionByIDTool,\n },\n findVersions: { mcpName: 'findVersions', requiresVersions: true, tool: findVersionsTool },\n getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },\n restoreVersion: { mcpName: 'restoreVersion', requiresVersions: true, tool: restoreVersionTool },\n update: { mcpName: 'updateDocument', tool: updateDocumentTool },\n} satisfies Record<string, CollectionBuiltin>\n\n/**\n * The static auth tools surfaced under auth-enabled collections. Keys are the\n * source of truth for `MCPCollectionAuthToolName`.\n */\nexport const COLLECTION_AUTH_BUILTINS = {\n auth: { mcpName: 'auth', tool: authCollectionTool },\n forgotPassword: {\n mcpName: 'forgotPassword',\n tool: forgotPasswordCollectionTool,\n },\n login: { mcpName: 'login', tool: loginCollectionTool },\n resetPassword: {\n mcpName: 'resetPassword',\n tool: resetPasswordCollectionTool,\n },\n unlock: { mcpName: 'unlock', tool: unlockCollectionTool },\n verify: { mcpName: 'verify', tool: verifyCollectionTool },\n} satisfies Record<string, { mcpName: string; tool: CollectionTool }>\n\n/**\n * The static built-in global tools. Keys are the source of truth for\n * `MCPGlobalBuiltinName`.\n */\nexport const GLOBAL_BUILTINS = {\n countGlobalVersions: {\n mcpName: 'countGlobalVersions',\n requiresVersions: true,\n tool: countGlobalVersionsTool,\n },\n find: { mcpName: 'findGlobal', tool: findGlobalTool },\n findGlobalVersionByID: {\n mcpName: 'findGlobalVersionByID',\n requiresVersions: true,\n tool: findGlobalVersionByIDTool,\n },\n findGlobalVersions: {\n mcpName: 'findGlobalVersions',\n requiresVersions: true,\n tool: findGlobalVersionsTool,\n },\n getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },\n restoreGlobalVersion: {\n mcpName: 'restoreGlobalVersion',\n requiresVersions: true,\n tool: restoreGlobalVersionTool,\n },\n update: { mcpName: 'updateGlobal', tool: updateGlobalTool },\n} satisfies Record<string, GlobalBuiltin>\n\nexport type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS\n\nexport type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS\n\nexport type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS\n\nexport type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS\n\n/**\n * Pre-typed `Object.entries` for each registry. The cast from `string` to the\n * literal key union lives here once so consumers can iterate without their own\n * cast — TypeScript's `Object.entries` always widens keys to `string`, which\n * defeats the narrow type lookups on `MCPCollectionToolsMap`.\n */\nexport const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS) as Array<\n [MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]\n>\n\nexport const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<\n [MCPCollectionBuiltinName, CollectionBuiltin]\n>\n\nexport const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<\n [MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]\n>\n\nexport const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<\n [MCPGlobalBuiltinName, GlobalBuiltin]\n>\n"],"names":["authCollectionTool","forgotPasswordCollectionTool","loginCollectionTool","resetPasswordCollectionTool","unlockCollectionTool","verifyCollectionTool","countDocumentsTool","countVersionsTool","createDocumentTool","deleteDocumentsTool","duplicateDocumentTool","findDistinctTool","findDocumentsTool","findVersionByIDTool","findVersionsTool","getCollectionSchemaTool","restoreVersionTool","updateDocumentTool","getConfigInfoTool","countGlobalVersionsTool","findGlobalTool","findGlobalVersionByIDTool","findGlobalVersionsTool","getGlobalSchemaTool","restoreGlobalVersionTool","updateGlobalTool","TOOL_BUILTINS","getConfigInfo","mcpName","tool","COLLECTION_BUILTINS","count","countVersions","requiresVersions","create","delete","duplicate","requiresDuplicateEnabled","find","findDistinct","findVersionByID","findVersions","getCollectionSchema","restoreVersion","update","COLLECTION_AUTH_BUILTINS","auth","forgotPassword","login","resetPassword","unlock","verify","GLOBAL_BUILTINS","countGlobalVersions","findGlobalVersionByID","findGlobalVersions","getGlobalSchema","restoreGlobalVersion","TOOL_BUILTIN_ENTRIES","Object","entries","COLLECTION_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTIN_ENTRIES","GLOBAL_BUILTIN_ENTRIES"],"mappings":"AAEA,SACEA,kBAAkB,EAClBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,2BAA2B,EAC3BC,oBAAoB,EACpBC,oBAAoB,QACf,qCAAoC;AAC3C,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,iBAAiB,QAAQ,6CAA4C;AAC9E,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,gBAAgB,QAAQ,4CAA2C;AAC5E,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,gBAAgB,QAAQ,4CAA2C;AAC5E,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,mBAAmB,QAAQ,2CAA0C;AAC9E,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,gBAAgB,QAAQ,kCAAiC;AAelE,OAAO,MAAMC,gBAAgB;IAC3BC,eAAe;QAAEC,SAAS;QAAiBC,MAAMX;IAAkB;AACrE,EAA2D;AAE3D;;;;CAIC,GACD,OAAO,MAAMY,sBAAsB;IACjCC,OAAO;QAAEH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rB1B,SAAS;QACTK,kBAAkB;QAClBJ,MAAMR;IACR;IACAkC,oBAAoB;QAClB3B,SAAS;QACTK,kBAAkB;QAClBJ,MAAMP;IACR;IACAkC,iBAAiB;QAAE5B,SAAS;QAAmBC,MAAMN;IAAoB;IACzEkC,sBAAsB;QACpB7B,SAAS;QACTK,kBAAkB;QAClBJ,MAAML;IACR;IACAoB,QAAQ;QAAEhB,SAAS;QAAgBC,MAAMJ;IAAiB;AAC5D,EAAyC;AAUzC;;;;;CAKC,GACD,OAAO,MAAMiC,uBAAuBC,OAAOC,OAAO,CAAClC,eAElD;AAED,OAAO,MAAMmC,6BAA6BF,OAAOC,OAAO,CAAC9B,qBAExD;AAED,OAAO,MAAMgC,kCAAkCH,OAAOC,OAAO,CAACf,0BAE7D;AAED,OAAO,MAAMkB,yBAAyBJ,OAAOC,OAAO,CAACR,iBAEpD"}
@@ -5,7 +5,6 @@ import type { MCPPluginConfig, SanitizedMCPPluginConfig } from '../types.js';
5
5
  * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
6
6
  * tool maps into a single `items` array.
7
7
  * - Applies built-in tools for collections and globals, respecting opt-out user overrides.
8
- * - Applies the `userCollection` default
9
8
  *
10
9
  * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
11
10
  * ?.options` holds the sanitized result
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAapB;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBAkEH,CAAA"}
1
+ {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAcpB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,8BAG3B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBA6DH,CAAA"}
@@ -1,10 +1,10 @@
1
+ import { defaultAccess } from '../defaultAccess.js';
1
2
  import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_BUILTIN_ENTRIES, COLLECTION_BUILTINS, GLOBAL_BUILTIN_ENTRIES, GLOBAL_BUILTINS, TOOL_BUILTIN_ENTRIES, TOOL_BUILTINS } from './builtinTools.js';
2
3
  /**
3
4
  * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:
4
5
  * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
5
6
  * tool maps into a single `items` array.
6
7
  * - Applies built-in tools for collections and globals, respecting opt-out user overrides.
7
- * - Applies the `userCollection` default
8
8
  *
9
9
  * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
10
10
  * ?.options` holds the sanitized result
@@ -22,13 +22,16 @@ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_B
22
22
  pluginConfig
23
23
  }));
24
24
  }
25
- for (const [configKey, { label, mcpName, tool }] of TOOL_BUILTIN_ENTRIES){
25
+ for (const [configKey, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES){
26
26
  items.push({
27
27
  type: 'tool',
28
28
  configKey,
29
- label,
29
+ label: tool.annotations?.title ?? configKey,
30
30
  mcpName,
31
- tool
31
+ tool: {
32
+ ...tool,
33
+ access: tool.access ?? defaultAccess
34
+ }
32
35
  });
33
36
  }
34
37
  for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})){
@@ -38,9 +41,12 @@ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_B
38
41
  items.push({
39
42
  type: 'tool',
40
43
  configKey,
41
- label: configKey,
44
+ label: tool.annotations?.title ?? configKey,
42
45
  mcpName: configKey,
43
- tool
46
+ tool: {
47
+ ...tool,
48
+ access: tool.access ?? defaultAccess
49
+ }
44
50
  });
45
51
  }
46
52
  for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})){
@@ -49,7 +55,10 @@ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_B
49
55
  configKey,
50
56
  label: prompt.title ?? configKey,
51
57
  mcpName: configKey,
52
- prompt
58
+ prompt: {
59
+ ...prompt,
60
+ access: prompt.access ?? defaultAccess
61
+ }
53
62
  });
54
63
  }
55
64
  for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})){
@@ -58,62 +67,81 @@ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_B
58
67
  configKey,
59
68
  label: resource.title ?? configKey,
60
69
  mcpName: configKey,
61
- resource
70
+ resource: {
71
+ ...resource,
72
+ access: resource.access ?? defaultAccess
73
+ }
62
74
  });
63
75
  }
64
- // Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.
65
- const firstCollectionWithAuth = config.collections.find(({ auth })=>Boolean(auth));
66
76
  return {
67
77
  disabled: pluginConfig.disabled,
78
+ hooks: pluginConfig.hooks,
68
79
  items,
69
80
  mcp: pluginConfig.mcp,
70
- overrideApiKeyCollection: pluginConfig.overrideApiKeyCollection,
71
- overrideAuth: pluginConfig.overrideAuth,
72
- userCollection: pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users'
81
+ overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP
73
82
  };
74
83
  };
75
84
  const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
76
- if (collection.slug === 'payload-mcp-api-keys') {
77
- return [];
78
- }
79
85
  const slug = collection.slug;
80
86
  const collectionPluginConfig = pluginConfig.collections?.[slug];
81
87
  const items = [];
82
- for (const [toolKey, { mcpName, tool }] of COLLECTION_BUILTIN_ENTRIES){
88
+ /**
89
+ * Payload disables duplicate for auth collections by default unless the
90
+ * collection explicitly opts back in with `disableDuplicate: false`.
91
+ */ const isDuplicateDisabled = collection.disableDuplicate === true || Boolean(collection.auth) && collection.disableDuplicate !== false;
92
+ for (const [toolKey, { mcpName, requiresDuplicateEnabled, requiresVersions, tool }] of COLLECTION_BUILTIN_ENTRIES){
93
+ if (requiresVersions && !collection.versions) {
94
+ continue;
95
+ }
96
+ if (requiresDuplicateEnabled && isDuplicateDisabled) {
97
+ continue;
98
+ }
83
99
  const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey];
84
100
  if (matchedConfigEntry === false) {
85
101
  continue;
86
102
  }
87
103
  const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
104
+ const annotations = {
105
+ ...tool.annotations,
106
+ ...override?.annotations
107
+ };
88
108
  items.push({
89
109
  type: 'collectionTool',
90
110
  collectionSlug: slug,
91
111
  configKey: toolKey,
92
- label: capitalize(toolKey),
112
+ label: annotations.title ?? toolKey,
93
113
  mcpName,
94
114
  tool: {
95
115
  ...tool,
116
+ access: override?.access ?? tool.access ?? defaultAccess,
117
+ annotations,
96
118
  description: override?.description ?? tool.description,
97
119
  overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
98
120
  }
99
121
  });
100
122
  }
101
123
  if (collection.auth) {
102
- for (const [authToolKey, { label, mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES){
124
+ for (const [authToolKey, { mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES){
103
125
  const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey];
104
126
  if (!matchedConfigEntry) {
105
127
  continue;
106
128
  }
107
129
  // `true` means "enable, no override"; only the object form carries fields.
108
130
  const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
131
+ const annotations = {
132
+ ...tool.annotations,
133
+ ...override?.annotations
134
+ };
109
135
  items.push({
110
136
  type: 'collectionTool',
111
137
  collectionSlug: slug,
112
138
  configKey: authToolKey,
113
- label,
139
+ label: annotations.title ?? authToolKey,
114
140
  mcpName,
115
141
  tool: {
116
142
  ...tool,
143
+ access: override?.access ?? tool.access ?? defaultAccess,
144
+ annotations,
117
145
  description: override?.description ?? tool.description,
118
146
  overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
119
147
  }
@@ -134,9 +162,12 @@ const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
134
162
  type: 'collectionTool',
135
163
  collectionSlug: slug,
136
164
  configKey,
137
- label: configKey,
165
+ label: customTool.annotations?.title ?? configKey,
138
166
  mcpName: configKey,
139
- tool: customTool
167
+ tool: {
168
+ ...customTool,
169
+ access: customTool.access ?? defaultAccess
170
+ }
140
171
  });
141
172
  }
142
173
  return items;
@@ -145,20 +176,29 @@ const sanitizeGlobalConfig = ({ global, pluginConfig })=>{
145
176
  const slug = global.slug;
146
177
  const globalPluginConfig = pluginConfig.globals?.[slug];
147
178
  const items = [];
148
- for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES){
179
+ for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES){
180
+ if (requiresVersions && !global.versions) {
181
+ continue;
182
+ }
149
183
  const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey];
150
184
  if (matchedConfigEntry === false) {
151
185
  continue;
152
186
  }
153
187
  const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
188
+ const annotations = {
189
+ ...tool.annotations,
190
+ ...override?.annotations
191
+ };
154
192
  items.push({
155
193
  type: 'globalTool',
156
194
  configKey: toolKey,
157
195
  globalSlug: slug,
158
- label: capitalize(toolKey),
196
+ label: annotations.title ?? toolKey,
159
197
  mcpName,
160
198
  tool: {
161
199
  ...tool,
200
+ access: override?.access ?? tool.access ?? defaultAccess,
201
+ annotations,
162
202
  description: override?.description ?? tool.description,
163
203
  overrideResponse: override?.overrideResponse ?? globalPluginConfig?.overrideResponse ?? tool.overrideResponse
164
204
  }
@@ -176,13 +216,15 @@ const sanitizeGlobalConfig = ({ global, pluginConfig })=>{
176
216
  type: 'globalTool',
177
217
  configKey,
178
218
  globalSlug: slug,
179
- label: configKey,
219
+ label: customTool.annotations?.title ?? configKey,
180
220
  mcpName: configKey,
181
- tool: customTool
221
+ tool: {
222
+ ...customTool,
223
+ access: customTool.access ?? defaultAccess
224
+ }
182
225
  });
183
226
  }
184
227
  return items;
185
228
  };
186
- const capitalize = (s)=>s.charAt(0).toUpperCase() + s.slice(1);
187
229
 
188
230
  //# sourceMappingURL=sanitizeMCPConfig.js.map