@payloadcms/plugin-mcp 4.0.0-canary.0 → 4.0.0-canary.2

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 (381) hide show
  1. package/dist/collection/getAccessField.d.ts.map +1 -1
  2. package/dist/collection/getAccessField.js +25 -10
  3. package/dist/collection/getAccessField.js.map +1 -1
  4. package/dist/collection/index.d.ts.map +1 -1
  5. package/dist/collection/index.js +73 -27
  6. package/dist/collection/index.js.map +1 -1
  7. package/dist/components/APIKeyField/index.client.d.ts +9 -0
  8. package/dist/components/APIKeyField/index.client.d.ts.map +1 -0
  9. package/dist/components/APIKeyField/index.client.js +85 -0
  10. package/dist/components/APIKeyField/index.client.js.map +1 -0
  11. package/dist/components/APIKeyField/index.css +105 -0
  12. package/dist/components/APIKeysEmptyState/index.client.d.ts +4 -0
  13. package/dist/components/APIKeysEmptyState/index.client.d.ts.map +1 -0
  14. package/dist/components/APIKeysEmptyState/index.client.js +21 -0
  15. package/dist/components/APIKeysEmptyState/index.client.js.map +1 -0
  16. package/dist/components/AccessField/index.client.d.ts.map +1 -1
  17. package/dist/components/AccessField/index.client.js +149 -207
  18. package/dist/components/AccessField/index.client.js.map +1 -1
  19. package/dist/components/AccessField/index.css +50 -44
  20. package/dist/components/SettingsMenu/index.client.d.ts +8 -0
  21. package/dist/components/SettingsMenu/index.client.d.ts.map +1 -0
  22. package/dist/components/SettingsMenu/index.client.js +29 -0
  23. package/dist/components/SettingsMenu/index.client.js.map +1 -0
  24. package/dist/endpoint/access.js +21 -5
  25. package/dist/endpoint/access.js.map +1 -1
  26. package/dist/exports/client.d.ts +3 -0
  27. package/dist/exports/client.d.ts.map +1 -1
  28. package/dist/exports/client.js +3 -0
  29. package/dist/exports/client.js.map +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +46 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  34. package/dist/mcp/buildMcpServer.js +100 -64
  35. package/dist/mcp/buildMcpServer.js.map +1 -1
  36. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  37. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  38. package/dist/mcp/builtin/collections/createTool.js +28 -21
  39. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  40. package/dist/mcp/builtin/collections/deleteTool.d.ts +1 -1
  41. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  42. package/dist/mcp/builtin/collections/deleteTool.js +5 -20
  43. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  44. package/dist/mcp/builtin/collections/findTool.d.ts +1 -1
  45. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  46. package/dist/mcp/builtin/collections/findTool.js +6 -21
  47. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  48. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  49. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  50. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  51. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  52. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  53. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  54. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
  55. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  56. package/dist/mcp/builtin/collections/updateTool.d.ts +1 -1
  57. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  58. package/dist/mcp/builtin/collections/updateTool.js +74 -62
  59. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  60. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  61. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  62. package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
  63. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  64. package/dist/mcp/builtin/globals/findTool.js +1 -1
  65. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  66. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  67. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  68. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
  69. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  70. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  71. package/dist/mcp/builtin/globals/updateTool.js +21 -19
  72. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  73. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  74. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  75. package/dist/mcp/builtin/validateEntityData.js +82 -0
  76. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  77. package/dist/mcp/builtinTools.d.ts +84 -16
  78. package/dist/mcp/builtinTools.d.ts.map +1 -1
  79. package/dist/mcp/builtinTools.js +54 -11
  80. package/dist/mcp/builtinTools.js.map +1 -1
  81. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  82. package/dist/mcp/sanitizeMCPConfig.js +61 -40
  83. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  84. package/dist/translations/index.d.ts +11 -0
  85. package/dist/translations/index.d.ts.map +1 -0
  86. package/dist/translations/index.js +92 -0
  87. package/dist/translations/index.js.map +1 -0
  88. package/dist/translations/languages/ar.d.ts +31 -0
  89. package/dist/translations/languages/ar.d.ts.map +1 -0
  90. package/dist/translations/languages/ar.js +34 -0
  91. package/dist/translations/languages/ar.js.map +1 -0
  92. package/dist/translations/languages/az.d.ts +31 -0
  93. package/dist/translations/languages/az.d.ts.map +1 -0
  94. package/dist/translations/languages/az.js +34 -0
  95. package/dist/translations/languages/az.js.map +1 -0
  96. package/dist/translations/languages/bg.d.ts +31 -0
  97. package/dist/translations/languages/bg.d.ts.map +1 -0
  98. package/dist/translations/languages/bg.js +34 -0
  99. package/dist/translations/languages/bg.js.map +1 -0
  100. package/dist/translations/languages/bnBd.d.ts +31 -0
  101. package/dist/translations/languages/bnBd.d.ts.map +1 -0
  102. package/dist/translations/languages/bnBd.js +34 -0
  103. package/dist/translations/languages/bnBd.js.map +1 -0
  104. package/dist/translations/languages/bnIn.d.ts +31 -0
  105. package/dist/translations/languages/bnIn.d.ts.map +1 -0
  106. package/dist/translations/languages/bnIn.js +34 -0
  107. package/dist/translations/languages/bnIn.js.map +1 -0
  108. package/dist/translations/languages/ca.d.ts +31 -0
  109. package/dist/translations/languages/ca.d.ts.map +1 -0
  110. package/dist/translations/languages/ca.js +34 -0
  111. package/dist/translations/languages/ca.js.map +1 -0
  112. package/dist/translations/languages/cs.d.ts +31 -0
  113. package/dist/translations/languages/cs.d.ts.map +1 -0
  114. package/dist/translations/languages/cs.js +34 -0
  115. package/dist/translations/languages/cs.js.map +1 -0
  116. package/dist/translations/languages/da.d.ts +31 -0
  117. package/dist/translations/languages/da.d.ts.map +1 -0
  118. package/dist/translations/languages/da.js +34 -0
  119. package/dist/translations/languages/da.js.map +1 -0
  120. package/dist/translations/languages/de.d.ts +31 -0
  121. package/dist/translations/languages/de.d.ts.map +1 -0
  122. package/dist/translations/languages/de.js +34 -0
  123. package/dist/translations/languages/de.js.map +1 -0
  124. package/dist/translations/languages/en.d.ts +31 -0
  125. package/dist/translations/languages/en.d.ts.map +1 -0
  126. package/dist/translations/languages/en.js +34 -0
  127. package/dist/translations/languages/en.js.map +1 -0
  128. package/dist/translations/languages/es.d.ts +31 -0
  129. package/dist/translations/languages/es.d.ts.map +1 -0
  130. package/dist/translations/languages/es.js +34 -0
  131. package/dist/translations/languages/es.js.map +1 -0
  132. package/dist/translations/languages/et.d.ts +31 -0
  133. package/dist/translations/languages/et.d.ts.map +1 -0
  134. package/dist/translations/languages/et.js +34 -0
  135. package/dist/translations/languages/et.js.map +1 -0
  136. package/dist/translations/languages/fa.d.ts +31 -0
  137. package/dist/translations/languages/fa.d.ts.map +1 -0
  138. package/dist/translations/languages/fa.js +34 -0
  139. package/dist/translations/languages/fa.js.map +1 -0
  140. package/dist/translations/languages/fr.d.ts +31 -0
  141. package/dist/translations/languages/fr.d.ts.map +1 -0
  142. package/dist/translations/languages/fr.js +34 -0
  143. package/dist/translations/languages/fr.js.map +1 -0
  144. package/dist/translations/languages/he.d.ts +31 -0
  145. package/dist/translations/languages/he.d.ts.map +1 -0
  146. package/dist/translations/languages/he.js +34 -0
  147. package/dist/translations/languages/he.js.map +1 -0
  148. package/dist/translations/languages/hr.d.ts +31 -0
  149. package/dist/translations/languages/hr.d.ts.map +1 -0
  150. package/dist/translations/languages/hr.js +34 -0
  151. package/dist/translations/languages/hr.js.map +1 -0
  152. package/dist/translations/languages/hu.d.ts +31 -0
  153. package/dist/translations/languages/hu.d.ts.map +1 -0
  154. package/dist/translations/languages/hu.js +34 -0
  155. package/dist/translations/languages/hu.js.map +1 -0
  156. package/dist/translations/languages/hy.d.ts +31 -0
  157. package/dist/translations/languages/hy.d.ts.map +1 -0
  158. package/dist/translations/languages/hy.js +34 -0
  159. package/dist/translations/languages/hy.js.map +1 -0
  160. package/dist/translations/languages/id.d.ts +31 -0
  161. package/dist/translations/languages/id.d.ts.map +1 -0
  162. package/dist/translations/languages/id.js +34 -0
  163. package/dist/translations/languages/id.js.map +1 -0
  164. package/dist/translations/languages/is.d.ts +31 -0
  165. package/dist/translations/languages/is.d.ts.map +1 -0
  166. package/dist/translations/languages/is.js +34 -0
  167. package/dist/translations/languages/is.js.map +1 -0
  168. package/dist/translations/languages/it.d.ts +31 -0
  169. package/dist/translations/languages/it.d.ts.map +1 -0
  170. package/dist/translations/languages/it.js +34 -0
  171. package/dist/translations/languages/it.js.map +1 -0
  172. package/dist/translations/languages/ja.d.ts +31 -0
  173. package/dist/translations/languages/ja.d.ts.map +1 -0
  174. package/dist/translations/languages/ja.js +34 -0
  175. package/dist/translations/languages/ja.js.map +1 -0
  176. package/dist/translations/languages/ko.d.ts +31 -0
  177. package/dist/translations/languages/ko.d.ts.map +1 -0
  178. package/dist/translations/languages/ko.js +34 -0
  179. package/dist/translations/languages/ko.js.map +1 -0
  180. package/dist/translations/languages/lt.d.ts +31 -0
  181. package/dist/translations/languages/lt.d.ts.map +1 -0
  182. package/dist/translations/languages/lt.js +34 -0
  183. package/dist/translations/languages/lt.js.map +1 -0
  184. package/dist/translations/languages/lv.d.ts +31 -0
  185. package/dist/translations/languages/lv.d.ts.map +1 -0
  186. package/dist/translations/languages/lv.js +34 -0
  187. package/dist/translations/languages/lv.js.map +1 -0
  188. package/dist/translations/languages/my.d.ts +31 -0
  189. package/dist/translations/languages/my.d.ts.map +1 -0
  190. package/dist/translations/languages/my.js +34 -0
  191. package/dist/translations/languages/my.js.map +1 -0
  192. package/dist/translations/languages/nb.d.ts +31 -0
  193. package/dist/translations/languages/nb.d.ts.map +1 -0
  194. package/dist/translations/languages/nb.js +34 -0
  195. package/dist/translations/languages/nb.js.map +1 -0
  196. package/dist/translations/languages/nl.d.ts +31 -0
  197. package/dist/translations/languages/nl.d.ts.map +1 -0
  198. package/dist/translations/languages/nl.js +34 -0
  199. package/dist/translations/languages/nl.js.map +1 -0
  200. package/dist/translations/languages/pl.d.ts +31 -0
  201. package/dist/translations/languages/pl.d.ts.map +1 -0
  202. package/dist/translations/languages/pl.js +34 -0
  203. package/dist/translations/languages/pl.js.map +1 -0
  204. package/dist/translations/languages/pt.d.ts +31 -0
  205. package/dist/translations/languages/pt.d.ts.map +1 -0
  206. package/dist/translations/languages/pt.js +34 -0
  207. package/dist/translations/languages/pt.js.map +1 -0
  208. package/dist/translations/languages/ro.d.ts +31 -0
  209. package/dist/translations/languages/ro.d.ts.map +1 -0
  210. package/dist/translations/languages/ro.js +34 -0
  211. package/dist/translations/languages/ro.js.map +1 -0
  212. package/dist/translations/languages/rs.d.ts +31 -0
  213. package/dist/translations/languages/rs.d.ts.map +1 -0
  214. package/dist/translations/languages/rs.js +34 -0
  215. package/dist/translations/languages/rs.js.map +1 -0
  216. package/dist/translations/languages/rsLatin.d.ts +31 -0
  217. package/dist/translations/languages/rsLatin.d.ts.map +1 -0
  218. package/dist/translations/languages/rsLatin.js +34 -0
  219. package/dist/translations/languages/rsLatin.js.map +1 -0
  220. package/dist/translations/languages/ru.d.ts +31 -0
  221. package/dist/translations/languages/ru.d.ts.map +1 -0
  222. package/dist/translations/languages/ru.js +34 -0
  223. package/dist/translations/languages/ru.js.map +1 -0
  224. package/dist/translations/languages/sk.d.ts +31 -0
  225. package/dist/translations/languages/sk.d.ts.map +1 -0
  226. package/dist/translations/languages/sk.js +34 -0
  227. package/dist/translations/languages/sk.js.map +1 -0
  228. package/dist/translations/languages/sl.d.ts +31 -0
  229. package/dist/translations/languages/sl.d.ts.map +1 -0
  230. package/dist/translations/languages/sl.js +34 -0
  231. package/dist/translations/languages/sl.js.map +1 -0
  232. package/dist/translations/languages/sv.d.ts +31 -0
  233. package/dist/translations/languages/sv.d.ts.map +1 -0
  234. package/dist/translations/languages/sv.js +34 -0
  235. package/dist/translations/languages/sv.js.map +1 -0
  236. package/dist/translations/languages/ta.d.ts +31 -0
  237. package/dist/translations/languages/ta.d.ts.map +1 -0
  238. package/dist/translations/languages/ta.js +34 -0
  239. package/dist/translations/languages/ta.js.map +1 -0
  240. package/dist/translations/languages/th.d.ts +31 -0
  241. package/dist/translations/languages/th.d.ts.map +1 -0
  242. package/dist/translations/languages/th.js +34 -0
  243. package/dist/translations/languages/th.js.map +1 -0
  244. package/dist/translations/languages/tr.d.ts +31 -0
  245. package/dist/translations/languages/tr.d.ts.map +1 -0
  246. package/dist/translations/languages/tr.js +34 -0
  247. package/dist/translations/languages/tr.js.map +1 -0
  248. package/dist/translations/languages/uk.d.ts +31 -0
  249. package/dist/translations/languages/uk.d.ts.map +1 -0
  250. package/dist/translations/languages/uk.js +34 -0
  251. package/dist/translations/languages/uk.js.map +1 -0
  252. package/dist/translations/languages/vi.d.ts +31 -0
  253. package/dist/translations/languages/vi.d.ts.map +1 -0
  254. package/dist/translations/languages/vi.js +34 -0
  255. package/dist/translations/languages/vi.js.map +1 -0
  256. package/dist/translations/languages/zh.d.ts +31 -0
  257. package/dist/translations/languages/zh.d.ts.map +1 -0
  258. package/dist/translations/languages/zh.js +34 -0
  259. package/dist/translations/languages/zh.js.map +1 -0
  260. package/dist/translations/languages/zhTw.d.ts +31 -0
  261. package/dist/translations/languages/zhTw.d.ts.map +1 -0
  262. package/dist/translations/languages/zhTw.js +34 -0
  263. package/dist/translations/languages/zhTw.js.map +1 -0
  264. package/dist/translations/types.d.ts +32 -0
  265. package/dist/translations/types.d.ts.map +1 -0
  266. package/dist/translations/types.js +3 -0
  267. package/dist/translations/types.js.map +1 -0
  268. package/dist/types.d.ts +22 -28
  269. package/dist/types.d.ts.map +1 -1
  270. package/dist/types.js.map +1 -1
  271. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  272. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  273. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  274. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  275. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
  276. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  277. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
  278. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  279. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
  280. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  281. package/dist/utils/whereSchema.d.ts +9 -0
  282. package/dist/utils/whereSchema.d.ts.map +1 -0
  283. package/dist/utils/whereSchema.js +13 -0
  284. package/dist/utils/whereSchema.js.map +1 -0
  285. package/package.json +7 -6
  286. package/src/collection/getAccessField.ts +33 -13
  287. package/src/collection/index.ts +64 -22
  288. package/src/components/APIKeyField/index.client.tsx +73 -0
  289. package/src/components/APIKeyField/index.css +105 -0
  290. package/src/components/APIKeysEmptyState/index.client.tsx +36 -0
  291. package/src/components/AccessField/index.client.tsx +175 -220
  292. package/src/components/AccessField/index.css +50 -44
  293. package/src/components/SettingsMenu/index.client.tsx +34 -0
  294. package/src/endpoint/access.ts +17 -5
  295. package/src/exports/client.ts +3 -0
  296. package/src/index.ts +49 -3
  297. package/src/mcp/buildMcpServer.ts +123 -90
  298. package/src/mcp/builtin/collections/createTool.ts +46 -50
  299. package/src/mcp/builtin/collections/deleteTool.ts +9 -16
  300. package/src/mcp/builtin/collections/findTool.ts +7 -17
  301. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  302. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
  303. package/src/mcp/builtin/collections/updateTool.ts +97 -91
  304. package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
  305. package/src/mcp/builtin/globals/findTool.ts +1 -1
  306. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
  307. package/src/mcp/builtin/globals/updateTool.ts +40 -43
  308. package/src/mcp/builtin/validateEntityData.ts +132 -0
  309. package/src/mcp/builtinTools.ts +52 -38
  310. package/src/mcp/sanitizeMCPConfig.ts +78 -57
  311. package/src/translations/index.ts +108 -0
  312. package/src/translations/languages/ar.ts +35 -0
  313. package/src/translations/languages/az.ts +35 -0
  314. package/src/translations/languages/bg.ts +35 -0
  315. package/src/translations/languages/bnBd.ts +35 -0
  316. package/src/translations/languages/bnIn.ts +35 -0
  317. package/src/translations/languages/ca.ts +35 -0
  318. package/src/translations/languages/cs.ts +35 -0
  319. package/src/translations/languages/da.ts +35 -0
  320. package/src/translations/languages/de.ts +35 -0
  321. package/src/translations/languages/en.ts +35 -0
  322. package/src/translations/languages/es.ts +35 -0
  323. package/src/translations/languages/et.ts +35 -0
  324. package/src/translations/languages/fa.ts +35 -0
  325. package/src/translations/languages/fr.ts +35 -0
  326. package/src/translations/languages/he.ts +35 -0
  327. package/src/translations/languages/hr.ts +35 -0
  328. package/src/translations/languages/hu.ts +35 -0
  329. package/src/translations/languages/hy.ts +35 -0
  330. package/src/translations/languages/id.ts +35 -0
  331. package/src/translations/languages/is.ts +35 -0
  332. package/src/translations/languages/it.ts +35 -0
  333. package/src/translations/languages/ja.ts +35 -0
  334. package/src/translations/languages/ko.ts +35 -0
  335. package/src/translations/languages/lt.ts +35 -0
  336. package/src/translations/languages/lv.ts +35 -0
  337. package/src/translations/languages/my.ts +35 -0
  338. package/src/translations/languages/nb.ts +35 -0
  339. package/src/translations/languages/nl.ts +35 -0
  340. package/src/translations/languages/pl.ts +35 -0
  341. package/src/translations/languages/pt.ts +35 -0
  342. package/src/translations/languages/ro.ts +35 -0
  343. package/src/translations/languages/rs.ts +35 -0
  344. package/src/translations/languages/rsLatin.ts +35 -0
  345. package/src/translations/languages/ru.ts +35 -0
  346. package/src/translations/languages/sk.ts +35 -0
  347. package/src/translations/languages/sl.ts +35 -0
  348. package/src/translations/languages/sv.ts +35 -0
  349. package/src/translations/languages/ta.ts +35 -0
  350. package/src/translations/languages/th.ts +35 -0
  351. package/src/translations/languages/tr.ts +35 -0
  352. package/src/translations/languages/uk.ts +35 -0
  353. package/src/translations/languages/vi.ts +35 -0
  354. package/src/translations/languages/zh.ts +35 -0
  355. package/src/translations/languages/zhTw.ts +35 -0
  356. package/src/translations/types.ts +34 -0
  357. package/src/types.ts +30 -30
  358. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  359. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
  360. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
  361. package/src/utils/whereSchema.ts +24 -0
  362. package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts +0 -7
  363. package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +0 -1
  364. package/dist/utils/schemaConversion/prepareCollectionSchema.js +0 -37
  365. package/dist/utils/schemaConversion/prepareCollectionSchema.js.map +0 -1
  366. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  367. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  368. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  369. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  370. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  371. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  372. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -56
  373. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  374. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  375. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  376. package/dist/utils/schemaConversion/transformPointFields.js +0 -57
  377. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  378. package/src/utils/schemaConversion/prepareCollectionSchema.ts +0 -39
  379. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  380. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -70
  381. package/src/utils/schemaConversion/transformPointFields.ts +0 -56
@@ -0,0 +1,82 @@
1
+ import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server';
2
+ import { getCollectionInputSchema, getGlobalInputSchema } from '../../utils/schemaConversion/getEntityInputSchema.js';
3
+ /**
4
+ * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.
5
+ */ const validator = new CfWorkerJsonSchemaValidator({
6
+ shortcircuit: true
7
+ });
8
+ /**
9
+ * - Caches each entity's schema and validator, so both are only built on the first request.
10
+ * - Keyed by payload config, then by entity type, slug, partial and language.
11
+ */ const validatorCache = new WeakMap();
12
+ export const validateCollectionData = ({ collectionSlug, data, partial, req })=>validateData({
13
+ slug: collectionSlug,
14
+ buildSchema: ()=>getCollectionInputSchema({
15
+ collectionSlug,
16
+ req
17
+ }),
18
+ data,
19
+ entity: 'collection',
20
+ partial,
21
+ req
22
+ });
23
+ export const validateGlobalData = ({ data, globalSlug, req })=>validateData({
24
+ slug: globalSlug,
25
+ buildSchema: ()=>getGlobalInputSchema({
26
+ globalSlug,
27
+ req
28
+ }),
29
+ data,
30
+ entity: 'global',
31
+ partial: true,
32
+ req
33
+ });
34
+ const validateData = ({ slug, buildSchema, data, entity, partial, req })=>{
35
+ let cache = validatorCache.get(req.payload.config);
36
+ if (!cache) {
37
+ cache = new Map();
38
+ validatorCache.set(req.payload.config, cache);
39
+ }
40
+ const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`;
41
+ let entityValidator = cache.get(cacheKey);
42
+ if (!entityValidator) {
43
+ const schema = buildSchema();
44
+ if (!schema) {
45
+ return null;
46
+ }
47
+ entityValidator = {
48
+ schema,
49
+ validate: validator.getValidator(partial ? withoutRequired(schema) : schema)
50
+ };
51
+ cache.set(cacheKey, entityValidator);
52
+ }
53
+ const result = entityValidator.validate(data);
54
+ if (result.valid) {
55
+ return null;
56
+ }
57
+ const { schema } = entityValidator;
58
+ return {
59
+ content: [
60
+ {
61
+ type: 'text',
62
+ text: `Invalid data for ${entity} "${slug}": ${result.errorMessage}\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``
63
+ }
64
+ ],
65
+ isError: true,
66
+ structuredContent: {
67
+ [`${entity}Slug`]: slug,
68
+ errors: [
69
+ {
70
+ message: result.errorMessage
71
+ }
72
+ ],
73
+ schema
74
+ }
75
+ };
76
+ };
77
+ /** Updates are partial — drop the schema's top-level `required` before validating. */ const withoutRequired = (schema)=>{
78
+ const { required: _required, ...rest } = schema;
79
+ return rest;
80
+ };
81
+
82
+ //# sourceMappingURL=validateEntityData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/mcp/builtin/validateEntityData.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server'\n\nimport type { JsonSchemaType, MCPToolResponse } from '../../types.js'\n\nimport {\n getCollectionInputSchema,\n getGlobalInputSchema,\n} from '../../utils/schemaConversion/getEntityInputSchema.js'\n\n/**\n * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.\n */\nconst validator = new CfWorkerJsonSchemaValidator({ shortcircuit: true })\n\ntype EntityValidator = {\n schema: JsonSchemaType\n validate: ReturnType<(typeof validator)['getValidator']>\n}\n\n/**\n * - Caches each entity's schema and validator, so both are only built on the first request.\n * - Keyed by payload config, then by entity type, slug, partial and language.\n */\nconst validatorCache = new WeakMap<SanitizedConfig, Map<string, EntityValidator>>()\n\nexport const validateCollectionData = ({\n collectionSlug,\n data,\n partial,\n req,\n}: {\n collectionSlug: CollectionSlug\n data: Record<string, unknown>\n partial?: boolean\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: collectionSlug,\n buildSchema: () => getCollectionInputSchema({ collectionSlug, req }),\n data,\n entity: 'collection',\n partial,\n req,\n })\n\nexport const validateGlobalData = ({\n data,\n globalSlug,\n req,\n}: {\n data: Record<string, unknown>\n globalSlug: GlobalSlug\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: globalSlug,\n buildSchema: () => getGlobalInputSchema({ globalSlug, req }),\n data,\n entity: 'global',\n partial: true,\n req,\n })\n\nconst validateData = ({\n slug,\n buildSchema,\n data,\n entity,\n partial,\n req,\n}: {\n buildSchema: () => JsonSchemaType | null\n data: Record<string, unknown>\n entity: 'collection' | 'global'\n partial?: boolean\n req: PayloadRequest\n slug: string\n}): MCPToolResponse | null => {\n let cache = validatorCache.get(req.payload.config)\n if (!cache) {\n cache = new Map()\n validatorCache.set(req.payload.config, cache)\n }\n\n const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`\n let entityValidator = cache.get(cacheKey)\n\n if (!entityValidator) {\n const schema = buildSchema()\n\n if (!schema) {\n return null\n }\n\n entityValidator = {\n schema,\n validate: validator.getValidator(partial ? withoutRequired(schema) : schema),\n }\n cache.set(cacheKey, entityValidator)\n }\n\n const result = entityValidator.validate(data)\n\n if (result.valid) {\n return null\n }\n\n const { schema } = entityValidator\n\n return {\n content: [\n {\n type: 'text',\n text: `Invalid data for ${entity} \"${slug}\": ${result.errorMessage}\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(schema)}\\n\\`\\`\\``,\n },\n ],\n isError: true,\n structuredContent: {\n [`${entity}Slug`]: slug,\n errors: [{ message: result.errorMessage }],\n schema,\n },\n }\n}\n\n/** Updates are partial — drop the schema's top-level `required` before validating. */\nconst withoutRequired = (schema: JsonSchemaType): JsonSchemaType => {\n const { required: _required, ...rest } = schema\n return rest\n}\n"],"names":["CfWorkerJsonSchemaValidator","getCollectionInputSchema","getGlobalInputSchema","validator","shortcircuit","validatorCache","WeakMap","validateCollectionData","collectionSlug","data","partial","req","validateData","slug","buildSchema","entity","validateGlobalData","globalSlug","cache","get","payload","config","Map","set","cacheKey","i18n","language","entityValidator","schema","validate","getValidator","withoutRequired","result","valid","content","type","text","errorMessage","JSON","stringify","isError","structuredContent","errors","message","required","_required","rest"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,+BAA8B;AAI1E,SACEC,wBAAwB,EACxBC,oBAAoB,QACf,uDAAsD;AAE7D;;CAEC,GACD,MAAMC,YAAY,IAAIH,4BAA4B;IAAEI,cAAc;AAAK;AAOvE;;;CAGC,GACD,MAAMC,iBAAiB,IAAIC;AAE3B,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,cAAc,EACdC,IAAI,EACJC,OAAO,EACPC,GAAG,EAMJ,GACCC,aAAa;QACXC,MAAML;QACNM,aAAa,IAAMb,yBAAyB;gBAAEO;gBAAgBG;YAAI;QAClEF;QACAM,QAAQ;QACRL;QACAC;IACF,GAAE;AAEJ,OAAO,MAAMK,qBAAqB,CAAC,EACjCP,IAAI,EACJQ,UAAU,EACVN,GAAG,EAKJ,GACCC,aAAa;QACXC,MAAMI;Q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;gBAAC;aAAE;YAC1CT;QACF;IACF;AACF;AAEA,oFAAoF,GACpF,MAAMG,kBAAkB,CAACH;IACvB,MAAM,EAAEgB,UAAUC,SAAS,EAAE,GAAGC,MAAM,GAAGlB;IACzC,OAAOkB;AACT"}
@@ -1,37 +1,105 @@
1
- import type { CollectionTool, GlobalTool } from '../types.js';
1
+ import type { CollectionTool, GlobalTool, Tool } from '../types.js';
2
+ export declare const TOOL_BUILTINS: {
3
+ getConfigInfo: {
4
+ label: string;
5
+ mcpName: string;
6
+ tool: Tool;
7
+ };
8
+ };
2
9
  /**
3
10
  * The static built-in collection CRUD tools. Keys here are the source of truth
4
11
  * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
5
12
  * automatically.
6
13
  */
7
- export declare const COLLECTION_BUILTINS: Record<MCPCollectionBuiltinName, CollectionTool>;
14
+ export declare const COLLECTION_BUILTINS: {
15
+ create: {
16
+ mcpName: string;
17
+ tool: CollectionTool;
18
+ };
19
+ delete: {
20
+ mcpName: string;
21
+ tool: CollectionTool;
22
+ };
23
+ find: {
24
+ mcpName: string;
25
+ tool: CollectionTool;
26
+ };
27
+ getCollectionSchema: {
28
+ mcpName: string;
29
+ tool: CollectionTool;
30
+ };
31
+ update: {
32
+ mcpName: string;
33
+ tool: CollectionTool;
34
+ };
35
+ };
8
36
  /**
9
37
  * The static auth tools surfaced under auth-enabled collections. Each entry
10
38
  * carries the admin-UI label alongside the tool. Keys are the source of truth
11
39
  * for `MCPCollectionAuthToolName`.
12
40
  */
13
- export declare const COLLECTION_AUTH_BUILTINS: Record<MCPCollectionAuthToolName, {
14
- label: string;
15
- tool: CollectionTool;
16
- }>;
41
+ export declare const COLLECTION_AUTH_BUILTINS: {
42
+ auth: {
43
+ label: string;
44
+ mcpName: string;
45
+ tool: CollectionTool;
46
+ };
47
+ forgotPassword: {
48
+ label: string;
49
+ mcpName: string;
50
+ tool: CollectionTool;
51
+ };
52
+ login: {
53
+ label: string;
54
+ mcpName: string;
55
+ tool: CollectionTool;
56
+ };
57
+ resetPassword: {
58
+ label: string;
59
+ mcpName: string;
60
+ tool: CollectionTool;
61
+ };
62
+ unlock: {
63
+ label: string;
64
+ mcpName: string;
65
+ tool: CollectionTool;
66
+ };
67
+ verify: {
68
+ label: string;
69
+ mcpName: string;
70
+ tool: CollectionTool;
71
+ };
72
+ };
17
73
  /**
18
74
  * The static built-in global tools. Keys are the source of truth for
19
75
  * `MCPGlobalBuiltinName`.
20
76
  */
21
- export declare const GLOBAL_BUILTINS: Record<MCPGlobalBuiltinName, GlobalTool>;
22
- export type MCPCollectionBuiltinName = 'create' | 'delete' | 'find' | 'update';
23
- export type MCPCollectionAuthToolName = 'auth' | 'forgotPassword' | 'login' | 'resetPassword' | 'unlock' | 'verify';
24
- export type MCPGlobalBuiltinName = 'find' | 'update';
77
+ export declare const GLOBAL_BUILTINS: {
78
+ find: {
79
+ mcpName: string;
80
+ tool: GlobalTool;
81
+ };
82
+ getGlobalSchema: {
83
+ mcpName: string;
84
+ tool: GlobalTool;
85
+ };
86
+ update: {
87
+ mcpName: string;
88
+ tool: GlobalTool;
89
+ };
90
+ };
91
+ export type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS;
92
+ export type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS;
93
+ export type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS;
94
+ export type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS;
25
95
  /**
26
96
  * Pre-typed `Object.entries` for each registry. The cast from `string` to the
27
97
  * literal key union lives here once so consumers can iterate without their own
28
98
  * cast — TypeScript's `Object.entries` always widens keys to `string`, which
29
99
  * defeats the narrow type lookups on `MCPCollectionToolsMap`.
30
100
  */
31
- export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, CollectionTool]>;
32
- export declare const COLLECTION_AUTH_BUILTIN_ENTRIES: Array<[MCPCollectionAuthToolName, {
33
- label: string;
34
- tool: CollectionTool;
35
- }]>;
36
- export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, GlobalTool]>;
101
+ export declare const TOOL_BUILTIN_ENTRIES: Array<[MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]>;
102
+ export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, (typeof COLLECTION_BUILTINS)[MCPCollectionBuiltinName]]>;
103
+ export declare const COLLECTION_AUTH_BUILTIN_ENTRIES: Array<[MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]>;
104
+ export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, (typeof GLOBAL_BUILTINS)[MCPGlobalBuiltinName]]>;
37
105
  //# sourceMappingURL=builtinTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAiB7D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,wBAAwB,EAAE,cAAc,CAKhF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,yBAAyB,EACzB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAQxC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAGpE,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;AAE9E,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,gBAAgB,GAChB,OAAO,GACP,eAAe,GACf,QAAQ,GACR,QAAQ,CAAA;AAEZ,MAAM,MAAM,oBAAoB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KAAK,CACpF,CAAC,wBAAwB,EAAE,CAAC,OAAO,mBAAmB,EAAE,wBAAwB,CAAC,CAAC,CACnF,CAAA;AAED,eAAO,MAAM,+BAA+B,EAA+C,KAAK,CAC9F,CAAC,yBAAyB,EAAE,CAAC,OAAO,wBAAwB,EAAE,yBAAyB,CAAC,CAAC,CAC1F,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAsC,KAAK,CAC5E,CAAC,oBAAoB,EAAE,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,CAAC,CACvE,CAAA"}
@@ -1,19 +1,45 @@
1
1
  import { authCollectionTool, forgotPasswordCollectionTool, loginCollectionTool, resetPasswordCollectionTool, unlockCollectionTool, verifyCollectionTool } from './builtin/collections/authTools.js';
2
- import { createCollectionTool } from './builtin/collections/createTool.js';
3
- import { deleteCollectionTool } from './builtin/collections/deleteTool.js';
4
- import { findCollectionTool } from './builtin/collections/findTool.js';
5
- import { updateCollectionTool } from './builtin/collections/updateTool.js';
2
+ import { createDocumentTool } from './builtin/collections/createTool.js';
3
+ import { deleteDocumentsTool } from './builtin/collections/deleteTool.js';
4
+ import { findDocumentsTool } from './builtin/collections/findTool.js';
5
+ import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js';
6
+ import { updateDocumentTool } from './builtin/collections/updateTool.js';
7
+ import { getConfigInfoTool } from './builtin/getConfigInfoTool.js';
6
8
  import { findGlobalTool } from './builtin/globals/findTool.js';
9
+ import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js';
7
10
  import { updateGlobalTool } from './builtin/globals/updateTool.js';
11
+ export const TOOL_BUILTINS = {
12
+ getConfigInfo: {
13
+ label: 'Config Info',
14
+ mcpName: 'getConfigInfo',
15
+ tool: getConfigInfoTool
16
+ }
17
+ };
8
18
  /**
9
19
  * The static built-in collection CRUD tools. Keys here are the source of truth
10
20
  * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
11
21
  * automatically.
12
22
  */ export const COLLECTION_BUILTINS = {
13
- create: createCollectionTool,
14
- delete: deleteCollectionTool,
15
- find: findCollectionTool,
16
- update: updateCollectionTool
23
+ create: {
24
+ mcpName: 'createDocument',
25
+ tool: createDocumentTool
26
+ },
27
+ delete: {
28
+ mcpName: 'deleteDocuments',
29
+ tool: deleteDocumentsTool
30
+ },
31
+ find: {
32
+ mcpName: 'findDocuments',
33
+ tool: findDocumentsTool
34
+ },
35
+ getCollectionSchema: {
36
+ mcpName: 'getCollectionSchema',
37
+ tool: getCollectionSchemaTool
38
+ },
39
+ update: {
40
+ mcpName: 'updateDocument',
41
+ tool: updateDocumentTool
42
+ }
17
43
  };
18
44
  /**
19
45
  * The static auth tools surfaced under auth-enabled collections. Each entry
@@ -22,26 +48,32 @@ import { updateGlobalTool } from './builtin/globals/updateTool.js';
22
48
  */ export const COLLECTION_AUTH_BUILTINS = {
23
49
  auth: {
24
50
  label: 'Check Auth Status',
51
+ mcpName: 'auth',
25
52
  tool: authCollectionTool
26
53
  },
27
54
  forgotPassword: {
28
55
  label: 'Forgot Password',
56
+ mcpName: 'forgotPassword',
29
57
  tool: forgotPasswordCollectionTool
30
58
  },
31
59
  login: {
32
60
  label: 'User Login',
61
+ mcpName: 'login',
33
62
  tool: loginCollectionTool
34
63
  },
35
64
  resetPassword: {
36
65
  label: 'Reset Password',
66
+ mcpName: 'resetPassword',
37
67
  tool: resetPasswordCollectionTool
38
68
  },
39
69
  unlock: {
40
70
  label: 'Unlock Account',
71
+ mcpName: 'unlock',
41
72
  tool: unlockCollectionTool
42
73
  },
43
74
  verify: {
44
75
  label: 'Email Verification',
76
+ mcpName: 'verify',
45
77
  tool: verifyCollectionTool
46
78
  }
47
79
  };
@@ -49,15 +81,26 @@ import { updateGlobalTool } from './builtin/globals/updateTool.js';
49
81
  * The static built-in global tools. Keys are the source of truth for
50
82
  * `MCPGlobalBuiltinName`.
51
83
  */ export const GLOBAL_BUILTINS = {
52
- find: findGlobalTool,
53
- update: updateGlobalTool
84
+ find: {
85
+ mcpName: 'findGlobal',
86
+ tool: findGlobalTool
87
+ },
88
+ getGlobalSchema: {
89
+ mcpName: 'getGlobalSchema',
90
+ tool: getGlobalSchemaTool
91
+ },
92
+ update: {
93
+ mcpName: 'updateGlobal',
94
+ tool: updateGlobalTool
95
+ }
54
96
  };
55
97
  /**
56
98
  * Pre-typed `Object.entries` for each registry. The cast from `string` to the
57
99
  * literal key union lives here once so consumers can iterate without their own
58
100
  * cast — TypeScript's `Object.entries` always widens keys to `string`, which
59
101
  * defeats the narrow type lookups on `MCPCollectionToolsMap`.
60
- */ export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS);
102
+ */ export const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS);
103
+ export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS);
61
104
  export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS);
62
105
  export const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS);
63
106
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/builtinTools.ts"],"sourcesContent":["import type { CollectionTool, GlobalTool } from '../types.js'\n\nimport {\n authCollectionTool,\n forgotPasswordCollectionTool,\n loginCollectionTool,\n resetPasswordCollectionTool,\n unlockCollectionTool,\n verifyCollectionTool,\n} from './builtin/collections/authTools.js'\nimport { createCollectionTool } from './builtin/collections/createTool.js'\nimport { deleteCollectionTool } from './builtin/collections/deleteTool.js'\nimport { findCollectionTool } from './builtin/collections/findTool.js'\nimport { updateCollectionTool } from './builtin/collections/updateTool.js'\nimport { findGlobalTool } from './builtin/globals/findTool.js'\nimport { updateGlobalTool } from './builtin/globals/updateTool.js'\n\n/**\n * The static built-in collection CRUD tools. Keys here are the source of truth\n * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type\n * automatically.\n */\nexport const COLLECTION_BUILTINS: Record<MCPCollectionBuiltinName, CollectionTool> = {\n create: createCollectionTool,\n delete: deleteCollectionTool,\n find: findCollectionTool,\n update: updateCollectionTool,\n}\n\n/**\n * The static auth tools surfaced under auth-enabled collections. Each entry\n * carries the admin-UI label alongside the tool. Keys are the source of truth\n * for `MCPCollectionAuthToolName`.\n */\nexport const COLLECTION_AUTH_BUILTINS: Record<\n MCPCollectionAuthToolName,\n { label: string; tool: CollectionTool }\n> = {\n auth: { label: 'Check Auth Status', tool: authCollectionTool },\n forgotPassword: { label: 'Forgot Password', tool: forgotPasswordCollectionTool },\n login: { label: 'User Login', tool: loginCollectionTool },\n resetPassword: { label: 'Reset Password', tool: resetPasswordCollectionTool },\n unlock: { label: 'Unlock Account', tool: unlockCollectionTool },\n verify: { label: 'Email Verification', tool: verifyCollectionTool },\n}\n\n/**\n * The static built-in global tools. Keys are the source of truth for\n * `MCPGlobalBuiltinName`.\n */\nexport const GLOBAL_BUILTINS: Record<MCPGlobalBuiltinName, GlobalTool> = {\n find: findGlobalTool,\n update: updateGlobalTool,\n}\n\nexport type MCPCollectionBuiltinName = 'create' | 'delete' | 'find' | 'update'\n\nexport type MCPCollectionAuthToolName =\n | 'auth'\n | 'forgotPassword'\n | 'login'\n | 'resetPassword'\n | 'unlock'\n | 'verify'\n\nexport type MCPGlobalBuiltinName = 'find' | 'update'\n\n/**\n * Pre-typed `Object.entries` for each registry. The cast from `string` to the\n * literal key union lives here once so consumers can iterate without their own\n * cast — TypeScript's `Object.entries` always widens keys to `string`, which\n * defeats the narrow type lookups on `MCPCollectionToolsMap`.\n */\nexport const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<\n [MCPCollectionBuiltinName, CollectionTool]\n>\n\nexport const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<\n [MCPCollectionAuthToolName, { label: string; tool: CollectionTool }]\n>\n\nexport const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<\n [MCPGlobalBuiltinName, GlobalTool]\n>\n"],"names":["authCollectionTool","forgotPasswordCollectionTool","loginCollectionTool","resetPasswordCollectionTool","unlockCollectionTool","verifyCollectionTool","createCollectionTool","deleteCollectionTool","findCollectionTool","updateCollectionTool","findGlobalTool","updateGlobalTool","COLLECTION_BUILTINS","create","delete","find","update","COLLECTION_AUTH_BUILTINS","auth","label","tool","forgotPassword","login","resetPassword","unlock","verify","GLOBAL_BUILTINS","COLLECTION_BUILTIN_ENTRIES","Object","entries","COLLECTION_AUTH_BUILTIN_ENTRIES","GLOBAL_BUILTIN_ENTRIES"],"mappings":"AAEA,SACEA,kBAAkB,EAClBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,2BAA2B,EAC3BC,oBAAoB,EACpBC,oBAAoB,QACf,qCAAoC;AAC3C,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,gBAAgB,QAAQ,kCAAiC;AAElE;;;;CAIC,GACD,OAAO,MAAMC,sBAAwE;IACnFC,QAAQP;IACRQ,QAAQP;IACRQ,MAAMP;IACNQ,QAAQP;AACV,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAMQ,2BAGT;IACFC,MAAM;QAAEC,OAAO;QAAqBC,MAAMpB;IAAmB;IAC7DqB,gBAAgB;QAAEF,OAAO;QAAmBC,MAAMnB;IAA6B;IAC/EqB,OAAO;QAAEH,OAAO;QAAcC,MAAMlB;IAAoB;IACxDqB,eAAe;QAAEJ,OAAO;QAAkBC,MAAMjB;IAA4B;IAC5EqB,QAAQ;QAAEL,OAAO;QAAkBC,MAAMhB;IAAqB;IAC9DqB,QAAQ;QAAEN,OAAO;QAAsBC,MAAMf;IAAqB;AACpE,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMqB,kBAA4D;IACvEX,MAAML;IACNM,QAAQL;AACV,EAAC;AAcD;;;;;CAKC,GACD,OAAO,MAAMgB,6BAA6BC,OAAOC,OAAO,CAACjB,qBAExD;AAED,OAAO,MAAMkB,kCAAkCF,OAAOC,OAAO,CAACZ,0BAE7D;AAED,OAAO,MAAMc,yBAAyBH,OAAOC,OAAO,CAACH,iBAEpD"}
1
+ {"version":3,"sources":["../../src/mcp/builtinTools.ts"],"sourcesContent":["import type { CollectionTool, GlobalTool, Tool } from '../types.js'\n\nimport {\n authCollectionTool,\n forgotPasswordCollectionTool,\n loginCollectionTool,\n resetPasswordCollectionTool,\n unlockCollectionTool,\n verifyCollectionTool,\n} from './builtin/collections/authTools.js'\nimport { createDocumentTool } from './builtin/collections/createTool.js'\nimport { deleteDocumentsTool } from './builtin/collections/deleteTool.js'\nimport { findDocumentsTool } from './builtin/collections/findTool.js'\nimport { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'\nimport { updateDocumentTool } from './builtin/collections/updateTool.js'\nimport { getConfigInfoTool } from './builtin/getConfigInfoTool.js'\nimport { findGlobalTool } from './builtin/globals/findTool.js'\nimport { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'\nimport { updateGlobalTool } from './builtin/globals/updateTool.js'\n\nexport const TOOL_BUILTINS = {\n getConfigInfo: { label: 'Config Info', mcpName: 'getConfigInfo', tool: getConfigInfoTool },\n} satisfies Record<string, { label: string; mcpName: string; tool: Tool }>\n\n/**\n * The static built-in collection CRUD tools. Keys here are the source of truth\n * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type\n * automatically.\n */\nexport const COLLECTION_BUILTINS = {\n create: { mcpName: 'createDocument', tool: createDocumentTool },\n delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },\n find: { mcpName: 'findDocuments', tool: findDocumentsTool },\n getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },\n update: { mcpName: 'updateDocument', tool: updateDocumentTool },\n} satisfies Record<string, { mcpName: string; tool: CollectionTool }>\n\n/**\n * The static auth tools surfaced under auth-enabled collections. Each entry\n * carries the admin-UI label alongside the tool. Keys are the source of truth\n * for `MCPCollectionAuthToolName`.\n */\nexport const COLLECTION_AUTH_BUILTINS = {\n auth: { label: 'Check Auth Status', mcpName: 'auth', tool: authCollectionTool },\n forgotPassword: {\n label: 'Forgot Password',\n mcpName: 'forgotPassword',\n tool: forgotPasswordCollectionTool,\n },\n login: { label: 'User Login', mcpName: 'login', tool: loginCollectionTool },\n resetPassword: {\n label: 'Reset Password',\n mcpName: 'resetPassword',\n tool: resetPasswordCollectionTool,\n },\n unlock: { label: 'Unlock Account', mcpName: 'unlock', tool: unlockCollectionTool },\n verify: { label: 'Email Verification', mcpName: 'verify', tool: verifyCollectionTool },\n} satisfies Record<string, { label: string; mcpName: string; tool: CollectionTool }>\n\n/**\n * The static built-in global tools. Keys are the source of truth for\n * `MCPGlobalBuiltinName`.\n */\nexport const GLOBAL_BUILTINS = {\n find: { mcpName: 'findGlobal', tool: findGlobalTool },\n getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },\n update: { mcpName: 'updateGlobal', tool: updateGlobalTool },\n} satisfies Record<string, { mcpName: string; tool: GlobalTool }>\n\nexport type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS\n\nexport type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS\n\nexport type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS\n\nexport type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS\n\n/**\n * Pre-typed `Object.entries` for each registry. The cast from `string` to the\n * literal key union lives here once so consumers can iterate without their own\n * cast — TypeScript's `Object.entries` always widens keys to `string`, which\n * defeats the narrow type lookups on `MCPCollectionToolsMap`.\n */\nexport const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS) as Array<\n [MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]\n>\n\nexport const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<\n [MCPCollectionBuiltinName, (typeof COLLECTION_BUILTINS)[MCPCollectionBuiltinName]]\n>\n\nexport const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<\n [MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]\n>\n\nexport const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<\n [MCPGlobalBuiltinName, (typeof GLOBAL_BUILTINS)[MCPGlobalBuiltinName]]\n>\n"],"names":["authCollectionTool","forgotPasswordCollectionTool","loginCollectionTool","resetPasswordCollectionTool","unlockCollectionTool","verifyCollectionTool","createDocumentTool","deleteDocumentsTool","findDocumentsTool","getCollectionSchemaTool","updateDocumentTool","getConfigInfoTool","findGlobalTool","getGlobalSchemaTool","updateGlobalTool","TOOL_BUILTINS","getConfigInfo","label","mcpName","tool","COLLECTION_BUILTINS","create","delete","find","getCollectionSchema","update","COLLECTION_AUTH_BUILTINS","auth","forgotPassword","login","resetPassword","unlock","verify","GLOBAL_BUILTINS","getGlobalSchema","TOOL_BUILTIN_ENTRIES","Object","entries","COLLECTION_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTIN_ENTRIES","GLOBAL_BUILTIN_ENTRIES"],"mappings":"AAEA,SACEA,kBAAkB,EAClBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,2BAA2B,EAC3BC,oBAAoB,EACpBC,oBAAoB,QACf,qCAAoC;AAC3C,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,mB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C,OAAO,CAACjB,qBAExD;AAED,OAAO,MAAMmB,kCAAkCH,OAAOC,OAAO,CAACX,0BAE7D;AAED,OAAO,MAAMc,yBAAyBJ,OAAOC,OAAO,CAACJ,iBAEpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EAEf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAWpB;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBAkDH,CAAA"}
1
+ {"version":3,"file":"sanitizeMCPConfig.d.ts","sourceRoot":"","sources":["../../src/mcp/sanitizeMCPConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,MAAM,EAGN,eAAe,EAEhB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAMV,eAAe,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAapB;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBAkEH,CAAA"}
@@ -1,4 +1,4 @@
1
- import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_BUILTIN_ENTRIES, COLLECTION_BUILTINS, GLOBAL_BUILTIN_ENTRIES, GLOBAL_BUILTINS } from './builtinTools.js';
1
+ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_BUILTIN_ENTRIES, COLLECTION_BUILTINS, GLOBAL_BUILTIN_ENTRIES, GLOBAL_BUILTINS, TOOL_BUILTIN_ENTRIES, TOOL_BUILTINS } from './builtinTools.js';
2
2
  /**
3
3
  * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:
4
4
  * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
@@ -22,27 +22,42 @@ import { COLLECTION_AUTH_BUILTIN_ENTRIES, COLLECTION_AUTH_BUILTINS, COLLECTION_B
22
22
  pluginConfig
23
23
  }));
24
24
  }
25
- for (const [key, tool] of Object.entries(pluginConfig.tools ?? {})){
25
+ for (const [configKey, { label, mcpName, tool }] of TOOL_BUILTIN_ENTRIES){
26
26
  items.push({
27
27
  type: 'tool',
28
- key,
29
- label: key,
28
+ configKey,
29
+ label,
30
+ mcpName,
30
31
  tool
31
32
  });
32
33
  }
33
- for (const [key, prompt] of Object.entries(pluginConfig.prompts ?? {})){
34
+ for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})){
35
+ if (configKey in TOOL_BUILTINS) {
36
+ continue;
37
+ }
38
+ items.push({
39
+ type: 'tool',
40
+ configKey,
41
+ label: configKey,
42
+ mcpName: configKey,
43
+ tool
44
+ });
45
+ }
46
+ for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})){
34
47
  items.push({
35
48
  type: 'prompt',
36
- key,
37
- label: prompt.title ?? key,
49
+ configKey,
50
+ label: prompt.title ?? configKey,
51
+ mcpName: configKey,
38
52
  prompt
39
53
  });
40
54
  }
41
- for (const [key, resource] of Object.entries(pluginConfig.resources ?? {})){
55
+ for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})){
42
56
  items.push({
43
57
  type: 'resource',
44
- key,
45
- label: resource.title ?? key,
58
+ configKey,
59
+ label: resource.title ?? configKey,
60
+ mcpName: configKey,
46
61
  resource
47
62
  });
48
63
  }
@@ -64,21 +79,27 @@ const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
64
79
  const slug = collection.slug;
65
80
  const collectionPluginConfig = pluginConfig.collections?.[slug];
66
81
  const items = [];
67
- for (const [toolKey, tool] of COLLECTION_BUILTIN_ENTRIES){
82
+ for (const [toolKey, { mcpName, tool }] of COLLECTION_BUILTIN_ENTRIES){
68
83
  const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey];
69
84
  if (matchedConfigEntry === false) {
70
85
  continue;
71
86
  }
87
+ const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
72
88
  items.push({
73
89
  type: 'collectionTool',
74
90
  collectionSlug: slug,
75
- key: toolKey,
91
+ configKey: toolKey,
76
92
  label: capitalize(toolKey),
77
- tool: overrideBuiltinTool(tool, matchedConfigEntry, collectionPluginConfig)
93
+ mcpName,
94
+ tool: {
95
+ ...tool,
96
+ description: override?.description ?? tool.description,
97
+ overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
98
+ }
78
99
  });
79
100
  }
80
101
  if (collection.auth) {
81
- for (const [authToolKey, { label, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES){
102
+ for (const [authToolKey, { label, mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES){
82
103
  const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey];
83
104
  if (!matchedConfigEntry) {
84
105
  continue;
@@ -88,17 +109,22 @@ const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
88
109
  items.push({
89
110
  type: 'collectionTool',
90
111
  collectionSlug: slug,
91
- key: authToolKey,
112
+ configKey: authToolKey,
92
113
  label,
93
- tool: overrideBuiltinTool(tool, override, collectionPluginConfig)
114
+ mcpName,
115
+ tool: {
116
+ ...tool,
117
+ description: override?.description ?? tool.description,
118
+ overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
119
+ }
94
120
  });
95
121
  }
96
122
  }
97
123
  // Cast: builtin keys are filtered out below, so the remaining values are
98
124
  // always custom tools (`CollectionTool`) or undefined
99
125
  const customEntries = Object.entries(collectionPluginConfig?.tools ?? {});
100
- for (const [key, customTool] of customEntries){
101
- if (key in COLLECTION_BUILTINS || key in COLLECTION_AUTH_BUILTINS) {
126
+ for (const [configKey, customTool] of customEntries){
127
+ if (configKey in COLLECTION_BUILTINS || configKey in COLLECTION_AUTH_BUILTINS) {
102
128
  continue;
103
129
  }
104
130
  if (!customTool) {
@@ -107,8 +133,9 @@ const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
107
133
  items.push({
108
134
  type: 'collectionTool',
109
135
  collectionSlug: slug,
110
- key,
111
- label: key,
136
+ configKey,
137
+ label: configKey,
138
+ mcpName: configKey,
112
139
  tool: customTool
113
140
  });
114
141
  }
@@ -118,22 +145,28 @@ const sanitizeGlobalConfig = ({ global, pluginConfig })=>{
118
145
  const slug = global.slug;
119
146
  const globalPluginConfig = pluginConfig.globals?.[slug];
120
147
  const items = [];
121
- for (const [toolKey, baseTool] of GLOBAL_BUILTIN_ENTRIES){
148
+ for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES){
122
149
  const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey];
123
150
  if (matchedConfigEntry === false) {
124
151
  continue;
125
152
  }
153
+ const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
126
154
  items.push({
127
155
  type: 'globalTool',
156
+ configKey: toolKey,
128
157
  globalSlug: slug,
129
- key: toolKey,
130
158
  label: capitalize(toolKey),
131
- tool: overrideBuiltinTool(baseTool, matchedConfigEntry, globalPluginConfig)
159
+ mcpName,
160
+ tool: {
161
+ ...tool,
162
+ description: override?.description ?? tool.description,
163
+ overrideResponse: override?.overrideResponse ?? globalPluginConfig?.overrideResponse ?? tool.overrideResponse
164
+ }
132
165
  });
133
166
  }
134
167
  const customEntries = Object.entries(globalPluginConfig?.tools ?? {});
135
- for (const [key, customTool] of customEntries){
136
- if (key in GLOBAL_BUILTINS) {
168
+ for (const [configKey, customTool] of customEntries){
169
+ if (configKey in GLOBAL_BUILTINS) {
137
170
  continue;
138
171
  }
139
172
  if (!customTool) {
@@ -141,27 +174,15 @@ const sanitizeGlobalConfig = ({ global, pluginConfig })=>{
141
174
  }
142
175
  items.push({
143
176
  type: 'globalTool',
177
+ configKey,
144
178
  globalSlug: slug,
145
- key,
146
- label: key,
179
+ label: configKey,
180
+ mcpName: configKey,
147
181
  tool: customTool
148
182
  });
149
183
  }
150
184
  return items;
151
185
  };
152
186
  const capitalize = (s)=>s.charAt(0).toUpperCase() + s.slice(1);
153
- /**
154
- * Spread the static built-in tool and apply consumer-side overrides.
155
- * Precedence: per-tool override > scope-level (collection/global) override >
156
- * the static tool's defaults. `toolEntry` is whatever the user put under
157
- * `tools: { find: ... }` — could be `true`, `false`, or an override object —
158
- * so it's narrowed internally.
159
- */ const overrideBuiltinTool = (tool, toolOverride, entityPluginConfig)=>{
160
- return {
161
- ...tool,
162
- description: toolOverride?.description ?? entityPluginConfig?.description ?? tool.description,
163
- overrideResponse: toolOverride?.overrideResponse ?? entityPluginConfig?.overrideResponse ?? tool.overrideResponse
164
- };
165
- };
166
187
 
167
188
  //# sourceMappingURL=sanitizeMCPConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/sanitizeMCPConfig.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Config,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport type {\n CollectionTool,\n GlobalTool,\n MCPBuiltInToolOverride,\n MCPItem,\n MCPPluginCollectionConfig,\n MCPPluginConfig,\n MCPPluginGlobalConfig,\n SanitizedMCPPluginConfig,\n} from '../types.js'\n\nimport {\n COLLECTION_AUTH_BUILTIN_ENTRIES,\n COLLECTION_AUTH_BUILTINS,\n COLLECTION_BUILTIN_ENTRIES,\n COLLECTION_BUILTINS,\n GLOBAL_BUILTIN_ENTRIES,\n GLOBAL_BUILTINS,\n} from './builtinTools.js'\n\n/**\n * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:\n * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global\n * tool maps into a single `items` array.\n * - Applies built-in tools for collections and globals, respecting opt-out user overrides.\n * - Applies the `userCollection` default\n *\n * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']\n * ?.options` holds the sanitized result\n */\nexport const sanitizeMCPConfig = ({\n config,\n pluginConfig,\n}: {\n config: Config | SanitizedConfig\n pluginConfig: MCPPluginConfig\n}): SanitizedMCPPluginConfig => {\n const items: MCPItem[] = []\n\n for (const collection of config.collections ?? []) {\n items.push(...sanitizeCollectionConfig({ collection, pluginConfig }))\n }\n\n for (const global of config.globals ?? []) {\n items.push(...sanitizeGlobalConfig({ global, pluginConfig }))\n }\n\n for (const [key, tool] of Object.entries(pluginConfig.tools ?? {})) {\n items.push({\n type: 'tool',\n key,\n label: key,\n tool,\n })\n }\n\n for (const [key, prompt] of Object.entries(pluginConfig.prompts ?? {})) {\n items.push({\n type: 'prompt',\n key,\n label: prompt.title ?? key,\n prompt,\n })\n }\n\n for (const [key, resource] of Object.entries(pluginConfig.resources ?? {})) {\n items.push({\n type: 'resource',\n key,\n label: resource.title ?? key,\n resource,\n })\n }\n\n // Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.\n const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))\n\n return {\n disabled: pluginConfig.disabled,\n items,\n mcp: pluginConfig.mcp,\n overrideApiKeyCollection: pluginConfig.overrideApiKeyCollection,\n overrideAuth: pluginConfig.overrideAuth,\n userCollection:\n pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',\n }\n}\n\nconst sanitizeCollectionConfig = ({\n collection,\n pluginConfig,\n}: {\n collection: CollectionConfig | SanitizedCollectionConfig\n pluginConfig: MCPPluginConfig\n}): MCPItem[] => {\n if (collection.slug === 'payload-mcp-api-keys') {\n return []\n }\n const slug = collection.slug\n const collectionPluginConfig = pluginConfig.collections?.[slug]\n const items: MCPItem[] = []\n\n for (const [toolKey, tool] of COLLECTION_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n key: toolKey,\n label: capitalize(toolKey),\n tool: overrideBuiltinTool(tool, matchedConfigEntry, collectionPluginConfig),\n })\n }\n\n if (collection.auth) {\n for (const [authToolKey, { label, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]\n if (!matchedConfigEntry) {\n continue\n }\n // `true` means \"enable, no override\"; only the object form carries fields.\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n key: authToolKey,\n label,\n tool: overrideBuiltinTool(tool, override, collectionPluginConfig),\n })\n }\n }\n\n // Cast: builtin keys are filtered out below, so the remaining values are\n // always custom tools (`CollectionTool`) or undefined\n const customEntries = Object.entries(collectionPluginConfig?.tools ?? {}) as Array<\n [string, CollectionTool | undefined]\n >\n for (const [key, customTool] of customEntries) {\n if (key in COLLECTION_BUILTINS || key in COLLECTION_AUTH_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n key,\n label: key,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst sanitizeGlobalConfig = ({\n global,\n pluginConfig,\n}: {\n global: GlobalConfig | SanitizedGlobalConfig\n pluginConfig: MCPPluginConfig\n}): MCPItem[] => {\n const slug = global.slug\n const globalPluginConfig = pluginConfig.globals?.[slug]\n const items: MCPItem[] = []\n\n for (const [toolKey, baseTool] of GLOBAL_BUILTIN_ENTRIES) {\n const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n items.push({\n type: 'globalTool',\n globalSlug: slug,\n key: toolKey,\n label: capitalize(toolKey),\n tool: overrideBuiltinTool(baseTool, matchedConfigEntry, globalPluginConfig),\n })\n }\n\n const customEntries = Object.entries(globalPluginConfig?.tools ?? {}) as Array<\n [string, GlobalTool | undefined]\n >\n for (const [key, customTool] of customEntries) {\n if (key in GLOBAL_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'globalTool',\n globalSlug: slug,\n key,\n label: key,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1)\n\n/**\n * Spread the static built-in tool and apply consumer-side overrides.\n * Precedence: per-tool override > scope-level (collection/global) override >\n * the static tool's defaults. `toolEntry` is whatever the user put under\n * `tools: { find: ... }` — could be `true`, `false`, or an override object —\n * so it's narrowed internally.\n */\nconst overrideBuiltinTool = <TTool extends CollectionTool | GlobalTool>(\n tool: TTool,\n toolOverride?: MCPBuiltInToolOverride,\n entityPluginConfig?: TTool extends CollectionTool\n ? MCPPluginCollectionConfig<any>\n : MCPPluginGlobalConfig,\n): TTool => {\n return {\n ...tool,\n description: toolOverride?.description ?? entityPluginConfig?.description ?? tool.description,\n overrideResponse:\n toolOverride?.overrideResponse ??\n entityPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n }\n}\n"],"names":["COLLECTION_AUTH_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTINS","COLLECTION_BUILTIN_ENTRIES","COLLECTION_BUILTINS","GLOBAL_BUILTIN_ENTRIES","GLOBAL_BUILTINS","sanitizeMCPConfig","config","pluginConfig","items","collection","collections","push","sanitizeCollectionConfig","global","globals","sanitizeGlobalConfig","key","tool","Object","entries","tools","type","label","prompt","prompts","title","resource","resources","firstCollectionWithAuth","find","auth","Boolean","disabled","mcp","overrideApiKeyCollection","overrideAuth","userCollection","admin","user","slug","collectionPluginConfig","toolKey","matchedConfigEntry","collectionSlug","capitalize","overrideBuiltinTool","authToolKey","override","undefined","customEntries","customTool","globalPluginConfig","baseTool","globalSlug","s","charAt","toUpperCase","slice","toolOverride","entityPluginConfig","description","overrideRes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,OAAO;QACL,GAAG1C,IAAI;QACP2C,aAAaF,cAAcE,eAAeD,oBAAoBC,eAAe3C,KAAK2C,WAAW;QAC7FC,kBACEH,cAAcG,oBACdF,oBAAoBE,oBACpB5C,KAAK4C,gBAAgB;IACzB;AACF"}
1
+ {"version":3,"sources":["../../src/mcp/sanitizeMCPConfig.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Config,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport type {\n CollectionMCPItem,\n CollectionTool,\n GlobalMCPItem,\n GlobalTool,\n MCPItem,\n MCPPluginConfig,\n SanitizedMCPPluginConfig,\n} from '../types.js'\n\nimport {\n COLLECTION_AUTH_BUILTIN_ENTRIES,\n COLLECTION_AUTH_BUILTINS,\n COLLECTION_BUILTIN_ENTRIES,\n COLLECTION_BUILTINS,\n GLOBAL_BUILTIN_ENTRIES,\n GLOBAL_BUILTINS,\n TOOL_BUILTIN_ENTRIES,\n TOOL_BUILTINS,\n} from './builtinTools.js'\n\n/**\n * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:\n * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global\n * tool maps into a single `items` array.\n * - Applies built-in tools for collections and globals, respecting opt-out user overrides.\n * - Applies the `userCollection` default\n *\n * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']\n * ?.options` holds the sanitized result\n */\nexport const sanitizeMCPConfig = ({\n config,\n pluginConfig,\n}: {\n config: Config | SanitizedConfig\n pluginConfig: MCPPluginConfig\n}): SanitizedMCPPluginConfig => {\n const items: MCPItem[] = []\n\n for (const collection of config.collections ?? []) {\n items.push(...sanitizeCollectionConfig({ collection, pluginConfig }))\n }\n\n for (const global of config.globals ?? []) {\n items.push(...sanitizeGlobalConfig({ global, pluginConfig }))\n }\n\n for (const [configKey, { label, mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {\n items.push({\n type: 'tool',\n configKey,\n label,\n mcpName,\n tool,\n })\n }\n\n for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})) {\n if (configKey in TOOL_BUILTINS) {\n continue\n }\n items.push({\n type: 'tool',\n configKey,\n label: configKey,\n mcpName: configKey,\n tool,\n })\n }\n\n for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})) {\n items.push({\n type: 'prompt',\n configKey,\n label: prompt.title ?? configKey,\n mcpName: configKey,\n prompt,\n })\n }\n\n for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})) {\n items.push({\n type: 'resource',\n configKey,\n label: resource.title ?? configKey,\n mcpName: configKey,\n resource,\n })\n }\n\n // Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.\n const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))\n\n return {\n disabled: pluginConfig.disabled,\n items,\n mcp: pluginConfig.mcp,\n overrideApiKeyCollection: pluginConfig.overrideApiKeyCollection,\n overrideAuth: pluginConfig.overrideAuth,\n userCollection:\n pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',\n }\n}\n\nconst sanitizeCollectionConfig = ({\n collection,\n pluginConfig,\n}: {\n collection: CollectionConfig | SanitizedCollectionConfig\n pluginConfig: MCPPluginConfig\n}): CollectionMCPItem[] => {\n if (collection.slug === 'payload-mcp-api-keys') {\n return []\n }\n const slug = collection.slug\n const collectionPluginConfig = pluginConfig.collections?.[slug]\n const items: CollectionMCPItem[] = []\n\n for (const [toolKey, { mcpName, tool }] of COLLECTION_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: toolKey,\n label: capitalize(toolKey),\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n collectionPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n\n if (collection.auth) {\n for (const [authToolKey, { label, mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]\n if (!matchedConfigEntry) {\n continue\n }\n // `true` means \"enable, no override\"; only the object form carries fields.\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: authToolKey,\n label,\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n collectionPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n }\n\n // Cast: builtin keys are filtered out below, so the remaining values are\n // always custom tools (`CollectionTool`) or undefined\n const customEntries = Object.entries(collectionPluginConfig?.tools ?? {}) as Array<\n [string, CollectionTool | undefined]\n >\n for (const [configKey, customTool] of customEntries) {\n if (configKey in COLLECTION_BUILTINS || configKey in COLLECTION_AUTH_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey,\n label: configKey,\n mcpName: configKey,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst sanitizeGlobalConfig = ({\n global,\n pluginConfig,\n}: {\n global: GlobalConfig | SanitizedGlobalConfig\n pluginConfig: MCPPluginConfig\n}): GlobalMCPItem[] => {\n const slug = global.slug\n const globalPluginConfig = pluginConfig.globals?.[slug]\n const items: GlobalMCPItem[] = []\n\n for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES) {\n const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'globalTool',\n configKey: toolKey,\n globalSlug: slug,\n label: capitalize(toolKey),\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n globalPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n\n const customEntries = Object.entries(globalPluginConfig?.tools ?? {}) as Array<\n [string, GlobalTool | undefined]\n >\n for (const [configKey, customTool] of customEntries) {\n if (configKey in GLOBAL_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'globalTool',\n configKey,\n globalSlug: slug,\n label: configKey,\n mcpName: configKey,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1)\n"],"names":["COLLECTION_AUTH_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTINS","COLLECTION_BUILTIN_ENTRIES","COLLECTION_BUILTINS","GLOBAL_BUILTIN_ENTRIES","GLOBAL_BUILTINS","TOOL_BUILTIN_ENTRIES","TOOL_BUILTINS","sanitizeMCPConfig","config","pluginConfig","items","collection","collections","push","sanitizeCollectionConfig","global","globals","sanitizeGlobalConfig","configKey","label","mcpName","tool","type","Object","entries","tools","prompt","prompts","title","resource","resources","firstCollectionWithAuth","find","auth","Boolean","disabled","mcp","overrideApiKeyCollection","overrideAuth","userCollection","admin","user","slug","collectionPluginConfig","toolKey","matchedConfigEntry","override","undefined","collectionSlug","capitalize","description","overrideResponse","authToolKey","customEntries","customTool","globalPluginConfig","globalSlug","s","charAt","toUpperCase","slice"],"mappings":"AAmBA,SACEA,+BAA+B,EAC/BC,wBAAwB,EACxBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,sBAAsB,EACtBC,eAAe,EACfC,oBAAoB,EACpBC,aAAa,QACR,oBAAmB;AAE1B;;;;;;;;;CASC,GACD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,MAAM,EACNC,YAAY,EAIb;IACC,MAAMC,QAAmB,EAAE;IAE3B,KAAK,MAAMC,cAAcH,OAAOI,WAAW,IAAI,EAAE,CAAE;QACjDF,MAAMG,IAAI,IAAIC,yBAAyB;YAAEH;YAAY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