@payloadcms/plugin-mcp 3.86.0-internal.ac46214 → 4.0.0-canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. package/README.md +2 -2
  2. package/bin.js +39 -0
  3. package/dist/collection/getAccessField.d.ts +12 -0
  4. package/dist/collection/getAccessField.d.ts.map +1 -0
  5. package/dist/collection/getAccessField.js +57 -0
  6. package/dist/collection/getAccessField.js.map +1 -0
  7. package/dist/collection/index.d.ts +6 -0
  8. package/dist/collection/index.d.ts.map +1 -0
  9. package/dist/collection/index.js +60 -0
  10. package/dist/collection/index.js.map +1 -0
  11. package/dist/components/AccessField/index.client.d.ts +10 -0
  12. package/dist/components/AccessField/index.client.d.ts.map +1 -0
  13. package/dist/components/AccessField/index.client.js +305 -0
  14. package/dist/components/AccessField/index.client.js.map +1 -0
  15. package/dist/components/AccessField/index.css +93 -0
  16. package/dist/defineTool.d.ts +26 -0
  17. package/dist/defineTool.d.ts.map +1 -0
  18. package/dist/defineTool.js +37 -0
  19. package/dist/defineTool.js.map +1 -0
  20. package/dist/endpoint/access.d.ts +10 -0
  21. package/dist/endpoint/access.d.ts.map +1 -0
  22. package/dist/endpoint/access.js +106 -0
  23. package/dist/endpoint/access.js.map +1 -0
  24. package/dist/endpoint/index.d.ts +3 -0
  25. package/dist/endpoint/index.d.ts.map +1 -0
  26. package/dist/endpoint/index.js +36 -0
  27. package/dist/endpoint/index.js.map +1 -0
  28. package/dist/exports/client.d.ts +2 -0
  29. package/dist/exports/client.d.ts.map +1 -0
  30. package/dist/exports/client.js +4 -0
  31. package/dist/exports/client.js.map +1 -0
  32. package/dist/index.d.ts +4 -7
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +44 -67
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp/buildMcpServer.d.ts +19 -0
  37. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  38. package/dist/mcp/buildMcpServer.js +199 -0
  39. package/dist/mcp/buildMcpServer.js.map +1 -0
  40. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  41. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  42. package/dist/mcp/builtin/collections/authTools.js +250 -0
  43. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  44. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  45. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  46. package/dist/mcp/builtin/collections/createTool.js +94 -0
  47. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  48. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  49. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  50. package/dist/mcp/builtin/collections/deleteTool.js +102 -0
  51. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  52. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  53. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  54. package/dist/mcp/builtin/collections/findTool.js +144 -0
  55. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  56. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  57. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  58. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  59. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  60. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  61. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  62. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
  63. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  64. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  65. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  66. package/dist/mcp/builtin/collections/updateTool.js +199 -0
  67. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  68. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  69. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  70. package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
  71. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  72. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  73. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  74. package/dist/mcp/builtin/globals/findTool.js +76 -0
  75. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  76. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  77. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  78. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
  79. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  80. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  81. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  82. package/dist/mcp/builtin/globals/updateTool.js +94 -0
  83. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  84. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  85. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  86. package/dist/mcp/builtin/validateEntityData.js +82 -0
  87. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  88. package/dist/mcp/builtinTools.d.ts +105 -0
  89. package/dist/mcp/builtinTools.d.ts.map +1 -0
  90. package/dist/mcp/builtinTools.js +107 -0
  91. package/dist/mcp/builtinTools.js.map +1 -0
  92. package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
  93. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  94. package/dist/mcp/sanitizeMCPConfig.js +188 -0
  95. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  96. package/dist/stdio.d.ts +8 -0
  97. package/dist/stdio.d.ts.map +1 -0
  98. package/dist/stdio.js +89 -0
  99. package/dist/stdio.js.map +1 -0
  100. package/dist/types.d.ts +251 -455
  101. package/dist/types.d.ts.map +1 -1
  102. package/dist/types.js +6 -1
  103. package/dist/types.js.map +1 -1
  104. package/dist/utils/camelCase.d.ts.map +1 -1
  105. package/dist/utils/getLogger.d.ts +10 -0
  106. package/dist/utils/getLogger.d.ts.map +1 -0
  107. package/dist/utils/getLogger.js +22 -0
  108. package/dist/utils/getLogger.js.map +1 -0
  109. package/dist/utils/getPluginConfig.d.ts +12 -0
  110. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  111. package/dist/utils/getPluginConfig.js +15 -0
  112. package/dist/utils/getPluginConfig.js.map +1 -0
  113. package/dist/utils/localAPIDefaults.d.ts +20 -0
  114. package/dist/utils/localAPIDefaults.d.ts.map +1 -0
  115. package/dist/utils/localAPIDefaults.js +19 -0
  116. package/dist/utils/localAPIDefaults.js.map +1 -0
  117. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  118. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  119. package/dist/utils/resolveProjectRoot.js +15 -0
  120. package/dist/utils/resolveProjectRoot.js.map +1 -0
  121. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  122. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  123. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  124. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  125. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
  126. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
  127. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
  128. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
  129. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  130. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
  131. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  132. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
  133. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  134. package/dist/utils/toStandardSchema.d.ts +5 -0
  135. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  136. package/dist/utils/toStandardSchema.js +4 -0
  137. package/dist/utils/toStandardSchema.js.map +1 -0
  138. package/dist/utils/whereSchema.d.ts +9 -0
  139. package/dist/utils/whereSchema.d.ts.map +1 -0
  140. package/dist/utils/whereSchema.js +13 -0
  141. package/dist/utils/whereSchema.js.map +1 -0
  142. package/package.json +35 -10
  143. package/src/collection/getAccessField.ts +64 -0
  144. package/src/collection/index.ts +64 -0
  145. package/src/components/AccessField/index.client.tsx +347 -0
  146. package/src/components/AccessField/index.css +93 -0
  147. package/src/defineTool.ts +44 -0
  148. package/src/endpoint/access.ts +132 -0
  149. package/src/endpoint/index.ts +35 -0
  150. package/src/exports/client.ts +2 -0
  151. package/src/index.ts +35 -85
  152. package/src/mcp/buildMcpServer.ts +257 -0
  153. package/src/mcp/builtin/collections/authTools.ts +233 -0
  154. package/src/mcp/builtin/collections/createTool.ts +112 -0
  155. package/src/mcp/builtin/collections/deleteTool.ts +116 -0
  156. package/src/mcp/builtin/collections/findTool.ts +177 -0
  157. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  158. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
  159. package/src/mcp/builtin/collections/updateTool.ts +211 -0
  160. package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
  161. package/src/mcp/builtin/globals/findTool.ts +96 -0
  162. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
  163. package/src/mcp/builtin/globals/updateTool.ts +115 -0
  164. package/src/mcp/builtin/validateEntityData.ts +132 -0
  165. package/src/mcp/builtinTools.ts +98 -0
  166. package/src/mcp/sanitizeMCPConfig.ts +260 -0
  167. package/src/stdio.ts +98 -0
  168. package/src/types.ts +290 -490
  169. package/src/utils/getLogger.ts +22 -0
  170. package/src/utils/getPluginConfig.ts +24 -0
  171. package/src/utils/localAPIDefaults.ts +22 -0
  172. package/src/utils/resolveProjectRoot.ts +17 -0
  173. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  174. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
  175. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
  176. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
  177. package/src/utils/toStandardSchema.ts +9 -0
  178. package/src/utils/whereSchema.ts +24 -0
  179. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  180. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  181. package/dist/collections/createApiKeysCollection.js +0 -317
  182. package/dist/collections/createApiKeysCollection.js.map +0 -1
  183. package/dist/defaults.d.ts +0 -4
  184. package/dist/defaults.d.ts.map +0 -1
  185. package/dist/defaults.js +0 -5
  186. package/dist/defaults.js.map +0 -1
  187. package/dist/endpoints/mcp.d.ts +0 -4
  188. package/dist/endpoints/mcp.d.ts.map +0 -1
  189. package/dist/endpoints/mcp.js +0 -71
  190. package/dist/endpoints/mcp.js.map +0 -1
  191. package/dist/mcp/createRequest.d.ts +0 -3
  192. package/dist/mcp/createRequest.d.ts.map +0 -1
  193. package/dist/mcp/createRequest.js +0 -14
  194. package/dist/mcp/createRequest.js.map +0 -1
  195. package/dist/mcp/getMcpHandler.d.ts +0 -4
  196. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  197. package/dist/mcp/getMcpHandler.js +0 -231
  198. package/dist/mcp/getMcpHandler.js.map +0 -1
  199. package/dist/mcp/helpers/config.d.ts +0 -22
  200. package/dist/mcp/helpers/config.d.ts.map +0 -1
  201. package/dist/mcp/helpers/config.js +0 -153
  202. package/dist/mcp/helpers/config.js.map +0 -1
  203. package/dist/mcp/helpers/fields.d.ts +0 -19
  204. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  205. package/dist/mcp/helpers/fields.js +0 -102
  206. package/dist/mcp/helpers/fields.js.map +0 -1
  207. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  208. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  209. package/dist/mcp/helpers/fileValidation.js +0 -267
  210. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  211. package/dist/mcp/registerTool.d.ts +0 -6
  212. package/dist/mcp/registerTool.d.ts.map +0 -1
  213. package/dist/mcp/registerTool.js +0 -18
  214. package/dist/mcp/registerTool.js.map +0 -1
  215. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  216. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  217. package/dist/mcp/tools/auth/auth.js +0 -57
  218. package/dist/mcp/tools/auth/auth.js.map +0 -1
  219. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  220. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  221. package/dist/mcp/tools/auth/forgotPassword.js +0 -48
  222. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  223. package/dist/mcp/tools/auth/login.d.ts +0 -4
  224. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  225. package/dist/mcp/tools/auth/login.js +0 -51
  226. package/dist/mcp/tools/auth/login.js.map +0 -1
  227. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  228. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  229. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  230. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  231. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  232. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  233. package/dist/mcp/tools/auth/unlock.js +0 -48
  234. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  235. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  236. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  237. package/dist/mcp/tools/auth/verify.js +0 -45
  238. package/dist/mcp/tools/auth/verify.js.map +0 -1
  239. package/dist/mcp/tools/collection/create.d.ts +0 -10
  240. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  241. package/dist/mcp/tools/collection/create.js +0 -139
  242. package/dist/mcp/tools/collection/create.js.map +0 -1
  243. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  244. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  245. package/dist/mcp/tools/collection/delete.js +0 -154
  246. package/dist/mcp/tools/collection/delete.js.map +0 -1
  247. package/dist/mcp/tools/collection/find.d.ts +0 -10
  248. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  249. package/dist/mcp/tools/collection/find.js +0 -165
  250. package/dist/mcp/tools/collection/find.js.map +0 -1
  251. package/dist/mcp/tools/collection/update.d.ts +0 -10
  252. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  253. package/dist/mcp/tools/collection/update.js +0 -209
  254. package/dist/mcp/tools/collection/update.js.map +0 -1
  255. package/dist/mcp/tools/config/find.d.ts +0 -10
  256. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  257. package/dist/mcp/tools/config/find.js +0 -97
  258. package/dist/mcp/tools/config/find.js.map +0 -1
  259. package/dist/mcp/tools/config/update.d.ts +0 -10
  260. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  261. package/dist/mcp/tools/config/update.js +0 -215
  262. package/dist/mcp/tools/config/update.js.map +0 -1
  263. package/dist/mcp/tools/global/find.d.ts +0 -5
  264. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  265. package/dist/mcp/tools/global/find.js +0 -82
  266. package/dist/mcp/tools/global/find.js.map +0 -1
  267. package/dist/mcp/tools/global/update.d.ts +0 -6
  268. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  269. package/dist/mcp/tools/global/update.js +0 -124
  270. package/dist/mcp/tools/global/update.js.map +0 -1
  271. package/dist/mcp/tools/job/create.d.ts +0 -10
  272. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  273. package/dist/mcp/tools/job/create.js +0 -293
  274. package/dist/mcp/tools/job/create.js.map +0 -1
  275. package/dist/mcp/tools/job/run.d.ts +0 -10
  276. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  277. package/dist/mcp/tools/job/run.js +0 -129
  278. package/dist/mcp/tools/job/run.js.map +0 -1
  279. package/dist/mcp/tools/job/update.d.ts +0 -11
  280. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  281. package/dist/mcp/tools/job/update.js +0 -186
  282. package/dist/mcp/tools/job/update.js.map +0 -1
  283. package/dist/mcp/tools/resource/create.d.ts +0 -6
  284. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  285. package/dist/mcp/tools/resource/create.js +0 -124
  286. package/dist/mcp/tools/resource/create.js.map +0 -1
  287. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  288. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  289. package/dist/mcp/tools/resource/delete.js +0 -151
  290. package/dist/mcp/tools/resource/delete.js.map +0 -1
  291. package/dist/mcp/tools/resource/find.d.ts +0 -5
  292. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  293. package/dist/mcp/tools/resource/find.js +0 -170
  294. package/dist/mcp/tools/resource/find.js.map +0 -1
  295. package/dist/mcp/tools/resource/update.d.ts +0 -6
  296. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  297. package/dist/mcp/tools/resource/update.js +0 -256
  298. package/dist/mcp/tools/resource/update.js.map +0 -1
  299. package/dist/mcp/tools/schemas.d.ts +0 -457
  300. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  301. package/dist/mcp/tools/schemas.js +0 -243
  302. package/dist/mcp/tools/schemas.js.map +0 -1
  303. package/dist/utils/adminEntitySettings.d.ts +0 -17
  304. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  305. package/dist/utils/adminEntitySettings.js +0 -41
  306. package/dist/utils/adminEntitySettings.js.map +0 -1
  307. package/dist/utils/createApiKeyFields.d.ts +0 -15
  308. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  309. package/dist/utils/createApiKeyFields.js +0 -57
  310. package/dist/utils/createApiKeyFields.js.map +0 -1
  311. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  312. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  313. package/dist/utils/getEnabledSlugs.js +0 -32
  314. package/dist/utils/getEnabledSlugs.js.map +0 -1
  315. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
  316. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  317. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
  318. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  319. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  320. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  321. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  322. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  323. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  324. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  325. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  326. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  327. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  328. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  329. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  330. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  331. package/src/collections/createApiKeysCollection.ts +0 -373
  332. package/src/defaults.ts +0 -3
  333. package/src/endpoints/mcp.ts +0 -91
  334. package/src/mcp/createRequest.ts +0 -13
  335. package/src/mcp/getMcpHandler.ts +0 -545
  336. package/src/mcp/helpers/config.ts +0 -213
  337. package/src/mcp/helpers/fields.ts +0 -154
  338. package/src/mcp/helpers/fileValidation.ts +0 -362
  339. package/src/mcp/registerTool.ts +0 -22
  340. package/src/mcp/tools/auth/auth.ts +0 -71
  341. package/src/mcp/tools/auth/forgotPassword.ts +0 -70
  342. package/src/mcp/tools/auth/login.ts +0 -72
  343. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  344. package/src/mcp/tools/auth/unlock.ts +0 -64
  345. package/src/mcp/tools/auth/verify.ts +0 -57
  346. package/src/mcp/tools/collection/create.ts +0 -210
  347. package/src/mcp/tools/collection/delete.ts +0 -211
  348. package/src/mcp/tools/collection/find.ts +0 -224
  349. package/src/mcp/tools/collection/update.ts +0 -290
  350. package/src/mcp/tools/config/find.ts +0 -128
  351. package/src/mcp/tools/config/update.ts +0 -280
  352. package/src/mcp/tools/global/find.ts +0 -128
  353. package/src/mcp/tools/global/update.ts +0 -207
  354. package/src/mcp/tools/job/create.ts +0 -416
  355. package/src/mcp/tools/job/run.ts +0 -167
  356. package/src/mcp/tools/job/update.ts +0 -274
  357. package/src/mcp/tools/resource/create.ts +0 -211
  358. package/src/mcp/tools/resource/delete.ts +0 -218
  359. package/src/mcp/tools/resource/find.ts +0 -246
  360. package/src/mcp/tools/resource/update.ts +0 -383
  361. package/src/mcp/tools/schemas.ts +0 -520
  362. package/src/utils/adminEntitySettings.ts +0 -40
  363. package/src/utils/createApiKeyFields.ts +0 -72
  364. package/src/utils/getEnabledSlugs.ts +0 -42
  365. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
  366. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  367. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  368. package/src/utils/schemaConversion/transformPointFields.ts +0 -55
@@ -1,64 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
- import type { PayloadRequest } from 'payload'
3
-
4
- import { toolSchemas } from '../schemas.js'
5
-
6
- export const unlockTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
7
- const tool = async (collection: string, email: string) => {
8
- const payload = req.payload
9
-
10
- if (verboseLogs) {
11
- payload.logger.info(
12
- `[payload-mcp] Unlocking user account for user: ${email} in collection: ${collection}`,
13
- )
14
- }
15
-
16
- try {
17
- const result = await payload.unlock({
18
- collection,
19
- data: {
20
- email,
21
- },
22
- overrideAccess: true,
23
- })
24
-
25
- if (verboseLogs) {
26
- payload.logger.info(`[payload-mcp] User account unlocked successfully for user: ${email}`)
27
- }
28
-
29
- return {
30
- content: [
31
- {
32
- type: 'text' as const,
33
- text: `# User Account Unlocked\n\n**User:** ${email}\n**Collection:** ${collection}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
34
- },
35
- ],
36
- }
37
- } catch (error) {
38
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
39
- payload.logger.error(
40
- `[payload-mcp] Error unlocking user account for user ${email}: ${errorMessage}`,
41
- )
42
-
43
- return {
44
- content: [
45
- {
46
- type: 'text' as const,
47
- text: `❌ **Error unlocking user account for user "${email}"**: ${errorMessage}`,
48
- },
49
- ],
50
- }
51
- }
52
- }
53
-
54
- server.registerTool(
55
- 'unlock',
56
- {
57
- description: toolSchemas.unlock.description,
58
- inputSchema: toolSchemas.unlock.parameters.shape,
59
- },
60
- async ({ collection, email }) => {
61
- return await tool(collection, email)
62
- },
63
- )
64
- }
@@ -1,57 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
- import type { PayloadRequest } from 'payload'
3
-
4
- import { toolSchemas } from '../schemas.js'
5
-
6
- export const verifyTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
7
- const tool = async (collection: string, token: string) => {
8
- const payload = req.payload
9
-
10
- if (verboseLogs) {
11
- payload.logger.info(`[payload-mcp] Verifying user account for collection: ${collection}`)
12
- }
13
-
14
- try {
15
- const result = await payload.verifyEmail({
16
- collection,
17
- token,
18
- })
19
-
20
- if (verboseLogs) {
21
- payload.logger.info('[payload-mcp] Email verification completed successfully')
22
- }
23
-
24
- return {
25
- content: [
26
- {
27
- type: 'text' as const,
28
- text: `# Email Verification Successful\n\n**Collection:** ${collection}\n**Token:** ${token}\n**Result:** ${result ? 'Success' : 'Failed'}`,
29
- },
30
- ],
31
- }
32
- } catch (error) {
33
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
34
- payload.logger.error(`[payload-mcp] Error verifying email: ${errorMessage}`)
35
-
36
- return {
37
- content: [
38
- {
39
- type: 'text' as const,
40
- text: `❌ **Error verifying email**: ${errorMessage}`,
41
- },
42
- ],
43
- }
44
- }
45
- }
46
-
47
- server.registerTool(
48
- 'verify',
49
- {
50
- description: toolSchemas.verify.description,
51
- inputSchema: toolSchemas.verify.parameters.shape,
52
- },
53
- async ({ collection, token }) => {
54
- return await tool(collection, token)
55
- },
56
- )
57
- }
@@ -1,210 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
- import type { PayloadRequest } from 'payload'
3
-
4
- import { writeFileSync } from 'fs'
5
- import { join } from 'path'
6
-
7
- import { generateFieldDefinitionString } from '../../helpers/fields.js'
8
- import { validateCollectionFile } from '../../helpers/fileValidation.js'
9
- import { toolSchemas } from '../schemas.js'
10
-
11
- export const createCollection = async (
12
- req: PayloadRequest,
13
- verboseLogs: boolean,
14
- collectionsDirPath: string,
15
- configFilePath: string,
16
- collectionName: string,
17
- collectionDescription: string | undefined,
18
- fields: any[],
19
- hasUpload: boolean | undefined,
20
- ) => {
21
- const payload = req.payload
22
- if (verboseLogs) {
23
- payload.logger.info(
24
- `[payload-mcp] Creating collection: ${collectionName} with ${fields.length} fields`,
25
- )
26
- }
27
-
28
- const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)
29
- const slug = collectionName
30
- .replace(/([A-Z])/g, '-$1')
31
- .toLowerCase()
32
- .replace(/^-/, '')
33
-
34
- if (verboseLogs) {
35
- payload.logger.info(`[payload-mcp] Generated slug: ${slug} for collection: ${collectionName}`)
36
- }
37
-
38
- const fieldDefinitions = fields.map(generateFieldDefinitionString).join('\n')
39
-
40
- // Generate collection file content
41
- const collectionContent = `import type { CollectionConfig } from 'payload'
42
-
43
- export const ${capitalizedName}: CollectionConfig = {
44
- slug: '${slug}',${
45
- collectionDescription
46
- ? `
47
- admin: {
48
- description: '${collectionDescription}',
49
- },`
50
- : ''
51
- }${
52
- hasUpload
53
- ? `
54
- upload: true,`
55
- : ''
56
- }
57
- fields: [
58
- ${fieldDefinitions}
59
- ],
60
- }
61
- `
62
-
63
- try {
64
- // Validate the collection name and path
65
- const fileName = `${capitalizedName}.ts`
66
- const filePath = join(collectionsDirPath, fileName)
67
-
68
- // Security check: ensure we're working with the collections directory
69
- if (!filePath.startsWith(collectionsDirPath)) {
70
- payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${filePath}`)
71
- return {
72
- content: [
73
- {
74
- type: 'text' as const,
75
- text: '❌ **Error**: Invalid collection path',
76
- },
77
- ],
78
- }
79
- }
80
-
81
- // Check if file already exists
82
- try {
83
- const fs = await import('fs')
84
- if (fs.existsSync(filePath)) {
85
- return {
86
- content: [
87
- {
88
- type: 'text' as const,
89
- text: `❌ **Error**: Collection file already exists: ${fileName}`,
90
- },
91
- ],
92
- }
93
- }
94
- } catch (_ignore) {
95
- // File doesn't exist, which is what we want
96
- }
97
-
98
- // Write the collection file
99
- writeFileSync(filePath, collectionContent, 'utf8')
100
- if (verboseLogs) {
101
- payload.logger.info(`[payload-mcp] Successfully created collection file: ${filePath}`)
102
- }
103
-
104
- // Validate the generated file
105
- const validationResult = await validateCollectionFile(fileName)
106
- if (validationResult.error) {
107
- return {
108
- content: [
109
- {
110
- type: 'text' as const,
111
- text: `❌ **Error**: Generated collection has validation issues:\n\n${validationResult.error}`,
112
- },
113
- ],
114
- }
115
- }
116
-
117
- return {
118
- content: [
119
- {
120
- type: 'text' as const,
121
- text: `✅ **Collection created successfully!**
122
- **File**: \`${fileName}\`
123
- **Collection Config:**
124
- \`\`\`typescript
125
- ${collectionContent}
126
- \`\`\``,
127
- },
128
- ],
129
- }
130
- } catch (error) {
131
- const errorMessage = (error as Error).message
132
- payload.logger.error(`[payload-mcp] Error creating collection: ${errorMessage}`)
133
-
134
- return {
135
- content: [
136
- {
137
- type: 'text' as const,
138
- text: `❌ **Error creating collection**: ${errorMessage}`,
139
- },
140
- ],
141
- }
142
- }
143
- }
144
-
145
- export const createCollectionTool = (
146
- server: McpServer,
147
- req: PayloadRequest,
148
- verboseLogs: boolean,
149
- collectionsDirPath: string,
150
- configFilePath: string,
151
- ) => {
152
- const tool = async (
153
- collectionName: string,
154
- collectionDescription?: string,
155
- fields: any[] = [],
156
- hasUpload?: boolean,
157
- ) => {
158
- const payload = req.payload
159
-
160
- if (verboseLogs) {
161
- payload.logger.info(
162
- `[payload-mcp] Creating collection: ${collectionName}, fields: ${fields.length}, upload: ${hasUpload}`,
163
- )
164
- }
165
-
166
- try {
167
- const result = await createCollection(
168
- req,
169
- verboseLogs,
170
- collectionsDirPath,
171
- configFilePath,
172
- collectionName,
173
- collectionDescription,
174
- fields,
175
- hasUpload,
176
- )
177
-
178
- if (verboseLogs) {
179
- payload.logger.info(`[payload-mcp] Collection creation completed for: ${collectionName}`)
180
- }
181
-
182
- return result
183
- } catch (error) {
184
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
185
- payload.logger.error(
186
- `[payload-mcp] Error creating collection ${collectionName}: ${errorMessage}`,
187
- )
188
-
189
- return {
190
- content: [
191
- {
192
- type: 'text' as const,
193
- text: `Error creating collection "${collectionName}": ${errorMessage}`,
194
- },
195
- ],
196
- }
197
- }
198
- }
199
-
200
- server.registerTool(
201
- 'createCollection',
202
- {
203
- description: toolSchemas.createCollection.description,
204
- inputSchema: toolSchemas.createCollection.parameters.shape,
205
- },
206
- async ({ collectionDescription, collectionName, fields, hasUpload }) => {
207
- return await tool(collectionName, collectionDescription, fields, hasUpload)
208
- },
209
- )
210
- }
@@ -1,211 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
- import type { PayloadRequest } from 'payload'
3
-
4
- import { readFileSync, unlinkSync, writeFileSync } from 'fs'
5
- import { join } from 'path'
6
-
7
- import { removeCollectionFromConfig } from '../../helpers/config.js'
8
- import { toolSchemas } from '../schemas.js'
9
-
10
- export const deleteCollection = (
11
- req: PayloadRequest,
12
- verboseLogs: boolean,
13
- collectionsDirPath: string,
14
- configFilePath: string,
15
- collectionName: string,
16
- confirmDeletion: boolean,
17
- updateConfig: boolean,
18
- ) => {
19
- const payload = req.payload
20
-
21
- if (verboseLogs) {
22
- payload.logger.info(`[payload-mcp] Attempting to delete collection: ${collectionName}`)
23
- }
24
-
25
- if (!confirmDeletion) {
26
- payload.logger.warn(`[payload-mcp] Deletion cancelled for collection: ${collectionName}`)
27
- return {
28
- content: [
29
- {
30
- type: 'text' as const,
31
- text: `❌ **Deletion cancelled**. Set confirmDeletion to true to proceed with deleting collection "${collectionName}".`,
32
- },
33
- ],
34
- }
35
- }
36
-
37
- const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)
38
- const collectionFilePath = join(collectionsDirPath, `${capitalizedName}.ts`)
39
-
40
- // Security check: ensure we're working with the collections directory
41
- if (!collectionFilePath.startsWith(collectionsDirPath)) {
42
- payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${collectionFilePath}`)
43
- return {
44
- content: [
45
- {
46
- type: 'text' as const,
47
- text: '❌ **Error**: Invalid collection path',
48
- },
49
- ],
50
- }
51
- }
52
-
53
- try {
54
- // Check if collection file exists
55
- let fileExists = false
56
- try {
57
- readFileSync(collectionFilePath, 'utf8')
58
- fileExists = true
59
- } catch {
60
- payload.logger.warn(`[payload-mcp] Collection file does not exist: ${collectionFilePath}`)
61
- }
62
-
63
- // Read current config if we need to update it
64
- let configContent = ''
65
- let configExists = false
66
- if (updateConfig) {
67
- try {
68
- configContent = readFileSync(configFilePath, 'utf8')
69
- configExists = true
70
- } catch {
71
- payload.logger.warn(`[payload-mcp] Config file does not exist: ${configFilePath}`)
72
- }
73
- }
74
-
75
- let responseText = ''
76
- let operationsPerformed = 0
77
-
78
- // Delete the collection file
79
- if (fileExists) {
80
- try {
81
- unlinkSync(collectionFilePath)
82
- if (verboseLogs) {
83
- payload.logger.info(
84
- `[payload-mcp] Successfully deleted collection file: ${collectionFilePath}`,
85
- )
86
- }
87
- responseText += `✅ Deleted collection file: \`${capitalizedName}.ts\`\n`
88
- operationsPerformed++
89
- } catch (error) {
90
- const errorMessage = (error as Error).message
91
- payload.logger.error(`[payload-mcp] Error deleting collection file: ${errorMessage}`)
92
- responseText += `❌ Error deleting collection file: ${errorMessage}\n`
93
- }
94
- } else {
95
- responseText += `⚠️ Collection file not found: \`${capitalizedName}.ts\`\n`
96
- }
97
-
98
- // Update the config file if requested and it exists
99
- if (updateConfig && configExists) {
100
- try {
101
- const updatedConfigContent = removeCollectionFromConfig(configContent, capitalizedName)
102
- writeFileSync(configFilePath, updatedConfigContent, 'utf8')
103
- if (verboseLogs) {
104
- payload.logger.info(`[payload-mcp] Successfully updated config file: ${configFilePath}`)
105
- }
106
- responseText += `✅ Updated payload.config.ts to remove collection reference\n`
107
- operationsPerformed++
108
- } catch (error) {
109
- const errorMessage = (error as Error).message
110
- payload.logger.error(`[payload-mcp] Error updating config file: ${errorMessage}`)
111
- responseText += `❌ Error updating config file: ${errorMessage}\n`
112
- }
113
- } else if (updateConfig && !configExists) {
114
- responseText += `⚠️ Config file not found: payload.config.ts\n`
115
- }
116
-
117
- // Summary
118
- if (operationsPerformed > 0) {
119
- responseText += `\n✅ **Collection deletion completed!**`
120
- } else {
121
- responseText += `\n⚠️ **No operations performed**
122
-
123
- The collection file may not have existed or there were errors during deletion.`
124
- }
125
-
126
- return {
127
- content: [
128
- {
129
- type: 'text' as const,
130
- text: responseText,
131
- },
132
- ],
133
- }
134
- } catch (error) {
135
- const errorMessage = (error as Error).message
136
- payload.logger.error(`[payload-mcp] Error during collection deletion: ${errorMessage}`)
137
- return {
138
- content: [
139
- {
140
- type: 'text' as const,
141
- text: `❌ **Error during collection deletion**: ${errorMessage}`,
142
- },
143
- ],
144
- }
145
- }
146
- }
147
-
148
- export const deleteCollectionTool = (
149
- server: McpServer,
150
- req: PayloadRequest,
151
- verboseLogs: boolean,
152
- collectionsDirPath: string,
153
- configFilePath: string,
154
- ) => {
155
- const tool = (
156
- collectionName: string,
157
- confirmDeletion: boolean,
158
- updateConfig: boolean = false,
159
- ) => {
160
- const payload = req.payload
161
-
162
- if (verboseLogs) {
163
- payload.logger.info(
164
- `[payload-mcp] Deleting collection: ${collectionName}, confirmDeletion: ${confirmDeletion}, updateConfig: ${updateConfig}`,
165
- )
166
- }
167
-
168
- try {
169
- const result = deleteCollection(
170
- req,
171
- verboseLogs,
172
- collectionsDirPath,
173
- configFilePath,
174
- collectionName,
175
- confirmDeletion,
176
- updateConfig,
177
- )
178
-
179
- if (verboseLogs) {
180
- payload.logger.info(`[payload-mcp] Collection deletion completed for: ${collectionName}`)
181
- }
182
-
183
- return result
184
- } catch (error) {
185
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
186
- payload.logger.error(
187
- `[payload-mcp] Error deleting collection ${collectionName}: ${errorMessage}`,
188
- )
189
-
190
- return {
191
- content: [
192
- {
193
- type: 'text' as const,
194
- text: `Error deleting collection "${collectionName}": ${errorMessage}`,
195
- },
196
- ],
197
- }
198
- }
199
- }
200
-
201
- server.registerTool(
202
- 'deleteCollection',
203
- {
204
- description: toolSchemas.deleteCollection.description,
205
- inputSchema: toolSchemas.deleteCollection.parameters.shape,
206
- },
207
- ({ collectionName, confirmDeletion, updateConfig }) => {
208
- return tool(collectionName, confirmDeletion, updateConfig)
209
- },
210
- )
211
- }