@payloadcms/plugin-mcp 4.0.0-internal.011fd46 → 4.0.0-internal.0731f09

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 (502) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/defaultAccess.d.ts +3 -0
  3. package/dist/defaultAccess.d.ts.map +1 -0
  4. package/dist/defaultAccess.js +3 -0
  5. package/dist/defaultAccess.js.map +1 -0
  6. package/dist/defineTool.d.ts +8 -8
  7. package/dist/defineTool.d.ts.map +1 -1
  8. package/dist/endpoint/access.d.ts +12 -5
  9. package/dist/endpoint/access.d.ts.map +1 -1
  10. package/dist/endpoint/access.js +86 -103
  11. package/dist/endpoint/access.js.map +1 -1
  12. package/dist/endpoint/index.d.ts +1 -1
  13. package/dist/endpoint/index.d.ts.map +1 -1
  14. package/dist/endpoint/index.js +109 -16
  15. package/dist/endpoint/index.js.map +1 -1
  16. package/dist/endpoint/oauth.d.ts +39 -0
  17. package/dist/endpoint/oauth.d.ts.map +1 -0
  18. package/dist/endpoint/oauth.js +92 -0
  19. package/dist/endpoint/oauth.js.map +1 -0
  20. package/dist/endpoint/oauthServer.d.ts +11 -0
  21. package/dist/endpoint/oauthServer.d.ts.map +1 -0
  22. package/dist/endpoint/oauthServer.js +351 -0
  23. package/dist/endpoint/oauthServer.js.map +1 -0
  24. package/dist/exports/client.d.ts +1 -4
  25. package/dist/exports/client.d.ts.map +1 -1
  26. package/dist/exports/client.js +1 -4
  27. package/dist/exports/client.js.map +1 -1
  28. package/dist/exports/internal.d.ts +2 -0
  29. package/dist/exports/internal.d.ts.map +1 -0
  30. package/dist/exports/internal.js +3 -0
  31. package/dist/exports/internal.js.map +1 -0
  32. package/dist/index.d.ts +12 -4
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +18 -58
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp/buildMcpServer.d.ts +6 -6
  37. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  38. package/dist/mcp/buildMcpServer.js +68 -34
  39. package/dist/mcp/buildMcpServer.js.map +1 -1
  40. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  41. package/dist/mcp/builtin/collections/authTools.js +80 -56
  42. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  43. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  44. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  45. package/dist/mcp/builtin/collections/countTool.js +63 -0
  46. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  47. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  48. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  49. package/dist/mcp/builtin/collections/countVersionsTool.js +60 -0
  50. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  51. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  52. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  53. package/dist/mcp/builtin/collections/createTool.js +105 -53
  54. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  55. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  56. package/dist/mcp/builtin/collections/deleteTool.js +46 -44
  57. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  58. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  59. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  60. package/dist/mcp/builtin/collections/duplicateTool.js +90 -0
  61. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  62. package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
  63. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  64. package/dist/mcp/builtin/collections/fileInput.js +88 -0
  65. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  66. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  67. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  68. package/dist/mcp/builtin/collections/findDistinctTool.js +77 -0
  69. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  70. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  71. package/dist/mcp/builtin/collections/findTool.js +31 -48
  72. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  73. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  74. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  75. package/dist/mcp/builtin/collections/findVersionByIDTool.js +74 -0
  76. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  77. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  78. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  79. package/dist/mcp/builtin/collections/findVersionsTool.js +84 -0
  80. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  81. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  82. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +71 -10
  83. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  84. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  85. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  86. package/dist/mcp/builtin/collections/restoreVersionTool.js +69 -0
  87. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  88. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  89. package/dist/mcp/builtin/collections/updateTool.js +68 -86
  90. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  91. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
  92. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
  93. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
  94. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
  95. package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
  96. package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
  97. package/dist/mcp/builtin/formatEntityError.js +55 -0
  98. package/dist/mcp/builtin/formatEntityError.js.map +1 -0
  99. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  100. package/dist/mcp/builtin/getConfigInfoTool.js +23 -10
  101. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  102. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  103. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  104. package/dist/mcp/builtin/globals/countVersionsTool.js +60 -0
  105. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  106. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  107. package/dist/mcp/builtin/globals/findTool.js +13 -17
  108. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  109. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  110. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  111. package/dist/mcp/builtin/globals/findVersionByIDTool.js +68 -0
  112. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  113. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  114. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  115. package/dist/mcp/builtin/globals/findVersionsTool.js +78 -0
  116. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  117. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  118. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +49 -10
  119. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  120. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  121. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  122. package/dist/mcp/builtin/globals/restoreVersionTool.js +70 -0
  123. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  124. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  125. package/dist/mcp/builtin/globals/updateTool.js +29 -36
  126. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  127. package/dist/mcp/builtinTools.d.ts +73 -2
  128. package/dist/mcp/builtinTools.d.ts.map +1 -1
  129. package/dist/mcp/builtinTools.js +73 -3
  130. package/dist/mcp/builtinTools.js.map +1 -1
  131. package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
  132. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  133. package/dist/mcp/sanitizeMCPConfig.js +51 -17
  134. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  135. package/dist/stdio.d.ts +3 -3
  136. package/dist/stdio.d.ts.map +1 -1
  137. package/dist/stdio.js +86 -47
  138. package/dist/stdio.js.map +1 -1
  139. package/dist/types.d.ts +170 -92
  140. package/dist/types.d.ts.map +1 -1
  141. package/dist/types.js +2 -4
  142. package/dist/types.js.map +1 -1
  143. package/dist/utils/camelCase.d.ts.map +1 -1
  144. package/dist/utils/getPluginConfig.d.ts +1 -1
  145. package/dist/utils/getPluginConfig.js +1 -1
  146. package/dist/utils/getPluginConfig.js.map +1 -1
  147. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  148. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  149. package/dist/utils/toStandardSchema.js.map +1 -1
  150. package/package.json +27 -38
  151. package/src/defaultAccess.ts +3 -0
  152. package/src/endpoint/access.ts +88 -112
  153. package/src/endpoint/index.ts +95 -15
  154. package/src/endpoint/oauth.ts +91 -0
  155. package/src/endpoint/oauthServer.ts +386 -0
  156. package/src/exports/client.ts +2 -4
  157. package/src/exports/internal.ts +1 -0
  158. package/src/index.ts +43 -67
  159. package/src/mcp/buildMcpServer.ts +86 -51
  160. package/src/mcp/builtin/collections/authTools.ts +82 -71
  161. package/src/mcp/builtin/collections/countTool.ts +61 -0
  162. package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
  163. package/src/mcp/builtin/collections/createTool.ts +110 -76
  164. package/src/mcp/builtin/collections/deleteTool.ts +39 -65
  165. package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
  166. package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
  167. package/src/mcp/builtin/collections/fileInput.ts +127 -0
  168. package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
  169. package/src/mcp/builtin/collections/findTool.ts +28 -108
  170. package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
  171. package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
  172. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +63 -7
  173. package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
  174. package/src/mcp/builtin/collections/updateTool.ts +65 -100
  175. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
  176. package/src/mcp/builtin/formatEntityError.ts +77 -0
  177. package/src/mcp/builtin/getConfigInfoTool.ts +22 -5
  178. package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
  179. package/src/mcp/builtin/globals/findTool.ts +16 -52
  180. package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
  181. package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
  182. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +45 -7
  183. package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
  184. package/src/mcp/builtin/globals/updateTool.ts +41 -61
  185. package/src/mcp/builtinTools.ts +72 -6
  186. package/src/mcp/sanitizeMCPConfig.ts +37 -19
  187. package/src/stdio.ts +80 -47
  188. package/src/types.ts +177 -95
  189. package/src/utils/getPluginConfig.ts +1 -1
  190. package/src/utils/toStandardSchema.ts +1 -1
  191. package/dist/collection/getAccessField.d.ts +0 -12
  192. package/dist/collection/getAccessField.d.ts.map +0 -1
  193. package/dist/collection/getAccessField.js +0 -72
  194. package/dist/collection/getAccessField.js.map +0 -1
  195. package/dist/collection/index.d.ts +0 -6
  196. package/dist/collection/index.d.ts.map +0 -1
  197. package/dist/collection/index.js +0 -105
  198. package/dist/collection/index.js.map +0 -1
  199. package/dist/components/APIKeyField/index.client.d.ts +0 -9
  200. package/dist/components/APIKeyField/index.client.d.ts.map +0 -1
  201. package/dist/components/APIKeyField/index.client.js +0 -85
  202. package/dist/components/APIKeyField/index.client.js.map +0 -1
  203. package/dist/components/APIKeyField/index.css +0 -105
  204. package/dist/components/APIKeysEmptyState/index.client.d.ts +0 -4
  205. package/dist/components/APIKeysEmptyState/index.client.d.ts.map +0 -1
  206. package/dist/components/APIKeysEmptyState/index.client.js +0 -21
  207. package/dist/components/APIKeysEmptyState/index.client.js.map +0 -1
  208. package/dist/components/AccessField/index.client.d.ts +0 -10
  209. package/dist/components/AccessField/index.client.d.ts.map +0 -1
  210. package/dist/components/AccessField/index.client.js +0 -247
  211. package/dist/components/AccessField/index.client.js.map +0 -1
  212. package/dist/components/AccessField/index.css +0 -99
  213. package/dist/components/SettingsMenu/index.client.d.ts +0 -8
  214. package/dist/components/SettingsMenu/index.client.d.ts.map +0 -1
  215. package/dist/components/SettingsMenu/index.client.js +0 -24
  216. package/dist/components/SettingsMenu/index.client.js.map +0 -1
  217. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
  218. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
  219. package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
  220. package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
  221. package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
  222. package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
  223. package/dist/mcp/builtin/validateEntityData.js +0 -82
  224. package/dist/mcp/builtin/validateEntityData.js.map +0 -1
  225. package/dist/translations/index.d.ts +0 -11
  226. package/dist/translations/index.d.ts.map +0 -1
  227. package/dist/translations/index.js +0 -92
  228. package/dist/translations/index.js.map +0 -1
  229. package/dist/translations/languages/ar.d.ts +0 -31
  230. package/dist/translations/languages/ar.d.ts.map +0 -1
  231. package/dist/translations/languages/ar.js +0 -34
  232. package/dist/translations/languages/ar.js.map +0 -1
  233. package/dist/translations/languages/az.d.ts +0 -31
  234. package/dist/translations/languages/az.d.ts.map +0 -1
  235. package/dist/translations/languages/az.js +0 -34
  236. package/dist/translations/languages/az.js.map +0 -1
  237. package/dist/translations/languages/bg.d.ts +0 -31
  238. package/dist/translations/languages/bg.d.ts.map +0 -1
  239. package/dist/translations/languages/bg.js +0 -34
  240. package/dist/translations/languages/bg.js.map +0 -1
  241. package/dist/translations/languages/bnBd.d.ts +0 -31
  242. package/dist/translations/languages/bnBd.d.ts.map +0 -1
  243. package/dist/translations/languages/bnBd.js +0 -34
  244. package/dist/translations/languages/bnBd.js.map +0 -1
  245. package/dist/translations/languages/bnIn.d.ts +0 -31
  246. package/dist/translations/languages/bnIn.d.ts.map +0 -1
  247. package/dist/translations/languages/bnIn.js +0 -34
  248. package/dist/translations/languages/bnIn.js.map +0 -1
  249. package/dist/translations/languages/ca.d.ts +0 -31
  250. package/dist/translations/languages/ca.d.ts.map +0 -1
  251. package/dist/translations/languages/ca.js +0 -34
  252. package/dist/translations/languages/ca.js.map +0 -1
  253. package/dist/translations/languages/cs.d.ts +0 -31
  254. package/dist/translations/languages/cs.d.ts.map +0 -1
  255. package/dist/translations/languages/cs.js +0 -34
  256. package/dist/translations/languages/cs.js.map +0 -1
  257. package/dist/translations/languages/da.d.ts +0 -31
  258. package/dist/translations/languages/da.d.ts.map +0 -1
  259. package/dist/translations/languages/da.js +0 -34
  260. package/dist/translations/languages/da.js.map +0 -1
  261. package/dist/translations/languages/de.d.ts +0 -31
  262. package/dist/translations/languages/de.d.ts.map +0 -1
  263. package/dist/translations/languages/de.js +0 -34
  264. package/dist/translations/languages/de.js.map +0 -1
  265. package/dist/translations/languages/en.d.ts +0 -31
  266. package/dist/translations/languages/en.d.ts.map +0 -1
  267. package/dist/translations/languages/en.js +0 -34
  268. package/dist/translations/languages/en.js.map +0 -1
  269. package/dist/translations/languages/es.d.ts +0 -31
  270. package/dist/translations/languages/es.d.ts.map +0 -1
  271. package/dist/translations/languages/es.js +0 -34
  272. package/dist/translations/languages/es.js.map +0 -1
  273. package/dist/translations/languages/et.d.ts +0 -31
  274. package/dist/translations/languages/et.d.ts.map +0 -1
  275. package/dist/translations/languages/et.js +0 -34
  276. package/dist/translations/languages/et.js.map +0 -1
  277. package/dist/translations/languages/fa.d.ts +0 -31
  278. package/dist/translations/languages/fa.d.ts.map +0 -1
  279. package/dist/translations/languages/fa.js +0 -34
  280. package/dist/translations/languages/fa.js.map +0 -1
  281. package/dist/translations/languages/fr.d.ts +0 -31
  282. package/dist/translations/languages/fr.d.ts.map +0 -1
  283. package/dist/translations/languages/fr.js +0 -34
  284. package/dist/translations/languages/fr.js.map +0 -1
  285. package/dist/translations/languages/he.d.ts +0 -31
  286. package/dist/translations/languages/he.d.ts.map +0 -1
  287. package/dist/translations/languages/he.js +0 -34
  288. package/dist/translations/languages/he.js.map +0 -1
  289. package/dist/translations/languages/hr.d.ts +0 -31
  290. package/dist/translations/languages/hr.d.ts.map +0 -1
  291. package/dist/translations/languages/hr.js +0 -34
  292. package/dist/translations/languages/hr.js.map +0 -1
  293. package/dist/translations/languages/hu.d.ts +0 -31
  294. package/dist/translations/languages/hu.d.ts.map +0 -1
  295. package/dist/translations/languages/hu.js +0 -34
  296. package/dist/translations/languages/hu.js.map +0 -1
  297. package/dist/translations/languages/hy.d.ts +0 -31
  298. package/dist/translations/languages/hy.d.ts.map +0 -1
  299. package/dist/translations/languages/hy.js +0 -34
  300. package/dist/translations/languages/hy.js.map +0 -1
  301. package/dist/translations/languages/id.d.ts +0 -31
  302. package/dist/translations/languages/id.d.ts.map +0 -1
  303. package/dist/translations/languages/id.js +0 -34
  304. package/dist/translations/languages/id.js.map +0 -1
  305. package/dist/translations/languages/is.d.ts +0 -31
  306. package/dist/translations/languages/is.d.ts.map +0 -1
  307. package/dist/translations/languages/is.js +0 -34
  308. package/dist/translations/languages/is.js.map +0 -1
  309. package/dist/translations/languages/it.d.ts +0 -31
  310. package/dist/translations/languages/it.d.ts.map +0 -1
  311. package/dist/translations/languages/it.js +0 -34
  312. package/dist/translations/languages/it.js.map +0 -1
  313. package/dist/translations/languages/ja.d.ts +0 -31
  314. package/dist/translations/languages/ja.d.ts.map +0 -1
  315. package/dist/translations/languages/ja.js +0 -34
  316. package/dist/translations/languages/ja.js.map +0 -1
  317. package/dist/translations/languages/ko.d.ts +0 -31
  318. package/dist/translations/languages/ko.d.ts.map +0 -1
  319. package/dist/translations/languages/ko.js +0 -34
  320. package/dist/translations/languages/ko.js.map +0 -1
  321. package/dist/translations/languages/lt.d.ts +0 -31
  322. package/dist/translations/languages/lt.d.ts.map +0 -1
  323. package/dist/translations/languages/lt.js +0 -34
  324. package/dist/translations/languages/lt.js.map +0 -1
  325. package/dist/translations/languages/lv.d.ts +0 -31
  326. package/dist/translations/languages/lv.d.ts.map +0 -1
  327. package/dist/translations/languages/lv.js +0 -34
  328. package/dist/translations/languages/lv.js.map +0 -1
  329. package/dist/translations/languages/my.d.ts +0 -31
  330. package/dist/translations/languages/my.d.ts.map +0 -1
  331. package/dist/translations/languages/my.js +0 -34
  332. package/dist/translations/languages/my.js.map +0 -1
  333. package/dist/translations/languages/nb.d.ts +0 -31
  334. package/dist/translations/languages/nb.d.ts.map +0 -1
  335. package/dist/translations/languages/nb.js +0 -34
  336. package/dist/translations/languages/nb.js.map +0 -1
  337. package/dist/translations/languages/nl.d.ts +0 -31
  338. package/dist/translations/languages/nl.d.ts.map +0 -1
  339. package/dist/translations/languages/nl.js +0 -34
  340. package/dist/translations/languages/nl.js.map +0 -1
  341. package/dist/translations/languages/pl.d.ts +0 -31
  342. package/dist/translations/languages/pl.d.ts.map +0 -1
  343. package/dist/translations/languages/pl.js +0 -34
  344. package/dist/translations/languages/pl.js.map +0 -1
  345. package/dist/translations/languages/pt.d.ts +0 -31
  346. package/dist/translations/languages/pt.d.ts.map +0 -1
  347. package/dist/translations/languages/pt.js +0 -34
  348. package/dist/translations/languages/pt.js.map +0 -1
  349. package/dist/translations/languages/ro.d.ts +0 -31
  350. package/dist/translations/languages/ro.d.ts.map +0 -1
  351. package/dist/translations/languages/ro.js +0 -34
  352. package/dist/translations/languages/ro.js.map +0 -1
  353. package/dist/translations/languages/rs.d.ts +0 -31
  354. package/dist/translations/languages/rs.d.ts.map +0 -1
  355. package/dist/translations/languages/rs.js +0 -34
  356. package/dist/translations/languages/rs.js.map +0 -1
  357. package/dist/translations/languages/rsLatin.d.ts +0 -31
  358. package/dist/translations/languages/rsLatin.d.ts.map +0 -1
  359. package/dist/translations/languages/rsLatin.js +0 -34
  360. package/dist/translations/languages/rsLatin.js.map +0 -1
  361. package/dist/translations/languages/ru.d.ts +0 -31
  362. package/dist/translations/languages/ru.d.ts.map +0 -1
  363. package/dist/translations/languages/ru.js +0 -34
  364. package/dist/translations/languages/ru.js.map +0 -1
  365. package/dist/translations/languages/sk.d.ts +0 -31
  366. package/dist/translations/languages/sk.d.ts.map +0 -1
  367. package/dist/translations/languages/sk.js +0 -34
  368. package/dist/translations/languages/sk.js.map +0 -1
  369. package/dist/translations/languages/sl.d.ts +0 -31
  370. package/dist/translations/languages/sl.d.ts.map +0 -1
  371. package/dist/translations/languages/sl.js +0 -34
  372. package/dist/translations/languages/sl.js.map +0 -1
  373. package/dist/translations/languages/sv.d.ts +0 -31
  374. package/dist/translations/languages/sv.d.ts.map +0 -1
  375. package/dist/translations/languages/sv.js +0 -34
  376. package/dist/translations/languages/sv.js.map +0 -1
  377. package/dist/translations/languages/ta.d.ts +0 -31
  378. package/dist/translations/languages/ta.d.ts.map +0 -1
  379. package/dist/translations/languages/ta.js +0 -34
  380. package/dist/translations/languages/ta.js.map +0 -1
  381. package/dist/translations/languages/th.d.ts +0 -31
  382. package/dist/translations/languages/th.d.ts.map +0 -1
  383. package/dist/translations/languages/th.js +0 -34
  384. package/dist/translations/languages/th.js.map +0 -1
  385. package/dist/translations/languages/tr.d.ts +0 -31
  386. package/dist/translations/languages/tr.d.ts.map +0 -1
  387. package/dist/translations/languages/tr.js +0 -34
  388. package/dist/translations/languages/tr.js.map +0 -1
  389. package/dist/translations/languages/uk.d.ts +0 -31
  390. package/dist/translations/languages/uk.d.ts.map +0 -1
  391. package/dist/translations/languages/uk.js +0 -34
  392. package/dist/translations/languages/uk.js.map +0 -1
  393. package/dist/translations/languages/vi.d.ts +0 -31
  394. package/dist/translations/languages/vi.d.ts.map +0 -1
  395. package/dist/translations/languages/vi.js +0 -34
  396. package/dist/translations/languages/vi.js.map +0 -1
  397. package/dist/translations/languages/zh.d.ts +0 -31
  398. package/dist/translations/languages/zh.d.ts.map +0 -1
  399. package/dist/translations/languages/zh.js +0 -34
  400. package/dist/translations/languages/zh.js.map +0 -1
  401. package/dist/translations/languages/zhTw.d.ts +0 -31
  402. package/dist/translations/languages/zhTw.d.ts.map +0 -1
  403. package/dist/translations/languages/zhTw.js +0 -34
  404. package/dist/translations/languages/zhTw.js.map +0 -1
  405. package/dist/translations/types.d.ts +0 -32
  406. package/dist/translations/types.d.ts.map +0 -1
  407. package/dist/translations/types.js +0 -3
  408. package/dist/translations/types.js.map +0 -1
  409. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  410. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  411. package/dist/utils/getVirtualFieldNames.js +0 -35
  412. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  413. package/dist/utils/localAPIDefaults.d.ts +0 -20
  414. package/dist/utils/localAPIDefaults.d.ts.map +0 -1
  415. package/dist/utils/localAPIDefaults.js +0 -19
  416. package/dist/utils/localAPIDefaults.js.map +0 -1
  417. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -11
  418. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
  419. package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
  420. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
  421. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  422. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  423. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  424. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  425. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
  426. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
  427. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
  428. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
  429. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
  430. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
  431. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  432. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  433. package/dist/utils/transformPointDataToPayload.js +0 -28
  434. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  435. package/dist/utils/whereSchema.d.ts +0 -9
  436. package/dist/utils/whereSchema.d.ts.map +0 -1
  437. package/dist/utils/whereSchema.js +0 -13
  438. package/dist/utils/whereSchema.js.map +0 -1
  439. package/src/collection/getAccessField.ts +0 -84
  440. package/src/collection/index.ts +0 -105
  441. package/src/components/APIKeyField/index.client.tsx +0 -68
  442. package/src/components/APIKeyField/index.css +0 -105
  443. package/src/components/APIKeysEmptyState/index.client.tsx +0 -33
  444. package/src/components/AccessField/index.client.tsx +0 -296
  445. package/src/components/AccessField/index.css +0 -99
  446. package/src/components/SettingsMenu/index.client.tsx +0 -30
  447. package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
  448. package/src/mcp/builtin/validateEntityData.ts +0 -132
  449. package/src/translations/index.ts +0 -105
  450. package/src/translations/languages/ar.ts +0 -38
  451. package/src/translations/languages/az.ts +0 -38
  452. package/src/translations/languages/bg.ts +0 -39
  453. package/src/translations/languages/bnBd.ts +0 -39
  454. package/src/translations/languages/bnIn.ts +0 -39
  455. package/src/translations/languages/ca.ts +0 -39
  456. package/src/translations/languages/cs.ts +0 -39
  457. package/src/translations/languages/da.ts +0 -38
  458. package/src/translations/languages/de.ts +0 -39
  459. package/src/translations/languages/en.ts +0 -39
  460. package/src/translations/languages/es.ts +0 -39
  461. package/src/translations/languages/et.ts +0 -38
  462. package/src/translations/languages/fa.ts +0 -39
  463. package/src/translations/languages/fr.ts +0 -39
  464. package/src/translations/languages/he.ts +0 -37
  465. package/src/translations/languages/hr.ts +0 -39
  466. package/src/translations/languages/hu.ts +0 -39
  467. package/src/translations/languages/hy.ts +0 -39
  468. package/src/translations/languages/id.ts +0 -39
  469. package/src/translations/languages/is.ts +0 -39
  470. package/src/translations/languages/it.ts +0 -39
  471. package/src/translations/languages/ja.ts +0 -39
  472. package/src/translations/languages/ko.ts +0 -39
  473. package/src/translations/languages/lt.ts +0 -39
  474. package/src/translations/languages/lv.ts +0 -38
  475. package/src/translations/languages/my.ts +0 -39
  476. package/src/translations/languages/nb.ts +0 -39
  477. package/src/translations/languages/nl.ts +0 -39
  478. package/src/translations/languages/pl.ts +0 -38
  479. package/src/translations/languages/pt.ts +0 -39
  480. package/src/translations/languages/ro.ts +0 -39
  481. package/src/translations/languages/rs.ts +0 -38
  482. package/src/translations/languages/rsLatin.ts +0 -38
  483. package/src/translations/languages/ru.ts +0 -39
  484. package/src/translations/languages/sk.ts +0 -39
  485. package/src/translations/languages/sl.ts +0 -38
  486. package/src/translations/languages/sv.ts +0 -39
  487. package/src/translations/languages/ta.ts +0 -39
  488. package/src/translations/languages/th.ts +0 -38
  489. package/src/translations/languages/tr.ts +0 -38
  490. package/src/translations/languages/uk.ts +0 -39
  491. package/src/translations/languages/vi.ts +0 -39
  492. package/src/translations/languages/zh.ts +0 -36
  493. package/src/translations/languages/zhTw.ts +0 -36
  494. package/src/translations/types.ts +0 -34
  495. package/src/utils/getVirtualFieldNames.ts +0 -53
  496. package/src/utils/localAPIDefaults.ts +0 -22
  497. package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
  498. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
  499. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
  500. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
  501. package/src/utils/transformPointDataToPayload.ts +0 -40
  502. package/src/utils/whereSchema.ts +0 -24
@@ -1,6 +1,12 @@
1
+ import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload';
2
+ import { getLLMInstructions } from 'payload/internal';
3
+ import { defaultAccess } from '../../../defaultAccess.js';
1
4
  import { defineCollectionTool } from '../../../defineTool.js';
2
- import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js';
3
5
  export const getCollectionSchemaTool = defineCollectionTool({
6
+ access: (args)=>{
7
+ const permissions = args.permissions?.collections?.[args.slug];
8
+ return defaultAccess(args) && Boolean(permissions?.create || permissions?.update);
9
+ },
4
10
  annotations: {
5
11
  destructiveHint: false,
6
12
  idempotentHint: true,
@@ -8,33 +14,88 @@ export const getCollectionSchemaTool = defineCollectionTool({
8
14
  readOnlyHint: true,
9
15
  title: 'Get Collection Schema'
10
16
  },
11
- description: 'Get the input schema for creating or updating documents in a collection.'
12
- }).handler(({ collectionSlug, req })=>{
13
- const inputSchema = getCollectionInputSchema({
14
- collectionSlug,
17
+ description: 'Get the input schema and LLM instructions before creating or updating documents in a collection.',
18
+ input: getCollectionSchemaInputSchema
19
+ }).handler(async ({ slug, authorizedMCP, req })=>{
20
+ const permissions = authorizedMCP.overrideAccess ? null : (await getAccessResults({
15
21
  req
22
+ })).collections?.[slug];
23
+ if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {
24
+ return {
25
+ content: [
26
+ {
27
+ type: 'text',
28
+ text: `Error: MCP access to "getCollectionSchema" is not enabled for collection "${slug}"`
29
+ }
30
+ ],
31
+ isError: true
32
+ };
33
+ }
34
+ const inputSchema = getCollectionInputSchema({
35
+ collectionSlug: slug,
36
+ req,
37
+ ...permissions ? {
38
+ permissions
39
+ } : {}
16
40
  });
17
41
  if (!inputSchema) {
18
42
  return {
19
43
  content: [
20
44
  {
21
45
  type: 'text',
22
- text: `Error: Collection "${collectionSlug}" not found`
46
+ text: `Error: Collection "${slug}" not found`
23
47
  }
24
48
  ],
25
49
  isError: true
26
50
  };
27
51
  }
52
+ const uploadConfig = req.payload.collections[slug]?.config.upload;
53
+ const maxFileSize = req.payload.config.upload.limits?.fileSize;
54
+ const upload = uploadConfig ? {
55
+ enabled: true,
56
+ filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,
57
+ mimeTypes: uploadConfig.mimeTypes ?? [
58
+ '*/*'
59
+ ],
60
+ sources: [
61
+ ...uploadConfig.pasteURL !== false ? [
62
+ 'externalURL'
63
+ ] : [],
64
+ 'base64',
65
+ 'uploadReference'
66
+ ],
67
+ ...typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? {
68
+ maxFileSize
69
+ } : {}
70
+ } : {
71
+ enabled: false
72
+ };
73
+ const instructions = await getLLMInstructions({
74
+ slug,
75
+ type: 'collection',
76
+ overrideAccess: authorizedMCP.overrideAccess,
77
+ req
78
+ });
28
79
  return {
29
80
  content: [
30
81
  {
31
82
  type: 'text',
32
- text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``
33
- }
83
+ text: `Schema for collection "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\`\nUpload configuration:\n\`\`\`json\n${JSON.stringify(upload)}\n\`\`\``
84
+ },
85
+ ...instructions ? [
86
+ {
87
+ type: 'text',
88
+ text: instructions
89
+ }
90
+ ] : []
34
91
  ],
35
92
  structuredContent: {
36
- collectionSlug,
37
- schema: inputSchema
93
+ slug,
94
+ schema: inputSchema,
95
+ upload,
96
+ ...instructions ? {
97
+ instructions
98
+ } : {}
38
99
  }
39
100
  };
40
101
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { defineCollectionTool } from '../../../defineTool.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n}).handler(({ collectionSlug, req }) => {\n const inputSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${collectionSlug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${collectionSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n collectionSlug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["defineCollectionTool","getCollectionInputSchema","getCollectionSchemaTool","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","collectionSlug","req","inputSchema","content","type","text","isError","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,wBAAwB,QAAQ,0DAAyD;AAElG,OAAO,MAAMC,0BAA0BF,qBAAqB;IAC1DG,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,CAAC,EAAEC,cAAc,EAAEC,GAAG,EAAE;IACjC,MAAMC,cAAcZ,yBAAyB;QAAEU;QAAgBC;IAAI;IAEnE,IAAI,CAACC,aAAa;QAChB,OAAO;YACLC,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,mBAAmB,EAAEL,eAAe,WAAW,CAAC;gBAAC;aAAE;YACpFM,SAAS;QACX;IACF;IAEA,OAAO;QACLH,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAEL,eAAe,gBAAgB,EAAEO,KAAKC,SAAS,CAACN,aAAa,QAAQ,CAAC;YACxG;SACD;QACDO,mBAAmB;YACjBT;YACAU,QAAQR;QACV;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload'\nimport { getLLMInstructions } from 'payload/internal'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.slug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description:\n 'Get the input schema and LLM instructions before creating or updating documents in a collection.',\n input: getCollectionSchemaInputSchema,\n}).handler(async ({ slug, authorizedMCP, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[slug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${slug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug: slug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${slug}\" not found` }],\n isError: true,\n }\n }\n\n const uploadConfig = req.payload.collections[slug]?.config.upload\n const maxFileSize = req.payload.config.upload.limits?.fileSize\n const upload = uploadConfig\n ? {\n enabled: true,\n filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,\n mimeTypes: uploadConfig.mimeTypes ?? ['*/*'],\n sources: [\n ...(uploadConfig.pasteURL !== false ? ['externalURL'] : []),\n 'base64',\n 'uploadReference',\n ],\n ...(typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? { maxFileSize } : {}),\n }\n : { enabled: false }\n\n const instructions = await getLLMInstructions({\n slug,\n type: 'collection',\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\`\\nUpload configuration:\\n\\`\\`\\`json\\n${JSON.stringify(upload)}\\n\\`\\`\\``,\n },\n ...(instructions ? [{ type: 'text' as const, text: instructions }] : []),\n ],\n structuredContent: {\n slug,\n schema: inputSchema,\n upload,\n ...(instructions ? { instructions } : {}),\n },\n }\n})\n"],"names":["getAccessResults","getCollectionInputSchema","getCollectionSchemaInputSchema","getLLMInstructions","defaultAccess","defineCollectionTool","getCollectionSchemaTool","access","args","permissions","collections","slug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","collectionSlug","uploadConfig","payload","config","upload","maxFileSize","limits","fileSize","enabled","filesRequiredOnCreate","mimeTypes","sources","pasteURL","Number","isFinite","instructions","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,wBAAwB,EAAEC,8BAA8B,QAAQ,UAAS;AACpG,SAASC,kBAAkB,QAAQ,mBAAkB;AAErD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAO,MAAMC,0BAA0BD,qBAAqB;IAC1DE,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,IAAI,CAAC;QAE9D,OAAOP,cAAcI,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;Q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CAAC;IAC5F,IACA;QAAEG,SAAS;IAAM;IAErB,MAAMO,eAAe,MAAM5C,mBAAmB;QAC5CQ;QACAiB,MAAM;QACNF,gBAAgBF,cAAcE,cAAc;QAC5CD;IACF;IAEA,OAAO;QACLE,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAElB,KAAK,gBAAgB,EAAEqC,KAAKC,SAAS,CAAClB,aAAa,6CAA6C,EAAEiB,KAAKC,SAAS,CAACb,QAAQ,QAAQ,CAAC;YACpK;eACIW,eAAe;gBAAC;oBAAEnB,MAAM;oBAAiBC,MAAMkB;gBAAa;aAAE,GAAG,EAAE;SACxE;QACDG,mBAAmB;YACjBvC;YACAwC,QAAQpB;YACRK;YACA,GAAIW,eAAe;gBAAEA;YAAa,IAAI,CAAC,CAAC;QAC1C;IACF;AACF,GAAE"}
@@ -0,0 +1,2 @@
1
+ export declare const restoreVersionTool: import("../../../types.js").CollectionTool;
2
+ //# sourceMappingURL=restoreVersionTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restoreVersionTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/restoreVersionTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,kBAAkB,4CAuD7B,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { restoreVersionInputSchema } from 'payload';
2
+ import { defaultAccess } from '../../../defaultAccess.js';
3
+ import { defineCollectionTool } from '../../../defineTool.js';
4
+ import { getLogger } from '../../../utils/getLogger.js';
5
+ const DEFAULT_DESCRIPTION = 'Restore a document from a previous version in any version-enabled collection.';
6
+ export const restoreVersionTool = defineCollectionTool({
7
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.update),
8
+ annotations: {
9
+ destructiveHint: true,
10
+ idempotentHint: false,
11
+ openWorldHint: false,
12
+ readOnlyHint: false,
13
+ title: 'Restore Version'
14
+ },
15
+ description: DEFAULT_DESCRIPTION,
16
+ input: restoreVersionInputSchema
17
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
18
+ const payload = req.payload;
19
+ const logger = getLogger({
20
+ payload
21
+ });
22
+ const { id, depth, draft, fallbackLocale, locale, populate, select } = input;
23
+ logger.info(`Restoring version in collection: ${slug} with ID: ${id}`);
24
+ try {
25
+ const result = await payload.restoreVersion({
26
+ id: String(id),
27
+ collection: slug,
28
+ depth,
29
+ draft,
30
+ overrideAccess: authorizedMCP.overrideAccess,
31
+ req,
32
+ ...fallbackLocale !== undefined ? {
33
+ fallbackLocale
34
+ } : {},
35
+ ...locale ? {
36
+ locale
37
+ } : {},
38
+ ...populate ? {
39
+ populate
40
+ } : {},
41
+ ...select ? {
42
+ select
43
+ } : {}
44
+ });
45
+ return {
46
+ content: [
47
+ {
48
+ type: 'text',
49
+ text: `Version "${id}" restored successfully in collection "${slug}"!\nRestored document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
50
+ }
51
+ ],
52
+ doc: result
53
+ };
54
+ } catch (error) {
55
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
56
+ logger.error(`Error restoring version ${id} in ${slug}: ${errorMessage}`);
57
+ return {
58
+ content: [
59
+ {
60
+ type: 'text',
61
+ text: `❌ **Error restoring version "${id}" in collection "${slug}":** ${errorMessage}`
62
+ }
63
+ ],
64
+ isError: true
65
+ };
66
+ }
67
+ });
68
+
69
+ //# sourceMappingURL=restoreVersionTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/restoreVersionTool.ts"],"sourcesContent":["import { restoreVersionInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Restore a document from a previous version in any version-enabled collection.'\n\nexport const restoreVersionTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Restore Version',\n },\n description: DEFAULT_DESCRIPTION,\n input: restoreVersionInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, draft, fallbackLocale, locale, populate, select } = input\n\n logger.info(`Restoring version in collection: ${slug} with ID: ${id}`)\n\n try {\n const result = await payload.restoreVersion({\n id: String(id),\n collection: slug,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" restored successfully in collection \"${slug}\"!\\nRestored document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error restoring version ${id} in ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error restoring version \"${id}\" in collection \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["restoreVersionInputSchema","defaultAccess","defineCollectionTool","getLogger","DEFAULT_DESCRIPTION","restoreVersionTool","access","args","Boolean","permissions","collections","slug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","id","depth","draft","fallbackLocale","locale","populate","select","info","result","restoreVersion","String","collection","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,UAAS;AAEnD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;A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,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DxB,OAAOqB,KAAK,CAAC,CAAC,wBAAwB,EAAEpB,GAAG,IAAI,EAAEf,KAAK,EAAE,EAAEoC,cAAc;QACxE,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6BAA6B,EAAEhB,GAAG,iBAAiB,EAAEf,KAAK,KAAK,EAAEoC,cAAc;gBACxF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB,4CA2L7B,CAAA"}
1
+ {"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,kBAAkB,4CAuJ7B,CAAA"}
@@ -1,15 +1,12 @@
1
- import { z } from 'zod';
1
+ import { getCollectionInputSchema, getCollectionVirtualFieldNames, parseDocumentID, stripVirtualFields, transformPointDataToPayload, updateDocumentInputSchema, validateCollectionData } from 'payload';
2
+ import { defaultAccess } from '../../../defaultAccess.js';
2
3
  import { defineCollectionTool } from '../../../defineTool.js';
3
4
  import { getLogger } from '../../../utils/getLogger.js';
4
- import { getCollectionVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
5
- import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
6
- import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js';
7
- import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
8
- import { whereSchema } from '../../../utils/whereSchema.js';
9
- import { validateCollectionData } from '../validateEntityData.js';
10
- import { formatCollectionError } from './formatCollectionError.js';
11
- const DEFAULT_DESCRIPTION = 'Update documents in any collection by passing the collection slug and data.';
5
+ import { formatEntityError } from '../formatEntityError.js';
6
+ import { fileInputSchema, resolveFile } from './fileInput.js';
7
+ const DEFAULT_DESCRIPTION = 'Update documents. Prefer uploadReference after upload, externalURL for URLs, or base64 for small local files.';
12
8
  export const updateDocumentTool = defineCollectionTool({
9
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.update),
13
10
  annotations: {
14
11
  destructiveHint: true,
15
12
  idempotentHint: false,
@@ -18,124 +15,108 @@ export const updateDocumentTool = defineCollectionTool({
18
15
  title: 'Update Document'
19
16
  },
20
17
  description: DEFAULT_DESCRIPTION,
21
- input: z.object({
22
- id: z.union([
23
- z.string(),
24
- z.number()
25
- ]).describe('The ID of the document to update').optional(),
26
- data: z.record(z.string(), z.unknown()).describe('The fields to update'),
27
- depth: z.number().describe('How many levels deep to populate relationships').optional().default(0),
28
- draft: z.boolean().describe('Whether to update the document as a draft').optional().default(false),
29
- fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
30
- filePath: z.string().describe('File path for file uploads').optional(),
31
- locale: z.string().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
32
- overrideLock: z.boolean().describe('Whether to override document locks').optional().default(true),
33
- overwriteExistingFiles: z.boolean().describe('Whether to overwrite existing files').optional().default(false),
34
- select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}').optional(),
35
- where: whereSchema.describe('Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}').optional()
18
+ input: updateDocumentInputSchema({
19
+ file: fileInputSchema
36
20
  })
37
- }).handler(async ({ authorizedMCP, collectionSlug, input, req })=>{
21
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
38
22
  const payload = req.payload;
39
23
  const logger = getLogger({
40
24
  payload
41
25
  });
42
- const { id, data, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, select, where } = input;
43
- logger.info(`Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
26
+ const { id, data, depth, draft, fallbackLocale, file: fileInput, limit, locale, overrideLock, populate, publishAllLocales, returning, select, sort, trash, unpublishAllLocales, where } = input;
27
+ logger.info(`Updating document in collection: ${slug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
44
28
  try {
45
- if (!id && !where) {
46
- return {
47
- content: [
48
- {
49
- type: 'text',
50
- text: 'Error: Either id or where clause must be provided'
51
- }
52
- ]
53
- };
54
- }
55
- const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug);
29
+ const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, slug);
56
30
  const inputData = stripVirtualFields(data, virtualFieldNames);
57
- const validationError = validateCollectionData({
58
- collectionSlug,
31
+ validateCollectionData({
32
+ slug,
59
33
  data: inputData,
60
34
  partial: true,
61
35
  req
62
36
  });
63
- if (validationError) {
64
- return validationError;
65
- }
66
37
  const parsedData = transformPointDataToPayload(inputData);
38
+ const file = await resolveFile({
39
+ slug,
40
+ input: fileInput,
41
+ req
42
+ });
67
43
  const whereClause = where ?? {};
68
- if (id) {
44
+ if (id !== undefined) {
69
45
  const result = await payload.update({
70
- id,
71
- collection: collectionSlug,
46
+ id: parseDocumentID({
47
+ id,
48
+ collectionSlug: slug,
49
+ payload
50
+ }),
51
+ collection: slug,
72
52
  data: parsedData,
73
53
  depth,
74
54
  draft,
55
+ fallbackLocale,
56
+ locale,
57
+ overrideAccess: authorizedMCP.overrideAccess,
75
58
  overrideLock,
59
+ populate,
60
+ publishAllLocales,
76
61
  req,
77
- ...localAPIDefaults(authorizedMCP),
78
- ...filePath ? {
79
- filePath
80
- } : {},
81
- ...overwriteExistingFiles ? {
82
- overwriteExistingFiles
83
- } : {},
84
- ...locale ? {
85
- locale
86
- } : {},
87
- ...fallbackLocale ? {
88
- fallbackLocale
89
- } : {},
90
- ...select ? {
91
- select: select
62
+ select: returning ? select : {
63
+ id: true
64
+ },
65
+ trash,
66
+ unpublishAllLocales,
67
+ ...file ? {
68
+ file
92
69
  } : {}
93
70
  });
71
+ const responseResult = returning ? result : {
72
+ id: result.id
73
+ };
94
74
  return {
95
75
  content: [
96
76
  {
97
77
  type: 'text',
98
- text: `Document updated successfully in collection "${collectionSlug}"!\nUpdated document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
78
+ text: `Document updated successfully in collection "${slug}"!\nResult:\n\`\`\`json\n${JSON.stringify(responseResult)}\n\`\`\``
99
79
  }
100
80
  ],
101
- doc: result
81
+ doc: responseResult
102
82
  };
103
83
  }
104
84
  const result = await payload.update({
105
- collection: collectionSlug,
85
+ collection: slug,
106
86
  data: parsedData,
107
87
  depth,
108
88
  draft,
89
+ fallbackLocale,
90
+ limit,
91
+ locale,
92
+ overrideAccess: authorizedMCP.overrideAccess,
109
93
  overrideLock,
94
+ populate,
95
+ publishAllLocales,
110
96
  req,
97
+ select: returning ? select : {
98
+ id: true
99
+ },
100
+ sort,
101
+ trash,
102
+ unpublishAllLocales,
111
103
  where: whereClause,
112
- ...localAPIDefaults(authorizedMCP),
113
- ...filePath ? {
114
- filePath
115
- } : {},
116
- ...overwriteExistingFiles ? {
117
- overwriteExistingFiles
118
- } : {},
119
- ...locale ? {
120
- locale
121
- } : {},
122
- ...fallbackLocale ? {
123
- fallbackLocale
124
- } : {},
125
- ...select ? {
126
- select: select
104
+ ...file ? {
105
+ file
127
106
  } : {}
128
107
  });
129
- const docs = result.docs || [];
108
+ const docs = returning ? result.docs : result.docs.map(({ id })=>({
109
+ id
110
+ }));
130
111
  const errors = result.errors || [];
131
- let responseText = `Multiple documents updated in collection "${collectionSlug}"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`;
112
+ let responseText = `Multiple documents updated in collection "${slug}"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`;
132
113
  if (docs.length > 0) {
133
114
  responseText += `\n\nUpdated documents:\n\`\`\`json\n${JSON.stringify(docs)}\n\`\`\``;
134
115
  }
135
116
  if (errors.length > 0) {
136
117
  responseText += `\n\nErrors:\n\`\`\`json\n${JSON.stringify(errors)}\n\`\`\``;
137
118
  const errorSchema = getCollectionInputSchema({
138
- collectionSlug,
119
+ collectionSlug: slug,
139
120
  req
140
121
  });
141
122
  if (errorSchema) {
@@ -155,7 +136,7 @@ export const updateDocumentTool = defineCollectionTool({
155
136
  isError: true,
156
137
  ...errorSchema ? {
157
138
  structuredContent: {
158
- collectionSlug,
139
+ slug,
159
140
  docs,
160
141
  errors,
161
142
  schema: errorSchema
@@ -177,10 +158,11 @@ export const updateDocumentTool = defineCollectionTool({
177
158
  };
178
159
  } catch (error) {
179
160
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
180
- logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`);
181
- return formatCollectionError({
161
+ logger.error(`Error updating document in ${slug}: ${errorMessage}`);
162
+ return formatEntityError({
163
+ slug,
182
164
  action: 'updating',
183
- collectionSlug,
165
+ entity: 'collection',
184
166
  error,
185
167
  req
186
168
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { SelectType, Where } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents in any collection by passing the collection slug and data.'\n\nexport const updateDocumentTool = defineCollectionTool({\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),\n data: z.record(z.string(), z.unknown()).describe('The fields to update'),\n depth: z\n .number()\n .describe('How many levels deep to populate relationships')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Whether to update the document as a draft')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n filePath: z.string().describe('File path for file uploads').optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n overrideLock: z\n .boolean()\n .describe('Whether to override document locks')\n .optional()\n .default(true),\n overwriteExistingFiles: z\n .boolean()\n .describe('Whether to overwrite existing files')\n .optional()\n .default(false),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n where: whereSchema\n .describe(\n 'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\n select,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (!id && !where) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({\n collectionSlug,\n data: inputData,\n partial: true,\n req,\n })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const whereClause: Where = where ?? {}\n\n if (id) {\n const result = await payload.update({\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideLock,\n req,\n ...localAPIDefaults(authorizedMCP),\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${collectionSlug}\"!\\nUpdated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n const result = await payload.update({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideLock,\n req,\n where: whereClause,\n ...localAPIDefaults(authorizedMCP),\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n collectionSlug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'updating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","localAPIDefaults","getCollectionInputSchema","transformPointDataToPayload","whereSchema","validateCollectionData","formatCollectionError","DEFAULT_DESCRIPTION","updateDocumentTool","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","data","record","unknown","depth","default","draft","boolean","fallbackLocale","filePath","locale","overrideLock","overwriteExistingFiles","select","where","handler","authorizedMCP","collectionSlug","req","payload","logger","info","content","type","text","virtualFieldNames","config","inputData","validationError","partial","parsedData","whereClause","result","update","collection","JSON","stringify","doc","docs","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,wBAAwB,QAAQ,0DAAyD;AAClG,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,WAAW,QAAQ,gCAA+B;AAC3D,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,qBAAqBX,qBAAqB;IACrDY,aAAa;QACXC,iBAAiB;QACjBC,gB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BAC/CH,KAAK;oBAAEC;oBAAMC;gBAAO;gBACpBI,SAAS;gBACT,GAAID,cACA;oBACEE,mBAAmB;wBACjB3B;wBACAqB;wBACAC;wBACAM,QAAQH;oBACV;gBACF,IACA,CAAC,CAAC;YACR;QACF;QAEA,OAAO;YACLpB,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAMgB;gBAAa;aAAE;YAC/CH,KAAK;gBAAEC;gBAAMC;YAAO;QACtB;IACF,EAAE,OAAOO,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9D7B,OAAO0B,KAAK,CAAC,CAAC,2BAA2B,EAAE7B,eAAe,EAAE,EAAE8B,cAAc;QAC5E,OAAOhE,sBAAsB;YAAEmE,QAAQ;YAAYjC;YAAgB6B;YAAO5B;QAAI;IAChF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport {\n getCollectionInputSchema,\n getCollectionVirtualFieldNames,\n parseDocumentID,\n stripVirtualFields,\n transformPointDataToPayload,\n updateDocumentInputSchema,\n validateCollectionData,\n} from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { formatEntityError } from '../formatEntityError.js'\nimport { fileInputSchema, resolveFile } from './fileInput.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents. Prefer uploadReference after upload, externalURL for URLs, or base64 for small local files.'\n\nexport const updateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: updateDocumentInputSchema({ file: fileInputSchema }),\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n file: fileInput,\n limit,\n locale,\n overrideLock,\n populate,\n publishAllLocales,\n returning,\n select,\n sort,\n trash,\n unpublishAllLocales,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${slug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, slug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n validateCollectionData({\n slug,\n data: inputData,\n partial: true,\n req,\n })\n\n const parsedData = transformPointDataToPayload(inputData)\n const file = await resolveFile({ slug, input: fileInput, req })\n\n const whereClause: Where = where ?? {}\n\n if (id !== undefined) {\n const result = await payload.update({\n id: parseDocumentID({ id, collectionSlug: slug, payload }),\n collection: slug,\n data: parsedData,\n depth,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n populate,\n publishAllLocales,\n req,\n select: returning ? select : { id: true },\n trash,\n unpublishAllLocales,\n ...(file ? { file } : {}),\n })\n\n const responseResult = returning ? result : { id: result.id }\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${slug}\"!\\nResult:\\n\\`\\`\\`json\\n${JSON.stringify(responseResult)}\\n\\`\\`\\``,\n },\n ],\n doc: responseResult,\n }\n }\n\n const result = await payload.update({\n collection: slug,\n data: parsedData,\n depth,\n draft,\n fallbackLocale,\n limit,\n locale,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n populate,\n publishAllLocales,\n req,\n select: returning ? select : { id: true },\n sort,\n trash,\n unpublishAllLocales,\n where: whereClause,\n ...(file ? { file } : {}),\n })\n\n const docs = returning ? result.docs : result.docs.map(({ id }) => ({ id }))\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${slug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug: slug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n slug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${slug}: ${errorMessage}`)\n return formatEntityError({ slug, action: 'updating', entity: 'collection', error, req })\n }\n})\n"],"names":["getCollectionInputSchema","getCollectionVirtualFieldNames","parseDocumentID","stripVirtualFields","transformPointDataToPayload","updateDocumentInputSchema","validateCollectionData","defaultAccess","defineCollectionTool","getLogger","formatEntityError","fileInputSchema","resolveFile","DEFAULT_DESCRIPTION","updateDocumentTool","access","args","Boolean","permissions","collections","slug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","file","handler","authorizedMCP","req","payload","logger","id","data","depth","draft","fallbackLocale","fileInput","limit","locale","overrideLock","populate","publishAllLocales","returning","select","sort","trash","unpublishAllLocales","where","info","virtualFieldNames","config","inputData","partial","parsedData","whereClause","undefined","result","collectionSlug","collection","overrideAccess","responseResult","content","type","text","JSON","stringify","doc","docs","map","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action","entity"],"mappings":"AAEA,SACEA,wBAAwB,EACxBC,8BAA8B,EAC9BC,eAA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,cAAc;QAClE,OAAOxE,kBAAkB;YAAEU;YAAMiE,QAAQ;YAAYC,QAAQ;YAAcL;YAAOhD;QAAI;IACxF;AACF,GAAE"}
@@ -0,0 +1,2 @@
1
+ export declare const getUploadInstructionsTool: import("../../../types.js").CollectionTool;
2
+ //# sourceMappingURL=uploadInstructionsTool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uploadInstructionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/uploadInstructionsTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,4CAyDpC,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { strictObject, z } from 'payload';
2
+ import { getUploadInstructions as getPayloadUploadInstructions } from 'payload/internal';
3
+ import { defaultAccess } from '../../../defaultAccess.js';
4
+ import { defineCollectionTool } from '../../../defineTool.js';
5
+ export const getUploadInstructionsTool = defineCollectionTool({
6
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.create || args.permissions?.collections?.[args.slug]?.update),
7
+ annotations: {
8
+ destructiveHint: false,
9
+ idempotentHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ title: 'Get Upload Instructions'
13
+ },
14
+ description: 'Prepare uploads for createDocuments or updateDocument. This does not upload bytes; finish the returned action before use.',
15
+ input: strictObject({
16
+ docPrefix: z.optional(z.string()).check(z.describe('Document folder or prefix.')),
17
+ filename: z.string().check(z.describe('The original file name.')),
18
+ filesize: z.int().check(z.nonnegative(), z.describe('The file size in bytes.')),
19
+ mimeType: z.string().check(z.describe('The file MIME type.'))
20
+ })
21
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
22
+ try {
23
+ const instructions = await getPayloadUploadInstructions({
24
+ ...input,
25
+ collectionSlug: slug,
26
+ overrideAccess: authorizedMCP.overrideAccess,
27
+ req
28
+ });
29
+ const nextStep = instructions.type === 'http' ? 'Upload bytes with instructions.request. After success, pass { source: "uploadReference", file: instructions.file }.' : `Call "${instructions.name}" with file and data. After success, pass { source: "uploadReference", file: instructions.file }.`;
30
+ return {
31
+ content: [
32
+ {
33
+ type: 'text',
34
+ text: `Upload instructions for collection "${slug}":\n\`\`\`json\n${JSON.stringify(instructions)}\n\`\`\`\n${nextStep}`
35
+ }
36
+ ],
37
+ structuredContent: {
38
+ instructions
39
+ }
40
+ };
41
+ } catch (error) {
42
+ const message = error instanceof Error ? error.message : 'Unknown error';
43
+ return {
44
+ content: [
45
+ {
46
+ type: 'text',
47
+ text: `Error getting upload instructions for collection "${slug}": ${message}`
48
+ }
49
+ ],
50
+ isError: true
51
+ };
52
+ }
53
+ });
54
+
55
+ //# sourceMappingURL=uploadInstructionsTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/uploadInstructionsTool.ts"],"sourcesContent":["import { strictObject, z } from 'payload'\nimport { getUploadInstructions as getPayloadUploadInstructions } from 'payload/internal'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\n\nexport const getUploadInstructionsTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) &&\n Boolean(\n args.permissions?.collections?.[args.slug]?.create ||\n args.permissions?.collections?.[args.slug]?.update,\n ),\n annotations: {\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n readOnlyHint: false,\n title: 'Get Upload Instructions',\n },\n description:\n 'Prepare uploads for createDocuments or updateDocument. This does not upload bytes; finish the returned action before use.',\n input: strictObject({\n docPrefix: z.optional(z.string()).check(z.describe('Document folder or prefix.')),\n filename: z.string().check(z.describe('The original file name.')),\n filesize: z.int().check(z.nonnegative(), z.describe('The file size in bytes.')),\n mimeType: z.string().check(z.describe('The file MIME type.')),\n }),\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n try {\n const instructions = await getPayloadUploadInstructions({\n ...input,\n collectionSlug: slug,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n })\n\n const nextStep =\n instructions.type === 'http'\n ? 'Upload bytes with instructions.request. After success, pass { source: \"uploadReference\", file: instructions.file }.'\n : `Call \"${instructions.name}\" with file and data. After success, pass { source: \"uploadReference\", file: instructions.file }.`\n\n return {\n content: [\n {\n type: 'text',\n text: `Upload instructions for collection \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(instructions)}\\n\\`\\`\\`\\n${nextStep}`,\n },\n ],\n structuredContent: { instructions },\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown error'\n return {\n content: [\n {\n type: 'text',\n text: `Error getting upload instructions for collection \"${slug}\": ${message}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["strictObject","z","getUploadInstructions","getPayloadUploadInstructions","defaultAccess","defineCollectionTool","getUploadInstructionsTool","access","args","Boolean","permissions","collections","slug","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","docPrefix","optional","string","check","describe","filename","filesize","int","nonnegative","mimeType","handler","authorizedMCP","req","instructions","collectionSlug","overrideAccess","nextStep","type","name","content","text","JSON","stringify","structuredContent","error","message","Error","isError"],"mappings":"AAAA,SAASA,YAAY,EAAEC,CAAC,QAAQ,UAAS;AACzC,SAASC,yBAAyBC,4BAA4B,QAAQ,mBAAkB;AAExF,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAO,MAAMC,4BAA4BD,qBAAqB;IAC5DE,QAAQ,CAACC,OACPJ,cAAcI,SACdC,QACED,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,IAAI,CAAC,EAAEC,UAC5CL,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,IAAI,CAAC,EAAEE;IAEhDC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aACE;IACFC,OAAOtB,aAAa;QAClBuB,WAAWtB,EAAEuB,QAAQ,CAACvB,EAAEwB,MAAM,IAAIC,KAAK,CAACzB,EAAE0B,QAAQ,CAAC;QACnDC,UAAU3B,EAAEwB,MAAM,GAAGC,KAAK,CAACzB,EAAE0B,QAAQ,CAAC;QACtCE,UAAU5B,EAAE6B,GAAG,GAAGJ,KAAK,CAACzB,EAAE8B,WAAW,IAAI9B,EAAE0B,QAAQ,CAAC;QACpDK,UAAU/B,EAAEwB,MAAM,GAAGC,KAAK,CAACzB,EAAE0B,QAAQ,CAAC;IACxC;AACF,GAAGM,OAAO,CAAC,OAAO,EAAErB,IAAI,EAAEsB,aAAa,EAAEZ,KAAK,EAAEa,GAAG,EAAE;IACnD,IAAI;QACF,MAAMC,eAAe,MAAMjC,6BAA6B;YACtD,GAAGmB,KAAK;YACRe,gBAAgBzB;YAChB0B,gBAAgBJ,cAAcI,cAAc;YAC5CH;QACF;QAEA,MAAMI,WACJH,aAAaI,IAAI,KAAK,SAClB,wHACA,CAAC,MAAM,EAAEJ,aAAaK,IAAI,CAAC,iGAAiG,CAAC;QAEnI,OAAO;YACLC,SAAS;gBACP;oBACEF,MAAM;oBACNG,MAAM,CAAC,oCAAoC,EAAE/B,KAAK,gBAAgB,EAAEgC,KAAKC,SAAS,CAACT,cAAc,UAAU,EAAEG,UAAU;gBACzH;aACD;YACDO,mBAAmB;gBAAEV;YAAa;QACpC;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAG;QACzD,OAAO;YACLN,SAAS;gBACP;oBACEF,MAAM;oBACNG,MAAM,CAAC,kDAAkD,EAAE/B,KAAK,GAAG,EAAEoC,SAAS;gBAChF;aACD;YACDE,SAAS;QACX;IACF;AACF,GAAE"}
@@ -0,0 +1,16 @@
1
+ import type { CollectionSlug, GlobalSlug, PayloadRequest } from 'payload';
2
+ import type { MCPToolResponse } from '../../types.js';
3
+ export declare const formatEntityError: ({ slug, action, entity, error, req, }: {
4
+ action: 'creating' | 'duplicating' | 'updating';
5
+ entity: 'collection';
6
+ error: unknown;
7
+ req: PayloadRequest;
8
+ slug: CollectionSlug;
9
+ } | {
10
+ action: 'updating';
11
+ entity: 'global';
12
+ error: unknown;
13
+ req: PayloadRequest;
14
+ slug: GlobalSlug;
15
+ }) => MCPToolResponse;
16
+ //# sourceMappingURL=formatEntityError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatEntityError.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/formatEntityError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,eAAO,MAAM,iBAAiB,0CAO1B;IACE,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;IAC/C,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAA;CACrB,GACD;IACE,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,QAAQ,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,eAsCP,CAAA"}