@payloadcms/plugin-mcp 4.0.0-internal.d28e9fb → 4.0.0-internal.d927017

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 (432) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +48 -0
  3. package/dist/bin/index.d.ts +2 -0
  4. package/dist/bin/index.d.ts.map +1 -0
  5. package/dist/bin/index.js +12 -0
  6. package/dist/bin/index.js.map +1 -0
  7. package/dist/bin/initializeViteHMR.d.ts +8 -0
  8. package/dist/bin/initializeViteHMR.d.ts.map +1 -0
  9. package/dist/bin/initializeViteHMR.js +63 -0
  10. package/dist/bin/initializeViteHMR.js.map +1 -0
  11. package/dist/bin/viteConfigBoundary.d.ts +6 -0
  12. package/dist/bin/viteConfigBoundary.d.ts.map +1 -0
  13. package/dist/bin/viteConfigBoundary.js +25 -0
  14. package/dist/bin/viteConfigBoundary.js.map +1 -0
  15. package/dist/defaultAccess.d.ts +3 -0
  16. package/dist/defaultAccess.d.ts.map +1 -0
  17. package/dist/defaultAccess.js +3 -0
  18. package/dist/defaultAccess.js.map +1 -0
  19. package/dist/defineTool.d.ts +26 -0
  20. package/dist/defineTool.d.ts.map +1 -0
  21. package/dist/defineTool.js +37 -0
  22. package/dist/defineTool.js.map +1 -0
  23. package/dist/endpoint/access.d.ts +17 -0
  24. package/dist/endpoint/access.d.ts.map +1 -0
  25. package/dist/endpoint/access.js +93 -0
  26. package/dist/endpoint/access.js.map +1 -0
  27. package/dist/endpoint/index.d.ts +3 -0
  28. package/dist/endpoint/index.d.ts.map +1 -0
  29. package/dist/endpoint/index.js +87 -0
  30. package/dist/endpoint/index.js.map +1 -0
  31. package/dist/exports/client.d.ts +2 -0
  32. package/dist/exports/client.d.ts.map +1 -0
  33. package/dist/exports/client.js +4 -0
  34. package/dist/exports/client.js.map +1 -0
  35. package/dist/exports/internal.d.ts +2 -0
  36. package/dist/exports/internal.d.ts.map +1 -0
  37. package/dist/exports/internal.js +3 -0
  38. package/dist/exports/internal.js.map +1 -0
  39. package/dist/index.d.ts +6 -9
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +39 -67
  42. package/dist/index.js.map +1 -1
  43. package/dist/mcp/buildMcpServer.d.ts +19 -0
  44. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  45. package/dist/mcp/buildMcpServer.js +223 -0
  46. package/dist/mcp/buildMcpServer.js.map +1 -0
  47. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  48. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  49. package/dist/mcp/builtin/collections/authTools.js +288 -0
  50. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  51. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  52. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  53. package/dist/mcp/builtin/collections/countTool.js +68 -0
  54. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  55. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  56. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  57. package/dist/mcp/builtin/collections/countVersionsTool.js +64 -0
  58. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  59. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  60. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  61. package/dist/mcp/builtin/collections/createTool.js +86 -0
  62. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  63. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  64. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  65. package/dist/mcp/builtin/collections/deleteTool.js +110 -0
  66. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  67. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  68. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  69. package/dist/mcp/builtin/collections/duplicateTool.js +96 -0
  70. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  71. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  72. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  73. package/dist/mcp/builtin/collections/findDistinctTool.js +92 -0
  74. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  75. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  76. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  77. package/dist/mcp/builtin/collections/findTool.js +164 -0
  78. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  79. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  80. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  81. package/dist/mcp/builtin/collections/findVersionByIDTool.js +83 -0
  82. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  83. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  84. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  85. package/dist/mcp/builtin/collections/findVersionsTool.js +98 -0
  86. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  87. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  88. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  89. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  90. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  91. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  92. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  93. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +65 -0
  94. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  95. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  96. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  97. package/dist/mcp/builtin/collections/restoreVersionTool.js +81 -0
  98. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  99. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  100. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  101. package/dist/mcp/builtin/collections/updateTool.js +198 -0
  102. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  103. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  104. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  105. package/dist/mcp/builtin/getConfigInfoTool.js +68 -0
  106. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  107. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  108. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  109. package/dist/mcp/builtin/globals/countVersionsTool.js +64 -0
  110. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  111. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  112. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  113. package/dist/mcp/builtin/globals/findTool.js +73 -0
  114. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  115. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  116. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  117. package/dist/mcp/builtin/globals/findVersionByIDTool.js +79 -0
  118. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  119. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  120. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  121. package/dist/mcp/builtin/globals/findVersionsTool.js +94 -0
  122. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  123. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  124. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  125. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +65 -0
  126. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  127. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  128. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  129. package/dist/mcp/builtin/globals/restoreVersionTool.js +77 -0
  130. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  131. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  132. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  133. package/dist/mcp/builtin/globals/updateTool.js +87 -0
  134. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  135. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  136. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  137. package/dist/mcp/builtin/validateEntityData.js +82 -0
  138. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  139. package/dist/mcp/builtinTools.d.ts +162 -0
  140. package/dist/mcp/builtinTools.d.ts.map +1 -0
  141. package/dist/mcp/builtinTools.js +163 -0
  142. package/dist/mcp/builtinTools.js.map +1 -0
  143. package/dist/mcp/sanitizeMCPConfig.d.ts +16 -0
  144. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  145. package/dist/mcp/sanitizeMCPConfig.js +230 -0
  146. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  147. package/dist/stdio.d.ts +9 -0
  148. package/dist/stdio.d.ts.map +1 -0
  149. package/dist/stdio.js +127 -0
  150. package/dist/stdio.js.map +1 -0
  151. package/dist/types.d.ts +256 -447
  152. package/dist/types.d.ts.map +1 -1
  153. package/dist/types.js +4 -1
  154. package/dist/types.js.map +1 -1
  155. package/dist/utils/camelCase.d.ts.map +1 -1
  156. package/dist/utils/getLogger.d.ts +10 -0
  157. package/dist/utils/getLogger.d.ts.map +1 -0
  158. package/dist/utils/getLogger.js +22 -0
  159. package/dist/utils/getLogger.js.map +1 -0
  160. package/dist/utils/getPluginConfig.d.ts +12 -0
  161. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  162. package/dist/utils/getPluginConfig.js +15 -0
  163. package/dist/utils/getPluginConfig.js.map +1 -0
  164. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  165. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  166. package/dist/utils/resolveProjectRoot.js +15 -0
  167. package/dist/utils/resolveProjectRoot.js.map +1 -0
  168. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
  169. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
  170. package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
  171. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
  172. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +13 -0
  173. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  174. package/dist/utils/schemaConversion/getEntityInputSchema.js +66 -0
  175. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  176. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +10 -0
  177. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  178. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +384 -0
  179. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  180. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +133 -0
  181. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  182. package/dist/utils/toStandardSchema.d.ts +5 -0
  183. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  184. package/dist/utils/toStandardSchema.js +4 -0
  185. package/dist/utils/toStandardSchema.js.map +1 -0
  186. package/dist/utils/whereSchema.d.ts +9 -0
  187. package/dist/utils/whereSchema.d.ts.map +1 -0
  188. package/dist/utils/whereSchema.js +13 -0
  189. package/dist/utils/whereSchema.js.map +1 -0
  190. package/package.json +43 -10
  191. package/src/bin/index.ts +16 -0
  192. package/src/bin/initializeViteHMR.ts +60 -0
  193. package/src/bin/viteConfigBoundary.ts +39 -0
  194. package/src/defaultAccess.ts +3 -0
  195. package/src/defineTool.ts +44 -0
  196. package/src/endpoint/access.ts +112 -0
  197. package/src/endpoint/index.ts +77 -0
  198. package/src/exports/client.ts +3 -0
  199. package/src/exports/internal.ts +1 -0
  200. package/src/index.ts +31 -89
  201. package/src/mcp/buildMcpServer.ts +284 -0
  202. package/src/mcp/builtin/collections/authTools.ts +269 -0
  203. package/src/mcp/builtin/collections/countTool.ts +73 -0
  204. package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
  205. package/src/mcp/builtin/collections/createTool.ts +117 -0
  206. package/src/mcp/builtin/collections/deleteTool.ts +125 -0
  207. package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
  208. package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
  209. package/src/mcp/builtin/collections/findTool.ts +216 -0
  210. package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
  211. package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
  212. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  213. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +63 -0
  214. package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
  215. package/src/mcp/builtin/collections/updateTool.ts +225 -0
  216. package/src/mcp/builtin/getConfigInfoTool.ts +67 -0
  217. package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
  218. package/src/mcp/builtin/globals/findTool.ts +105 -0
  219. package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
  220. package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
  221. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +63 -0
  222. package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
  223. package/src/mcp/builtin/globals/updateTool.ts +115 -0
  224. package/src/mcp/builtin/validateEntityData.ts +132 -0
  225. package/src/mcp/builtinTools.ts +154 -0
  226. package/src/mcp/sanitizeMCPConfig.ts +278 -0
  227. package/src/stdio.ts +131 -0
  228. package/src/types.ts +304 -486
  229. package/src/utils/getLogger.ts +22 -0
  230. package/src/utils/getPluginConfig.ts +24 -0
  231. package/src/utils/resolveProjectRoot.ts +17 -0
  232. package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
  233. package/src/utils/schemaConversion/getEntityInputSchema.ts +96 -0
  234. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +96 -0
  235. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +432 -0
  236. package/src/utils/toStandardSchema.ts +9 -0
  237. package/src/utils/whereSchema.ts +24 -0
  238. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  239. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  240. package/dist/collections/createApiKeysCollection.js +0 -317
  241. package/dist/collections/createApiKeysCollection.js.map +0 -1
  242. package/dist/defaults.d.ts +0 -4
  243. package/dist/defaults.d.ts.map +0 -1
  244. package/dist/defaults.js +0 -5
  245. package/dist/defaults.js.map +0 -1
  246. package/dist/endpoints/mcp.d.ts +0 -4
  247. package/dist/endpoints/mcp.d.ts.map +0 -1
  248. package/dist/endpoints/mcp.js +0 -71
  249. package/dist/endpoints/mcp.js.map +0 -1
  250. package/dist/mcp/createRequest.d.ts +0 -3
  251. package/dist/mcp/createRequest.d.ts.map +0 -1
  252. package/dist/mcp/createRequest.js +0 -14
  253. package/dist/mcp/createRequest.js.map +0 -1
  254. package/dist/mcp/getMcpHandler.d.ts +0 -4
  255. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  256. package/dist/mcp/getMcpHandler.js +0 -231
  257. package/dist/mcp/getMcpHandler.js.map +0 -1
  258. package/dist/mcp/helpers/config.d.ts +0 -22
  259. package/dist/mcp/helpers/config.d.ts.map +0 -1
  260. package/dist/mcp/helpers/config.js +0 -153
  261. package/dist/mcp/helpers/config.js.map +0 -1
  262. package/dist/mcp/helpers/fields.d.ts +0 -19
  263. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  264. package/dist/mcp/helpers/fields.js +0 -102
  265. package/dist/mcp/helpers/fields.js.map +0 -1
  266. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  267. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  268. package/dist/mcp/helpers/fileValidation.js +0 -267
  269. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  270. package/dist/mcp/registerTool.d.ts +0 -6
  271. package/dist/mcp/registerTool.d.ts.map +0 -1
  272. package/dist/mcp/registerTool.js +0 -18
  273. package/dist/mcp/registerTool.js.map +0 -1
  274. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  275. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  276. package/dist/mcp/tools/auth/auth.js +0 -57
  277. package/dist/mcp/tools/auth/auth.js.map +0 -1
  278. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  279. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  280. package/dist/mcp/tools/auth/forgotPassword.js +0 -48
  281. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  282. package/dist/mcp/tools/auth/login.d.ts +0 -4
  283. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  284. package/dist/mcp/tools/auth/login.js +0 -51
  285. package/dist/mcp/tools/auth/login.js.map +0 -1
  286. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  287. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  288. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  289. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  290. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  291. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  292. package/dist/mcp/tools/auth/unlock.js +0 -48
  293. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  294. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  295. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  296. package/dist/mcp/tools/auth/verify.js +0 -45
  297. package/dist/mcp/tools/auth/verify.js.map +0 -1
  298. package/dist/mcp/tools/collection/create.d.ts +0 -10
  299. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  300. package/dist/mcp/tools/collection/create.js +0 -139
  301. package/dist/mcp/tools/collection/create.js.map +0 -1
  302. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  303. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  304. package/dist/mcp/tools/collection/delete.js +0 -154
  305. package/dist/mcp/tools/collection/delete.js.map +0 -1
  306. package/dist/mcp/tools/collection/find.d.ts +0 -10
  307. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  308. package/dist/mcp/tools/collection/find.js +0 -165
  309. package/dist/mcp/tools/collection/find.js.map +0 -1
  310. package/dist/mcp/tools/collection/update.d.ts +0 -10
  311. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  312. package/dist/mcp/tools/collection/update.js +0 -209
  313. package/dist/mcp/tools/collection/update.js.map +0 -1
  314. package/dist/mcp/tools/config/find.d.ts +0 -10
  315. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  316. package/dist/mcp/tools/config/find.js +0 -97
  317. package/dist/mcp/tools/config/find.js.map +0 -1
  318. package/dist/mcp/tools/config/update.d.ts +0 -10
  319. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  320. package/dist/mcp/tools/config/update.js +0 -215
  321. package/dist/mcp/tools/config/update.js.map +0 -1
  322. package/dist/mcp/tools/global/find.d.ts +0 -5
  323. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  324. package/dist/mcp/tools/global/find.js +0 -82
  325. package/dist/mcp/tools/global/find.js.map +0 -1
  326. package/dist/mcp/tools/global/update.d.ts +0 -6
  327. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  328. package/dist/mcp/tools/global/update.js +0 -124
  329. package/dist/mcp/tools/global/update.js.map +0 -1
  330. package/dist/mcp/tools/job/create.d.ts +0 -10
  331. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  332. package/dist/mcp/tools/job/create.js +0 -293
  333. package/dist/mcp/tools/job/create.js.map +0 -1
  334. package/dist/mcp/tools/job/run.d.ts +0 -10
  335. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  336. package/dist/mcp/tools/job/run.js +0 -129
  337. package/dist/mcp/tools/job/run.js.map +0 -1
  338. package/dist/mcp/tools/job/update.d.ts +0 -11
  339. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  340. package/dist/mcp/tools/job/update.js +0 -186
  341. package/dist/mcp/tools/job/update.js.map +0 -1
  342. package/dist/mcp/tools/resource/create.d.ts +0 -6
  343. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  344. package/dist/mcp/tools/resource/create.js +0 -124
  345. package/dist/mcp/tools/resource/create.js.map +0 -1
  346. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  347. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  348. package/dist/mcp/tools/resource/delete.js +0 -151
  349. package/dist/mcp/tools/resource/delete.js.map +0 -1
  350. package/dist/mcp/tools/resource/find.d.ts +0 -5
  351. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  352. package/dist/mcp/tools/resource/find.js +0 -170
  353. package/dist/mcp/tools/resource/find.js.map +0 -1
  354. package/dist/mcp/tools/resource/update.d.ts +0 -6
  355. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  356. package/dist/mcp/tools/resource/update.js +0 -256
  357. package/dist/mcp/tools/resource/update.js.map +0 -1
  358. package/dist/mcp/tools/schemas.d.ts +0 -457
  359. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  360. package/dist/mcp/tools/schemas.js +0 -243
  361. package/dist/mcp/tools/schemas.js.map +0 -1
  362. package/dist/utils/adminEntitySettings.d.ts +0 -17
  363. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  364. package/dist/utils/adminEntitySettings.js +0 -41
  365. package/dist/utils/adminEntitySettings.js.map +0 -1
  366. package/dist/utils/createApiKeyFields.d.ts +0 -15
  367. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  368. package/dist/utils/createApiKeyFields.js +0 -57
  369. package/dist/utils/createApiKeyFields.js.map +0 -1
  370. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  371. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  372. package/dist/utils/getEnabledSlugs.js +0 -32
  373. package/dist/utils/getEnabledSlugs.js.map +0 -1
  374. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
  375. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  376. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
  377. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  378. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  379. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  380. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  381. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  382. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  383. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  384. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  385. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  386. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  387. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  388. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  389. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  390. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  391. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  392. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  393. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  394. package/src/collections/createApiKeysCollection.ts +0 -373
  395. package/src/defaults.ts +0 -3
  396. package/src/endpoints/mcp.ts +0 -91
  397. package/src/mcp/createRequest.ts +0 -13
  398. package/src/mcp/getMcpHandler.ts +0 -545
  399. package/src/mcp/helpers/config.ts +0 -213
  400. package/src/mcp/helpers/fields.ts +0 -154
  401. package/src/mcp/helpers/fileValidation.ts +0 -362
  402. package/src/mcp/registerTool.ts +0 -22
  403. package/src/mcp/tools/auth/auth.ts +0 -71
  404. package/src/mcp/tools/auth/forgotPassword.ts +0 -70
  405. package/src/mcp/tools/auth/login.ts +0 -72
  406. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  407. package/src/mcp/tools/auth/unlock.ts +0 -64
  408. package/src/mcp/tools/auth/verify.ts +0 -57
  409. package/src/mcp/tools/collection/create.ts +0 -210
  410. package/src/mcp/tools/collection/delete.ts +0 -211
  411. package/src/mcp/tools/collection/find.ts +0 -224
  412. package/src/mcp/tools/collection/update.ts +0 -290
  413. package/src/mcp/tools/config/find.ts +0 -128
  414. package/src/mcp/tools/config/update.ts +0 -280
  415. package/src/mcp/tools/global/find.ts +0 -128
  416. package/src/mcp/tools/global/update.ts +0 -207
  417. package/src/mcp/tools/job/create.ts +0 -416
  418. package/src/mcp/tools/job/run.ts +0 -167
  419. package/src/mcp/tools/job/update.ts +0 -274
  420. package/src/mcp/tools/resource/create.ts +0 -211
  421. package/src/mcp/tools/resource/delete.ts +0 -218
  422. package/src/mcp/tools/resource/find.ts +0 -246
  423. package/src/mcp/tools/resource/update.ts +0 -383
  424. package/src/mcp/tools/schemas.ts +0 -520
  425. package/src/utils/adminEntitySettings.ts +0 -40
  426. package/src/utils/createApiKeyFields.ts +0 -72
  427. package/src/utils/getEnabledSlugs.ts +0 -42
  428. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
  429. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
  430. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  431. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  432. package/src/utils/schemaConversion/transformPointFields.ts +0 -55
@@ -0,0 +1,162 @@
1
+ import type { CollectionTool, GlobalTool, Tool } from '../types.js';
2
+ type CollectionBuiltin = {
3
+ mcpName: string;
4
+ requiresDuplicateEnabled?: boolean;
5
+ requiresVersions?: boolean;
6
+ tool: CollectionTool;
7
+ };
8
+ type GlobalBuiltin = {
9
+ mcpName: string;
10
+ requiresVersions?: boolean;
11
+ tool: GlobalTool;
12
+ };
13
+ export declare const TOOL_BUILTINS: {
14
+ getConfigInfo: {
15
+ mcpName: string;
16
+ tool: Tool;
17
+ };
18
+ };
19
+ /**
20
+ * The static built-in collection CRUD tools. Keys here are the source of truth
21
+ * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
22
+ * automatically.
23
+ */
24
+ export declare const COLLECTION_BUILTINS: {
25
+ count: {
26
+ mcpName: string;
27
+ tool: CollectionTool;
28
+ };
29
+ countVersions: {
30
+ mcpName: string;
31
+ requiresVersions: true;
32
+ tool: CollectionTool;
33
+ };
34
+ create: {
35
+ mcpName: string;
36
+ tool: CollectionTool;
37
+ };
38
+ delete: {
39
+ mcpName: string;
40
+ tool: CollectionTool;
41
+ };
42
+ duplicate: {
43
+ mcpName: string;
44
+ requiresDuplicateEnabled: true;
45
+ tool: CollectionTool;
46
+ };
47
+ find: {
48
+ mcpName: string;
49
+ tool: CollectionTool;
50
+ };
51
+ findDistinct: {
52
+ mcpName: string;
53
+ tool: CollectionTool;
54
+ };
55
+ findVersionByID: {
56
+ mcpName: string;
57
+ requiresVersions: true;
58
+ tool: CollectionTool;
59
+ };
60
+ findVersions: {
61
+ mcpName: string;
62
+ requiresVersions: true;
63
+ tool: CollectionTool;
64
+ };
65
+ getCollectionSchema: {
66
+ mcpName: string;
67
+ tool: CollectionTool;
68
+ };
69
+ restoreVersion: {
70
+ mcpName: string;
71
+ requiresVersions: true;
72
+ tool: CollectionTool;
73
+ };
74
+ update: {
75
+ mcpName: string;
76
+ tool: CollectionTool;
77
+ };
78
+ };
79
+ /**
80
+ * The static auth tools surfaced under auth-enabled collections. Keys are the
81
+ * source of truth for `MCPCollectionAuthToolName`.
82
+ */
83
+ export declare const COLLECTION_AUTH_BUILTINS: {
84
+ auth: {
85
+ mcpName: string;
86
+ tool: CollectionTool;
87
+ };
88
+ forgotPassword: {
89
+ mcpName: string;
90
+ tool: CollectionTool;
91
+ };
92
+ login: {
93
+ mcpName: string;
94
+ tool: CollectionTool;
95
+ };
96
+ resetPassword: {
97
+ mcpName: string;
98
+ tool: CollectionTool;
99
+ };
100
+ unlock: {
101
+ mcpName: string;
102
+ tool: CollectionTool;
103
+ };
104
+ verify: {
105
+ mcpName: string;
106
+ tool: CollectionTool;
107
+ };
108
+ };
109
+ /**
110
+ * The static built-in global tools. Keys are the source of truth for
111
+ * `MCPGlobalBuiltinName`.
112
+ */
113
+ export declare const GLOBAL_BUILTINS: {
114
+ countGlobalVersions: {
115
+ mcpName: string;
116
+ requiresVersions: true;
117
+ tool: GlobalTool;
118
+ };
119
+ find: {
120
+ mcpName: string;
121
+ tool: GlobalTool;
122
+ };
123
+ findGlobalVersionByID: {
124
+ mcpName: string;
125
+ requiresVersions: true;
126
+ tool: GlobalTool;
127
+ };
128
+ findGlobalVersions: {
129
+ mcpName: string;
130
+ requiresVersions: true;
131
+ tool: GlobalTool;
132
+ };
133
+ getGlobalSchema: {
134
+ mcpName: string;
135
+ tool: GlobalTool;
136
+ };
137
+ restoreGlobalVersion: {
138
+ mcpName: string;
139
+ requiresVersions: true;
140
+ tool: GlobalTool;
141
+ };
142
+ update: {
143
+ mcpName: string;
144
+ tool: GlobalTool;
145
+ };
146
+ };
147
+ export type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS;
148
+ export type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS;
149
+ export type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS;
150
+ export type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS;
151
+ /**
152
+ * Pre-typed `Object.entries` for each registry. The cast from `string` to the
153
+ * literal key union lives here once so consumers can iterate without their own
154
+ * cast — TypeScript's `Object.entries` always widens keys to `string`, which
155
+ * defeats the narrow type lookups on `MCPCollectionToolsMap`.
156
+ */
157
+ export declare const TOOL_BUILTIN_ENTRIES: Array<[MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]>;
158
+ export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, CollectionBuiltin]>;
159
+ export declare const COLLECTION_AUTH_BUILTIN_ENTRIES: Array<[MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]>;
160
+ export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, GlobalBuiltin]>;
161
+ export {};
162
+ //# sourceMappingURL=builtinTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BnE,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;CAEiC,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBa,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;CAagC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBa,CAAA;AAEzC,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AAEvE,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,eAAe,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,aAAa,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAoC,KAAK,CACxE,CAAC,sBAAsB,EAAE,CAAC,OAAO,aAAa,EAAE,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAC9C,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,aAAa,CAAC,CACtC,CAAA"}
@@ -0,0 +1,163 @@
1
+ import { authCollectionTool, forgotPasswordCollectionTool, loginCollectionTool, resetPasswordCollectionTool, unlockCollectionTool, verifyCollectionTool } from './builtin/collections/authTools.js';
2
+ import { countDocumentsTool } from './builtin/collections/countTool.js';
3
+ import { countVersionsTool } from './builtin/collections/countVersionsTool.js';
4
+ import { createDocumentTool } from './builtin/collections/createTool.js';
5
+ import { deleteDocumentsTool } from './builtin/collections/deleteTool.js';
6
+ import { duplicateDocumentTool } from './builtin/collections/duplicateTool.js';
7
+ import { findDistinctTool } from './builtin/collections/findDistinctTool.js';
8
+ import { findDocumentsTool } from './builtin/collections/findTool.js';
9
+ import { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js';
10
+ import { findVersionsTool } from './builtin/collections/findVersionsTool.js';
11
+ import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js';
12
+ import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js';
13
+ import { updateDocumentTool } from './builtin/collections/updateTool.js';
14
+ import { getConfigInfoTool } from './builtin/getConfigInfoTool.js';
15
+ import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js';
16
+ import { findGlobalTool } from './builtin/globals/findTool.js';
17
+ import { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js';
18
+ import { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js';
19
+ import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js';
20
+ import { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js';
21
+ import { updateGlobalTool } from './builtin/globals/updateTool.js';
22
+ export const TOOL_BUILTINS = {
23
+ getConfigInfo: {
24
+ mcpName: 'getConfigInfo',
25
+ tool: getConfigInfoTool
26
+ }
27
+ };
28
+ /**
29
+ * The static built-in collection CRUD tools. Keys here are the source of truth
30
+ * for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
31
+ * automatically.
32
+ */ export const COLLECTION_BUILTINS = {
33
+ count: {
34
+ mcpName: 'countDocuments',
35
+ tool: countDocumentsTool
36
+ },
37
+ countVersions: {
38
+ mcpName: 'countVersions',
39
+ requiresVersions: true,
40
+ tool: countVersionsTool
41
+ },
42
+ create: {
43
+ mcpName: 'createDocument',
44
+ tool: createDocumentTool
45
+ },
46
+ delete: {
47
+ mcpName: 'deleteDocuments',
48
+ tool: deleteDocumentsTool
49
+ },
50
+ duplicate: {
51
+ mcpName: 'duplicateDocument',
52
+ requiresDuplicateEnabled: true,
53
+ tool: duplicateDocumentTool
54
+ },
55
+ find: {
56
+ mcpName: 'findDocuments',
57
+ tool: findDocumentsTool
58
+ },
59
+ findDistinct: {
60
+ mcpName: 'findDistinct',
61
+ tool: findDistinctTool
62
+ },
63
+ findVersionByID: {
64
+ mcpName: 'findVersionByID',
65
+ requiresVersions: true,
66
+ tool: findVersionByIDTool
67
+ },
68
+ findVersions: {
69
+ mcpName: 'findVersions',
70
+ requiresVersions: true,
71
+ tool: findVersionsTool
72
+ },
73
+ getCollectionSchema: {
74
+ mcpName: 'getCollectionSchema',
75
+ tool: getCollectionSchemaTool
76
+ },
77
+ restoreVersion: {
78
+ mcpName: 'restoreVersion',
79
+ requiresVersions: true,
80
+ tool: restoreVersionTool
81
+ },
82
+ update: {
83
+ mcpName: 'updateDocument',
84
+ tool: updateDocumentTool
85
+ }
86
+ };
87
+ /**
88
+ * The static auth tools surfaced under auth-enabled collections. Keys are the
89
+ * source of truth for `MCPCollectionAuthToolName`.
90
+ */ export const COLLECTION_AUTH_BUILTINS = {
91
+ auth: {
92
+ mcpName: 'auth',
93
+ tool: authCollectionTool
94
+ },
95
+ forgotPassword: {
96
+ mcpName: 'forgotPassword',
97
+ tool: forgotPasswordCollectionTool
98
+ },
99
+ login: {
100
+ mcpName: 'login',
101
+ tool: loginCollectionTool
102
+ },
103
+ resetPassword: {
104
+ mcpName: 'resetPassword',
105
+ tool: resetPasswordCollectionTool
106
+ },
107
+ unlock: {
108
+ mcpName: 'unlock',
109
+ tool: unlockCollectionTool
110
+ },
111
+ verify: {
112
+ mcpName: 'verify',
113
+ tool: verifyCollectionTool
114
+ }
115
+ };
116
+ /**
117
+ * The static built-in global tools. Keys are the source of truth for
118
+ * `MCPGlobalBuiltinName`.
119
+ */ export const GLOBAL_BUILTINS = {
120
+ countGlobalVersions: {
121
+ mcpName: 'countGlobalVersions',
122
+ requiresVersions: true,
123
+ tool: countGlobalVersionsTool
124
+ },
125
+ find: {
126
+ mcpName: 'findGlobal',
127
+ tool: findGlobalTool
128
+ },
129
+ findGlobalVersionByID: {
130
+ mcpName: 'findGlobalVersionByID',
131
+ requiresVersions: true,
132
+ tool: findGlobalVersionByIDTool
133
+ },
134
+ findGlobalVersions: {
135
+ mcpName: 'findGlobalVersions',
136
+ requiresVersions: true,
137
+ tool: findGlobalVersionsTool
138
+ },
139
+ getGlobalSchema: {
140
+ mcpName: 'getGlobalSchema',
141
+ tool: getGlobalSchemaTool
142
+ },
143
+ restoreGlobalVersion: {
144
+ mcpName: 'restoreGlobalVersion',
145
+ requiresVersions: true,
146
+ tool: restoreGlobalVersionTool
147
+ },
148
+ update: {
149
+ mcpName: 'updateGlobal',
150
+ tool: updateGlobalTool
151
+ }
152
+ };
153
+ /**
154
+ * Pre-typed `Object.entries` for each registry. The cast from `string` to the
155
+ * literal key union lives here once so consumers can iterate without their own
156
+ * cast — TypeScript's `Object.entries` always widens keys to `string`, which
157
+ * defeats the narrow type lookups on `MCPCollectionToolsMap`.
158
+ */ export const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS);
159
+ export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS);
160
+ export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS);
161
+ export const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS);
162
+
163
+ //# sourceMappingURL=builtinTools.js.map
@@ -0,0 +1 @@
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 { countDocumentsTool } from './builtin/collections/countTool.js'\nimport { countVersionsTool } from './builtin/collections/countVersionsTool.js'\nimport { createDocumentTool } from './builtin/collections/createTool.js'\nimport { deleteDocumentsTool } from './builtin/collections/deleteTool.js'\nimport { duplicateDocumentTool } from './builtin/collections/duplicateTool.js'\nimport { findDistinctTool } from './builtin/collections/findDistinctTool.js'\nimport { findDocumentsTool } from './builtin/collections/findTool.js'\nimport { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js'\nimport { findVersionsTool } from './builtin/collections/findVersionsTool.js'\nimport { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'\nimport { restoreVersionTool } from './builtin/collections/restoreVersionTool.js'\nimport { updateDocumentTool } from './builtin/collections/updateTool.js'\nimport { getConfigInfoTool } from './builtin/getConfigInfoTool.js'\nimport { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js'\nimport { findGlobalTool } from './builtin/globals/findTool.js'\nimport { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js'\nimport { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js'\nimport { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'\nimport { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js'\nimport { updateGlobalTool } from './builtin/globals/updateTool.js'\n\ntype CollectionBuiltin = {\n mcpName: string\n requiresDuplicateEnabled?: boolean\n requiresVersions?: boolean\n tool: CollectionTool\n}\n\ntype GlobalBuiltin = {\n mcpName: string\n requiresVersions?: boolean\n tool: GlobalTool\n}\n\nexport const TOOL_BUILTINS = {\n getConfigInfo: { mcpName: 'getConfigInfo', tool: getConfigInfoTool },\n} satisfies Record<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 count: { mcpName: 'countDocuments', tool: countDocumentsTool },\n countVersions: { mcpName: 'countVersions', requiresVersions: true, tool: countVersionsTool },\n create: { mcpName: 'createDocument', tool: createDocumentTool },\n delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },\n duplicate: {\n mcpName: 'duplicateDocument',\n requiresDuplicateEnabled: true,\n tool: duplicateDocumentTool,\n },\n find: { mcpName: 'findDocuments', tool: findDocumentsTool },\n findDistinct: { mcpName: 'findDistinct', tool: findDistinctTool },\n findVersionByID: {\n mcpName: 'findVersionByID',\n requiresVersions: true,\n tool: findVersionByIDTool,\n },\n findVersions: { mcpName: 'findVersions', requiresVersions: true, tool: findVersionsTool },\n getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },\n restoreVersion: { mcpName: 'restoreVersion', requiresVersions: true, tool: restoreVersionTool },\n update: { mcpName: 'updateDocument', tool: updateDocumentTool },\n} satisfies Record<string, CollectionBuiltin>\n\n/**\n * The static auth tools surfaced under auth-enabled collections. Keys are the\n * source of truth for `MCPCollectionAuthToolName`.\n */\nexport const COLLECTION_AUTH_BUILTINS = {\n auth: { mcpName: 'auth', tool: authCollectionTool },\n forgotPassword: {\n mcpName: 'forgotPassword',\n tool: forgotPasswordCollectionTool,\n },\n login: { mcpName: 'login', tool: loginCollectionTool },\n resetPassword: {\n mcpName: 'resetPassword',\n tool: resetPasswordCollectionTool,\n },\n unlock: { mcpName: 'unlock', tool: unlockCollectionTool },\n verify: { mcpName: 'verify', tool: verifyCollectionTool },\n} satisfies Record<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 countGlobalVersions: {\n mcpName: 'countGlobalVersions',\n requiresVersions: true,\n tool: countGlobalVersionsTool,\n },\n find: { mcpName: 'findGlobal', tool: findGlobalTool },\n findGlobalVersionByID: {\n mcpName: 'findGlobalVersionByID',\n requiresVersions: true,\n tool: findGlobalVersionByIDTool,\n },\n findGlobalVersions: {\n mcpName: 'findGlobalVersions',\n requiresVersions: true,\n tool: findGlobalVersionsTool,\n },\n getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },\n restoreGlobalVersion: {\n mcpName: 'restoreGlobalVersion',\n requiresVersions: true,\n tool: restoreGlobalVersionTool,\n },\n update: { mcpName: 'updateGlobal', tool: updateGlobalTool },\n} satisfies Record<string, GlobalBuiltin>\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, CollectionBuiltin]\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, GlobalBuiltin]\n>\n"],"names":["authCollectionTool","forgotPasswordCollectionTool","loginCollectionTool","resetPasswordCollectionTool","unlockCollectionTool","verifyCollectionTool","countDocumentsTool","countVersionsTool","createDocumentTool","deleteDocumentsTool","duplicateDocumentTool","findDistinctTool","findDocumentsTool","findVersionByIDTool","findVersionsTool","getCollectionSchemaTool","restoreVersionTool","updateDocumentTool","getConfigInfoTool","countGlobalVersionsTool","findGlobalTool","findGlobalVersionByIDTool","findGlobalVersionsTool","getGlobalSchemaTool","restoreGlobalVersionTool","updateGlobalTool","TOOL_BUILTINS","getConfigInfo","mcpName","tool","COLLECTION_BUILTINS","count","countVersions","requiresVersions","create","delete","duplicate","requiresDuplicateEnabled","find","findDistinct","findVersionByID","findVersions","getCollectionSchema","restoreVersion","update","COLLECTION_AUTH_BUILTINS","auth","forgotPassword","login","resetPassword","unlock","verify","GLOBAL_BUILTINS","countGlobalVersions","findGlobalVersionByID","findGlobalVersions","getGlobalSchema","restoreGlobalVersion","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,qCAAoC;AACvE,SAASC,iBAAiB,QAAQ,6CAA4C;AAC9E,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,gBAAgB,QAAQ,4CAA2C;AAC5E,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,SAASC,gBAAgB,QAAQ,4CAA2C;AAC5E,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,kBAAkB,QAAQ,8CAA6C;AAChF,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,mBAAmB,QAAQ,2CAA0C;AAC9E,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,gBAAgB,QAAQ,kCAAiC;AAelE,OAAO,MAAMC,gBAAgB;IAC3BC,eAAe;QAAEC,SAAS;QAAiBC,MAAMX;IAAkB;AACrE,EAA2D;AAE3D;;;;CAIC,GACD,OAAO,MAAMY,sBAAsB;IACjCC,OAAO;QAAE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ACrB1B,SAAS;QACTK,kBAAkB;QAClBJ,MAAMR;IACR;IACAkC,oBAAoB;QAClB3B,SAAS;QACTK,kBAAkB;QAClBJ,MAAMP;IACR;IACAkC,iBAAiB;QAAE5B,SAAS;QAAmBC,MAAMN;IAAoB;IACzEkC,sBAAsB;QACpB7B,SAAS;QACTK,kBAAkB;QAClBJ,MAAML;IACR;IACAoB,QAAQ;QAAEhB,SAAS;QAAgBC,MAAMJ;IAAiB;AAC5D,EAAyC;AAUzC;;;;;CAKC,GACD,OAAO,MAAMiC,uBAAuBC,OAAOC,OAAO,CAAClC,eAElD;AAED,OAAO,MAAMmC,6BAA6BF,OAAOC,OAAO,CAAC9B,qBAExD;AAED,OAAO,MAAMgC,kCAAkCH,OAAOC,OAAO,CAACf,0BAE7D;AAED,OAAO,MAAMkB,yBAAyBJ,OAAOC,OAAO,CAACR,iBAEpD"}
@@ -0,0 +1,16 @@
1
+ import type { Config, SanitizedConfig } from 'payload';
2
+ import type { MCPPluginConfig, SanitizedMCPPluginConfig } from '../types.js';
3
+ /**
4
+ * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:
5
+ * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
6
+ * tool maps into a single `items` array.
7
+ * - Applies built-in tools for collections and globals, respecting opt-out user overrides.
8
+ *
9
+ * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
10
+ * ?.options` holds the sanitized result
11
+ */
12
+ export declare const sanitizeMCPConfig: ({ config, pluginConfig, }: {
13
+ config: Config | SanitizedConfig;
14
+ pluginConfig: MCPPluginConfig;
15
+ }) => SanitizedMCPPluginConfig;
16
+ //# sourceMappingURL=sanitizeMCPConfig.d.ts.map
@@ -0,0 +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,EACf,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAcpB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,2BAG/B;IACD,MAAM,EAAE,MAAM,GAAG,eAAe,CAAA;IAChC,YAAY,EAAE,eAAe,CAAA;CAC9B,KAAG,wBA6DH,CAAA"}
@@ -0,0 +1,230 @@
1
+ import { defaultAccess } from '../defaultAccess.js';
2
+ 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';
3
+ /**
4
+ * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:
5
+ * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
6
+ * tool maps into a single `items` array.
7
+ * - Applies built-in tools for collections and globals, respecting opt-out user overrides.
8
+ *
9
+ * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
10
+ * ?.options` holds the sanitized result
11
+ */ export const sanitizeMCPConfig = ({ config, pluginConfig })=>{
12
+ const items = [];
13
+ for (const collection of config.collections ?? []){
14
+ items.push(...sanitizeCollectionConfig({
15
+ collection,
16
+ pluginConfig
17
+ }));
18
+ }
19
+ for (const global of config.globals ?? []){
20
+ items.push(...sanitizeGlobalConfig({
21
+ global,
22
+ pluginConfig
23
+ }));
24
+ }
25
+ for (const [configKey, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES){
26
+ items.push({
27
+ type: 'tool',
28
+ configKey,
29
+ label: tool.annotations?.title ?? configKey,
30
+ mcpName,
31
+ tool: {
32
+ ...tool,
33
+ access: tool.access ?? defaultAccess
34
+ }
35
+ });
36
+ }
37
+ for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})){
38
+ if (configKey in TOOL_BUILTINS) {
39
+ continue;
40
+ }
41
+ items.push({
42
+ type: 'tool',
43
+ configKey,
44
+ label: tool.annotations?.title ?? configKey,
45
+ mcpName: configKey,
46
+ tool: {
47
+ ...tool,
48
+ access: tool.access ?? defaultAccess
49
+ }
50
+ });
51
+ }
52
+ for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})){
53
+ items.push({
54
+ type: 'prompt',
55
+ configKey,
56
+ label: prompt.title ?? configKey,
57
+ mcpName: configKey,
58
+ prompt: {
59
+ ...prompt,
60
+ access: prompt.access ?? defaultAccess
61
+ }
62
+ });
63
+ }
64
+ for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})){
65
+ items.push({
66
+ type: 'resource',
67
+ configKey,
68
+ label: resource.title ?? configKey,
69
+ mcpName: configKey,
70
+ resource: {
71
+ ...resource,
72
+ access: resource.access ?? defaultAccess
73
+ }
74
+ });
75
+ }
76
+ return {
77
+ disabled: pluginConfig.disabled,
78
+ hooks: pluginConfig.hooks,
79
+ items,
80
+ mcp: pluginConfig.mcp,
81
+ overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP
82
+ };
83
+ };
84
+ const sanitizeCollectionConfig = ({ collection, pluginConfig })=>{
85
+ const slug = collection.slug;
86
+ const collectionPluginConfig = pluginConfig.collections?.[slug];
87
+ const items = [];
88
+ /**
89
+ * Payload disables duplicate for auth collections by default unless the
90
+ * collection explicitly opts back in with `disableDuplicate: false`.
91
+ */ const isDuplicateDisabled = collection.disableDuplicate === true || Boolean(collection.auth) && collection.disableDuplicate !== false;
92
+ for (const [toolKey, { mcpName, requiresDuplicateEnabled, requiresVersions, tool }] of COLLECTION_BUILTIN_ENTRIES){
93
+ if (requiresVersions && !collection.versions) {
94
+ continue;
95
+ }
96
+ if (requiresDuplicateEnabled && isDuplicateDisabled) {
97
+ continue;
98
+ }
99
+ const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey];
100
+ if (matchedConfigEntry === false) {
101
+ continue;
102
+ }
103
+ const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
104
+ const annotations = {
105
+ ...tool.annotations,
106
+ ...override?.annotations
107
+ };
108
+ items.push({
109
+ type: 'collectionTool',
110
+ collectionSlug: slug,
111
+ configKey: toolKey,
112
+ label: annotations.title ?? toolKey,
113
+ mcpName,
114
+ tool: {
115
+ ...tool,
116
+ access: override?.access ?? tool.access ?? defaultAccess,
117
+ annotations,
118
+ description: override?.description ?? tool.description,
119
+ overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
120
+ }
121
+ });
122
+ }
123
+ if (collection.auth) {
124
+ for (const [authToolKey, { mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES){
125
+ const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey];
126
+ if (!matchedConfigEntry) {
127
+ continue;
128
+ }
129
+ // `true` means "enable, no override"; only the object form carries fields.
130
+ const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
131
+ const annotations = {
132
+ ...tool.annotations,
133
+ ...override?.annotations
134
+ };
135
+ items.push({
136
+ type: 'collectionTool',
137
+ collectionSlug: slug,
138
+ configKey: authToolKey,
139
+ label: annotations.title ?? authToolKey,
140
+ mcpName,
141
+ tool: {
142
+ ...tool,
143
+ access: override?.access ?? tool.access ?? defaultAccess,
144
+ annotations,
145
+ description: override?.description ?? tool.description,
146
+ overrideResponse: override?.overrideResponse ?? collectionPluginConfig?.overrideResponse ?? tool.overrideResponse
147
+ }
148
+ });
149
+ }
150
+ }
151
+ // Cast: builtin keys are filtered out below, so the remaining values are
152
+ // always custom tools (`CollectionTool`) or undefined
153
+ const customEntries = Object.entries(collectionPluginConfig?.tools ?? {});
154
+ for (const [configKey, customTool] of customEntries){
155
+ if (configKey in COLLECTION_BUILTINS || configKey in COLLECTION_AUTH_BUILTINS) {
156
+ continue;
157
+ }
158
+ if (!customTool) {
159
+ continue;
160
+ }
161
+ items.push({
162
+ type: 'collectionTool',
163
+ collectionSlug: slug,
164
+ configKey,
165
+ label: customTool.annotations?.title ?? configKey,
166
+ mcpName: configKey,
167
+ tool: {
168
+ ...customTool,
169
+ access: customTool.access ?? defaultAccess
170
+ }
171
+ });
172
+ }
173
+ return items;
174
+ };
175
+ const sanitizeGlobalConfig = ({ global, pluginConfig })=>{
176
+ const slug = global.slug;
177
+ const globalPluginConfig = pluginConfig.globals?.[slug];
178
+ const items = [];
179
+ for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES){
180
+ if (requiresVersions && !global.versions) {
181
+ continue;
182
+ }
183
+ const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey];
184
+ if (matchedConfigEntry === false) {
185
+ continue;
186
+ }
187
+ const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined;
188
+ const annotations = {
189
+ ...tool.annotations,
190
+ ...override?.annotations
191
+ };
192
+ items.push({
193
+ type: 'globalTool',
194
+ configKey: toolKey,
195
+ globalSlug: slug,
196
+ label: annotations.title ?? toolKey,
197
+ mcpName,
198
+ tool: {
199
+ ...tool,
200
+ access: override?.access ?? tool.access ?? defaultAccess,
201
+ annotations,
202
+ description: override?.description ?? tool.description,
203
+ overrideResponse: override?.overrideResponse ?? globalPluginConfig?.overrideResponse ?? tool.overrideResponse
204
+ }
205
+ });
206
+ }
207
+ const customEntries = Object.entries(globalPluginConfig?.tools ?? {});
208
+ for (const [configKey, customTool] of customEntries){
209
+ if (configKey in GLOBAL_BUILTINS) {
210
+ continue;
211
+ }
212
+ if (!customTool) {
213
+ continue;
214
+ }
215
+ items.push({
216
+ type: 'globalTool',
217
+ configKey,
218
+ globalSlug: slug,
219
+ label: customTool.annotations?.title ?? configKey,
220
+ mcpName: configKey,
221
+ tool: {
222
+ ...customTool,
223
+ access: customTool.access ?? defaultAccess
224
+ }
225
+ });
226
+ }
227
+ return items;
228
+ };
229
+
230
+ //# sourceMappingURL=sanitizeMCPConfig.js.map
@@ -0,0 +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 CollectionMCPItem,\n CollectionTool,\n GlobalMCPItem,\n GlobalTool,\n MCPItem,\n MCPPluginConfig,\n SanitizedMCPPluginConfig,\n} from '../types.js'\n\nimport { defaultAccess } from '../defaultAccess.js'\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 *\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, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {\n items.push({\n type: 'tool',\n configKey,\n label: tool.annotations?.title ?? configKey,\n mcpName,\n tool: { ...tool, access: tool.access ?? defaultAccess },\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: tool.annotations?.title ?? configKey,\n mcpName: configKey,\n tool: { ...tool, access: tool.access ?? defaultAccess },\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: { ...prompt, access: prompt.access ?? defaultAccess },\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: { ...resource, access: resource.access ?? defaultAccess },\n })\n }\n\n return {\n disabled: pluginConfig.disabled,\n hooks: pluginConfig.hooks,\n items,\n mcp: pluginConfig.mcp,\n overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP,\n }\n}\n\nconst sanitizeCollectionConfig = ({\n collection,\n pluginConfig,\n}: {\n collection: CollectionConfig | SanitizedCollectionConfig\n pluginConfig: MCPPluginConfig\n}): CollectionMCPItem[] => {\n const slug = collection.slug\n const collectionPluginConfig = pluginConfig.collections?.[slug]\n const items: CollectionMCPItem[] = []\n /**\n * Payload disables duplicate for auth collections by default unless the\n * collection explicitly opts back in with `disableDuplicate: false`.\n */\n const isDuplicateDisabled =\n collection.disableDuplicate === true ||\n (Boolean(collection.auth) && collection.disableDuplicate !== false)\n\n for (const [\n toolKey,\n { mcpName, requiresDuplicateEnabled, requiresVersions, tool },\n ] of COLLECTION_BUILTIN_ENTRIES) {\n if (requiresVersions && !collection.versions) {\n continue\n }\n if (requiresDuplicateEnabled && isDuplicateDisabled) {\n continue\n }\n const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n const annotations = { ...tool.annotations, ...override?.annotations }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: toolKey,\n label: annotations.title ?? toolKey,\n mcpName,\n tool: {\n ...tool,\n access: override?.access ?? tool.access ?? defaultAccess,\n annotations,\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, { 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 const annotations = { ...tool.annotations, ...override?.annotations }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: authToolKey,\n label: annotations.title ?? authToolKey,\n mcpName,\n tool: {\n ...tool,\n access: override?.access ?? tool.access ?? defaultAccess,\n annotations,\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: customTool.annotations?.title ?? configKey,\n mcpName: configKey,\n tool: { ...customTool, access: customTool.access ?? defaultAccess },\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, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES) {\n if (requiresVersions && !global.versions) {\n continue\n }\n const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n const annotations = { ...tool.annotations, ...override?.annotations }\n items.push({\n type: 'globalTool',\n configKey: toolKey,\n globalSlug: slug,\n label: annotations.title ?? toolKey,\n mcpName,\n tool: {\n ...tool,\n access: override?.access ?? tool.access ?? defaultAccess,\n annotations,\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: customTool.annotations?.title ?? configKey,\n mcpName: configKey,\n tool: { ...customTool, access: customTool.access ?? defaultAccess },\n })\n }\n\n return items\n}\n"],"names":["defaultAccess","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","mcpName","tool","type","label","annotations","title","access","Object","entries","tools","prompt","prompts","resource","resources","disabled","hooks","mcp","overrideGetAuthorizedMCP","slug","collectionPluginConfig","isDuplicateDisabled","disableDuplicate","Boolean","auth","toolKey","requiresDuplicateEnabled","requiresVersions","versions","matchedConfigEntry","override","undefined","collectionSlug","description","overrideResponse","authToolKey","customEntries","customTool","globalPluginConfig","globalSlug"],"mappings":"AAmBA,SAASA,aAAa,QAAQ,sBAAqB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kBACEJ,UAAUI,oBACVI,oBAAoBJ,oBACpBhC,KAAKgC,gBAAgB;YACzB;QACF;IACF;IAEA,MAAME,gBAAgB5B,OAAOC,OAAO,CAAC6B,oBAAoB5B,SAAS,CAAC;IAGnE,KAAK,MAAM,CAACV,WAAWqC,WAAW,IAAID,cAAe;QACnD,IAAIpC,aAAad,iBAAiB;YAChC;QACF;QACA,IAAI,CAACmD,YAAY;YACf;QACF;QACA7C,MAAMG,IAAI,CAAC;YACTQ,MAAM;YACNH;YACAuC,YAAYpB;YACZf,OAAOiC,WAAWhC,WAAW,EAAEC,SAASN;YACxCC,SAASD;YACTE,MAAM;gBAAE,GAAGmC,UAAU;gBAAE9B,QAAQ8B,WAAW9B,MAAM,IAAI3B;YAAc;QACpE;IACF;IAEA,OAAOY;AACT"}
@@ -0,0 +1,9 @@
1
+ import type { SanitizedConfig } from 'payload';
2
+ /**
3
+ * Starts Payload's MCP server over stdin and stdout.
4
+ *
5
+ * Set `PAYLOAD_MCP_AUTHORIZATION` to authenticate. In development,
6
+ * `PAYLOAD_MCP_OVERRIDE_ACCESS=true` skips access checks.
7
+ */
8
+ export declare const runMcpStdio: (configOverride?: SanitizedConfig) => Promise<void>;
9
+ //# sourceMappingURL=stdio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB9D;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAU,iBAAiB,eAAe,KAAG,OAAO,CAAC,IAAI,CA4GhF,CAAA"}