@payloadcms/plugin-mcp 3.86.0-internal.ac46214 → 4.0.0-canary.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 (368) hide show
  1. package/README.md +2 -2
  2. package/bin.js +39 -0
  3. package/dist/collection/getAccessField.d.ts +12 -0
  4. package/dist/collection/getAccessField.d.ts.map +1 -0
  5. package/dist/collection/getAccessField.js +57 -0
  6. package/dist/collection/getAccessField.js.map +1 -0
  7. package/dist/collection/index.d.ts +6 -0
  8. package/dist/collection/index.d.ts.map +1 -0
  9. package/dist/collection/index.js +60 -0
  10. package/dist/collection/index.js.map +1 -0
  11. package/dist/components/AccessField/index.client.d.ts +10 -0
  12. package/dist/components/AccessField/index.client.d.ts.map +1 -0
  13. package/dist/components/AccessField/index.client.js +305 -0
  14. package/dist/components/AccessField/index.client.js.map +1 -0
  15. package/dist/components/AccessField/index.css +93 -0
  16. package/dist/defineTool.d.ts +26 -0
  17. package/dist/defineTool.d.ts.map +1 -0
  18. package/dist/defineTool.js +37 -0
  19. package/dist/defineTool.js.map +1 -0
  20. package/dist/endpoint/access.d.ts +10 -0
  21. package/dist/endpoint/access.d.ts.map +1 -0
  22. package/dist/endpoint/access.js +106 -0
  23. package/dist/endpoint/access.js.map +1 -0
  24. package/dist/endpoint/index.d.ts +3 -0
  25. package/dist/endpoint/index.d.ts.map +1 -0
  26. package/dist/endpoint/index.js +36 -0
  27. package/dist/endpoint/index.js.map +1 -0
  28. package/dist/exports/client.d.ts +2 -0
  29. package/dist/exports/client.d.ts.map +1 -0
  30. package/dist/exports/client.js +4 -0
  31. package/dist/exports/client.js.map +1 -0
  32. package/dist/index.d.ts +4 -7
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +44 -67
  35. package/dist/index.js.map +1 -1
  36. package/dist/mcp/buildMcpServer.d.ts +19 -0
  37. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  38. package/dist/mcp/buildMcpServer.js +199 -0
  39. package/dist/mcp/buildMcpServer.js.map +1 -0
  40. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  41. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  42. package/dist/mcp/builtin/collections/authTools.js +250 -0
  43. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  44. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  45. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  46. package/dist/mcp/builtin/collections/createTool.js +94 -0
  47. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  48. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  49. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  50. package/dist/mcp/builtin/collections/deleteTool.js +102 -0
  51. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  52. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  53. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  54. package/dist/mcp/builtin/collections/findTool.js +144 -0
  55. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  56. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  57. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  58. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  59. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  60. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  61. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  62. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
  63. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  64. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  65. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  66. package/dist/mcp/builtin/collections/updateTool.js +199 -0
  67. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  68. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  69. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  70. package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
  71. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  72. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  73. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  74. package/dist/mcp/builtin/globals/findTool.js +76 -0
  75. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  76. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  77. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  78. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
  79. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  80. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  81. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  82. package/dist/mcp/builtin/globals/updateTool.js +94 -0
  83. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  84. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  85. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  86. package/dist/mcp/builtin/validateEntityData.js +82 -0
  87. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  88. package/dist/mcp/builtinTools.d.ts +105 -0
  89. package/dist/mcp/builtinTools.d.ts.map +1 -0
  90. package/dist/mcp/builtinTools.js +107 -0
  91. package/dist/mcp/builtinTools.js.map +1 -0
  92. package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
  93. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  94. package/dist/mcp/sanitizeMCPConfig.js +188 -0
  95. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  96. package/dist/stdio.d.ts +8 -0
  97. package/dist/stdio.d.ts.map +1 -0
  98. package/dist/stdio.js +89 -0
  99. package/dist/stdio.js.map +1 -0
  100. package/dist/types.d.ts +251 -455
  101. package/dist/types.d.ts.map +1 -1
  102. package/dist/types.js +6 -1
  103. package/dist/types.js.map +1 -1
  104. package/dist/utils/camelCase.d.ts.map +1 -1
  105. package/dist/utils/getLogger.d.ts +10 -0
  106. package/dist/utils/getLogger.d.ts.map +1 -0
  107. package/dist/utils/getLogger.js +22 -0
  108. package/dist/utils/getLogger.js.map +1 -0
  109. package/dist/utils/getPluginConfig.d.ts +12 -0
  110. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  111. package/dist/utils/getPluginConfig.js +15 -0
  112. package/dist/utils/getPluginConfig.js.map +1 -0
  113. package/dist/utils/localAPIDefaults.d.ts +20 -0
  114. package/dist/utils/localAPIDefaults.d.ts.map +1 -0
  115. package/dist/utils/localAPIDefaults.js +19 -0
  116. package/dist/utils/localAPIDefaults.js.map +1 -0
  117. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  118. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  119. package/dist/utils/resolveProjectRoot.js +15 -0
  120. package/dist/utils/resolveProjectRoot.js.map +1 -0
  121. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  122. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  123. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  124. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  125. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
  126. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
  127. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
  128. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
  129. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  130. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
  131. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  132. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
  133. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  134. package/dist/utils/toStandardSchema.d.ts +5 -0
  135. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  136. package/dist/utils/toStandardSchema.js +4 -0
  137. package/dist/utils/toStandardSchema.js.map +1 -0
  138. package/dist/utils/whereSchema.d.ts +9 -0
  139. package/dist/utils/whereSchema.d.ts.map +1 -0
  140. package/dist/utils/whereSchema.js +13 -0
  141. package/dist/utils/whereSchema.js.map +1 -0
  142. package/package.json +35 -10
  143. package/src/collection/getAccessField.ts +64 -0
  144. package/src/collection/index.ts +64 -0
  145. package/src/components/AccessField/index.client.tsx +347 -0
  146. package/src/components/AccessField/index.css +93 -0
  147. package/src/defineTool.ts +44 -0
  148. package/src/endpoint/access.ts +132 -0
  149. package/src/endpoint/index.ts +35 -0
  150. package/src/exports/client.ts +2 -0
  151. package/src/index.ts +35 -85
  152. package/src/mcp/buildMcpServer.ts +257 -0
  153. package/src/mcp/builtin/collections/authTools.ts +233 -0
  154. package/src/mcp/builtin/collections/createTool.ts +112 -0
  155. package/src/mcp/builtin/collections/deleteTool.ts +116 -0
  156. package/src/mcp/builtin/collections/findTool.ts +177 -0
  157. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  158. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
  159. package/src/mcp/builtin/collections/updateTool.ts +211 -0
  160. package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
  161. package/src/mcp/builtin/globals/findTool.ts +96 -0
  162. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
  163. package/src/mcp/builtin/globals/updateTool.ts +115 -0
  164. package/src/mcp/builtin/validateEntityData.ts +132 -0
  165. package/src/mcp/builtinTools.ts +98 -0
  166. package/src/mcp/sanitizeMCPConfig.ts +260 -0
  167. package/src/stdio.ts +98 -0
  168. package/src/types.ts +290 -490
  169. package/src/utils/getLogger.ts +22 -0
  170. package/src/utils/getPluginConfig.ts +24 -0
  171. package/src/utils/localAPIDefaults.ts +22 -0
  172. package/src/utils/resolveProjectRoot.ts +17 -0
  173. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  174. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
  175. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
  176. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
  177. package/src/utils/toStandardSchema.ts +9 -0
  178. package/src/utils/whereSchema.ts +24 -0
  179. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  180. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  181. package/dist/collections/createApiKeysCollection.js +0 -317
  182. package/dist/collections/createApiKeysCollection.js.map +0 -1
  183. package/dist/defaults.d.ts +0 -4
  184. package/dist/defaults.d.ts.map +0 -1
  185. package/dist/defaults.js +0 -5
  186. package/dist/defaults.js.map +0 -1
  187. package/dist/endpoints/mcp.d.ts +0 -4
  188. package/dist/endpoints/mcp.d.ts.map +0 -1
  189. package/dist/endpoints/mcp.js +0 -71
  190. package/dist/endpoints/mcp.js.map +0 -1
  191. package/dist/mcp/createRequest.d.ts +0 -3
  192. package/dist/mcp/createRequest.d.ts.map +0 -1
  193. package/dist/mcp/createRequest.js +0 -14
  194. package/dist/mcp/createRequest.js.map +0 -1
  195. package/dist/mcp/getMcpHandler.d.ts +0 -4
  196. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  197. package/dist/mcp/getMcpHandler.js +0 -231
  198. package/dist/mcp/getMcpHandler.js.map +0 -1
  199. package/dist/mcp/helpers/config.d.ts +0 -22
  200. package/dist/mcp/helpers/config.d.ts.map +0 -1
  201. package/dist/mcp/helpers/config.js +0 -153
  202. package/dist/mcp/helpers/config.js.map +0 -1
  203. package/dist/mcp/helpers/fields.d.ts +0 -19
  204. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  205. package/dist/mcp/helpers/fields.js +0 -102
  206. package/dist/mcp/helpers/fields.js.map +0 -1
  207. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  208. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  209. package/dist/mcp/helpers/fileValidation.js +0 -267
  210. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  211. package/dist/mcp/registerTool.d.ts +0 -6
  212. package/dist/mcp/registerTool.d.ts.map +0 -1
  213. package/dist/mcp/registerTool.js +0 -18
  214. package/dist/mcp/registerTool.js.map +0 -1
  215. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  216. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  217. package/dist/mcp/tools/auth/auth.js +0 -57
  218. package/dist/mcp/tools/auth/auth.js.map +0 -1
  219. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  220. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  221. package/dist/mcp/tools/auth/forgotPassword.js +0 -48
  222. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  223. package/dist/mcp/tools/auth/login.d.ts +0 -4
  224. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  225. package/dist/mcp/tools/auth/login.js +0 -51
  226. package/dist/mcp/tools/auth/login.js.map +0 -1
  227. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  228. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  229. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  230. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  231. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  232. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  233. package/dist/mcp/tools/auth/unlock.js +0 -48
  234. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  235. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  236. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  237. package/dist/mcp/tools/auth/verify.js +0 -45
  238. package/dist/mcp/tools/auth/verify.js.map +0 -1
  239. package/dist/mcp/tools/collection/create.d.ts +0 -10
  240. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  241. package/dist/mcp/tools/collection/create.js +0 -139
  242. package/dist/mcp/tools/collection/create.js.map +0 -1
  243. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  244. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  245. package/dist/mcp/tools/collection/delete.js +0 -154
  246. package/dist/mcp/tools/collection/delete.js.map +0 -1
  247. package/dist/mcp/tools/collection/find.d.ts +0 -10
  248. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  249. package/dist/mcp/tools/collection/find.js +0 -165
  250. package/dist/mcp/tools/collection/find.js.map +0 -1
  251. package/dist/mcp/tools/collection/update.d.ts +0 -10
  252. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  253. package/dist/mcp/tools/collection/update.js +0 -209
  254. package/dist/mcp/tools/collection/update.js.map +0 -1
  255. package/dist/mcp/tools/config/find.d.ts +0 -10
  256. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  257. package/dist/mcp/tools/config/find.js +0 -97
  258. package/dist/mcp/tools/config/find.js.map +0 -1
  259. package/dist/mcp/tools/config/update.d.ts +0 -10
  260. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  261. package/dist/mcp/tools/config/update.js +0 -215
  262. package/dist/mcp/tools/config/update.js.map +0 -1
  263. package/dist/mcp/tools/global/find.d.ts +0 -5
  264. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  265. package/dist/mcp/tools/global/find.js +0 -82
  266. package/dist/mcp/tools/global/find.js.map +0 -1
  267. package/dist/mcp/tools/global/update.d.ts +0 -6
  268. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  269. package/dist/mcp/tools/global/update.js +0 -124
  270. package/dist/mcp/tools/global/update.js.map +0 -1
  271. package/dist/mcp/tools/job/create.d.ts +0 -10
  272. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  273. package/dist/mcp/tools/job/create.js +0 -293
  274. package/dist/mcp/tools/job/create.js.map +0 -1
  275. package/dist/mcp/tools/job/run.d.ts +0 -10
  276. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  277. package/dist/mcp/tools/job/run.js +0 -129
  278. package/dist/mcp/tools/job/run.js.map +0 -1
  279. package/dist/mcp/tools/job/update.d.ts +0 -11
  280. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  281. package/dist/mcp/tools/job/update.js +0 -186
  282. package/dist/mcp/tools/job/update.js.map +0 -1
  283. package/dist/mcp/tools/resource/create.d.ts +0 -6
  284. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  285. package/dist/mcp/tools/resource/create.js +0 -124
  286. package/dist/mcp/tools/resource/create.js.map +0 -1
  287. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  288. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  289. package/dist/mcp/tools/resource/delete.js +0 -151
  290. package/dist/mcp/tools/resource/delete.js.map +0 -1
  291. package/dist/mcp/tools/resource/find.d.ts +0 -5
  292. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  293. package/dist/mcp/tools/resource/find.js +0 -170
  294. package/dist/mcp/tools/resource/find.js.map +0 -1
  295. package/dist/mcp/tools/resource/update.d.ts +0 -6
  296. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  297. package/dist/mcp/tools/resource/update.js +0 -256
  298. package/dist/mcp/tools/resource/update.js.map +0 -1
  299. package/dist/mcp/tools/schemas.d.ts +0 -457
  300. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  301. package/dist/mcp/tools/schemas.js +0 -243
  302. package/dist/mcp/tools/schemas.js.map +0 -1
  303. package/dist/utils/adminEntitySettings.d.ts +0 -17
  304. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  305. package/dist/utils/adminEntitySettings.js +0 -41
  306. package/dist/utils/adminEntitySettings.js.map +0 -1
  307. package/dist/utils/createApiKeyFields.d.ts +0 -15
  308. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  309. package/dist/utils/createApiKeyFields.js +0 -57
  310. package/dist/utils/createApiKeyFields.js.map +0 -1
  311. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  312. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  313. package/dist/utils/getEnabledSlugs.js +0 -32
  314. package/dist/utils/getEnabledSlugs.js.map +0 -1
  315. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
  316. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  317. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
  318. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  319. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  320. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  321. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  322. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  323. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  324. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  325. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  326. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  327. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  328. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  329. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  330. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  331. package/src/collections/createApiKeysCollection.ts +0 -373
  332. package/src/defaults.ts +0 -3
  333. package/src/endpoints/mcp.ts +0 -91
  334. package/src/mcp/createRequest.ts +0 -13
  335. package/src/mcp/getMcpHandler.ts +0 -545
  336. package/src/mcp/helpers/config.ts +0 -213
  337. package/src/mcp/helpers/fields.ts +0 -154
  338. package/src/mcp/helpers/fileValidation.ts +0 -362
  339. package/src/mcp/registerTool.ts +0 -22
  340. package/src/mcp/tools/auth/auth.ts +0 -71
  341. package/src/mcp/tools/auth/forgotPassword.ts +0 -70
  342. package/src/mcp/tools/auth/login.ts +0 -72
  343. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  344. package/src/mcp/tools/auth/unlock.ts +0 -64
  345. package/src/mcp/tools/auth/verify.ts +0 -57
  346. package/src/mcp/tools/collection/create.ts +0 -210
  347. package/src/mcp/tools/collection/delete.ts +0 -211
  348. package/src/mcp/tools/collection/find.ts +0 -224
  349. package/src/mcp/tools/collection/update.ts +0 -290
  350. package/src/mcp/tools/config/find.ts +0 -128
  351. package/src/mcp/tools/config/update.ts +0 -280
  352. package/src/mcp/tools/global/find.ts +0 -128
  353. package/src/mcp/tools/global/update.ts +0 -207
  354. package/src/mcp/tools/job/create.ts +0 -416
  355. package/src/mcp/tools/job/run.ts +0 -167
  356. package/src/mcp/tools/job/update.ts +0 -274
  357. package/src/mcp/tools/resource/create.ts +0 -211
  358. package/src/mcp/tools/resource/delete.ts +0 -218
  359. package/src/mcp/tools/resource/find.ts +0 -246
  360. package/src/mcp/tools/resource/update.ts +0 -383
  361. package/src/mcp/tools/schemas.ts +0 -520
  362. package/src/utils/adminEntitySettings.ts +0 -40
  363. package/src/utils/createApiKeyFields.ts +0 -72
  364. package/src/utils/getEnabledSlugs.ts +0 -42
  365. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
  366. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  367. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  368. package/src/utils/schemaConversion/transformPointFields.ts +0 -55
package/src/types.ts CHANGED
@@ -1,542 +1,342 @@
1
1
  import type {
2
+ CallToolResult,
3
+ ContentBlock,
4
+ JsonSchemaType,
5
+ McpServer,
6
+ ResourceTemplate,
7
+ ServerContext,
8
+ StandardSchemaWithJSON,
9
+ } from '@modelcontextprotocol/server'
10
+ import type {
11
+ AuthCollectionSlug,
2
12
  CollectionConfig,
3
13
  CollectionSlug,
14
+ DefaultDocumentIDType,
4
15
  GlobalSlug,
16
+ MaybePromise,
5
17
  PayloadRequest,
6
18
  TypedUser,
7
19
  } from 'payload'
8
- import type { z } from 'zod'
9
20
 
10
- import { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
21
+ import type {
22
+ MCPCollectionAuthToolName,
23
+ MCPCollectionBuiltinName,
24
+ MCPGlobalBuiltinName,
25
+ } from './mcp/builtinTools.js'
11
26
 
12
- export type MCPPluginConfig = {
13
- /**
14
- * Set the collections that should be available as resources via MCP.
15
- */
16
- collections?: Partial<
17
- Record<
18
- CollectionSlug,
19
- {
20
- /**
21
- * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.
22
- */
23
- description?: string
24
- /**
25
- * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.
26
- */
27
- enabled:
28
- | {
29
- create?: boolean
30
- delete?: boolean
31
- find?: boolean
32
- update?: boolean
33
- }
34
- | boolean
35
-
36
- /**
37
- * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.
38
- */
39
- overrideResponse?: (
40
- response: {
41
- content: Array<{
42
- text: string
43
- type: string
44
- }>
45
- },
46
- doc: Record<string, unknown>,
47
- req: PayloadRequest,
48
- ) => {
49
- content: Array<{
50
- text: string
51
- type: string
52
- }>
53
- }
54
- }
55
- >
56
- >
57
- /**
58
- * Disable the MCP plugin.
59
- */
60
- disabled?: boolean
61
- /**
62
- * Experimental features
63
- * **These features are for experimental purposes -- They are Disabled in Production by Default**
64
- */
65
- experimental?: {
66
- /**
67
- * These are MCP tools that can be used by a client to modify Payload.
68
- */
69
- tools: {
70
- /**
71
- * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.
72
- */
73
- auth?: {
74
- /**
75
- * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.
76
- * @default false
77
- */
78
- enabled: boolean
79
- }
80
- /**
81
- * **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.
82
- */
83
- collections?: {
84
- /**
85
- * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.
86
- */
87
- collectionsDirPath: string
88
- /**
89
- * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.
90
- * @default false
91
- */
92
- enabled: boolean
93
- }
94
- /**
95
- * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.
96
- */
97
- config?: {
98
- /**
99
- * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.
100
- */
101
- configFilePath: string
102
- /**
103
- * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.
104
- * @default false
105
- */
106
- enabled: boolean
107
- }
108
- /**
109
- * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.
110
- */
111
- jobs?: {
112
- /**
113
- * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.
114
- * @default false
115
- */
116
- enabled: boolean
117
- /**
118
- * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.
119
- */
120
- jobsDirPath: string
121
- }
122
- }
123
- }
124
- /**
125
- * Set the globals that should be available as resources via MCP.
126
- * Globals are singleton configuration objects (e.g., site settings, navigation).
127
- * Note: Globals only support find and update operations.
128
- */
129
- globals?: Partial<
130
- Record<
131
- GlobalSlug,
132
- {
133
- /**
134
- * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.
135
- */
136
- description?: string
137
- /**
138
- * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.
139
- * Note: Globals only support find and update operations as they are singletons.
140
- */
141
- enabled:
142
- | {
143
- find?: boolean
144
- update?: boolean
145
- }
146
- | boolean
147
-
148
- /**
149
- * Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.
150
- */
151
- overrideResponse?: (
152
- response: {
153
- content: Array<{
154
- text: string
155
- type: string
156
- }>
157
- },
158
- doc: Record<string, unknown>,
159
- req: PayloadRequest,
160
- ) => {
161
- content: Array<{
162
- text: string
163
- type: string
164
- }>
165
- }
166
- }
167
- >
168
- >
169
- /**
170
- * MCP Server options.
171
- */
172
- mcp?: {
173
- handlerOptions?: MCPHandlerOptions
174
- /**
175
- * Add custom MCP Prompts.
176
- */
177
- prompts?: {
178
- /**
179
- * Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.
180
- */
181
- argsSchema: z.ZodRawShape
182
- /**
183
- * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.
184
- */
185
- description: string
186
- /**
187
- * Set the handler of the prompt. This is the function that will be called when the prompt is used.
188
- */
189
- handler: (
190
- args: Record<string, unknown>,
191
- req: PayloadRequest,
192
- _extra: unknown,
193
- ) =>
194
- | {
195
- messages: Array<{
196
- content: {
197
- text: string
198
- type: 'text'
199
- }
200
- role: 'assistant' | 'user'
201
- }>
202
- }
203
- | Promise<{
204
- messages: Array<{
205
- content: {
206
- text: string
207
- type: 'text'
208
- }
209
- role: 'assistant' | 'user'
210
- }>
211
- }>
212
- /**
213
- * Set the function name of the prompt.
214
- */
215
- name: string
216
- /**
217
- * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.
218
- */
219
- title: string
220
- }[]
221
-
222
- /**
223
- * Add custom MCP Resource.
224
- */
225
- resources?: {
226
- /**
227
- * Set the description of the resource. This is used by MCP clients to determine when to use the resource.
228
- * example: 'Data is a resource that contains special data.'
229
- */
230
- description: string
231
- /**
232
- * Set the handler of the resource. This is the function that will be called when the resource is used.
233
- * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).
234
- */
235
- handler: (...args: any[]) =>
236
- | {
237
- contents: Array<{
238
- text: string
239
- uri: string
240
- }>
241
- }
242
- | Promise<{
243
- contents: Array<{
244
- text: string
245
- uri: string
246
- }>
247
- }>
248
- /**
249
- * Set the mime type of the resource.
250
- * example: 'text/plain'
251
- */
252
- mimeType: string
253
- /**
254
- * Set the function name of the resource.
255
- * example: 'data'
256
- */
257
- name: string
258
- /**
259
- * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.
260
- * example: 'Data'
261
- */
262
- title: string
263
- /**
264
- * Set the uri of the resource.
265
- * example: 'data://app'
266
- */
267
- uri: ResourceTemplate | string
268
- }[]
269
- serverOptions?: MCPServerOptions
270
- /**
271
- * Add custom MCP Tools.
272
- */
273
- tools?: {
274
- /**
275
- * Set the description of the tool. This is used by MCP clients to determine when to use the tool.
276
- */
277
- description: string
278
- /**
279
- * Set the handler of the tool. This is the function that will be called when the tool is used.
280
- */
281
- handler: (
282
- args: Record<string, unknown>,
283
- req: PayloadRequest,
284
- _extra: unknown,
285
- ) =>
286
- | {
287
- content: Array<{
288
- text: string
289
- type: 'text'
290
- }>
291
- role?: string
292
- }
293
- | Promise<{
294
- content: Array<{
295
- text: string
296
- type: 'text'
297
- }>
298
- role?: string
299
- }>
300
- /**
301
- * Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.
302
- */
303
- name: string
304
- /**
305
- * Set the parameters of the tool. This is the parameters that will be passed to the tool.
306
- */
307
- parameters: z.ZodRawShape
308
- }[]
309
- }
27
+ export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }
310
28
 
311
- /**
312
- * Override the API key collection.
313
- * This allows you to add fields to the API key collection or modify the collection in any way you want.
314
- * @param collection - The API key collection.
315
- * @returns The modified API key collection.
316
- */
317
- overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig
29
+ /** Re-exported from `@modelcontextprotocol/server` — the JSON Schema shape the MCP runtime validates against. */
30
+ export type { JsonSchemaType, StandardSchemaWithJSON }
31
+
32
+ /**
33
+ * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
34
+ * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
35
+ */
36
+ export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON
37
+
38
+ /**
39
+ * Serializable mirror of `SanitizedMCPPluginConfig` for client components —
40
+ * the full sanitized config carries functions (tool handlers, etc.) that can't
41
+ * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
42
+ * passed to the `AccessField` component via `clientProps`.
43
+ *
44
+ * @internal
45
+ */
46
+ export type ClientMCPPluginConfig = {
47
+ items: Array<{
48
+ collectionSlug?: string
49
+ configKey: string
50
+ description: string
51
+ globalSlug?: string
52
+ label: string
53
+ type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'
54
+ }>
55
+ }
318
56
 
57
+ export type MCPToolResponse = {
58
+ content: ContentBlock[]
319
59
  /**
320
- * Override the authentication method.
321
- * This allows you to use a custom authentication method instead of the default API key authentication.
322
- * @param req - The request object.
323
- * @returns The MCP access settings.
60
+ * If available, return the document fetched within the
61
+ * mcp tool. This is threaded as an additional argument to
62
+ * overrideResponse functions and stripped before going on the wire.
324
63
  */
325
- overrideAuth?: (
326
- req: PayloadRequest,
327
- getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,
328
- ) => MCPAccessSettings | Promise<MCPAccessSettings>
64
+ doc?: Record<string, unknown>
65
+ } & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>
329
66
 
67
+ export type MCPResponseOverride = (
68
+ response: MCPToolResponse,
69
+ doc: Record<string, unknown>,
70
+ req: PayloadRequest,
71
+ ) => MCPToolResponse
72
+
73
+ /**
74
+ * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets
75
+ * its inferred output; anything else falls back to `Record<string, unknown>`.
76
+ */
77
+ export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON
78
+ ? StandardSchemaWithJSON extends TSchema
79
+ ? Record<string, unknown>
80
+ : StandardSchemaWithJSON.InferOutput<TSchema>
81
+ : Record<string, unknown>
82
+
83
+ export type ToolHandlerArgs<TSchema = undefined> = {
84
+ authorizedMCP: AuthorizedMCP
85
+ input: TypedInput<TSchema>
86
+ req: PayloadRequest
87
+ serverContext: ServerContext
88
+ }
89
+
90
+ export type CollectionToolHandlerArgs<TSchema = undefined> = {
91
+ collectionSlug: CollectionSlug
92
+ } & ToolHandlerArgs<TSchema>
93
+
94
+ export type GlobalToolHandlerArgs<TSchema = undefined> = {
95
+ globalSlug: GlobalSlug
96
+ } & ToolHandlerArgs<TSchema>
97
+
98
+ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
99
+ description: string
100
+ handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
101
+ input?: TSchema
330
102
  /**
331
- * Set the users collection that API keys should be associated with.
103
+ * Override the return value of the tool handler
332
104
  */
333
- userCollection?: CollectionSlug
105
+ overrideResponse?: MCPResponseOverride
334
106
  }
335
107
 
108
+ export type CollectionTool<
109
+ TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
110
+ > = {
111
+ handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
112
+ input?: TSchema
113
+ } & Pick<Tool, 'description' | 'overrideResponse'>
114
+
115
+ export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =
116
+ {
117
+ handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
118
+ input?: TSchema
119
+ } & Pick<Tool, 'description' | 'overrideResponse'>
120
+
336
121
  /**
337
- * MCP Handler options.
122
+ * Configures (or disables) a built-in tool without replacing it.
123
+ * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
124
+ * required handler) from being silently accepted at a built-in key slot.
338
125
  */
339
- export type MCPHandlerOptions = {
340
- /**
341
- * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.
342
- * @default /api
343
- */
344
- basePath?: string
345
- /**
346
- * If true, disables the SSE endpoint. Only Streamable HTTP will be available.
347
- * @default true
348
- */
349
- disableSse?: boolean
350
- /**
351
- * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.
352
- * @default 60
353
- */
354
- maxDuration?: number
355
- /**
356
- * Callback function that receives MCP events.
357
- * This can be used to track analytics, debug issues, or implement custom behaviors.
358
- */
359
- onEvent?: (event: unknown) => void
360
- /**
361
- * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.
362
- * @default process.env.REDIS_URL
363
- */
364
- redisUrl?: string
365
- /**
366
- * Set verbose logging.
367
- * @default false
368
- */
369
- verboseLogs?: boolean
126
+ export type MCPBuiltInToolOverride = {
127
+ description?: string
128
+ handler?: never
129
+ overrideResponse?: MCPResponseOverride
370
130
  }
371
131
 
372
132
  /**
373
- * MCP Server options.
133
+ * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`
134
+ * to disable it (useful when one plugin defines a custom tool and another
135
+ * wants to opt out per-collection).
374
136
  */
375
- export type MCPServerOptions = {
376
- /**
377
- * Optional instructions describing how to use the server and its features.
378
- */
379
- instructions?: string
380
- /**
381
- * Set the server info of the MCP server.
382
- */
383
- serverInfo?: {
384
- /**
385
- * Set the name of the MCP server.
386
- * @default 'Payload MCP Server'
387
- */
388
- name: string
389
- /**
390
- * Set the version of the MCP server.
391
- * @default '1.0.0'
392
- */
393
- version: string
394
- }
137
+ export type MCPTopLevelToolEntry = Tool
138
+
139
+ export type MCPCollectionToolsMap = {
140
+ [customToolName: string]: boolean | CollectionTool | MCPBuiltInToolOverride | undefined
141
+ } & {
142
+ [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride
395
143
  }
396
144
 
397
- export type MCPAccessSettings = {
398
- auth?: {
399
- auth?: boolean
400
- forgotPassword?: boolean
401
- login?: boolean
402
- resetPassword?: boolean
403
- unlock?: boolean
404
- verify?: boolean
405
- }
406
- collections?: {
407
- create?: boolean
408
- delete?: boolean
409
- find?: boolean
410
- update?: boolean
411
- }
412
- config?: {
413
- find?: boolean
414
- update?: boolean
415
- }
416
- custom?: Record<string, boolean>
417
- globals?: {
418
- find?: boolean
419
- update?: boolean
420
- }
421
- jobs?: {
422
- create?: boolean
423
- run?: boolean
424
- update?: boolean
425
- }
426
- 'payload-mcp-prompt'?: Record<string, boolean>
427
- 'payload-mcp-resource'?: Record<string, boolean>
428
- 'payload-mcp-tool'?: Record<string, boolean>
429
- user: TypedUser
430
- } & Record<string, unknown>
145
+ export type MCPAuthCollectionToolsMap = {
146
+ [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | true
147
+ } & MCPCollectionToolsMap
431
148
 
432
- export type EntityConfig = MCPPluginConfig['collections'] | MCPPluginConfig['globals']
149
+ /** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
150
+ export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug
151
+ ? MCPAuthCollectionToolsMap
152
+ : MCPCollectionToolsMap
433
153
 
434
- export type FieldDefinition = {
435
- description?: string
436
- name: string
437
- options?: { label: string; value: string }[]
438
- position?: 'main' | 'sidebar'
439
- required?: boolean
440
- type: string
154
+ export type MCPGlobalToolsMap = {
155
+ [customToolName: string]: boolean | GlobalTool | MCPBuiltInToolOverride | undefined
156
+ } & {
157
+ [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride
441
158
  }
442
159
 
443
- export type FieldModification = {
444
- changes: {
445
- description?: string
446
- options?: { label: string; value: string }[]
447
- position?: 'main' | 'sidebar'
448
- required?: boolean
449
- type?: string
450
- }
451
- fieldName: string
160
+ export type MCPTopLevelToolsMap = Record<string, Tool>
161
+
162
+ export type PromptHandlerArgs<TSchema = undefined> = {
163
+ input: TypedInput<TSchema>
164
+ req: PayloadRequest
165
+ serverContext: ServerContext
452
166
  }
453
167
 
454
- export type CollectionConfigUpdates = {
455
- access?: {
456
- create?: string
457
- delete?: string
458
- read?: string
459
- update?: string
460
- }
168
+ export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
169
+ argsSchema: TSchema
170
+ description: string
171
+ handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
172
+ messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>
173
+ }>
174
+ title: string
175
+ }
176
+
177
+ export type ResourceHandlerArgs = {
178
+ /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */
179
+ params: Record<string, string>
180
+ req: PayloadRequest
181
+ serverContext: ServerContext
182
+ uri: URL
183
+ }
184
+
185
+ export type Resource = {
186
+ description: string
187
+ handler: (args: ResourceHandlerArgs) => MaybePromise<{
188
+ contents: Array<{ text: string; uri: string }>
189
+ }>
190
+ mimeType: string
191
+ title: string
192
+ uri: ResourceTemplate | string
193
+ }
194
+
195
+ export type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {
196
+ description?: string
197
+ /** Fallback for built-in tools that don't set their own `overrideResponse`. */
198
+ overrideResponse?: MCPResponseOverride
199
+ tools?: MCPToolsMapForCollection<TSlug>
200
+ }
201
+
202
+ export type MCPPluginGlobalConfig = {
461
203
  description?: string
462
- slug?: string
463
- timestamps?: boolean
464
- versioning?: boolean
204
+ overrideResponse?: MCPResponseOverride
205
+ tools?: MCPGlobalToolsMap
465
206
  }
466
207
 
467
- export type AdminConfig = {
468
- avatar?: string
469
- css?: string
470
- dateFormat?: string
471
- inactivityRoute?: string
472
- livePreview?: {
473
- breakpoints?: Array<{
474
- height: number
475
- label: string
476
- name: string
477
- width: number
478
- }>
208
+ /**
209
+ * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,
210
+ * resources, and per-collection/global tool maps live in their own nested
211
+ * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults
212
+ * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer
213
+ * actually works with.
214
+ */
215
+ export type MCPPluginConfig = {
216
+ collections?: {
217
+ [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>
218
+ }
219
+ /** Skip MCP registration. The API key collection is still added (so DB / types stay stable). */
220
+ disabled?: boolean
221
+ globals?: {
222
+ [Slug in GlobalSlug]?: MCPPluginGlobalConfig
479
223
  }
480
- logoutRoute?: string
481
- meta?: {
482
- favicon?: string
483
- ogImage?: string
484
- titleSuffix?: string
224
+ mcp?: {
225
+ serverOptions?: MCPServerOptions
226
+ verboseLogs?: boolean
485
227
  }
486
- user?: string
228
+ overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig
229
+ /** Replace the default API-key auth with a custom resolver. */
230
+ overrideAuth?: (args: {
231
+ getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>
232
+ getAuthorizedMCP: (args: { apiKeyDoc: MCPAPIKeysDoc }) => AuthorizedMCP
233
+ pluginConfig: SanitizedMCPPluginConfig
234
+ req: PayloadRequest
235
+ }) => MaybePromise<AuthorizedMCP>
236
+ prompts?: Record<string, Prompt>
237
+ resources?: Record<string, Resource>
238
+ /** Cross-cutting tools (not scoped to any collection or global). */
239
+ tools?: MCPTopLevelToolsMap
240
+ userCollection?: CollectionSlug
487
241
  }
488
242
 
489
- export type DatabaseConfig = {
490
- connectOptions?: string
491
- type?: 'mongodb' | 'postgres'
492
- url?: string
493
- }
243
+ export type SanitizedMCPPluginConfig = {
244
+ items: MCPItem[]
245
+ userCollection: CollectionSlug
246
+ } & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>
494
247
 
495
- export type PluginUpdates = {
496
- add?: string[]
497
- remove?: string[]
248
+ export type MCPServerOptions = {
249
+ options?: ConstructorParameters<typeof McpServer>[1]
250
+ serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>
498
251
  }
499
252
 
500
- export type GeneralConfig = {
501
- cookiePrefix?: string
502
- cors?: string
503
- csrf?: string
504
- graphQL?: {
505
- disable?: boolean
506
- schemaOutputFile?: string
253
+ /**
254
+ * Nested access tree as stored in the collection.
255
+ * A `false` leaf disables that tool; missing keys defer to
256
+ * defaults (built-in CRUD is on, opt-in tools are off).
257
+ */
258
+ export type MCPAPIKeysDocAccessTree = {
259
+ collections?: {
260
+ [CollectionSlug: CollectionSlug]: {
261
+ [ToolKey: string]: boolean
262
+ }
263
+ }
264
+ globals?: {
265
+ [GlobalSlug: GlobalSlug]: {
266
+ [ToolKey: string]: boolean
267
+ }
268
+ }
269
+ prompts?: {
270
+ [PromptKey: string]: boolean
507
271
  }
508
- rateLimit?: {
509
- max?: number
510
- skip?: string
511
- window?: number
272
+ resources?: {
273
+ [ResourceKey: string]: boolean
512
274
  }
513
- secret?: string
514
- serverURL?: string
515
- typescript?: {
516
- declare?: boolean
517
- outputFile?: string
275
+ tools?: {
276
+ [ToolKey: string]: boolean
518
277
  }
519
278
  }
520
279
 
521
- export interface SchemaField {
522
- description?: string
523
- name: string
524
- options?: string[]
525
- required?: boolean
526
- type: string
280
+ /**
281
+ * Stored on `payload-mcp-api-keys` docs
282
+ */
283
+ export type MCPAPIKeysDoc = {
284
+ access: MCPAPIKeysDocAccessTree
285
+ id: DefaultDocumentIDType
286
+ overrideAccess?: boolean
287
+ user: null | TypedUser
527
288
  }
528
289
 
529
- export interface TaskSequenceItem {
530
- description?: string
531
- retries?: number
532
- taskId: string
533
- taskSlug: string
534
- timeout?: number
290
+ /**
291
+ * One MCP primitive plus the metadata needed for access checks, admin UI, and
292
+ * registration.
293
+ *
294
+ * - `configKey`: the config/API-key identifier, e.g. `find` or `echo`.
295
+ * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
296
+ * - `label`: human-readable admin checkbox text.
297
+ */
298
+ export type MCPItemBase = {
299
+ configKey: string
300
+ label: string
301
+ mcpName: string
535
302
  }
536
303
 
537
- export interface JobConfigUpdate {
538
- description?: string
539
- queue?: string
540
- retries?: number
541
- timeout?: number
304
+ export type CollectionMCPItem = {
305
+ collectionSlug: CollectionSlug
306
+ tool: CollectionTool
307
+ type: 'collectionTool'
308
+ } & MCPItemBase
309
+
310
+ export type GlobalMCPItem = {
311
+ globalSlug: GlobalSlug
312
+ tool: GlobalTool
313
+ type: 'globalTool'
314
+ } & MCPItemBase
315
+
316
+ export type MCPItem =
317
+ | ({
318
+ prompt: Prompt
319
+ type: 'prompt'
320
+ } & MCPItemBase)
321
+ | ({
322
+ resource: Resource
323
+ type: 'resource'
324
+ } & MCPItemBase)
325
+ | ({
326
+ tool: Tool
327
+ type: 'tool'
328
+ } & MCPItemBase)
329
+ | CollectionMCPItem
330
+ | GlobalMCPItem
331
+
332
+ /**
333
+ * The caller's identity + the MCP items they can use for this request. Returned
334
+ * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
335
+ * receive this via `args.authorizedMCP` so they can spread
336
+ * `localAPIDefaults(authorizedMCP)` into every local API call.
337
+ */
338
+ export type AuthorizedMCP = {
339
+ items: MCPItem[]
340
+ overrideAccess: boolean
341
+ user: null | TypedUser
542
342
  }