@payloadcms/plugin-mcp 4.0.0-internal.5b1e7cd → 4.0.0-internal.688c4d0

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 (617) hide show
  1. package/bin.js +39 -0
  2. package/dist/@types/assets.d.js +2 -0
  3. package/dist/@types/assets.d.js.map +1 -0
  4. package/dist/collection/getAccessField.d.ts +12 -0
  5. package/dist/collection/getAccessField.d.ts.map +1 -0
  6. package/dist/collection/getAccessField.js +72 -0
  7. package/dist/collection/getAccessField.js.map +1 -0
  8. package/dist/collection/index.d.ts +6 -0
  9. package/dist/collection/index.d.ts.map +1 -0
  10. package/dist/collection/index.js +105 -0
  11. package/dist/collection/index.js.map +1 -0
  12. package/dist/components/APIKeyField/index.client.d.ts +9 -0
  13. package/dist/components/APIKeyField/index.client.d.ts.map +1 -0
  14. package/dist/components/APIKeyField/index.client.js +85 -0
  15. package/dist/components/APIKeyField/index.client.js.map +1 -0
  16. package/dist/components/APIKeyField/index.css +105 -0
  17. package/dist/components/APIKeysEmptyState/index.client.d.ts +4 -0
  18. package/dist/components/APIKeysEmptyState/index.client.d.ts.map +1 -0
  19. package/dist/components/APIKeysEmptyState/index.client.js +21 -0
  20. package/dist/components/APIKeysEmptyState/index.client.js.map +1 -0
  21. package/dist/components/AccessField/index.client.d.ts +10 -0
  22. package/dist/components/AccessField/index.client.d.ts.map +1 -0
  23. package/dist/components/AccessField/index.client.js +247 -0
  24. package/dist/components/AccessField/index.client.js.map +1 -0
  25. package/dist/components/AccessField/index.css +99 -0
  26. package/dist/components/SettingsMenu/index.client.d.ts +8 -0
  27. package/dist/components/SettingsMenu/index.client.d.ts.map +1 -0
  28. package/dist/components/SettingsMenu/index.client.js +29 -0
  29. package/dist/components/SettingsMenu/index.client.js.map +1 -0
  30. package/dist/defineTool.d.ts +26 -0
  31. package/dist/defineTool.d.ts.map +1 -0
  32. package/dist/defineTool.js +37 -0
  33. package/dist/defineTool.js.map +1 -0
  34. package/dist/endpoint/access.d.ts +10 -0
  35. package/dist/endpoint/access.d.ts.map +1 -0
  36. package/dist/endpoint/access.js +122 -0
  37. package/dist/endpoint/access.js.map +1 -0
  38. package/dist/endpoint/index.d.ts +3 -0
  39. package/dist/endpoint/index.d.ts.map +1 -0
  40. package/dist/endpoint/index.js +36 -0
  41. package/dist/endpoint/index.js.map +1 -0
  42. package/dist/exports/client.d.ts +5 -0
  43. package/dist/exports/client.d.ts.map +1 -0
  44. package/dist/exports/client.js +7 -0
  45. package/dist/exports/client.js.map +1 -0
  46. package/dist/index.d.ts +4 -7
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +87 -67
  49. package/dist/index.js.map +1 -1
  50. package/dist/mcp/buildMcpServer.d.ts +19 -0
  51. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  52. package/dist/mcp/buildMcpServer.js +199 -0
  53. package/dist/mcp/buildMcpServer.js.map +1 -0
  54. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  55. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  56. package/dist/mcp/builtin/collections/authTools.js +250 -0
  57. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  58. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  59. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  60. package/dist/mcp/builtin/collections/createTool.js +94 -0
  61. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  62. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  63. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  64. package/dist/mcp/builtin/collections/deleteTool.js +102 -0
  65. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  66. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  67. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  68. package/dist/mcp/builtin/collections/findTool.js +144 -0
  69. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  70. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  71. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  72. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  73. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  74. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  75. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  76. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
  77. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  78. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  79. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  80. package/dist/mcp/builtin/collections/updateTool.js +199 -0
  81. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  82. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  83. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  84. package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
  85. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  86. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  87. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  88. package/dist/mcp/builtin/globals/findTool.js +76 -0
  89. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  90. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  91. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  92. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
  93. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  94. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  95. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  96. package/dist/mcp/builtin/globals/updateTool.js +94 -0
  97. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  98. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  99. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  100. package/dist/mcp/builtin/validateEntityData.js +82 -0
  101. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  102. package/dist/mcp/builtinTools.d.ts +105 -0
  103. package/dist/mcp/builtinTools.d.ts.map +1 -0
  104. package/dist/mcp/builtinTools.js +107 -0
  105. package/dist/mcp/builtinTools.js.map +1 -0
  106. package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
  107. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  108. package/dist/mcp/sanitizeMCPConfig.js +188 -0
  109. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  110. package/dist/stdio.d.ts +8 -0
  111. package/dist/stdio.d.ts.map +1 -0
  112. package/dist/stdio.js +89 -0
  113. package/dist/stdio.js.map +1 -0
  114. package/dist/translations/index.d.ts +11 -0
  115. package/dist/translations/index.d.ts.map +1 -0
  116. package/dist/translations/index.js +92 -0
  117. package/dist/translations/index.js.map +1 -0
  118. package/dist/translations/languages/ar.d.ts +31 -0
  119. package/dist/translations/languages/ar.d.ts.map +1 -0
  120. package/dist/translations/languages/ar.js +34 -0
  121. package/dist/translations/languages/ar.js.map +1 -0
  122. package/dist/translations/languages/az.d.ts +31 -0
  123. package/dist/translations/languages/az.d.ts.map +1 -0
  124. package/dist/translations/languages/az.js +34 -0
  125. package/dist/translations/languages/az.js.map +1 -0
  126. package/dist/translations/languages/bg.d.ts +31 -0
  127. package/dist/translations/languages/bg.d.ts.map +1 -0
  128. package/dist/translations/languages/bg.js +34 -0
  129. package/dist/translations/languages/bg.js.map +1 -0
  130. package/dist/translations/languages/bnBd.d.ts +31 -0
  131. package/dist/translations/languages/bnBd.d.ts.map +1 -0
  132. package/dist/translations/languages/bnBd.js +34 -0
  133. package/dist/translations/languages/bnBd.js.map +1 -0
  134. package/dist/translations/languages/bnIn.d.ts +31 -0
  135. package/dist/translations/languages/bnIn.d.ts.map +1 -0
  136. package/dist/translations/languages/bnIn.js +34 -0
  137. package/dist/translations/languages/bnIn.js.map +1 -0
  138. package/dist/translations/languages/ca.d.ts +31 -0
  139. package/dist/translations/languages/ca.d.ts.map +1 -0
  140. package/dist/translations/languages/ca.js +34 -0
  141. package/dist/translations/languages/ca.js.map +1 -0
  142. package/dist/translations/languages/cs.d.ts +31 -0
  143. package/dist/translations/languages/cs.d.ts.map +1 -0
  144. package/dist/translations/languages/cs.js +34 -0
  145. package/dist/translations/languages/cs.js.map +1 -0
  146. package/dist/translations/languages/da.d.ts +31 -0
  147. package/dist/translations/languages/da.d.ts.map +1 -0
  148. package/dist/translations/languages/da.js +34 -0
  149. package/dist/translations/languages/da.js.map +1 -0
  150. package/dist/translations/languages/de.d.ts +31 -0
  151. package/dist/translations/languages/de.d.ts.map +1 -0
  152. package/dist/translations/languages/de.js +34 -0
  153. package/dist/translations/languages/de.js.map +1 -0
  154. package/dist/translations/languages/en.d.ts +31 -0
  155. package/dist/translations/languages/en.d.ts.map +1 -0
  156. package/dist/translations/languages/en.js +34 -0
  157. package/dist/translations/languages/en.js.map +1 -0
  158. package/dist/translations/languages/es.d.ts +31 -0
  159. package/dist/translations/languages/es.d.ts.map +1 -0
  160. package/dist/translations/languages/es.js +34 -0
  161. package/dist/translations/languages/es.js.map +1 -0
  162. package/dist/translations/languages/et.d.ts +31 -0
  163. package/dist/translations/languages/et.d.ts.map +1 -0
  164. package/dist/translations/languages/et.js +34 -0
  165. package/dist/translations/languages/et.js.map +1 -0
  166. package/dist/translations/languages/fa.d.ts +31 -0
  167. package/dist/translations/languages/fa.d.ts.map +1 -0
  168. package/dist/translations/languages/fa.js +34 -0
  169. package/dist/translations/languages/fa.js.map +1 -0
  170. package/dist/translations/languages/fr.d.ts +31 -0
  171. package/dist/translations/languages/fr.d.ts.map +1 -0
  172. package/dist/translations/languages/fr.js +34 -0
  173. package/dist/translations/languages/fr.js.map +1 -0
  174. package/dist/translations/languages/he.d.ts +31 -0
  175. package/dist/translations/languages/he.d.ts.map +1 -0
  176. package/dist/translations/languages/he.js +34 -0
  177. package/dist/translations/languages/he.js.map +1 -0
  178. package/dist/translations/languages/hr.d.ts +31 -0
  179. package/dist/translations/languages/hr.d.ts.map +1 -0
  180. package/dist/translations/languages/hr.js +34 -0
  181. package/dist/translations/languages/hr.js.map +1 -0
  182. package/dist/translations/languages/hu.d.ts +31 -0
  183. package/dist/translations/languages/hu.d.ts.map +1 -0
  184. package/dist/translations/languages/hu.js +34 -0
  185. package/dist/translations/languages/hu.js.map +1 -0
  186. package/dist/translations/languages/hy.d.ts +31 -0
  187. package/dist/translations/languages/hy.d.ts.map +1 -0
  188. package/dist/translations/languages/hy.js +34 -0
  189. package/dist/translations/languages/hy.js.map +1 -0
  190. package/dist/translations/languages/id.d.ts +31 -0
  191. package/dist/translations/languages/id.d.ts.map +1 -0
  192. package/dist/translations/languages/id.js +34 -0
  193. package/dist/translations/languages/id.js.map +1 -0
  194. package/dist/translations/languages/is.d.ts +31 -0
  195. package/dist/translations/languages/is.d.ts.map +1 -0
  196. package/dist/translations/languages/is.js +34 -0
  197. package/dist/translations/languages/is.js.map +1 -0
  198. package/dist/translations/languages/it.d.ts +31 -0
  199. package/dist/translations/languages/it.d.ts.map +1 -0
  200. package/dist/translations/languages/it.js +34 -0
  201. package/dist/translations/languages/it.js.map +1 -0
  202. package/dist/translations/languages/ja.d.ts +31 -0
  203. package/dist/translations/languages/ja.d.ts.map +1 -0
  204. package/dist/translations/languages/ja.js +34 -0
  205. package/dist/translations/languages/ja.js.map +1 -0
  206. package/dist/translations/languages/ko.d.ts +31 -0
  207. package/dist/translations/languages/ko.d.ts.map +1 -0
  208. package/dist/translations/languages/ko.js +34 -0
  209. package/dist/translations/languages/ko.js.map +1 -0
  210. package/dist/translations/languages/lt.d.ts +31 -0
  211. package/dist/translations/languages/lt.d.ts.map +1 -0
  212. package/dist/translations/languages/lt.js +34 -0
  213. package/dist/translations/languages/lt.js.map +1 -0
  214. package/dist/translations/languages/lv.d.ts +31 -0
  215. package/dist/translations/languages/lv.d.ts.map +1 -0
  216. package/dist/translations/languages/lv.js +34 -0
  217. package/dist/translations/languages/lv.js.map +1 -0
  218. package/dist/translations/languages/my.d.ts +31 -0
  219. package/dist/translations/languages/my.d.ts.map +1 -0
  220. package/dist/translations/languages/my.js +34 -0
  221. package/dist/translations/languages/my.js.map +1 -0
  222. package/dist/translations/languages/nb.d.ts +31 -0
  223. package/dist/translations/languages/nb.d.ts.map +1 -0
  224. package/dist/translations/languages/nb.js +34 -0
  225. package/dist/translations/languages/nb.js.map +1 -0
  226. package/dist/translations/languages/nl.d.ts +31 -0
  227. package/dist/translations/languages/nl.d.ts.map +1 -0
  228. package/dist/translations/languages/nl.js +34 -0
  229. package/dist/translations/languages/nl.js.map +1 -0
  230. package/dist/translations/languages/pl.d.ts +31 -0
  231. package/dist/translations/languages/pl.d.ts.map +1 -0
  232. package/dist/translations/languages/pl.js +34 -0
  233. package/dist/translations/languages/pl.js.map +1 -0
  234. package/dist/translations/languages/pt.d.ts +31 -0
  235. package/dist/translations/languages/pt.d.ts.map +1 -0
  236. package/dist/translations/languages/pt.js +34 -0
  237. package/dist/translations/languages/pt.js.map +1 -0
  238. package/dist/translations/languages/ro.d.ts +31 -0
  239. package/dist/translations/languages/ro.d.ts.map +1 -0
  240. package/dist/translations/languages/ro.js +34 -0
  241. package/dist/translations/languages/ro.js.map +1 -0
  242. package/dist/translations/languages/rs.d.ts +31 -0
  243. package/dist/translations/languages/rs.d.ts.map +1 -0
  244. package/dist/translations/languages/rs.js +34 -0
  245. package/dist/translations/languages/rs.js.map +1 -0
  246. package/dist/translations/languages/rsLatin.d.ts +31 -0
  247. package/dist/translations/languages/rsLatin.d.ts.map +1 -0
  248. package/dist/translations/languages/rsLatin.js +34 -0
  249. package/dist/translations/languages/rsLatin.js.map +1 -0
  250. package/dist/translations/languages/ru.d.ts +31 -0
  251. package/dist/translations/languages/ru.d.ts.map +1 -0
  252. package/dist/translations/languages/ru.js +34 -0
  253. package/dist/translations/languages/ru.js.map +1 -0
  254. package/dist/translations/languages/sk.d.ts +31 -0
  255. package/dist/translations/languages/sk.d.ts.map +1 -0
  256. package/dist/translations/languages/sk.js +34 -0
  257. package/dist/translations/languages/sk.js.map +1 -0
  258. package/dist/translations/languages/sl.d.ts +31 -0
  259. package/dist/translations/languages/sl.d.ts.map +1 -0
  260. package/dist/translations/languages/sl.js +34 -0
  261. package/dist/translations/languages/sl.js.map +1 -0
  262. package/dist/translations/languages/sv.d.ts +31 -0
  263. package/dist/translations/languages/sv.d.ts.map +1 -0
  264. package/dist/translations/languages/sv.js +34 -0
  265. package/dist/translations/languages/sv.js.map +1 -0
  266. package/dist/translations/languages/ta.d.ts +31 -0
  267. package/dist/translations/languages/ta.d.ts.map +1 -0
  268. package/dist/translations/languages/ta.js +34 -0
  269. package/dist/translations/languages/ta.js.map +1 -0
  270. package/dist/translations/languages/th.d.ts +31 -0
  271. package/dist/translations/languages/th.d.ts.map +1 -0
  272. package/dist/translations/languages/th.js +34 -0
  273. package/dist/translations/languages/th.js.map +1 -0
  274. package/dist/translations/languages/tr.d.ts +31 -0
  275. package/dist/translations/languages/tr.d.ts.map +1 -0
  276. package/dist/translations/languages/tr.js +34 -0
  277. package/dist/translations/languages/tr.js.map +1 -0
  278. package/dist/translations/languages/uk.d.ts +31 -0
  279. package/dist/translations/languages/uk.d.ts.map +1 -0
  280. package/dist/translations/languages/uk.js +34 -0
  281. package/dist/translations/languages/uk.js.map +1 -0
  282. package/dist/translations/languages/vi.d.ts +31 -0
  283. package/dist/translations/languages/vi.d.ts.map +1 -0
  284. package/dist/translations/languages/vi.js +34 -0
  285. package/dist/translations/languages/vi.js.map +1 -0
  286. package/dist/translations/languages/zh.d.ts +31 -0
  287. package/dist/translations/languages/zh.d.ts.map +1 -0
  288. package/dist/translations/languages/zh.js +34 -0
  289. package/dist/translations/languages/zh.js.map +1 -0
  290. package/dist/translations/languages/zhTw.d.ts +31 -0
  291. package/dist/translations/languages/zhTw.d.ts.map +1 -0
  292. package/dist/translations/languages/zhTw.js +34 -0
  293. package/dist/translations/languages/zhTw.js.map +1 -0
  294. package/dist/translations/types.d.ts +32 -0
  295. package/dist/translations/types.d.ts.map +1 -0
  296. package/dist/translations/types.js +3 -0
  297. package/dist/translations/types.js.map +1 -0
  298. package/dist/types.d.ts +255 -454
  299. package/dist/types.d.ts.map +1 -1
  300. package/dist/types.js +6 -1
  301. package/dist/types.js.map +1 -1
  302. package/dist/utils/camelCase.d.ts.map +1 -1
  303. package/dist/utils/getLogger.d.ts +10 -0
  304. package/dist/utils/getLogger.d.ts.map +1 -0
  305. package/dist/utils/getLogger.js +22 -0
  306. package/dist/utils/getLogger.js.map +1 -0
  307. package/dist/utils/getPluginConfig.d.ts +12 -0
  308. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  309. package/dist/utils/getPluginConfig.js +15 -0
  310. package/dist/utils/getPluginConfig.js.map +1 -0
  311. package/dist/utils/localAPIDefaults.d.ts +20 -0
  312. package/dist/utils/localAPIDefaults.d.ts.map +1 -0
  313. package/dist/utils/localAPIDefaults.js +19 -0
  314. package/dist/utils/localAPIDefaults.js.map +1 -0
  315. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  316. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  317. package/dist/utils/resolveProjectRoot.js +15 -0
  318. package/dist/utils/resolveProjectRoot.js.map +1 -0
  319. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  320. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  321. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  322. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  323. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
  324. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
  325. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
  326. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
  327. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  328. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
  329. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  330. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
  331. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  332. package/dist/utils/toStandardSchema.d.ts +5 -0
  333. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  334. package/dist/utils/toStandardSchema.js +4 -0
  335. package/dist/utils/toStandardSchema.js.map +1 -0
  336. package/dist/utils/whereSchema.d.ts +9 -0
  337. package/dist/utils/whereSchema.d.ts.map +1 -0
  338. package/dist/utils/whereSchema.js +13 -0
  339. package/dist/utils/whereSchema.js.map +1 -0
  340. package/package.json +36 -10
  341. package/src/@types/assets.d.ts +3 -0
  342. package/src/collection/getAccessField.ts +84 -0
  343. package/src/collection/index.ts +105 -0
  344. package/src/components/APIKeyField/index.client.tsx +73 -0
  345. package/src/components/APIKeyField/index.css +105 -0
  346. package/src/components/APIKeysEmptyState/index.client.tsx +36 -0
  347. package/src/components/AccessField/index.client.tsx +299 -0
  348. package/src/components/AccessField/index.css +99 -0
  349. package/src/components/SettingsMenu/index.client.tsx +34 -0
  350. package/src/defineTool.ts +44 -0
  351. package/src/endpoint/access.ts +144 -0
  352. package/src/endpoint/index.ts +35 -0
  353. package/src/exports/client.ts +5 -0
  354. package/src/index.ts +82 -86
  355. package/src/mcp/buildMcpServer.ts +257 -0
  356. package/src/mcp/builtin/collections/authTools.ts +233 -0
  357. package/src/mcp/builtin/collections/createTool.ts +112 -0
  358. package/src/mcp/builtin/collections/deleteTool.ts +116 -0
  359. package/src/mcp/builtin/collections/findTool.ts +177 -0
  360. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  361. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
  362. package/src/mcp/builtin/collections/updateTool.ts +211 -0
  363. package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
  364. package/src/mcp/builtin/globals/findTool.ts +96 -0
  365. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
  366. package/src/mcp/builtin/globals/updateTool.ts +115 -0
  367. package/src/mcp/builtin/validateEntityData.ts +132 -0
  368. package/src/mcp/builtinTools.ts +98 -0
  369. package/src/mcp/sanitizeMCPConfig.ts +260 -0
  370. package/src/stdio.ts +98 -0
  371. package/src/translations/index.ts +108 -0
  372. package/src/translations/languages/ar.ts +35 -0
  373. package/src/translations/languages/az.ts +35 -0
  374. package/src/translations/languages/bg.ts +35 -0
  375. package/src/translations/languages/bnBd.ts +35 -0
  376. package/src/translations/languages/bnIn.ts +35 -0
  377. package/src/translations/languages/ca.ts +35 -0
  378. package/src/translations/languages/cs.ts +35 -0
  379. package/src/translations/languages/da.ts +35 -0
  380. package/src/translations/languages/de.ts +35 -0
  381. package/src/translations/languages/en.ts +35 -0
  382. package/src/translations/languages/es.ts +35 -0
  383. package/src/translations/languages/et.ts +35 -0
  384. package/src/translations/languages/fa.ts +35 -0
  385. package/src/translations/languages/fr.ts +35 -0
  386. package/src/translations/languages/he.ts +35 -0
  387. package/src/translations/languages/hr.ts +35 -0
  388. package/src/translations/languages/hu.ts +35 -0
  389. package/src/translations/languages/hy.ts +35 -0
  390. package/src/translations/languages/id.ts +35 -0
  391. package/src/translations/languages/is.ts +35 -0
  392. package/src/translations/languages/it.ts +35 -0
  393. package/src/translations/languages/ja.ts +35 -0
  394. package/src/translations/languages/ko.ts +35 -0
  395. package/src/translations/languages/lt.ts +35 -0
  396. package/src/translations/languages/lv.ts +35 -0
  397. package/src/translations/languages/my.ts +35 -0
  398. package/src/translations/languages/nb.ts +35 -0
  399. package/src/translations/languages/nl.ts +35 -0
  400. package/src/translations/languages/pl.ts +35 -0
  401. package/src/translations/languages/pt.ts +35 -0
  402. package/src/translations/languages/ro.ts +35 -0
  403. package/src/translations/languages/rs.ts +35 -0
  404. package/src/translations/languages/rsLatin.ts +35 -0
  405. package/src/translations/languages/ru.ts +35 -0
  406. package/src/translations/languages/sk.ts +35 -0
  407. package/src/translations/languages/sl.ts +35 -0
  408. package/src/translations/languages/sv.ts +35 -0
  409. package/src/translations/languages/ta.ts +35 -0
  410. package/src/translations/languages/th.ts +35 -0
  411. package/src/translations/languages/tr.ts +35 -0
  412. package/src/translations/languages/uk.ts +35 -0
  413. package/src/translations/languages/vi.ts +35 -0
  414. package/src/translations/languages/zh.ts +35 -0
  415. package/src/translations/languages/zhTw.ts +35 -0
  416. package/src/translations/types.ts +34 -0
  417. package/src/types.ts +295 -490
  418. package/src/utils/getLogger.ts +22 -0
  419. package/src/utils/getPluginConfig.ts +24 -0
  420. package/src/utils/localAPIDefaults.ts +22 -0
  421. package/src/utils/resolveProjectRoot.ts +17 -0
  422. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  423. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
  424. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
  425. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
  426. package/src/utils/toStandardSchema.ts +9 -0
  427. package/src/utils/whereSchema.ts +24 -0
  428. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  429. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  430. package/dist/collections/createApiKeysCollection.js +0 -317
  431. package/dist/collections/createApiKeysCollection.js.map +0 -1
  432. package/dist/defaults.d.ts +0 -4
  433. package/dist/defaults.d.ts.map +0 -1
  434. package/dist/defaults.js +0 -5
  435. package/dist/defaults.js.map +0 -1
  436. package/dist/endpoints/mcp.d.ts +0 -4
  437. package/dist/endpoints/mcp.d.ts.map +0 -1
  438. package/dist/endpoints/mcp.js +0 -71
  439. package/dist/endpoints/mcp.js.map +0 -1
  440. package/dist/mcp/createRequest.d.ts +0 -3
  441. package/dist/mcp/createRequest.d.ts.map +0 -1
  442. package/dist/mcp/createRequest.js +0 -14
  443. package/dist/mcp/createRequest.js.map +0 -1
  444. package/dist/mcp/getMcpHandler.d.ts +0 -4
  445. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  446. package/dist/mcp/getMcpHandler.js +0 -231
  447. package/dist/mcp/getMcpHandler.js.map +0 -1
  448. package/dist/mcp/helpers/config.d.ts +0 -22
  449. package/dist/mcp/helpers/config.d.ts.map +0 -1
  450. package/dist/mcp/helpers/config.js +0 -153
  451. package/dist/mcp/helpers/config.js.map +0 -1
  452. package/dist/mcp/helpers/fields.d.ts +0 -19
  453. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  454. package/dist/mcp/helpers/fields.js +0 -102
  455. package/dist/mcp/helpers/fields.js.map +0 -1
  456. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  457. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  458. package/dist/mcp/helpers/fileValidation.js +0 -267
  459. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  460. package/dist/mcp/registerTool.d.ts +0 -6
  461. package/dist/mcp/registerTool.d.ts.map +0 -1
  462. package/dist/mcp/registerTool.js +0 -18
  463. package/dist/mcp/registerTool.js.map +0 -1
  464. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  465. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  466. package/dist/mcp/tools/auth/auth.js +0 -57
  467. package/dist/mcp/tools/auth/auth.js.map +0 -1
  468. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  469. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  470. package/dist/mcp/tools/auth/forgotPassword.js +0 -48
  471. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  472. package/dist/mcp/tools/auth/login.d.ts +0 -4
  473. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  474. package/dist/mcp/tools/auth/login.js +0 -51
  475. package/dist/mcp/tools/auth/login.js.map +0 -1
  476. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  477. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  478. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  479. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  480. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  481. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  482. package/dist/mcp/tools/auth/unlock.js +0 -48
  483. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  484. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  485. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  486. package/dist/mcp/tools/auth/verify.js +0 -45
  487. package/dist/mcp/tools/auth/verify.js.map +0 -1
  488. package/dist/mcp/tools/collection/create.d.ts +0 -10
  489. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  490. package/dist/mcp/tools/collection/create.js +0 -139
  491. package/dist/mcp/tools/collection/create.js.map +0 -1
  492. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  493. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  494. package/dist/mcp/tools/collection/delete.js +0 -154
  495. package/dist/mcp/tools/collection/delete.js.map +0 -1
  496. package/dist/mcp/tools/collection/find.d.ts +0 -10
  497. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  498. package/dist/mcp/tools/collection/find.js +0 -165
  499. package/dist/mcp/tools/collection/find.js.map +0 -1
  500. package/dist/mcp/tools/collection/update.d.ts +0 -10
  501. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  502. package/dist/mcp/tools/collection/update.js +0 -209
  503. package/dist/mcp/tools/collection/update.js.map +0 -1
  504. package/dist/mcp/tools/config/find.d.ts +0 -10
  505. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  506. package/dist/mcp/tools/config/find.js +0 -97
  507. package/dist/mcp/tools/config/find.js.map +0 -1
  508. package/dist/mcp/tools/config/update.d.ts +0 -10
  509. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  510. package/dist/mcp/tools/config/update.js +0 -215
  511. package/dist/mcp/tools/config/update.js.map +0 -1
  512. package/dist/mcp/tools/global/find.d.ts +0 -5
  513. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  514. package/dist/mcp/tools/global/find.js +0 -82
  515. package/dist/mcp/tools/global/find.js.map +0 -1
  516. package/dist/mcp/tools/global/update.d.ts +0 -6
  517. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  518. package/dist/mcp/tools/global/update.js +0 -124
  519. package/dist/mcp/tools/global/update.js.map +0 -1
  520. package/dist/mcp/tools/job/create.d.ts +0 -10
  521. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  522. package/dist/mcp/tools/job/create.js +0 -293
  523. package/dist/mcp/tools/job/create.js.map +0 -1
  524. package/dist/mcp/tools/job/run.d.ts +0 -10
  525. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  526. package/dist/mcp/tools/job/run.js +0 -129
  527. package/dist/mcp/tools/job/run.js.map +0 -1
  528. package/dist/mcp/tools/job/update.d.ts +0 -11
  529. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  530. package/dist/mcp/tools/job/update.js +0 -186
  531. package/dist/mcp/tools/job/update.js.map +0 -1
  532. package/dist/mcp/tools/resource/create.d.ts +0 -6
  533. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  534. package/dist/mcp/tools/resource/create.js +0 -124
  535. package/dist/mcp/tools/resource/create.js.map +0 -1
  536. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  537. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  538. package/dist/mcp/tools/resource/delete.js +0 -151
  539. package/dist/mcp/tools/resource/delete.js.map +0 -1
  540. package/dist/mcp/tools/resource/find.d.ts +0 -5
  541. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  542. package/dist/mcp/tools/resource/find.js +0 -170
  543. package/dist/mcp/tools/resource/find.js.map +0 -1
  544. package/dist/mcp/tools/resource/update.d.ts +0 -6
  545. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  546. package/dist/mcp/tools/resource/update.js +0 -256
  547. package/dist/mcp/tools/resource/update.js.map +0 -1
  548. package/dist/mcp/tools/schemas.d.ts +0 -457
  549. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  550. package/dist/mcp/tools/schemas.js +0 -243
  551. package/dist/mcp/tools/schemas.js.map +0 -1
  552. package/dist/utils/adminEntitySettings.d.ts +0 -17
  553. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  554. package/dist/utils/adminEntitySettings.js +0 -41
  555. package/dist/utils/adminEntitySettings.js.map +0 -1
  556. package/dist/utils/createApiKeyFields.d.ts +0 -15
  557. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  558. package/dist/utils/createApiKeyFields.js +0 -57
  559. package/dist/utils/createApiKeyFields.js.map +0 -1
  560. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  561. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  562. package/dist/utils/getEnabledSlugs.js +0 -32
  563. package/dist/utils/getEnabledSlugs.js.map +0 -1
  564. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
  565. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  566. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
  567. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  568. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  569. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  570. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  571. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  572. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  573. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  574. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  575. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  576. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  577. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  578. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  579. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  580. package/src/collections/createApiKeysCollection.ts +0 -373
  581. package/src/defaults.ts +0 -3
  582. package/src/endpoints/mcp.ts +0 -91
  583. package/src/mcp/createRequest.ts +0 -13
  584. package/src/mcp/getMcpHandler.ts +0 -545
  585. package/src/mcp/helpers/config.ts +0 -213
  586. package/src/mcp/helpers/fields.ts +0 -154
  587. package/src/mcp/helpers/fileValidation.ts +0 -362
  588. package/src/mcp/registerTool.ts +0 -22
  589. package/src/mcp/tools/auth/auth.ts +0 -71
  590. package/src/mcp/tools/auth/forgotPassword.ts +0 -70
  591. package/src/mcp/tools/auth/login.ts +0 -72
  592. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  593. package/src/mcp/tools/auth/unlock.ts +0 -64
  594. package/src/mcp/tools/auth/verify.ts +0 -57
  595. package/src/mcp/tools/collection/create.ts +0 -210
  596. package/src/mcp/tools/collection/delete.ts +0 -211
  597. package/src/mcp/tools/collection/find.ts +0 -224
  598. package/src/mcp/tools/collection/update.ts +0 -290
  599. package/src/mcp/tools/config/find.ts +0 -128
  600. package/src/mcp/tools/config/update.ts +0 -280
  601. package/src/mcp/tools/global/find.ts +0 -128
  602. package/src/mcp/tools/global/update.ts +0 -207
  603. package/src/mcp/tools/job/create.ts +0 -416
  604. package/src/mcp/tools/job/run.ts +0 -167
  605. package/src/mcp/tools/job/update.ts +0 -274
  606. package/src/mcp/tools/resource/create.ts +0 -211
  607. package/src/mcp/tools/resource/delete.ts +0 -218
  608. package/src/mcp/tools/resource/find.ts +0 -246
  609. package/src/mcp/tools/resource/update.ts +0 -383
  610. package/src/mcp/tools/schemas.ts +0 -520
  611. package/src/utils/adminEntitySettings.ts +0 -40
  612. package/src/utils/createApiKeyFields.ts +0 -72
  613. package/src/utils/getEnabledSlugs.ts +0 -42
  614. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
  615. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  616. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  617. 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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C,mCAAmC,EAAEL,eAAe,mBAAmB,EAAEC,gBAAgB,gBAAgB,EAAEC,cAAc;QAE9H;QAEA,IAAI;YACF,MAAM0B,SAASjC,iBACbC,KACAC,aACAC,oBACAC,gBACAC,gBACAC,iBACAC;YAGF,IAAIL,aAAa;gBACfM,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,iDAAiD,EAAEL,gBAAgB;YAC1F;YAEA,OAAO4B;QACT,EAAE,OAAOZ,OAAO;YACd,MAAMM,eAAeN,iBAAiBa,QAAQb,MAAMO,OAAO,GAAG;YAC9DpB,QAAQC,MAAM,CAACY,KAAK,CAClB,CAAC,wCAAwC,EAAEhB,eAAe,EAAE,EAAEsB,cAAc;YAG9E,OAAO;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,CAA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MAAM,CAAC,iCAAiC,EAAEuB,cAAc;gBAC1D;aACD;QACH;IACF;AACF,EAAC;AAED,+BAA+B;AAC/B,OAAO,MAAMC,qBAAqB,CAChCC,QACA3C,KACAC,aACAC;IAEA,MAAM0C,OAAO,CACXzC,gBACAC,iBAA0B,KAAK,EAC/BC,eAAwB,KAAK;QAE7B,MAAMC,UAAUN,IAAIM,OAAO;QAE3B,IAAIL,aAAa;YACfK,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,iCAAiC,EAAEL,iBAAiB,CAAC,MAAM,EAAEA,gBAAgB,GAAG,GAAG,kBAAkB,EAAEC,eAAe,gBAAgB,EAAEC,cAAc;QAE3J;QAEA,IAAI;YACF,MAAMwC,SAAS9C,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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I,CAAC,CAAC,+CAA+C,EAAET,gBAAgB;YACxF;YAEA,OAAOyC;QACT,EAAE,OAAOxB,OAAO;YACd,MAAMmB,eAAenB,iBAAiByB,QAAQzB,MAAMoB,OAAO,GAAG;YAC9D9B,QAAQC,MAAM,CAACS,KAAK,CAClB,CAAC,wCAAwC,EAAEjB,eAAe,EAAE,EAAEoC,cAAc;YAG9E,OAAO;gBACLlB,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,2BAA2B,EAAEpB,eAAe,GAAG,EAAEoC,cAAc;oBACxE;iBACD;YACH;QACF;IACF;IAEAG,OAAOI,YAAY,CACjB,oBACA;QACEC,aAAalD,YAAYC,gBAAgB,CAACiD,WAAW;QACrDC,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