@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,154 +0,0 @@
1
- import { readFileSync, unlinkSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { removeCollectionFromConfig } from '../../helpers/config.js';
4
- import { toolSchemas } from '../schemas.js';
5
- export const deleteCollection = (req, verboseLogs, collectionsDirPath, configFilePath, collectionName, confirmDeletion, updateConfig)=>{
6
- const payload = req.payload;
7
- if (verboseLogs) {
8
- payload.logger.info(`[payload-mcp] Attempting to delete collection: ${collectionName}`);
9
- }
10
- if (!confirmDeletion) {
11
- payload.logger.warn(`[payload-mcp] Deletion cancelled for collection: ${collectionName}`);
12
- return {
13
- content: [
14
- {
15
- type: 'text',
16
- text: `❌ **Deletion cancelled**. Set confirmDeletion to true to proceed with deleting collection "${collectionName}".`
17
- }
18
- ]
19
- };
20
- }
21
- const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1);
22
- const collectionFilePath = join(collectionsDirPath, `${capitalizedName}.ts`);
23
- // Security check: ensure we're working with the collections directory
24
- if (!collectionFilePath.startsWith(collectionsDirPath)) {
25
- payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${collectionFilePath}`);
26
- return {
27
- content: [
28
- {
29
- type: 'text',
30
- text: '❌ **Error**: Invalid collection path'
31
- }
32
- ]
33
- };
34
- }
35
- try {
36
- // Check if collection file exists
37
- let fileExists = false;
38
- try {
39
- readFileSync(collectionFilePath, 'utf8');
40
- fileExists = true;
41
- } catch {
42
- payload.logger.warn(`[payload-mcp] Collection file does not exist: ${collectionFilePath}`);
43
- }
44
- // Read current config if we need to update it
45
- let configContent = '';
46
- let configExists = false;
47
- if (updateConfig) {
48
- try {
49
- configContent = readFileSync(configFilePath, 'utf8');
50
- configExists = true;
51
- } catch {
52
- payload.logger.warn(`[payload-mcp] Config file does not exist: ${configFilePath}`);
53
- }
54
- }
55
- let responseText = '';
56
- let operationsPerformed = 0;
57
- // Delete the collection file
58
- if (fileExists) {
59
- try {
60
- unlinkSync(collectionFilePath);
61
- if (verboseLogs) {
62
- payload.logger.info(`[payload-mcp] Successfully deleted collection file: ${collectionFilePath}`);
63
- }
64
- responseText += `✅ Deleted collection file: \`${capitalizedName}.ts\`\n`;
65
- operationsPerformed++;
66
- } catch (error) {
67
- const errorMessage = error.message;
68
- payload.logger.error(`[payload-mcp] Error deleting collection file: ${errorMessage}`);
69
- responseText += `❌ Error deleting collection file: ${errorMessage}\n`;
70
- }
71
- } else {
72
- responseText += `⚠️ Collection file not found: \`${capitalizedName}.ts\`\n`;
73
- }
74
- // Update the config file if requested and it exists
75
- if (updateConfig && configExists) {
76
- try {
77
- const updatedConfigContent = removeCollectionFromConfig(configContent, capitalizedName);
78
- writeFileSync(configFilePath, updatedConfigContent, 'utf8');
79
- if (verboseLogs) {
80
- payload.logger.info(`[payload-mcp] Successfully updated config file: ${configFilePath}`);
81
- }
82
- responseText += `✅ Updated payload.config.ts to remove collection reference\n`;
83
- operationsPerformed++;
84
- } catch (error) {
85
- const errorMessage = error.message;
86
- payload.logger.error(`[payload-mcp] Error updating config file: ${errorMessage}`);
87
- responseText += `❌ Error updating config file: ${errorMessage}\n`;
88
- }
89
- } else if (updateConfig && !configExists) {
90
- responseText += `⚠️ Config file not found: payload.config.ts\n`;
91
- }
92
- // Summary
93
- if (operationsPerformed > 0) {
94
- responseText += `\n✅ **Collection deletion completed!**`;
95
- } else {
96
- responseText += `\n⚠️ **No operations performed**
97
-
98
- The collection file may not have existed or there were errors during deletion.`;
99
- }
100
- return {
101
- content: [
102
- {
103
- type: 'text',
104
- text: responseText
105
- }
106
- ]
107
- };
108
- } catch (error) {
109
- const errorMessage = error.message;
110
- payload.logger.error(`[payload-mcp] Error during collection deletion: ${errorMessage}`);
111
- return {
112
- content: [
113
- {
114
- type: 'text',
115
- text: `❌ **Error during collection deletion**: ${errorMessage}`
116
- }
117
- ]
118
- };
119
- }
120
- };
121
- export const deleteCollectionTool = (server, req, verboseLogs, collectionsDirPath, configFilePath)=>{
122
- const tool = (collectionName, confirmDeletion, updateConfig = false)=>{
123
- const payload = req.payload;
124
- if (verboseLogs) {
125
- payload.logger.info(`[payload-mcp] Deleting collection: ${collectionName}, confirmDeletion: ${confirmDeletion}, updateConfig: ${updateConfig}`);
126
- }
127
- try {
128
- const result = deleteCollection(req, verboseLogs, collectionsDirPath, configFilePath, collectionName, confirmDeletion, updateConfig);
129
- if (verboseLogs) {
130
- payload.logger.info(`[payload-mcp] Collection deletion completed for: ${collectionName}`);
131
- }
132
- return result;
133
- } catch (error) {
134
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
135
- payload.logger.error(`[payload-mcp] Error deleting collection ${collectionName}: ${errorMessage}`);
136
- return {
137
- content: [
138
- {
139
- type: 'text',
140
- text: `Error deleting collection "${collectionName}": ${errorMessage}`
141
- }
142
- ]
143
- };
144
- }
145
- };
146
- server.registerTool('deleteCollection', {
147
- description: toolSchemas.deleteCollection.description,
148
- inputSchema: toolSchemas.deleteCollection.parameters.shape
149
- }, ({ collectionName, confirmDeletion, updateConfig })=>{
150
- return tool(collectionName, confirmDeletion, updateConfig);
151
- });
152
- };
153
-
154
- //# sourceMappingURL=delete.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/collection/delete.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readFileSync, unlinkSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport { removeCollectionFromConfig } from '../../helpers/config.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const deleteCollection = (\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n collectionName: string,\n confirmDeletion: boolean,\n updateConfig: boolean,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Attempting to delete collection: ${collectionName}`)\n }\n\n if (!confirmDeletion) {\n payload.logger.warn(`[payload-mcp] Deletion cancelled for collection: ${collectionName}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Deletion cancelled**. Set confirmDeletion to true to proceed with deleting collection \"${collectionName}\".`,\n },\n ],\n }\n }\n\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n const collectionFilePath = join(collectionsDirPath, `${capitalizedName}.ts`)\n\n // Security check: ensure we're working with the collections directory\n if (!collectionFilePath.startsWith(collectionsDirPath)) {\n payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${collectionFilePath}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: Invalid collection path',\n },\n ],\n }\n }\n\n try {\n // Check if collection file exists\n let fileExists = false\n try {\n readFileSync(collectionFilePath, 'utf8')\n fileExists = true\n } catch {\n payload.logger.warn(`[payload-mcp] Collection file does not exist: ${collectionFilePath}`)\n }\n\n // Read current config if we need to update it\n let configContent = ''\n let configExists = false\n if (updateConfig) {\n try {\n configContent = readFileSync(configFilePath, 'utf8')\n configExists = true\n } catch {\n payload.logger.warn(`[payload-mcp] Config file does not exist: ${configFilePath}`)\n }\n }\n\n let responseText = ''\n let operationsPerformed = 0\n\n // Delete the collection file\n if (fileExists) {\n try {\n unlinkSync(collectionFilePath)\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully deleted collection file: ${collectionFilePath}`,\n )\n }\n responseText += `✅ Deleted collection file: \\`${capitalizedName}.ts\\`\\n`\n operationsPerformed++\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error deleting collection file: ${errorMessage}`)\n responseText += `❌ Error deleting collection file: ${errorMessage}\\n`\n }\n } else {\n responseText += `⚠️ Collection file not found: \\`${capitalizedName}.ts\\`\\n`\n }\n\n // Update the config file if requested and it exists\n if (updateConfig && configExists) {\n try {\n const updatedConfigContent = removeCollectionFromConfig(configContent, capitalizedName)\n writeFileSync(configFilePath, updatedConfigContent, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated config file: ${configFilePath}`)\n }\n responseText += `✅ Updated payload.config.ts to remove collection reference\\n`\n operationsPerformed++\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error updating config file: ${errorMessage}`)\n responseText += `❌ Error updating config file: ${errorMessage}\\n`\n }\n } else if (updateConfig && !configExists) {\n responseText += `⚠️ Config file not found: payload.config.ts\\n`\n }\n\n // Summary\n if (operationsPerformed > 0) {\n responseText += `\\n✅ **Collection deletion completed!**`\n } else {\n responseText += `\\n⚠️ **No operations performed**\n\nThe collection file may not have existed or there were errors during deletion.`\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error during collection deletion: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error during collection deletion**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\nexport const deleteCollectionTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n) => {\n const tool = (\n collectionName: string,\n confirmDeletion: boolean,\n updateConfig: boolean = false,\n ) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Deleting collection: ${collectionName}, confirmDeletion: ${confirmDeletion}, updateConfig: ${updateConfig}`,\n )\n }\n\n try {\n const result = deleteCollection(\n req,\n verboseLogs,\n collectionsDirPath,\n configFilePath,\n collectionName,\n confirmDeletion,\n updateConfig,\n )\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Collection deletion completed for: ${collectionName}`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error deleting collection ${collectionName}: ${errorMessage}`,\n )\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error deleting collection \"${collectionName}\": ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'deleteCollection',\n {\n description: toolSchemas.deleteCollection.description,\n inputSchema: toolSchemas.deleteCollection.parameters.shape,\n },\n ({ collectionName, confirmDeletion, updateConfig }) => {\n return tool(collectionName, confirmDeletion, updateConfig)\n },\n )\n}\n"],"names":["readFileSync","unlinkSync","writeFileSync","join","removeCollectionFromConfig","toolSchemas","deleteCollection","req","verboseLogs","collectionsDirPath","configFilePath","collectionName","confirmDeletion","updateConfig","payload","logger","info","warn","content","type","text","capitalizedName","charAt","toUpperCase","slice","collectionFilePath","startsWith","error","fileExists","configContent","configExists","responseText","operationsPerformed","errorMessage","message","updatedConfigContent","deleteCollectionTool","server","tool","result","Error","registerTool","description","inputSchema","parameters","shape"],"mappings":"AAGA,SAASA,YAAY,EAAEC,UAAU,EAAEC,aAAa,QAAQ,KAAI;AAC5D,SAASC,IAAI,QAAQ,OAAM;AAE3B,SAASC,0BAA0B,QAAQ,0BAAyB;AACpE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,CAC9BC,KACAC,aACAC,oBACAC,gBACAC,gBACAC,iBACAC;IAEA,MAAMC,UAAUP,IAAIO,OAAO;IAE3B,IAAIN,aAAa;QACfM,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,+CAA+C,EAAEL,gBAAgB;IACxF;IAEA,IAAI,CAACC,iBAAiB;QACpBE,QAAQC,MAAM,CAACE,IAAI,CAAC,CAAC,iDAAiD,EAAEN,gBAAgB;QACxF,OAAO;YACLO,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,2FAA2F,EAAET,eAAe,EAAE,CAAC;gBACxH;aACD;QACH;IACF;IAEA,MAAMU,kBAAkBV,eAAeW,MAAM,CAAC,GAAGC,WAAW,KAAKZ,eAAea,KAAK,CAAC;IACtF,MAAMC,qBAAqBtB,KAAKM,oBAAoB,GAAGY,gBAAgB,GAAG,CAAC;IAE3E,sEAAsE;IACtE,IAAI,CAACI,mBAAmBC,UAAU,CAACjB,qBAAqB;QACtDK,QAAQC,MAAM,CAACY,KAAK,CAAC,CAAC,iDAAiD,EAAEF,oBAAoB;QAC7F,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM;gBACR;aACD;QACH;IACF;IAEA,IAAI;QACF,kCAAkC;QAClC,IAAIQ,aAAa;QACjB,IAAI;YACF5B,aAAayB,oBAAoB;YACjCG,aAAa;QACf,EAAE,OAAM;YACNd,QAAQC,MAAM,CAACE,IAAI,CAAC,CAAC,8CAA8C,EAAEQ,oBA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O;gBACLf,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,2BAA2B,EAAET,eAAe,GAAG,EAAEsB,cAAc;oBACxE;iBACD;YACH;QACF;IACF;IAEAI,OAAOI,YAAY,CACjB,oBACA;QACEC,aAAarC,YAAYC,gBAAgB,CAACoC,WAAW;QACrDC,aAAatC,YAAYC,gBAAgB,CAACsC,UAAU,CAACC,KAAK;IAC5D,GACA,CAAC,EAAElC,cAAc,EAAEC,eAAe,EAAEC,YAAY,EAAE;QAChD,OAAOyB,KAAK3B,gBAAgBC,iBAAiBC;IAC/C;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const readCollections: (req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string, collectionName?: string, includeContent?: boolean, includeCount?: boolean) => {
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- };
9
- export declare const findCollectionTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string) => void;
10
- //# sourceMappingURL=find.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/collection/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAO7C,eAAO,MAAM,eAAe,QACrB,cAAc,eACN,OAAO,sBACA,MAAM,mBACT,MAAM,mBACP,OAAO,iBACT,OAAO;;;;;CAmJtB,CAAA;AAGD,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,eACN,OAAO,sBACA,MAAM,SAuD3B,CAAA"}
@@ -1,165 +0,0 @@
1
- import { readdirSync, readFileSync, statSync } from 'fs';
2
- import { extname, join } from 'path';
3
- import { toolSchemas } from '../schemas.js';
4
- export const readCollections = (req, verboseLogs, collectionsDirPath, collectionName, includeContent = false, includeCount = false)=>{
5
- const payload = req.payload;
6
- if (verboseLogs) {
7
- payload.logger.info(`[payload-mcp] Reading collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`);
8
- }
9
- try {
10
- // Read specific Collection (optional)
11
- if (collectionName) {
12
- const fileName = `${collectionName.charAt(0).toUpperCase() + collectionName.slice(1)}.ts`;
13
- const filePath = join(collectionsDirPath, fileName);
14
- if (!filePath.startsWith(collectionsDirPath)) {
15
- payload.logger.error(`[payload-mcp] Invalid collection name attempted: ${collectionName}`);
16
- return {
17
- content: [
18
- {
19
- type: 'text',
20
- text: 'Error: Invalid collection name'
21
- }
22
- ]
23
- };
24
- }
25
- try {
26
- const content = readFileSync(filePath, 'utf8');
27
- if (verboseLogs) {
28
- payload.logger.info(`[payload-mcp] Successfully read collection: ${collectionName}`);
29
- }
30
- return {
31
- content: [
32
- {
33
- type: 'text',
34
- text: `Collection: ${collectionName}
35
- File: ${fileName}
36
- ---
37
- ${content}`
38
- }
39
- ]
40
- };
41
- } catch (_error) {
42
- payload.logger.warn(`[payload-mcp] Collection not found: ${collectionName}`);
43
- return {
44
- content: [
45
- {
46
- type: 'text',
47
- text: `Error: Collection '${collectionName}' not found`
48
- }
49
- ]
50
- };
51
- }
52
- }
53
- // Read all Collections
54
- const files = readdirSync(collectionsDirPath).filter((file)=>extname(file) === '.ts').sort();
55
- if (verboseLogs) {
56
- payload.logger.info(`[payload-mcp] Found ${files.length} collection files in directory`);
57
- }
58
- if (files.length === 0) {
59
- payload.logger.warn('[payload-mcp] No collection files found in src/collections directory');
60
- return {
61
- content: [
62
- {
63
- type: 'text',
64
- text: 'No collection files found in src/collections directory'
65
- }
66
- ]
67
- };
68
- }
69
- const results = [];
70
- // Build complete table as a single markdown string
71
- let tableContent = `Found ${files.length} collection file(s):\n\n`;
72
- // Build table header
73
- let tableHeader = '| Collection | File | Size | Modified';
74
- let tableSeparator = '|------------|------|------|----------';
75
- if (includeCount) {
76
- tableHeader += ' | Documents';
77
- tableSeparator += ' |----------';
78
- }
79
- tableHeader += ' |';
80
- tableSeparator += ' |';
81
- tableContent += tableHeader + '\n';
82
- tableContent += tableSeparator + '\n';
83
- for (const file of files){
84
- const filePath = join(collectionsDirPath, file);
85
- const stats = statSync(filePath);
86
- const fileSize = stats.size;
87
- const lastModified = stats.mtime;
88
- const collectionName = file.replace('.ts', '');
89
- // Build table row
90
- let tableRow = `| **${collectionName}** | ${file} | ${fileSize.toLocaleString()} bytes | ${lastModified.toISOString()}`;
91
- // Add document count if requested
92
- if (includeCount) {
93
- try {
94
- // For now, we'll skip document counting since we don't have access to payload instance
95
- tableRow += ' | -';
96
- } catch (error) {
97
- tableRow += ` | Error: ${error.message}`;
98
- }
99
- }
100
- tableRow += ' |';
101
- tableContent += tableRow + '\n';
102
- if (includeContent) {
103
- try {
104
- const content = readFileSync(filePath, 'utf8');
105
- tableContent += `\n**${collectionName} Content:**\n\`\`\`typescript\n${content}\n\`\`\`\n\n`;
106
- } catch (error) {
107
- tableContent += `\nError reading content: ${error.message}\n\n`;
108
- }
109
- }
110
- }
111
- results.push({
112
- type: 'text',
113
- text: tableContent
114
- });
115
- return {
116
- content: results
117
- };
118
- } catch (error) {
119
- const errorMessage = error.message;
120
- payload.logger.error(`[payload-mcp] Error reading collections: ${errorMessage}`);
121
- return {
122
- content: [
123
- {
124
- type: 'text',
125
- text: `❌ **Error reading collections**: ${errorMessage}`
126
- }
127
- ]
128
- };
129
- }
130
- };
131
- // MCP Server tool registration
132
- export const findCollectionTool = (server, req, verboseLogs, collectionsDirPath)=>{
133
- const tool = (collectionName, includeContent = false, includeCount = false)=>{
134
- const payload = req.payload;
135
- if (verboseLogs) {
136
- payload.logger.info(`[payload-mcp] Finding collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`);
137
- }
138
- try {
139
- const result = readCollections(req, verboseLogs, collectionsDirPath, collectionName, includeContent, includeCount);
140
- if (verboseLogs) {
141
- payload.logger.info(`[payload-mcp] Collection search completed`);
142
- }
143
- return result;
144
- } catch (error) {
145
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
146
- payload.logger.error(`[payload-mcp] Error finding collections: ${errorMessage}`);
147
- return {
148
- content: [
149
- {
150
- type: 'text',
151
- text: `Error finding collections: ${errorMessage}`
152
- }
153
- ]
154
- };
155
- }
156
- };
157
- server.registerTool('findCollections', {
158
- description: toolSchemas.findCollections.description,
159
- inputSchema: toolSchemas.findCollections.parameters.shape
160
- }, ({ collectionName, includeContent, includeCount })=>{
161
- return tool(collectionName, includeContent, includeCount);
162
- });
163
- };
164
-
165
- //# sourceMappingURL=find.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/collection/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readdirSync, readFileSync, statSync } from 'fs'\nimport { extname, join } from 'path'\n\nimport { toolSchemas } from '../schemas.js'\n\nexport const readCollections = (\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n collectionName?: string,\n includeContent: boolean = false,\n includeCount: boolean = false,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Reading collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`,\n )\n }\n\n try {\n // Read specific Collection (optional)\n if (collectionName) {\n const fileName = `${collectionName.charAt(0).toUpperCase() + collectionName.slice(1)}.ts`\n const filePath = join(collectionsDirPath, fileName)\n\n if (!filePath.startsWith(collectionsDirPath)) {\n payload.logger.error(`[payload-mcp] Invalid collection name attempted: ${collectionName}`)\n return {\n content: [{ type: 'text' as const, text: 'Error: Invalid collection name' }],\n }\n }\n\n try {\n const content = readFileSync(filePath, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully read collection: ${collectionName}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Collection: ${collectionName}\nFile: ${fileName}\n---\n${content}`,\n },\n ],\n }\n } catch (_error) {\n payload.logger.warn(`[payload-mcp] Collection not found: ${collectionName}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error: Collection '${collectionName}' not found`,\n },\n ],\n }\n }\n }\n\n // Read all Collections\n const files = readdirSync(collectionsDirPath)\n .filter((file) => extname(file) === '.ts')\n .sort()\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found ${files.length} collection files in directory`)\n }\n\n if (files.length === 0) {\n payload.logger.warn('[payload-mcp] No collection files found in src/collections directory')\n return {\n content: [\n {\n type: 'text' as const,\n text: 'No collection files found in src/collections directory',\n },\n ],\n }\n }\n\n const results = []\n\n // Build complete table as a single markdown string\n let tableContent = `Found ${files.length} collection file(s):\\n\\n`\n\n // Build table header\n let tableHeader = '| Collection | File | Size | Modified'\n let tableSeparator = '|------------|------|------|----------'\n\n if (includeCount) {\n tableHeader += ' | Documents'\n tableSeparator += ' |----------'\n }\n tableHeader += ' |'\n tableSeparator += ' |'\n\n tableContent += tableHeader + '\\n'\n tableContent += tableSeparator + '\\n'\n\n for (const file of files) {\n const filePath = join(collectionsDirPath, file)\n const stats = statSync(filePath)\n const fileSize = stats.size\n const lastModified = stats.mtime\n\n const collectionName = file.replace('.ts', '')\n\n // Build table row\n let tableRow = `| **${collectionName}** | ${file} | ${fileSize.toLocaleString()} bytes | ${lastModified.toISOString()}`\n\n // Add document count if requested\n if (includeCount) {\n try {\n // For now, we'll skip document counting since we don't have access to payload instance\n tableRow += ' | -'\n } catch (error) {\n tableRow += ` | Error: ${(error as Error).message}`\n }\n }\n tableRow += ' |'\n\n tableContent += tableRow + '\\n'\n\n if (includeContent) {\n try {\n const content = readFileSync(filePath, 'utf8')\n tableContent += `\\n**${collectionName} Content:**\\n\\`\\`\\`typescript\\n${content}\\n\\`\\`\\`\\n\\n`\n } catch (error) {\n tableContent += `\\nError reading content: ${(error as Error).message}\\n\\n`\n }\n }\n }\n\n results.push({\n type: 'text' as const,\n text: tableContent,\n })\n\n return {\n content: results,\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error reading collections: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading collections**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// MCP Server tool registration\nexport const findCollectionTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n) => {\n const tool = (\n collectionName?: string,\n includeContent: boolean = false,\n includeCount: boolean = false,\n ) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Finding collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`,\n )\n }\n\n try {\n const result = readCollections(\n req,\n verboseLogs,\n collectionsDirPath,\n collectionName,\n includeContent,\n includeCount,\n )\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Collection search completed`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(`[payload-mcp] Error finding collections: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error finding collections: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'findCollections',\n {\n description: toolSchemas.findCollections.description,\n inputSchema: toolSchemas.findCollections.parameters.shape,\n },\n ({ collectionName, includeContent, includeCount }) => {\n return tool(collectionName, includeContent, includeCount)\n },\n )\n}\n"],"names":["readdirSync","readFileSync","statSync","extname","join","toolSchemas","readCollections","req","verboseLogs","collectionsDirPath","collectionName","includeContent","includeCount","payload","logger","info","fileName","charAt","toUpperCase","slice","filePath","startsWith","error","content","type","text","_error","warn","files","filter","file","sort","length","results","tableContent","tableHeader","tableSeparator","stats","fileSize","size","lastModified","mtime","replace","tableRow","toLocaleString","toISOString","message","push","errorMessage","findCollectionTool","server","tool","result","Error","registerTool","description","findCollections","inputSchema","parameters","shape"],"mappings":"AAGA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,KAAI;AACxD,SAASC,OAAO,EAAEC,IAAI,QAAQ,OAAM;AAEpC,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,kBAAkB,CAC7BC,KACAC,aACAC,oBACAC,gBACAC,iBAA0B,KAAK,EAC/BC,eAAwB,KAAK;IAE7B,MAAMC,UAAUN,IAAIM,OAAO;IAE3B,IAAIL,aAAa;QACfK,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,iCAAiC,EAAEL,iBAAiB,CAAC,MAAM,EAAEA,gBAAgB,GAAG,GAAG,kBAAkB,EAAEC,eAAe,gBAAgB,EAAEC,cAAc;IAE3J;IAEA,IAAI;QACF,sCAAsC;QACtC,IAAIF,gBAAgB;YAClB,MAAMM,WAAW,GAAGN,eAAeO,MAAM,CAAC,GAAGC,WAAW,KAAKR,eAAeS,KAAK,CAAC,GAAG,GAAG,CAAC;YACzF,MAAMC,WAAWhB,KAAKK,oBAAoBO;YAE1C,IAAI,CAACI,SAASC,UAAU,CAACZ,qBAAqB;gBAC5CI,QAAQC,MAAM,CAACQ,KAAK,CAAC,CAAC,iDAAiD,EAAEZ,gBAAgB;gBACzF,OAAO;oBACLa,SAAS;wBAAC;4BAAEC,MAAM;4BAAiBC,MAAM;wBAAiC;qBAAE;gBAC9E;YACF;YAEA,IAAI;gBACF,MAAMF,UAAUtB,aAAamB,UAAU;gBACvC,IAAIZ,aAAa;oBACfK,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,4CAA4C,EAAEL,gBAAgB;gBACrF;gBAEA,OAAO;oBACLa,SAAS;wBACP;4BACEC,MAAM;4BACNC,MAAM,CAAC,YAAY,EAAEf,eAAe;MAC5C,EAAEM,SAAS;;AAEjB,EAAEO,SAAS;wBACC;qBACD;gBACH;YACF,EAAE,OAAOG,QAAQ;gBACfb,Q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AS9C,gBACbC,KACAC,aACAC,oBACAC,gBACAC,gBACAC;YAGF,IAAIJ,aAAa;gBACfK,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,yCAAyC,CAAC;YACjE;YAEA,OAAOqC;QACT,EAAE,OAAO9B,OAAO;YACd,MAAM0B,eAAe1B,iBAAiB+B,QAAQ/B,MAAMwB,OAAO,GAAG;YAC9DjC,QAAQC,MAAM,CAACQ,KAAK,CAAC,CAAC,yCAAyC,EAAE0B,cAAc;YAE/E,OAAO;gBACLzB,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,2BAA2B,EAAEuB,cAAc;oBACpD;iBACD;YACH;QACF;IACF;IAEAE,OAAOI,YAAY,CACjB,mBACA;QACEC,aAAalD,YAAYmD,eAAe,CAACD,WAAW;QACpDE,aAAapD,YAAYmD,eAAe,CAACE,UAAU,CAACC,KAAK;IAC3D,GACA,CAAC,EAAEjD,cAAc,EAAEC,cAAc,EAAEC,YAAY,EAAE;QAC/C,OAAOuC,KAAKzC,gBAAgBC,gBAAgBC;IAC9C;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const updateCollection: (req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string, configFilePath: string, collectionName: string, updateType: string, newFields?: any[], fieldNamesToRemove?: string[], fieldModifications?: any[], configUpdates?: any, newContent?: string) => Promise<{
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- }>;
9
- export declare const updateCollectionTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string, configFilePath: string) => void;
10
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/collection/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAa7C,eAAO,MAAM,gBAAgB,QACtB,cAAc,eACN,OAAO,sBACA,MAAM,kBACV,MAAM,kBACN,MAAM,cACV,MAAM,cACN,GAAG,EAAE,uBACI,MAAM,EAAE,uBACR,GAAG,EAAE,kBACV,GAAG,eACN,MAAM;;;;;EAuLpB,CAAA;AAED,eAAO,MAAM,oBAAoB,WACvB,SAAS,OACZ,cAAc,eACN,OAAO,sBACA,MAAM,kBACV,MAAM,SA0EvB,CAAA"}
@@ -1,209 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { addFieldsToCollection, modifyFieldsInCollection, removeFieldsFromCollection } from '../../helpers/fields.js';
4
- import { validateCollectionFile } from '../../helpers/fileValidation.js';
5
- import { toolSchemas } from '../schemas.js';
6
- export const updateCollection = async (req, verboseLogs, collectionsDirPath, configFilePath, collectionName, updateType, newFields, fieldNamesToRemove, fieldModifications, configUpdates, newContent)=>{
7
- const payload = req.payload;
8
- if (verboseLogs) {
9
- payload.logger.info(`[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`);
10
- }
11
- const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1);
12
- const fileName = `${capitalizedName}.ts`;
13
- const filePath = join(collectionsDirPath, fileName);
14
- // Security check: ensure we're working with the collections directory
15
- if (!filePath.startsWith(collectionsDirPath)) {
16
- payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${filePath}`);
17
- return {
18
- content: [
19
- {
20
- type: 'text',
21
- text: '❌ **Error**: Invalid collection path'
22
- }
23
- ]
24
- };
25
- }
26
- try {
27
- // Check if collection file exists
28
- let currentContent;
29
- try {
30
- currentContent = readFileSync(filePath, 'utf8');
31
- } catch (_ignore) {
32
- return {
33
- content: [
34
- {
35
- type: 'text',
36
- text: `❌ **Error**: Collection file not found: ${fileName}`
37
- }
38
- ]
39
- };
40
- }
41
- let updatedContent;
42
- let updateSummary = [];
43
- switch(updateType){
44
- case 'add_field':
45
- if (!newFields || newFields.length === 0) {
46
- return {
47
- content: [
48
- {
49
- type: 'text',
50
- text: '❌ **Error**: No fields provided for add_field update type'
51
- }
52
- ]
53
- };
54
- }
55
- updatedContent = addFieldsToCollection(currentContent, newFields);
56
- updateSummary = newFields.map((field)=>`Added field: ${field.name} (${field.type})`);
57
- break;
58
- case 'modify_field':
59
- if (!fieldModifications || fieldModifications.length === 0) {
60
- return {
61
- content: [
62
- {
63
- type: 'text',
64
- text: '❌ **Error**: No field modifications provided for modify_field update type'
65
- }
66
- ]
67
- };
68
- }
69
- updatedContent = modifyFieldsInCollection(currentContent, fieldModifications);
70
- updateSummary = fieldModifications.map((mod)=>`Modified field: ${mod.fieldName}`);
71
- break;
72
- case 'remove_field':
73
- if (!fieldNamesToRemove || fieldNamesToRemove.length === 0) {
74
- return {
75
- content: [
76
- {
77
- type: 'text',
78
- text: '❌ **Error**: No field names provided for remove_field update type'
79
- }
80
- ]
81
- };
82
- }
83
- updatedContent = removeFieldsFromCollection(currentContent, fieldNamesToRemove);
84
- updateSummary = fieldNamesToRemove.map((fieldName)=>`Removed field: ${fieldName}`);
85
- break;
86
- case 'replace_content':
87
- if (!newContent) {
88
- return {
89
- content: [
90
- {
91
- type: 'text',
92
- text: '❌ **Error**: No new content provided for replace_content update type'
93
- }
94
- ]
95
- };
96
- }
97
- updatedContent = newContent;
98
- updateSummary = [
99
- 'Replaced entire collection content'
100
- ];
101
- break;
102
- case 'update_config':
103
- if (!configUpdates) {
104
- return {
105
- content: [
106
- {
107
- type: 'text',
108
- text: '❌ **Error**: No config updates provided for update_config update type'
109
- }
110
- ]
111
- };
112
- }
113
- // For now, we'll use a simple approach since the config helper might not have this functionality
114
- updatedContent = currentContent;
115
- updateSummary = Object.keys(configUpdates).map((key)=>`Updated config: ${key}`);
116
- break;
117
- default:
118
- return {
119
- content: [
120
- {
121
- type: 'text',
122
- text: `❌ **Error**: Unknown update type: ${updateType}`
123
- }
124
- ]
125
- };
126
- }
127
- // Write the updated content back to the file
128
- writeFileSync(filePath, updatedContent, 'utf8');
129
- if (verboseLogs) {
130
- payload.logger.info(`[payload-mcp] Successfully updated collection file: ${filePath}`);
131
- }
132
- // Validate the updated file
133
- const validationResult = await validateCollectionFile(fileName);
134
- if (validationResult.error) {
135
- return {
136
- content: [
137
- {
138
- type: 'text',
139
- text: `❌ **Error**: Updated collection has validation issues:\n\n${validationResult.error}`
140
- }
141
- ]
142
- };
143
- }
144
- return {
145
- content: [
146
- {
147
- type: 'text',
148
- text: `✅ **Collection updated successfully!**
149
-
150
- **File**: \`${fileName}\`
151
- **Update Type**: ${updateType}
152
-
153
- **Changes Made**:
154
- ${updateSummary.map((summary)=>`- ${summary}`).join('\n')}
155
-
156
- **Updated Collection Code:**
157
- \`\`\`typescript
158
- ${updatedContent}
159
- \`\`\``
160
- }
161
- ]
162
- };
163
- } catch (error) {
164
- const errorMessage = error.message;
165
- payload.logger.error(`[payload-mcp] Error updating collection: ${errorMessage}`);
166
- return {
167
- content: [
168
- {
169
- type: 'text',
170
- text: `❌ **Error updating collection**: ${errorMessage}`
171
- }
172
- ]
173
- };
174
- }
175
- };
176
- export const updateCollectionTool = (server, req, verboseLogs, collectionsDirPath, configFilePath)=>{
177
- const tool = async ({ collectionName, configUpdates, fieldModifications, fieldNamesToRemove, newContent, newFields, updateType })=>{
178
- const payload = req.payload;
179
- if (verboseLogs) {
180
- payload.logger.info(`[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`);
181
- }
182
- try {
183
- const result = await updateCollection(req, verboseLogs, collectionsDirPath, configFilePath, collectionName, updateType, newFields, fieldNamesToRemove, fieldModifications, configUpdates, newContent);
184
- if (verboseLogs) {
185
- payload.logger.info(`[payload-mcp] Collection update completed for: ${collectionName}`);
186
- }
187
- return result;
188
- } catch (error) {
189
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
190
- payload.logger.error(`[payload-mcp] Error updating collection ${collectionName}: ${errorMessage}`);
191
- return {
192
- content: [
193
- {
194
- type: 'text',
195
- text: `Error updating collection "${collectionName}": ${errorMessage}`
196
- }
197
- ]
198
- };
199
- }
200
- };
201
- server.registerTool('updateCollection', {
202
- description: toolSchemas.updateCollection.description,
203
- inputSchema: toolSchemas.updateCollection.parameters.shape
204
- }, async (args)=>{
205
- return await tool(args);
206
- });
207
- };
208
-
209
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/collection/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport {\n addFieldsToCollection,\n modifyFieldsInCollection,\n removeFieldsFromCollection,\n} from '../../helpers/fields.js'\nimport { validateCollectionFile } from '../../helpers/fileValidation.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const updateCollection = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n collectionName: string,\n updateType: string,\n newFields?: any[],\n fieldNamesToRemove?: string[],\n fieldModifications?: any[],\n configUpdates?: any,\n newContent?: string,\n) => {\n const payload = req.payload\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`,\n )\n }\n\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n const fileName = `${capitalizedName}.ts`\n const filePath = join(collectionsDirPath, fileName)\n\n // Security check: ensure we're working with the collections directory\n if (!filePath.startsWith(collectionsDirPath)) {\n payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${filePath}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: Invalid collection path',\n },\n ],\n }\n }\n\n try {\n // Check if collection file exists\n let currentContent: string\n try {\n currentContent = readFileSync(filePath, 'utf8')\n } catch (_ignore) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Collection file not found: ${fileName}`,\n },\n ],\n }\n }\n\n let updatedContent: string\n let updateSummary: string[] = []\n\n switch (updateType) {\n case 'add_field':\n if (!newFields || newFields.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No fields provided for add_field update type',\n },\n ],\n }\n }\n updatedContent = addFieldsToCollection(currentContent, newFields)\n updateSummary = newFields.map((field: any) => `Added field: ${field.name} (${field.type})`)\n break\n\n case 'modify_field':\n if (!fieldModifications || fieldModifications.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No field modifications provided for modify_field update type',\n },\n ],\n }\n }\n updatedContent = modifyFieldsInCollection(currentContent, fieldModifications)\n updateSummary = fieldModifications.map((mod: any) => `Modified field: ${mod.fieldName}`)\n break\n\n case 'remove_field':\n if (!fieldNamesToRemove || fieldNamesToRemove.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No field names provided for remove_field update type',\n },\n ],\n }\n }\n updatedContent = removeFieldsFromCollection(currentContent, fieldNamesToRemove)\n updateSummary = fieldNamesToRemove.map((fieldName: string) => `Removed field: ${fieldName}`)\n break\n\n case 'replace_content':\n if (!newContent) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No new content provided for replace_content update type',\n },\n ],\n }\n }\n updatedContent = newContent\n updateSummary = ['Replaced entire collection content']\n break\n\n case 'update_config':\n if (!configUpdates) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No config updates provided for update_config update type',\n },\n ],\n }\n }\n // For now, we'll use a simple approach since the config helper might not have this functionality\n updatedContent = currentContent\n updateSummary = Object.keys(configUpdates).map((key) => `Updated config: ${key}`)\n break\n\n default:\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Unknown update type: ${updateType}`,\n },\n ],\n }\n }\n\n // Write the updated content back to the file\n writeFileSync(filePath, updatedContent, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated collection file: ${filePath}`)\n }\n\n // Validate the updated file\n const validationResult = await validateCollectionFile(fileName)\n if (validationResult.error) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Updated collection has validation issues:\\n\\n${validationResult.error}`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `✅ **Collection updated successfully!**\n\n**File**: \\`${fileName}\\`\n**Update Type**: ${updateType}\n\n**Changes Made**:\n${updateSummary.map((summary) => `- ${summary}`).join('\\n')}\n\n**Updated Collection Code:**\n\\`\\`\\`typescript\n${updatedContent}\n\\`\\`\\``,\n },\n ],\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error updating collection: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error updating collection**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\nexport const updateCollectionTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n) => {\n const tool = async ({\n collectionName,\n configUpdates,\n fieldModifications,\n fieldNamesToRemove,\n newContent,\n newFields,\n updateType,\n }: {\n collectionName: string\n configUpdates?: any\n fieldModifications?: any[]\n fieldNamesToRemove?: string[]\n newContent?: string\n newFields?: any[]\n updateType: string\n }) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`,\n )\n }\n\n try {\n const result = await updateCollection(\n req,\n verboseLogs,\n collectionsDirPath,\n configFilePath,\n collectionName,\n updateType,\n newFields,\n fieldNamesToRemove,\n fieldModifications,\n configUpdates,\n newContent,\n )\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Collection update completed for: ${collectionName}`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating collection ${collectionName}: ${errorMessage}`,\n )\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error updating collection \"${collectionName}\": ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'updateCollection',\n {\n description: toolSchemas.updateCollection.description,\n inputSchema: toolSchemas.updateCollection.parameters.shape,\n },\n async (args) => {\n return await tool(args)\n },\n )\n}\n"],"names":["readFileSync","writeFileSync","join","addFieldsToCollection","modifyFieldsInCollection","removeFieldsFromCollection","validateCollectionFile","toolSchemas","updateCollection","req","verboseLogs","collectionsDirPath","configFilePath","collectionName","updateType","newFields","fieldNamesToRemove","fieldModifications","configUpdates","newContent","payload","logger","info","capitalizedName","charAt","toUpperCase","slice","fileName","filePath","startsWith","error","content","type","text","currentContent","_ignore","updatedContent","updateSummary","length","map","field","name","mod","fieldName","Object","keys","key","validationResult","summary","errorMessage","message","updateCollectionTool","server","tool","result","Error","registerTool","description","inputSchema","parameters","shape","args"],"mappings":"AAGA,SAASA,YAAY,EAAEC,aAAa,QAAQ,KAAI;AAChD,SAASC,IAAI,QAAQ,OAAM;AAE3B,SACEC,qBAAqB,EACrBC,wBAAwB,EACxBC,0BAA0B,QACrB,0BAAyB;AAChC,SAASC,sBAAsB,QAAQ,kCAAiC;AACxE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,OAC9BC,KACAC,aACAC,oBACAC,gBACAC,gBACAC,YACAC,WACAC,oBACAC,oBACAC,eACAC;IAEA,MAAMC,UAAUX,IAAIW,OAAO;IAC3B,IAAIV,aAAa;QACfU,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,mCAAmC,EAAET,eAAe,cAAc,EAAEC,YAAY;IAErF;IAEA,MAAMS,kBAAkBV,eAAeW,MAAM,CAAC,GAAGC,WAAW,KAAKZ,eAAea,KAAK,CAAC;IACtF,MAAMC,WAAW,GAAGJ,gBAAgB,GAAG,CAAC;IACxC,MAAMK,WAAW1B,KAAKS,oBAAoBgB;IAE1C,sEAAsE;IACtE,IAAI,CAACC,SAASC,UAAU,CAAClB,qBAAqB;QAC5CS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C,aAAanD,YAAYC,gBAAgB,CAACmD,UAAU,CAACC,KAAK;IAC5D,GACA,OAAOC;QACL,OAAO,MAAMR,KAAKQ;IACpB;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const readConfigFile: (req: PayloadRequest, verboseLogs: boolean, configFilePath: string, includeMetadata?: boolean) => {
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- };
9
- export declare const findConfigTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, configFilePath: string) => void;
10
- //# sourceMappingURL=find.d.ts.map