@payloadcms/plugin-mcp 3.91.0-internal.c1569dc → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -2
  3. package/bin.js +39 -0
  4. package/dist/defaultAccess.d.ts +3 -0
  5. package/dist/defaultAccess.d.ts.map +1 -0
  6. package/dist/defaultAccess.js +3 -0
  7. package/dist/defaultAccess.js.map +1 -0
  8. package/dist/defineTool.d.ts +26 -0
  9. package/dist/defineTool.d.ts.map +1 -0
  10. package/dist/defineTool.js +37 -0
  11. package/dist/defineTool.js.map +1 -0
  12. package/dist/endpoint/access.d.ts +17 -0
  13. package/dist/endpoint/access.d.ts.map +1 -0
  14. package/dist/endpoint/access.js +93 -0
  15. package/dist/endpoint/access.js.map +1 -0
  16. package/dist/endpoint/index.d.ts +3 -0
  17. package/dist/endpoint/index.d.ts.map +1 -0
  18. package/dist/endpoint/index.js +116 -0
  19. package/dist/endpoint/index.js.map +1 -0
  20. package/dist/exports/client.d.ts +2 -0
  21. package/dist/exports/client.d.ts.map +1 -0
  22. package/dist/exports/client.js +4 -0
  23. package/dist/exports/client.js.map +1 -0
  24. package/dist/exports/internal.d.ts +2 -0
  25. package/dist/exports/internal.d.ts.map +1 -0
  26. package/dist/exports/internal.js +3 -0
  27. package/dist/exports/internal.js.map +1 -0
  28. package/dist/index.d.ts +6 -9
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +39 -67
  31. package/dist/index.js.map +1 -1
  32. package/dist/mcp/buildMcpServer.d.ts +19 -0
  33. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  34. package/dist/mcp/buildMcpServer.js +235 -0
  35. package/dist/mcp/buildMcpServer.js.map +1 -0
  36. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  37. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  38. package/dist/mcp/builtin/collections/authTools.js +312 -0
  39. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  40. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  41. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  42. package/dist/mcp/builtin/collections/countTool.js +63 -0
  43. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  44. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  45. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  46. package/dist/mcp/builtin/collections/countVersionsTool.js +60 -0
  47. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  48. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  49. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  50. package/dist/mcp/builtin/collections/createTool.js +137 -0
  51. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  52. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  53. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  54. package/dist/mcp/builtin/collections/deleteTool.js +111 -0
  55. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  56. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  57. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  58. package/dist/mcp/builtin/collections/duplicateTool.js +90 -0
  59. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  60. package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
  61. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  62. package/dist/mcp/builtin/collections/fileInput.js +88 -0
  63. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  64. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  65. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  66. package/dist/mcp/builtin/collections/findDistinctTool.js +77 -0
  67. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  68. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  69. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  70. package/dist/mcp/builtin/collections/findTool.js +146 -0
  71. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  72. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  73. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  74. package/dist/mcp/builtin/collections/findVersionByIDTool.js +74 -0
  75. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  76. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  77. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  78. package/dist/mcp/builtin/collections/findVersionsTool.js +84 -0
  79. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  80. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  81. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  82. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +103 -0
  83. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  84. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  85. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  86. package/dist/mcp/builtin/collections/restoreVersionTool.js +69 -0
  87. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  88. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  89. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  90. package/dist/mcp/builtin/collections/updateTool.js +172 -0
  91. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  92. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
  93. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
  94. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
  95. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
  96. package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
  97. package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
  98. package/dist/mcp/builtin/formatEntityError.js +55 -0
  99. package/dist/mcp/builtin/formatEntityError.js.map +1 -0
  100. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  101. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  102. package/dist/mcp/builtin/getConfigInfoTool.js +69 -0
  103. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  104. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  105. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  106. package/dist/mcp/builtin/globals/countVersionsTool.js +60 -0
  107. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  108. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  109. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  110. package/dist/mcp/builtin/globals/findTool.js +67 -0
  111. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  112. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  113. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  114. package/dist/mcp/builtin/globals/findVersionByIDTool.js +68 -0
  115. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  116. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  117. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  118. package/dist/mcp/builtin/globals/findVersionsTool.js +78 -0
  119. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  120. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  121. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  122. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +81 -0
  123. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  124. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  125. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  126. package/dist/mcp/builtin/globals/restoreVersionTool.js +70 -0
  127. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  128. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  129. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  130. package/dist/mcp/builtin/globals/updateTool.js +78 -0
  131. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  132. package/dist/mcp/builtinTools.d.ts +168 -0
  133. package/dist/mcp/builtinTools.d.ts.map +1 -0
  134. package/dist/mcp/builtinTools.js +169 -0
  135. package/dist/mcp/builtinTools.js.map +1 -0
  136. package/dist/mcp/sanitizeMCPConfig.d.ts +16 -0
  137. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  138. package/dist/mcp/sanitizeMCPConfig.js +233 -0
  139. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  140. package/dist/stdio.d.ts +8 -0
  141. package/dist/stdio.d.ts.map +1 -0
  142. package/dist/stdio.js +128 -0
  143. package/dist/stdio.js.map +1 -0
  144. package/dist/types.d.ts +263 -447
  145. package/dist/types.d.ts.map +1 -1
  146. package/dist/types.js +4 -1
  147. package/dist/types.js.map +1 -1
  148. package/dist/utils/getLogger.d.ts +10 -0
  149. package/dist/utils/getLogger.d.ts.map +1 -0
  150. package/dist/utils/getLogger.js +22 -0
  151. package/dist/utils/getLogger.js.map +1 -0
  152. package/dist/utils/getPluginConfig.d.ts +12 -0
  153. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  154. package/dist/utils/getPluginConfig.js +15 -0
  155. package/dist/utils/getPluginConfig.js.map +1 -0
  156. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  157. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  158. package/dist/utils/resolveProjectRoot.js +15 -0
  159. package/dist/utils/resolveProjectRoot.js.map +1 -0
  160. package/dist/utils/toStandardSchema.d.ts +5 -0
  161. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  162. package/dist/utils/toStandardSchema.js +4 -0
  163. package/dist/utils/toStandardSchema.js.map +1 -0
  164. package/package.json +29 -11
  165. package/src/defaultAccess.ts +3 -0
  166. package/src/defineTool.ts +44 -0
  167. package/src/endpoint/access.ts +111 -0
  168. package/src/endpoint/index.ts +107 -0
  169. package/src/exports/client.ts +3 -0
  170. package/src/exports/internal.ts +1 -0
  171. package/src/index.ts +31 -89
  172. package/src/mcp/buildMcpServer.ts +294 -0
  173. package/src/mcp/builtin/collections/authTools.ts +280 -0
  174. package/src/mcp/builtin/collections/countTool.ts +61 -0
  175. package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
  176. package/src/mcp/builtin/collections/createTool.ts +145 -0
  177. package/src/mcp/builtin/collections/deleteTool.ts +97 -0
  178. package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
  179. package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
  180. package/src/mcp/builtin/collections/fileInput.ts +127 -0
  181. package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
  182. package/src/mcp/builtin/collections/findTool.ts +134 -0
  183. package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
  184. package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
  185. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +91 -0
  186. package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
  187. package/src/mcp/builtin/collections/updateTool.ts +173 -0
  188. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
  189. package/src/mcp/builtin/formatEntityError.ts +77 -0
  190. package/src/mcp/builtin/getConfigInfoTool.ts +68 -0
  191. package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
  192. package/src/mcp/builtin/globals/findTool.ts +66 -0
  193. package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
  194. package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
  195. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +73 -0
  196. package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
  197. package/src/mcp/builtin/globals/updateTool.ts +92 -0
  198. package/src/mcp/builtinTools.ts +161 -0
  199. package/src/mcp/sanitizeMCPConfig.ts +281 -0
  200. package/src/stdio.ts +131 -0
  201. package/src/types.ts +312 -486
  202. package/src/utils/getLogger.ts +22 -0
  203. package/src/utils/getPluginConfig.ts +24 -0
  204. package/src/utils/resolveProjectRoot.ts +17 -0
  205. package/src/utils/toStandardSchema.ts +9 -0
  206. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  207. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  208. package/dist/collections/createApiKeysCollection.js +0 -342
  209. package/dist/collections/createApiKeysCollection.js.map +0 -1
  210. package/dist/defaults.d.ts +0 -4
  211. package/dist/defaults.d.ts.map +0 -1
  212. package/dist/defaults.js +0 -5
  213. package/dist/defaults.js.map +0 -1
  214. package/dist/endpoints/mcp.d.ts +0 -4
  215. package/dist/endpoints/mcp.d.ts.map +0 -1
  216. package/dist/endpoints/mcp.js +0 -24
  217. package/dist/endpoints/mcp.js.map +0 -1
  218. package/dist/endpoints/resolveAccessSettings.d.ts +0 -10
  219. package/dist/endpoints/resolveAccessSettings.d.ts.map +0 -1
  220. package/dist/endpoints/resolveAccessSettings.js +0 -44
  221. package/dist/endpoints/resolveAccessSettings.js.map +0 -1
  222. package/dist/endpoints/withRestoredWebGlobals.d.ts +0 -5
  223. package/dist/endpoints/withRestoredWebGlobals.d.ts.map +0 -1
  224. package/dist/endpoints/withRestoredWebGlobals.js +0 -23
  225. package/dist/endpoints/withRestoredWebGlobals.js.map +0 -1
  226. package/dist/mcp/createRequest.d.ts +0 -3
  227. package/dist/mcp/createRequest.d.ts.map +0 -1
  228. package/dist/mcp/createRequest.js +0 -14
  229. package/dist/mcp/createRequest.js.map +0 -1
  230. package/dist/mcp/getMcpHandler.d.ts +0 -4
  231. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  232. package/dist/mcp/getMcpHandler.js +0 -231
  233. package/dist/mcp/getMcpHandler.js.map +0 -1
  234. package/dist/mcp/helpers/config.d.ts +0 -22
  235. package/dist/mcp/helpers/config.d.ts.map +0 -1
  236. package/dist/mcp/helpers/config.js +0 -153
  237. package/dist/mcp/helpers/config.js.map +0 -1
  238. package/dist/mcp/helpers/fields.d.ts +0 -19
  239. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  240. package/dist/mcp/helpers/fields.js +0 -102
  241. package/dist/mcp/helpers/fields.js.map +0 -1
  242. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  243. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  244. package/dist/mcp/helpers/fileValidation.js +0 -267
  245. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  246. package/dist/mcp/registerTool.d.ts +0 -6
  247. package/dist/mcp/registerTool.d.ts.map +0 -1
  248. package/dist/mcp/registerTool.js +0 -18
  249. package/dist/mcp/registerTool.js.map +0 -1
  250. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  251. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  252. package/dist/mcp/tools/auth/auth.js +0 -79
  253. package/dist/mcp/tools/auth/auth.js.map +0 -1
  254. package/dist/mcp/tools/auth/auth.spec.js +0 -83
  255. package/dist/mcp/tools/auth/auth.spec.js.map +0 -1
  256. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  257. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  258. package/dist/mcp/tools/auth/forgotPassword.js +0 -50
  259. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  260. package/dist/mcp/tools/auth/login.d.ts +0 -4
  261. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  262. package/dist/mcp/tools/auth/login.js +0 -50
  263. package/dist/mcp/tools/auth/login.js.map +0 -1
  264. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  265. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  266. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  267. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  268. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  269. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  270. package/dist/mcp/tools/auth/unlock.js +0 -49
  271. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  272. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  273. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  274. package/dist/mcp/tools/auth/verify.js +0 -45
  275. package/dist/mcp/tools/auth/verify.js.map +0 -1
  276. package/dist/mcp/tools/collection/create.d.ts +0 -10
  277. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  278. package/dist/mcp/tools/collection/create.js +0 -139
  279. package/dist/mcp/tools/collection/create.js.map +0 -1
  280. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  281. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  282. package/dist/mcp/tools/collection/delete.js +0 -154
  283. package/dist/mcp/tools/collection/delete.js.map +0 -1
  284. package/dist/mcp/tools/collection/find.d.ts +0 -10
  285. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  286. package/dist/mcp/tools/collection/find.js +0 -165
  287. package/dist/mcp/tools/collection/find.js.map +0 -1
  288. package/dist/mcp/tools/collection/update.d.ts +0 -10
  289. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  290. package/dist/mcp/tools/collection/update.js +0 -209
  291. package/dist/mcp/tools/collection/update.js.map +0 -1
  292. package/dist/mcp/tools/config/find.d.ts +0 -10
  293. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  294. package/dist/mcp/tools/config/find.js +0 -97
  295. package/dist/mcp/tools/config/find.js.map +0 -1
  296. package/dist/mcp/tools/config/update.d.ts +0 -10
  297. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  298. package/dist/mcp/tools/config/update.js +0 -215
  299. package/dist/mcp/tools/config/update.js.map +0 -1
  300. package/dist/mcp/tools/global/find.d.ts +0 -5
  301. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  302. package/dist/mcp/tools/global/find.js +0 -84
  303. package/dist/mcp/tools/global/find.js.map +0 -1
  304. package/dist/mcp/tools/global/update.d.ts +0 -6
  305. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  306. package/dist/mcp/tools/global/update.js +0 -126
  307. package/dist/mcp/tools/global/update.js.map +0 -1
  308. package/dist/mcp/tools/job/create.d.ts +0 -10
  309. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  310. package/dist/mcp/tools/job/create.js +0 -293
  311. package/dist/mcp/tools/job/create.js.map +0 -1
  312. package/dist/mcp/tools/job/run.d.ts +0 -10
  313. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  314. package/dist/mcp/tools/job/run.js +0 -131
  315. package/dist/mcp/tools/job/run.js.map +0 -1
  316. package/dist/mcp/tools/job/update.d.ts +0 -11
  317. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  318. package/dist/mcp/tools/job/update.js +0 -186
  319. package/dist/mcp/tools/job/update.js.map +0 -1
  320. package/dist/mcp/tools/resource/create.d.ts +0 -6
  321. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  322. package/dist/mcp/tools/resource/create.js +0 -124
  323. package/dist/mcp/tools/resource/create.js.map +0 -1
  324. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  325. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  326. package/dist/mcp/tools/resource/delete.js +0 -151
  327. package/dist/mcp/tools/resource/delete.js.map +0 -1
  328. package/dist/mcp/tools/resource/find.d.ts +0 -5
  329. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  330. package/dist/mcp/tools/resource/find.js +0 -170
  331. package/dist/mcp/tools/resource/find.js.map +0 -1
  332. package/dist/mcp/tools/resource/update.d.ts +0 -6
  333. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  334. package/dist/mcp/tools/resource/update.js +0 -242
  335. package/dist/mcp/tools/resource/update.js.map +0 -1
  336. package/dist/mcp/tools/schemas.d.ts +0 -442
  337. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  338. package/dist/mcp/tools/schemas.js +0 -238
  339. package/dist/mcp/tools/schemas.js.map +0 -1
  340. package/dist/utils/adminEntitySettings.d.ts +0 -17
  341. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  342. package/dist/utils/adminEntitySettings.js +0 -41
  343. package/dist/utils/adminEntitySettings.js.map +0 -1
  344. package/dist/utils/createApiKeyFields.d.ts +0 -15
  345. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  346. package/dist/utils/createApiKeyFields.js +0 -57
  347. package/dist/utils/createApiKeyFields.js.map +0 -1
  348. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  349. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  350. package/dist/utils/getEnabledSlugs.js +0 -32
  351. package/dist/utils/getEnabledSlugs.js.map +0 -1
  352. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  353. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  354. package/dist/utils/getVirtualFieldNames.js +0 -35
  355. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  356. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -4
  357. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  358. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -61
  359. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  360. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  361. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  362. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  363. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  364. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  365. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  366. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  367. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  368. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  369. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  370. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  371. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  372. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  373. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  374. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  375. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  376. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  377. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  378. package/dist/utils/transformPointDataToPayload.js +0 -28
  379. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  380. package/src/collections/createApiKeysCollection.ts +0 -399
  381. package/src/defaults.ts +0 -3
  382. package/src/endpoints/mcp.ts +0 -26
  383. package/src/endpoints/resolveAccessSettings.ts +0 -74
  384. package/src/endpoints/withRestoredWebGlobals.ts +0 -19
  385. package/src/mcp/createRequest.ts +0 -13
  386. package/src/mcp/getMcpHandler.ts +0 -546
  387. package/src/mcp/helpers/config.ts +0 -213
  388. package/src/mcp/helpers/fields.ts +0 -154
  389. package/src/mcp/helpers/fileValidation.ts +0 -362
  390. package/src/mcp/registerTool.ts +0 -22
  391. package/src/mcp/tools/auth/auth.spec.ts +0 -98
  392. package/src/mcp/tools/auth/auth.ts +0 -89
  393. package/src/mcp/tools/auth/forgotPassword.ts +0 -72
  394. package/src/mcp/tools/auth/login.ts +0 -64
  395. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  396. package/src/mcp/tools/auth/unlock.ts +0 -65
  397. package/src/mcp/tools/auth/verify.ts +0 -57
  398. package/src/mcp/tools/collection/create.ts +0 -210
  399. package/src/mcp/tools/collection/delete.ts +0 -211
  400. package/src/mcp/tools/collection/find.ts +0 -224
  401. package/src/mcp/tools/collection/update.ts +0 -290
  402. package/src/mcp/tools/config/find.ts +0 -128
  403. package/src/mcp/tools/config/update.ts +0 -280
  404. package/src/mcp/tools/global/find.ts +0 -130
  405. package/src/mcp/tools/global/update.ts +0 -209
  406. package/src/mcp/tools/job/create.ts +0 -416
  407. package/src/mcp/tools/job/run.ts +0 -169
  408. package/src/mcp/tools/job/update.ts +0 -274
  409. package/src/mcp/tools/resource/create.ts +0 -211
  410. package/src/mcp/tools/resource/delete.ts +0 -218
  411. package/src/mcp/tools/resource/find.ts +0 -246
  412. package/src/mcp/tools/resource/update.ts +0 -367
  413. package/src/mcp/tools/schemas.ts +0 -499
  414. package/src/utils/adminEntitySettings.ts +0 -40
  415. package/src/utils/createApiKeyFields.ts +0 -72
  416. package/src/utils/getEnabledSlugs.ts +0 -42
  417. package/src/utils/getVirtualFieldNames.ts +0 -53
  418. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -72
  419. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
  420. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  421. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  422. package/src/utils/schemaConversion/transformPointFields.ts +0 -55
  423. package/src/utils/transformPointDataToPayload.ts +0 -40
@@ -1,399 +0,0 @@
1
- import type { CollectionConfig, CollectionSlug, PayloadRequest, Where } from 'payload'
2
-
3
- import type { MCPPluginConfig } from '../types.js'
4
-
5
- import { toCamelCase } from '../utils/camelCase.js'
6
- import { createApiKeyFields } from '../utils/createApiKeyFields.js'
7
-
8
- export const createAPIKeysCollection = (
9
- collections: MCPPluginConfig['collections'],
10
- globals: MCPPluginConfig['globals'],
11
- customTools: Array<{ description: string; name: string }> = [],
12
- experimentalTools: NonNullable<MCPPluginConfig['experimental']>['tools'] = {},
13
- pluginOptions: MCPPluginConfig,
14
- ): CollectionConfig => {
15
- const customToolsFields = customTools.map((tool) => {
16
- const camelCasedName = toCamelCase(tool.name)
17
- return {
18
- name: camelCasedName,
19
- type: 'checkbox' as const,
20
- admin: {
21
- description: tool.description,
22
- },
23
- defaultValue: true,
24
- label: camelCasedName,
25
- }
26
- })
27
-
28
- const customResourceFields =
29
- pluginOptions.mcp?.resources?.map((resource) => {
30
- const camelCasedName = toCamelCase(resource.name)
31
- return {
32
- name: camelCasedName,
33
- type: 'checkbox' as const,
34
- admin: {
35
- description: resource.description,
36
- },
37
- defaultValue: true,
38
- label: camelCasedName,
39
- }
40
- }) || []
41
-
42
- const customPromptFields =
43
- pluginOptions.mcp?.prompts?.map((prompt) => {
44
- const camelCasedName = toCamelCase(prompt.name)
45
- return {
46
- name: camelCasedName,
47
- type: 'checkbox' as const,
48
- admin: {
49
- description: prompt.description,
50
- },
51
- defaultValue: true,
52
- label: camelCasedName,
53
- }
54
- }) || []
55
-
56
- const userCollection = pluginOptions.userCollection
57
-
58
- const isAuthenticated = ({ req }: { req: PayloadRequest }): boolean =>
59
- Boolean(req.user && req.user.collection === userCollection)
60
-
61
- const restrictToOwnKeys = ({ req }: { req: PayloadRequest }): boolean | Where =>
62
- req.user && req.user.collection === userCollection ? { user: { equals: req.user.id } } : false
63
-
64
- return {
65
- slug: 'payload-mcp-api-keys',
66
- access: {
67
- // Fail-safe default: any authenticated user may manage only their OWN keys.
68
- // Cross-user key issuance is disabled by default (see the `user` field below)
69
- // and must be granted explicitly via `overrideApiKeyCollection`.
70
- create: isAuthenticated,
71
- delete: restrictToOwnKeys,
72
- read: restrictToOwnKeys,
73
- unlock: restrictToOwnKeys,
74
- update: restrictToOwnKeys,
75
- },
76
- admin: {
77
- description:
78
- 'API keys control which collections, resources, tools, and prompts MCP clients can access',
79
- group: 'MCP',
80
- useAsTitle: 'label',
81
- },
82
- auth: {
83
- disableLocalStrategy: true,
84
- useAPIKey: true,
85
- },
86
- fields: [
87
- {
88
- name: 'user',
89
- type: 'relationship',
90
- access: {
91
- // Bind new keys to the creating user and prevent re-binding on update.
92
- // A key acts as its associated user, so allowing arbitrary assignment lets
93
- // any key manager impersonate anyone. Grant these via `overrideApiKeyCollection`
94
- // to let trusted administrators issue keys on behalf of other users.
95
- create: () => false,
96
- update: () => false,
97
- },
98
- admin: {
99
- description: 'The user that the API key is associated with.',
100
- },
101
- defaultValue: ({ req }: { req: PayloadRequest }) =>
102
- req.user && req.user.collection === userCollection ? req.user.id : undefined,
103
- relationTo: userCollection as CollectionSlug,
104
- required: true,
105
- },
106
- {
107
- name: 'label',
108
- type: 'text',
109
- admin: {
110
- description: 'A useful label for the API key.',
111
- },
112
- },
113
- {
114
- name: 'description',
115
- type: 'text',
116
- admin: {
117
- description: 'The purpose of the API key.',
118
- },
119
- },
120
-
121
- ...createApiKeyFields({
122
- config: collections,
123
- configType: 'collection',
124
- }),
125
-
126
- ...createApiKeyFields({
127
- config: globals,
128
- configType: 'global',
129
- }),
130
-
131
- ...(customTools.length > 0
132
- ? [
133
- {
134
- type: 'collapsible' as const,
135
- admin: {
136
- description: 'Manage client access to tools',
137
- position: 'sidebar' as const,
138
- },
139
- fields: [
140
- {
141
- name: 'payload-mcp-tool',
142
- type: 'group' as const,
143
- fields: customToolsFields,
144
- label: false as const,
145
- },
146
- ],
147
- label: 'Tools',
148
- },
149
- ]
150
- : []),
151
-
152
- ...(pluginOptions.mcp?.resources && pluginOptions.mcp?.resources.length > 0
153
- ? [
154
- {
155
- type: 'collapsible' as const,
156
- admin: {
157
- description: 'Manage client access to resources',
158
- position: 'sidebar' as const,
159
- },
160
- fields: [
161
- {
162
- name: 'payload-mcp-resource',
163
- type: 'group' as const,
164
- fields: customResourceFields,
165
- label: false as const,
166
- },
167
- ],
168
- label: 'Resources',
169
- },
170
- ]
171
- : []),
172
-
173
- ...(pluginOptions.mcp?.prompts && pluginOptions.mcp?.prompts.length > 0
174
- ? [
175
- {
176
- type: 'collapsible' as const,
177
- admin: {
178
- description: 'Manage client access to prompts',
179
- position: 'sidebar' as const,
180
- },
181
- fields: [
182
- {
183
- name: 'payload-mcp-prompt',
184
- type: 'group' as const,
185
- fields: customPromptFields,
186
- label: false as const,
187
- },
188
- ],
189
- label: 'Prompts',
190
- },
191
- ]
192
- : []),
193
-
194
- // Experimental Tools
195
- ...(process.env.NODE_ENV === 'development' &&
196
- (experimentalTools?.collections?.enabled ||
197
- experimentalTools?.jobs?.enabled ||
198
- experimentalTools?.config?.enabled ||
199
- experimentalTools?.auth?.enabled)
200
- ? [
201
- {
202
- type: 'collapsible' as const,
203
- admin: {
204
- description: 'Manage client access to experimental tools',
205
- position: 'sidebar' as const,
206
- },
207
- fields: [
208
- ...(experimentalTools?.collections?.enabled
209
- ? [
210
- {
211
- name: 'collections',
212
- type: 'group' as const,
213
- fields: [
214
- {
215
- name: 'find',
216
- type: 'checkbox' as const,
217
- admin: {
218
- description:
219
- 'Allow LLMs to find and list Payload collections with optional content and document counts.',
220
- },
221
- defaultValue: false,
222
- },
223
- {
224
- name: 'create',
225
- type: 'checkbox' as const,
226
- admin: {
227
- description:
228
- 'Allow LLMs to create new Payload collections with specified fields and configuration.',
229
- },
230
- defaultValue: false,
231
- },
232
- {
233
- name: 'update',
234
- type: 'checkbox' as const,
235
- admin: {
236
- description:
237
- 'Allow LLMs to update existing Payload collections with new fields, modifications, or configuration changes.',
238
- },
239
- defaultValue: false,
240
- },
241
- {
242
- name: 'delete',
243
- type: 'checkbox' as const,
244
- admin: {
245
- description:
246
- 'Allow LLMs to delete Payload collections and optionally update the configuration.',
247
- },
248
- defaultValue: false,
249
- },
250
- ],
251
- },
252
- ]
253
- : []),
254
- ...(experimentalTools?.jobs?.enabled
255
- ? [
256
- {
257
- name: 'jobs',
258
- type: 'group' as const,
259
- fields: [
260
- {
261
- name: 'create',
262
- type: 'checkbox' as const,
263
- admin: {
264
- description:
265
- 'Allow LLMs to create new Payload jobs (tasks and workflows) with custom schemas and configuration.',
266
- },
267
- defaultValue: false,
268
- },
269
- {
270
- name: 'run',
271
- type: 'checkbox' as const,
272
- admin: {
273
- description:
274
- 'Allow LLMs to execute Payload jobs with custom input data and queue options.',
275
- },
276
- defaultValue: false,
277
- },
278
- {
279
- name: 'update',
280
- type: 'checkbox' as const,
281
- admin: {
282
- description:
283
- 'Allow LLMs to update existing Payload jobs with new schemas, configuration, or handler code.',
284
- },
285
- defaultValue: false,
286
- },
287
- ],
288
- },
289
- ]
290
- : []),
291
- ...(experimentalTools?.config?.enabled
292
- ? [
293
- {
294
- name: 'config',
295
- type: 'group' as const,
296
- fields: [
297
- {
298
- name: 'find',
299
- type: 'checkbox' as const,
300
- admin: {
301
- description:
302
- 'Allow LLMs to read and display a Payload configuration file.',
303
- },
304
- defaultValue: false,
305
- },
306
- {
307
- name: 'update',
308
- type: 'checkbox' as const,
309
- admin: {
310
- description:
311
- 'Allow LLMs to update a Payload configuration file with various modifications.',
312
- },
313
- defaultValue: false,
314
- },
315
- ],
316
- },
317
- ]
318
- : []),
319
- ...(experimentalTools?.auth?.enabled
320
- ? [
321
- {
322
- name: 'auth',
323
- type: 'group' as const,
324
- fields: [
325
- {
326
- name: 'auth',
327
- type: 'checkbox' as const,
328
- admin: {
329
- description:
330
- 'Allow LLMs to check authentication status for a user by setting custom headers. (e.g. {"Authorization": "Bearer <token>"})',
331
- },
332
- defaultValue: false,
333
- label: 'Check Auth Status',
334
- },
335
- {
336
- name: 'login',
337
- type: 'checkbox' as const,
338
- admin: {
339
- description:
340
- 'Allow LLMs to authenticate a user with email and password.',
341
- },
342
- defaultValue: false,
343
- label: 'User Login',
344
- },
345
- {
346
- name: 'verify',
347
- type: 'checkbox' as const,
348
- admin: {
349
- description:
350
- 'Allow LLMs to verify a user email with a verification token.',
351
- },
352
- defaultValue: false,
353
- label: 'Email Verification',
354
- },
355
- {
356
- name: 'resetPassword',
357
- type: 'checkbox' as const,
358
- admin: {
359
- description:
360
- 'Allow LLMs to reset a user password with a reset token.',
361
- },
362
- defaultValue: false,
363
- label: 'Reset Password',
364
- },
365
- {
366
- name: 'forgotPassword',
367
- type: 'checkbox' as const,
368
- admin: {
369
- description: 'Allow LLMs to send a password reset email to a user.',
370
- },
371
- defaultValue: false,
372
- label: 'Forgot Password',
373
- },
374
- {
375
- name: 'unlock',
376
- type: 'checkbox' as const,
377
- admin: {
378
- description:
379
- 'Allow LLMs to unlock a user account that has been locked due to failed login attempts.',
380
- },
381
- defaultValue: false,
382
- label: 'Unlock Account',
383
- },
384
- ],
385
- },
386
- ]
387
- : []),
388
- ],
389
- label: 'Experimental Tools',
390
- },
391
- ]
392
- : []),
393
- ],
394
- labels: {
395
- plural: 'API Keys',
396
- singular: 'API Key',
397
- },
398
- }
399
- }
package/src/defaults.ts DELETED
@@ -1,3 +0,0 @@
1
- export const defaults = {
2
- userCollection: 'users',
3
- }
@@ -1,26 +0,0 @@
1
- import type { PayloadHandler } from 'payload'
2
-
3
- import type { MCPPluginConfig } from '../types.js'
4
-
5
- import { createRequestFromPayloadRequest } from '../mcp/createRequest.js'
6
- import { getMcpHandler } from '../mcp/getMcpHandler.js'
7
- import { resolveAccessSettings } from './resolveAccessSettings.js'
8
- import { withRestoredWebGlobals } from './withRestoredWebGlobals.js'
9
-
10
- export const initializeMCPHandler = (pluginOptions: MCPPluginConfig) => {
11
- const mcpHandler: PayloadHandler = async (req) => {
12
- const useVerboseLogs = pluginOptions.mcp?.handlerOptions?.verboseLogs ?? false
13
-
14
- req.payloadAPI = 'MCP' as const
15
-
16
- const mcpAccessSettings = await resolveAccessSettings({ pluginOptions, req, useVerboseLogs })
17
- req.user = mcpAccessSettings.user
18
-
19
- return await withRestoredWebGlobals(async () => {
20
- const handler = getMcpHandler(pluginOptions, mcpAccessSettings, req)
21
- const request = createRequestFromPayloadRequest(req)
22
- return await handler(request)
23
- })
24
- }
25
- return mcpHandler
26
- }
@@ -1,74 +0,0 @@
1
- import crypto from 'crypto'
2
- import { type PayloadRequest, type TypedUser, UnauthorizedError, type Where } from 'payload'
3
-
4
- import type { MCPAccessSettings, MCPPluginConfig } from '../types.js'
5
-
6
- type ResolveAccessSettingsArgs = {
7
- pluginOptions: MCPPluginConfig
8
- req: PayloadRequest
9
- useVerboseLogs: boolean
10
- }
11
-
12
- const createDefaultAccessSettingsResolver = ({
13
- pluginOptions,
14
- req,
15
- useVerboseLogs,
16
- }: ResolveAccessSettingsArgs) => {
17
- return async (overrideApiKey?: null | string): Promise<MCPAccessSettings> => {
18
- const authorization = req.headers.get('Authorization')
19
- const apiKey =
20
- overrideApiKey ??
21
- (authorization?.startsWith('Bearer ') ? authorization.replace('Bearer ', '').trim() : null)
22
-
23
- if (apiKey === null) {
24
- throw new UnauthorizedError()
25
- }
26
-
27
- const sha256APIKeyIndex = crypto
28
- .createHmac('sha256', req.payload.secret)
29
- .update(apiKey || '')
30
- .digest('hex')
31
- const where: Where = {
32
- apiKeyIndex: {
33
- equals: sha256APIKeyIndex,
34
- },
35
- }
36
- const { docs } = await req.payload.find({
37
- collection: 'payload-mcp-api-keys',
38
- depth: 1,
39
- limit: 1,
40
- pagination: false,
41
- where,
42
- })
43
- const apiKeyDoc = docs[0]
44
-
45
- if (!apiKeyDoc) {
46
- throw new UnauthorizedError()
47
- }
48
-
49
- if (useVerboseLogs) {
50
- req.payload.logger.info('[payload-mcp] API Key is valid')
51
- }
52
-
53
- const user = apiKeyDoc.user as TypedUser
54
-
55
- if (!user || typeof user !== 'object' || !('id' in user)) {
56
- throw new UnauthorizedError()
57
- }
58
-
59
- user.collection = pluginOptions.userCollection as string
60
- user._strategy = 'mcp-api-key' as const
61
-
62
- return apiKeyDoc as unknown as MCPAccessSettings
63
- }
64
- }
65
-
66
- export const resolveAccessSettings = async (
67
- args: ResolveAccessSettingsArgs,
68
- ): Promise<MCPAccessSettings> => {
69
- const getDefaultMcpAccessSettings = createDefaultAccessSettingsResolver(args)
70
-
71
- return args.pluginOptions.overrideAuth
72
- ? await args.pluginOptions.overrideAuth(args.req, getDefaultMcpAccessSettings)
73
- : await getDefaultMcpAccessSettings()
74
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Restores globals replaced by @hono/node-server while handling an MCP request.
3
- */
4
- export const withRestoredWebGlobals = async <T>(handler: () => Promise<T>): Promise<T> => {
5
- const globals = globalThis as Record<string, unknown>
6
- const originalRequest = globals['Request']
7
- const originalResponse = globals['Response']
8
-
9
- try {
10
- return await handler()
11
- } finally {
12
- if (globals['Response'] !== originalResponse) {
13
- Object.defineProperty(globalThis, 'Response', { value: originalResponse })
14
- }
15
- if (globals['Request'] !== originalRequest) {
16
- Object.defineProperty(globalThis, 'Request', { value: originalRequest })
17
- }
18
- }
19
- }
@@ -1,13 +0,0 @@
1
- import { AuthenticationError, type PayloadRequest } from 'payload'
2
-
3
- export const createRequestFromPayloadRequest = (req: PayloadRequest) => {
4
- if (!req.url) {
5
- throw new AuthenticationError()
6
- }
7
- return new Request(req.url, {
8
- body: req.body,
9
- duplex: 'half',
10
- headers: req.headers,
11
- method: req.method,
12
- } as { duplex: 'half' } & RequestInit)
13
- }