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

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 (420) hide show
  1. package/dist/defaultAccess.d.ts +3 -0
  2. package/dist/defaultAccess.d.ts.map +1 -0
  3. package/dist/defaultAccess.js +3 -0
  4. package/dist/defaultAccess.js.map +1 -0
  5. package/dist/endpoint/access.d.ts +17 -5
  6. package/dist/endpoint/access.d.ts.map +1 -1
  7. package/dist/endpoint/access.js +81 -103
  8. package/dist/endpoint/access.js.map +1 -1
  9. package/dist/endpoint/index.d.ts.map +1 -1
  10. package/dist/endpoint/index.js +11 -0
  11. package/dist/endpoint/index.js.map +1 -1
  12. package/dist/exports/client.d.ts +1 -4
  13. package/dist/exports/client.d.ts.map +1 -1
  14. package/dist/exports/client.js +1 -4
  15. package/dist/exports/client.js.map +1 -1
  16. package/dist/exports/internal.d.ts +2 -0
  17. package/dist/exports/internal.d.ts.map +1 -0
  18. package/dist/exports/internal.js +3 -0
  19. package/dist/exports/internal.js.map +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1 -49
  22. package/dist/index.js.map +1 -1
  23. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  24. package/dist/mcp/buildMcpServer.js +2 -0
  25. package/dist/mcp/buildMcpServer.js.map +1 -1
  26. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  27. package/dist/mcp/builtin/collections/authTools.js +44 -6
  28. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  29. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  30. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  31. package/dist/mcp/builtin/collections/countTool.js +69 -0
  32. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  33. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  34. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  35. package/dist/mcp/builtin/collections/countVersionsTool.js +65 -0
  36. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  37. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  38. package/dist/mcp/builtin/collections/createTool.js +12 -19
  39. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  40. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  41. package/dist/mcp/builtin/collections/deleteTool.js +9 -0
  42. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  43. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  44. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  45. package/dist/mcp/builtin/collections/duplicateTool.js +97 -0
  46. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  47. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  48. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  49. package/dist/mcp/builtin/collections/findDistinctTool.js +93 -0
  50. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  51. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  52. package/dist/mcp/builtin/collections/findTool.js +43 -22
  53. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  54. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  55. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  56. package/dist/mcp/builtin/collections/findVersionByIDTool.js +84 -0
  57. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  58. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  59. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  60. package/dist/mcp/builtin/collections/findVersionsTool.js +99 -0
  61. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  62. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  63. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  64. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
  65. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  66. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +12 -0
  67. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  68. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  69. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  70. package/dist/mcp/builtin/collections/restoreVersionTool.js +82 -0
  71. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  72. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  73. package/dist/mcp/builtin/collections/updateTool.js +14 -21
  74. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  75. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  76. package/dist/mcp/builtin/getConfigInfoTool.js +27 -5
  77. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  78. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  79. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  80. package/dist/mcp/builtin/globals/countVersionsTool.js +65 -0
  81. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  82. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  83. package/dist/mcp/builtin/globals/findTool.js +17 -20
  84. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  85. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  86. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  87. package/dist/mcp/builtin/globals/findVersionByIDTool.js +80 -0
  88. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  89. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  90. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  91. package/dist/mcp/builtin/globals/findVersionsTool.js +95 -0
  92. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  93. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  94. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +12 -0
  95. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  96. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  97. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  98. package/dist/mcp/builtin/globals/restoreVersionTool.js +78 -0
  99. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  100. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  101. package/dist/mcp/builtin/globals/updateTool.js +12 -19
  102. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  103. package/dist/mcp/builtinTools.d.ts +69 -12
  104. package/dist/mcp/builtinTools.d.ts.map +1 -1
  105. package/dist/mcp/builtinTools.js +66 -10
  106. package/dist/mcp/builtinTools.js.map +1 -1
  107. package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
  108. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  109. package/dist/mcp/sanitizeMCPConfig.js +68 -27
  110. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  111. package/dist/stdio.d.ts +3 -2
  112. package/dist/stdio.d.ts.map +1 -1
  113. package/dist/stdio.js +27 -8
  114. package/dist/stdio.js.map +1 -1
  115. package/dist/types.d.ts +50 -90
  116. package/dist/types.d.ts.map +1 -1
  117. package/dist/types.js +4 -4
  118. package/dist/types.js.map +1 -1
  119. package/dist/utils/getPluginConfig.d.ts +1 -1
  120. package/dist/utils/getPluginConfig.js +1 -1
  121. package/dist/utils/getPluginConfig.js.map +1 -1
  122. package/package.json +9 -13
  123. package/src/defaultAccess.ts +3 -0
  124. package/src/endpoint/access.ts +87 -112
  125. package/src/endpoint/index.ts +14 -1
  126. package/src/exports/client.ts +2 -4
  127. package/src/exports/internal.ts +1 -0
  128. package/src/index.ts +1 -55
  129. package/src/mcp/buildMcpServer.ts +8 -1
  130. package/src/mcp/builtin/collections/authTools.ts +45 -9
  131. package/src/mcp/builtin/collections/countTool.ts +74 -0
  132. package/src/mcp/builtin/collections/countVersionsTool.ts +70 -0
  133. package/src/mcp/builtin/collections/createTool.ts +13 -13
  134. package/src/mcp/builtin/collections/deleteTool.ts +10 -0
  135. package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
  136. package/src/mcp/builtin/collections/findDistinctTool.ts +120 -0
  137. package/src/mcp/builtin/collections/findTool.ts +56 -16
  138. package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
  139. package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
  140. package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
  141. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +18 -0
  142. package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
  143. package/src/mcp/builtin/collections/updateTool.ts +14 -14
  144. package/src/mcp/builtin/getConfigInfoTool.ts +29 -4
  145. package/src/mcp/builtin/globals/countVersionsTool.ts +69 -0
  146. package/src/mcp/builtin/globals/findTool.ts +25 -16
  147. package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
  148. package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
  149. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +13 -0
  150. package/src/mcp/builtin/globals/restoreVersionTool.ts +100 -0
  151. package/src/mcp/builtin/globals/updateTool.ts +14 -14
  152. package/src/mcp/builtinTools.ts +72 -16
  153. package/src/mcp/sanitizeMCPConfig.ts +47 -30
  154. package/src/stdio.ts +23 -8
  155. package/src/types.ts +57 -92
  156. package/src/utils/getPluginConfig.ts +1 -1
  157. package/dist/collection/getAccessField.d.ts +0 -12
  158. package/dist/collection/getAccessField.d.ts.map +0 -1
  159. package/dist/collection/getAccessField.js +0 -72
  160. package/dist/collection/getAccessField.js.map +0 -1
  161. package/dist/collection/index.d.ts +0 -6
  162. package/dist/collection/index.d.ts.map +0 -1
  163. package/dist/collection/index.js +0 -105
  164. package/dist/collection/index.js.map +0 -1
  165. package/dist/components/APIKeyField/index.client.d.ts +0 -9
  166. package/dist/components/APIKeyField/index.client.d.ts.map +0 -1
  167. package/dist/components/APIKeyField/index.client.js +0 -85
  168. package/dist/components/APIKeyField/index.client.js.map +0 -1
  169. package/dist/components/APIKeyField/index.css +0 -105
  170. package/dist/components/APIKeysEmptyState/index.client.d.ts +0 -4
  171. package/dist/components/APIKeysEmptyState/index.client.d.ts.map +0 -1
  172. package/dist/components/APIKeysEmptyState/index.client.js +0 -21
  173. package/dist/components/APIKeysEmptyState/index.client.js.map +0 -1
  174. package/dist/components/AccessField/index.client.d.ts +0 -10
  175. package/dist/components/AccessField/index.client.d.ts.map +0 -1
  176. package/dist/components/AccessField/index.client.js +0 -247
  177. package/dist/components/AccessField/index.client.js.map +0 -1
  178. package/dist/components/AccessField/index.css +0 -99
  179. package/dist/components/SettingsMenu/index.client.d.ts +0 -8
  180. package/dist/components/SettingsMenu/index.client.d.ts.map +0 -1
  181. package/dist/components/SettingsMenu/index.client.js +0 -29
  182. package/dist/components/SettingsMenu/index.client.js.map +0 -1
  183. package/dist/translations/index.d.ts +0 -11
  184. package/dist/translations/index.d.ts.map +0 -1
  185. package/dist/translations/index.js +0 -92
  186. package/dist/translations/index.js.map +0 -1
  187. package/dist/translations/languages/ar.d.ts +0 -31
  188. package/dist/translations/languages/ar.d.ts.map +0 -1
  189. package/dist/translations/languages/ar.js +0 -34
  190. package/dist/translations/languages/ar.js.map +0 -1
  191. package/dist/translations/languages/az.d.ts +0 -31
  192. package/dist/translations/languages/az.d.ts.map +0 -1
  193. package/dist/translations/languages/az.js +0 -34
  194. package/dist/translations/languages/az.js.map +0 -1
  195. package/dist/translations/languages/bg.d.ts +0 -31
  196. package/dist/translations/languages/bg.d.ts.map +0 -1
  197. package/dist/translations/languages/bg.js +0 -34
  198. package/dist/translations/languages/bg.js.map +0 -1
  199. package/dist/translations/languages/bnBd.d.ts +0 -31
  200. package/dist/translations/languages/bnBd.d.ts.map +0 -1
  201. package/dist/translations/languages/bnBd.js +0 -34
  202. package/dist/translations/languages/bnBd.js.map +0 -1
  203. package/dist/translations/languages/bnIn.d.ts +0 -31
  204. package/dist/translations/languages/bnIn.d.ts.map +0 -1
  205. package/dist/translations/languages/bnIn.js +0 -34
  206. package/dist/translations/languages/bnIn.js.map +0 -1
  207. package/dist/translations/languages/ca.d.ts +0 -31
  208. package/dist/translations/languages/ca.d.ts.map +0 -1
  209. package/dist/translations/languages/ca.js +0 -34
  210. package/dist/translations/languages/ca.js.map +0 -1
  211. package/dist/translations/languages/cs.d.ts +0 -31
  212. package/dist/translations/languages/cs.d.ts.map +0 -1
  213. package/dist/translations/languages/cs.js +0 -34
  214. package/dist/translations/languages/cs.js.map +0 -1
  215. package/dist/translations/languages/da.d.ts +0 -31
  216. package/dist/translations/languages/da.d.ts.map +0 -1
  217. package/dist/translations/languages/da.js +0 -34
  218. package/dist/translations/languages/da.js.map +0 -1
  219. package/dist/translations/languages/de.d.ts +0 -31
  220. package/dist/translations/languages/de.d.ts.map +0 -1
  221. package/dist/translations/languages/de.js +0 -34
  222. package/dist/translations/languages/de.js.map +0 -1
  223. package/dist/translations/languages/en.d.ts +0 -31
  224. package/dist/translations/languages/en.d.ts.map +0 -1
  225. package/dist/translations/languages/en.js +0 -34
  226. package/dist/translations/languages/en.js.map +0 -1
  227. package/dist/translations/languages/es.d.ts +0 -31
  228. package/dist/translations/languages/es.d.ts.map +0 -1
  229. package/dist/translations/languages/es.js +0 -34
  230. package/dist/translations/languages/es.js.map +0 -1
  231. package/dist/translations/languages/et.d.ts +0 -31
  232. package/dist/translations/languages/et.d.ts.map +0 -1
  233. package/dist/translations/languages/et.js +0 -34
  234. package/dist/translations/languages/et.js.map +0 -1
  235. package/dist/translations/languages/fa.d.ts +0 -31
  236. package/dist/translations/languages/fa.d.ts.map +0 -1
  237. package/dist/translations/languages/fa.js +0 -34
  238. package/dist/translations/languages/fa.js.map +0 -1
  239. package/dist/translations/languages/fr.d.ts +0 -31
  240. package/dist/translations/languages/fr.d.ts.map +0 -1
  241. package/dist/translations/languages/fr.js +0 -34
  242. package/dist/translations/languages/fr.js.map +0 -1
  243. package/dist/translations/languages/he.d.ts +0 -31
  244. package/dist/translations/languages/he.d.ts.map +0 -1
  245. package/dist/translations/languages/he.js +0 -34
  246. package/dist/translations/languages/he.js.map +0 -1
  247. package/dist/translations/languages/hr.d.ts +0 -31
  248. package/dist/translations/languages/hr.d.ts.map +0 -1
  249. package/dist/translations/languages/hr.js +0 -34
  250. package/dist/translations/languages/hr.js.map +0 -1
  251. package/dist/translations/languages/hu.d.ts +0 -31
  252. package/dist/translations/languages/hu.d.ts.map +0 -1
  253. package/dist/translations/languages/hu.js +0 -34
  254. package/dist/translations/languages/hu.js.map +0 -1
  255. package/dist/translations/languages/hy.d.ts +0 -31
  256. package/dist/translations/languages/hy.d.ts.map +0 -1
  257. package/dist/translations/languages/hy.js +0 -34
  258. package/dist/translations/languages/hy.js.map +0 -1
  259. package/dist/translations/languages/id.d.ts +0 -31
  260. package/dist/translations/languages/id.d.ts.map +0 -1
  261. package/dist/translations/languages/id.js +0 -34
  262. package/dist/translations/languages/id.js.map +0 -1
  263. package/dist/translations/languages/is.d.ts +0 -31
  264. package/dist/translations/languages/is.d.ts.map +0 -1
  265. package/dist/translations/languages/is.js +0 -34
  266. package/dist/translations/languages/is.js.map +0 -1
  267. package/dist/translations/languages/it.d.ts +0 -31
  268. package/dist/translations/languages/it.d.ts.map +0 -1
  269. package/dist/translations/languages/it.js +0 -34
  270. package/dist/translations/languages/it.js.map +0 -1
  271. package/dist/translations/languages/ja.d.ts +0 -31
  272. package/dist/translations/languages/ja.d.ts.map +0 -1
  273. package/dist/translations/languages/ja.js +0 -34
  274. package/dist/translations/languages/ja.js.map +0 -1
  275. package/dist/translations/languages/ko.d.ts +0 -31
  276. package/dist/translations/languages/ko.d.ts.map +0 -1
  277. package/dist/translations/languages/ko.js +0 -34
  278. package/dist/translations/languages/ko.js.map +0 -1
  279. package/dist/translations/languages/lt.d.ts +0 -31
  280. package/dist/translations/languages/lt.d.ts.map +0 -1
  281. package/dist/translations/languages/lt.js +0 -34
  282. package/dist/translations/languages/lt.js.map +0 -1
  283. package/dist/translations/languages/lv.d.ts +0 -31
  284. package/dist/translations/languages/lv.d.ts.map +0 -1
  285. package/dist/translations/languages/lv.js +0 -34
  286. package/dist/translations/languages/lv.js.map +0 -1
  287. package/dist/translations/languages/my.d.ts +0 -31
  288. package/dist/translations/languages/my.d.ts.map +0 -1
  289. package/dist/translations/languages/my.js +0 -34
  290. package/dist/translations/languages/my.js.map +0 -1
  291. package/dist/translations/languages/nb.d.ts +0 -31
  292. package/dist/translations/languages/nb.d.ts.map +0 -1
  293. package/dist/translations/languages/nb.js +0 -34
  294. package/dist/translations/languages/nb.js.map +0 -1
  295. package/dist/translations/languages/nl.d.ts +0 -31
  296. package/dist/translations/languages/nl.d.ts.map +0 -1
  297. package/dist/translations/languages/nl.js +0 -34
  298. package/dist/translations/languages/nl.js.map +0 -1
  299. package/dist/translations/languages/pl.d.ts +0 -31
  300. package/dist/translations/languages/pl.d.ts.map +0 -1
  301. package/dist/translations/languages/pl.js +0 -34
  302. package/dist/translations/languages/pl.js.map +0 -1
  303. package/dist/translations/languages/pt.d.ts +0 -31
  304. package/dist/translations/languages/pt.d.ts.map +0 -1
  305. package/dist/translations/languages/pt.js +0 -34
  306. package/dist/translations/languages/pt.js.map +0 -1
  307. package/dist/translations/languages/ro.d.ts +0 -31
  308. package/dist/translations/languages/ro.d.ts.map +0 -1
  309. package/dist/translations/languages/ro.js +0 -34
  310. package/dist/translations/languages/ro.js.map +0 -1
  311. package/dist/translations/languages/rs.d.ts +0 -31
  312. package/dist/translations/languages/rs.d.ts.map +0 -1
  313. package/dist/translations/languages/rs.js +0 -34
  314. package/dist/translations/languages/rs.js.map +0 -1
  315. package/dist/translations/languages/rsLatin.d.ts +0 -31
  316. package/dist/translations/languages/rsLatin.d.ts.map +0 -1
  317. package/dist/translations/languages/rsLatin.js +0 -34
  318. package/dist/translations/languages/rsLatin.js.map +0 -1
  319. package/dist/translations/languages/ru.d.ts +0 -31
  320. package/dist/translations/languages/ru.d.ts.map +0 -1
  321. package/dist/translations/languages/ru.js +0 -34
  322. package/dist/translations/languages/ru.js.map +0 -1
  323. package/dist/translations/languages/sk.d.ts +0 -31
  324. package/dist/translations/languages/sk.d.ts.map +0 -1
  325. package/dist/translations/languages/sk.js +0 -34
  326. package/dist/translations/languages/sk.js.map +0 -1
  327. package/dist/translations/languages/sl.d.ts +0 -31
  328. package/dist/translations/languages/sl.d.ts.map +0 -1
  329. package/dist/translations/languages/sl.js +0 -34
  330. package/dist/translations/languages/sl.js.map +0 -1
  331. package/dist/translations/languages/sv.d.ts +0 -31
  332. package/dist/translations/languages/sv.d.ts.map +0 -1
  333. package/dist/translations/languages/sv.js +0 -34
  334. package/dist/translations/languages/sv.js.map +0 -1
  335. package/dist/translations/languages/ta.d.ts +0 -31
  336. package/dist/translations/languages/ta.d.ts.map +0 -1
  337. package/dist/translations/languages/ta.js +0 -34
  338. package/dist/translations/languages/ta.js.map +0 -1
  339. package/dist/translations/languages/th.d.ts +0 -31
  340. package/dist/translations/languages/th.d.ts.map +0 -1
  341. package/dist/translations/languages/th.js +0 -34
  342. package/dist/translations/languages/th.js.map +0 -1
  343. package/dist/translations/languages/tr.d.ts +0 -31
  344. package/dist/translations/languages/tr.d.ts.map +0 -1
  345. package/dist/translations/languages/tr.js +0 -34
  346. package/dist/translations/languages/tr.js.map +0 -1
  347. package/dist/translations/languages/uk.d.ts +0 -31
  348. package/dist/translations/languages/uk.d.ts.map +0 -1
  349. package/dist/translations/languages/uk.js +0 -34
  350. package/dist/translations/languages/uk.js.map +0 -1
  351. package/dist/translations/languages/vi.d.ts +0 -31
  352. package/dist/translations/languages/vi.d.ts.map +0 -1
  353. package/dist/translations/languages/vi.js +0 -34
  354. package/dist/translations/languages/vi.js.map +0 -1
  355. package/dist/translations/languages/zh.d.ts +0 -31
  356. package/dist/translations/languages/zh.d.ts.map +0 -1
  357. package/dist/translations/languages/zh.js +0 -34
  358. package/dist/translations/languages/zh.js.map +0 -1
  359. package/dist/translations/languages/zhTw.d.ts +0 -31
  360. package/dist/translations/languages/zhTw.d.ts.map +0 -1
  361. package/dist/translations/languages/zhTw.js +0 -34
  362. package/dist/translations/languages/zhTw.js.map +0 -1
  363. package/dist/translations/types.d.ts +0 -32
  364. package/dist/translations/types.d.ts.map +0 -1
  365. package/dist/translations/types.js +0 -3
  366. package/dist/translations/types.js.map +0 -1
  367. package/src/collection/getAccessField.ts +0 -84
  368. package/src/collection/index.ts +0 -105
  369. package/src/components/APIKeyField/index.client.tsx +0 -73
  370. package/src/components/APIKeyField/index.css +0 -105
  371. package/src/components/APIKeysEmptyState/index.client.tsx +0 -36
  372. package/src/components/AccessField/index.client.tsx +0 -299
  373. package/src/components/AccessField/index.css +0 -99
  374. package/src/components/SettingsMenu/index.client.tsx +0 -34
  375. package/src/translations/index.ts +0 -108
  376. package/src/translations/languages/ar.ts +0 -35
  377. package/src/translations/languages/az.ts +0 -35
  378. package/src/translations/languages/bg.ts +0 -35
  379. package/src/translations/languages/bnBd.ts +0 -35
  380. package/src/translations/languages/bnIn.ts +0 -35
  381. package/src/translations/languages/ca.ts +0 -35
  382. package/src/translations/languages/cs.ts +0 -35
  383. package/src/translations/languages/da.ts +0 -35
  384. package/src/translations/languages/de.ts +0 -35
  385. package/src/translations/languages/en.ts +0 -35
  386. package/src/translations/languages/es.ts +0 -35
  387. package/src/translations/languages/et.ts +0 -35
  388. package/src/translations/languages/fa.ts +0 -35
  389. package/src/translations/languages/fr.ts +0 -35
  390. package/src/translations/languages/he.ts +0 -35
  391. package/src/translations/languages/hr.ts +0 -35
  392. package/src/translations/languages/hu.ts +0 -35
  393. package/src/translations/languages/hy.ts +0 -35
  394. package/src/translations/languages/id.ts +0 -35
  395. package/src/translations/languages/is.ts +0 -35
  396. package/src/translations/languages/it.ts +0 -35
  397. package/src/translations/languages/ja.ts +0 -35
  398. package/src/translations/languages/ko.ts +0 -35
  399. package/src/translations/languages/lt.ts +0 -35
  400. package/src/translations/languages/lv.ts +0 -35
  401. package/src/translations/languages/my.ts +0 -35
  402. package/src/translations/languages/nb.ts +0 -35
  403. package/src/translations/languages/nl.ts +0 -35
  404. package/src/translations/languages/pl.ts +0 -35
  405. package/src/translations/languages/pt.ts +0 -35
  406. package/src/translations/languages/ro.ts +0 -35
  407. package/src/translations/languages/rs.ts +0 -35
  408. package/src/translations/languages/rsLatin.ts +0 -35
  409. package/src/translations/languages/ru.ts +0 -35
  410. package/src/translations/languages/sk.ts +0 -35
  411. package/src/translations/languages/sl.ts +0 -35
  412. package/src/translations/languages/sv.ts +0 -35
  413. package/src/translations/languages/ta.ts +0 -35
  414. package/src/translations/languages/th.ts +0 -35
  415. package/src/translations/languages/tr.ts +0 -35
  416. package/src/translations/languages/uk.ts +0 -35
  417. package/src/translations/languages/vi.ts +0 -35
  418. package/src/translations/languages/zh.ts +0 -35
  419. package/src/translations/languages/zhTw.ts +0 -35
  420. package/src/translations/types.ts +0 -34
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/sanitizeMCPConfig.ts"],"sourcesContent":["import type {\n CollectionConfig,\n Config,\n GlobalConfig,\n SanitizedCollectionConfig,\n SanitizedConfig,\n SanitizedGlobalConfig,\n} from 'payload'\n\nimport type {\n CollectionMCPItem,\n CollectionTool,\n GlobalMCPItem,\n GlobalTool,\n MCPItem,\n MCPPluginConfig,\n SanitizedMCPPluginConfig,\n} from '../types.js'\n\nimport {\n COLLECTION_AUTH_BUILTIN_ENTRIES,\n COLLECTION_AUTH_BUILTINS,\n COLLECTION_BUILTIN_ENTRIES,\n COLLECTION_BUILTINS,\n GLOBAL_BUILTIN_ENTRIES,\n GLOBAL_BUILTINS,\n TOOL_BUILTIN_ENTRIES,\n TOOL_BUILTINS,\n} from './builtinTools.js'\n\n/**\n * Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:\n * - Flattens `tools` / `prompts` / `resources` / per-collection / per-global\n * tool maps into a single `items` array.\n * - Applies built-in tools for collections and globals, respecting opt-out user overrides.\n * - Applies the `userCollection` default\n *\n * Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']\n * ?.options` holds the sanitized result\n */\nexport const sanitizeMCPConfig = ({\n config,\n pluginConfig,\n}: {\n config: Config | SanitizedConfig\n pluginConfig: MCPPluginConfig\n}): SanitizedMCPPluginConfig => {\n const items: MCPItem[] = []\n\n for (const collection of config.collections ?? []) {\n items.push(...sanitizeCollectionConfig({ collection, pluginConfig }))\n }\n\n for (const global of config.globals ?? []) {\n items.push(...sanitizeGlobalConfig({ global, pluginConfig }))\n }\n\n for (const [configKey, { label, mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {\n items.push({\n type: 'tool',\n configKey,\n label,\n mcpName,\n tool,\n })\n }\n\n for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})) {\n if (configKey in TOOL_BUILTINS) {\n continue\n }\n items.push({\n type: 'tool',\n configKey,\n label: configKey,\n mcpName: configKey,\n tool,\n })\n }\n\n for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})) {\n items.push({\n type: 'prompt',\n configKey,\n label: prompt.title ?? configKey,\n mcpName: configKey,\n prompt,\n })\n }\n\n for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})) {\n items.push({\n type: 'resource',\n configKey,\n label: resource.title ?? configKey,\n mcpName: configKey,\n resource,\n })\n }\n\n // Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.\n const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))\n\n return {\n disabled: pluginConfig.disabled,\n items,\n mcp: pluginConfig.mcp,\n overrideApiKeyCollection: pluginConfig.overrideApiKeyCollection,\n overrideAuth: pluginConfig.overrideAuth,\n userCollection:\n pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',\n }\n}\n\nconst sanitizeCollectionConfig = ({\n collection,\n pluginConfig,\n}: {\n collection: CollectionConfig | SanitizedCollectionConfig\n pluginConfig: MCPPluginConfig\n}): CollectionMCPItem[] => {\n if (collection.slug === 'payload-mcp-api-keys') {\n return []\n }\n const slug = collection.slug\n const collectionPluginConfig = pluginConfig.collections?.[slug]\n const items: CollectionMCPItem[] = []\n\n for (const [toolKey, { mcpName, tool }] of COLLECTION_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: toolKey,\n label: capitalize(toolKey),\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n collectionPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n\n if (collection.auth) {\n for (const [authToolKey, { label, mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {\n const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]\n if (!matchedConfigEntry) {\n continue\n }\n // `true` means \"enable, no override\"; only the object form carries fields.\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey: authToolKey,\n label,\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n collectionPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n }\n\n // Cast: builtin keys are filtered out below, so the remaining values are\n // always custom tools (`CollectionTool`) or undefined\n const customEntries = Object.entries(collectionPluginConfig?.tools ?? {}) as Array<\n [string, CollectionTool | undefined]\n >\n for (const [configKey, customTool] of customEntries) {\n if (configKey in COLLECTION_BUILTINS || configKey in COLLECTION_AUTH_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'collectionTool',\n collectionSlug: slug,\n configKey,\n label: configKey,\n mcpName: configKey,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst sanitizeGlobalConfig = ({\n global,\n pluginConfig,\n}: {\n global: GlobalConfig | SanitizedGlobalConfig\n pluginConfig: MCPPluginConfig\n}): GlobalMCPItem[] => {\n const slug = global.slug\n const globalPluginConfig = pluginConfig.globals?.[slug]\n const items: GlobalMCPItem[] = []\n\n for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES) {\n const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]\n if (matchedConfigEntry === false) {\n continue\n }\n const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined\n items.push({\n type: 'globalTool',\n configKey: toolKey,\n globalSlug: slug,\n label: capitalize(toolKey),\n mcpName,\n tool: {\n ...tool,\n description: override?.description ?? tool.description,\n overrideResponse:\n override?.overrideResponse ??\n globalPluginConfig?.overrideResponse ??\n tool.overrideResponse,\n },\n })\n }\n\n const customEntries = Object.entries(globalPluginConfig?.tools ?? {}) as Array<\n [string, GlobalTool | undefined]\n >\n for (const [configKey, customTool] of customEntries) {\n if (configKey in GLOBAL_BUILTINS) {\n continue\n }\n if (!customTool) {\n continue\n }\n items.push({\n type: 'globalTool',\n configKey,\n globalSlug: slug,\n label: configKey,\n mcpName: configKey,\n tool: customTool,\n })\n }\n\n return items\n}\n\nconst capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1)\n"],"names":["COLLECTION_AUTH_BUILTIN_ENTRIES","COLLECTION_AUTH_BUILTINS","COLLECTION_BUILTIN_ENTRIES","COLLECTION_BUILTINS","GLOBAL_BUILTIN_ENTRIES","GLOBAL_BUILTINS","TOOL_BUILTIN_ENTRIES","TOOL_BUILTINS","sanitizeMCPConfig","config","pluginConfig","items","collection","collections","push","sanitizeCollectionConfig","global","globals","sanitizeGlobalConfig","configKey","label","mcpName","tool","type","Object","entries","tools","prompt","prompts","title","resource","resources","firstCollectionWithAuth","find","auth","Boolean","disabled","mcp","overrideApiKeyCollection","overrideAuth","userCollection","admin","user","slug","collectionPluginConfig","toolKey","matchedConfigEntry","override","undefined","collectionSlug","capitalize","description","overrideResponse","authToolKey","customEntries","customTool","globalPluginConfig","globalSlug","s","charAt","toUpperCase","slice"],"mappings":"AAmBA,SACEA,+BAA+B,EAC/BC,wBAAwB,EACxBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,sBAAsB,EACtBC,eAAe,EACfC,oBAAoB,EACpBC,aAAa,QACR,oBAAmB;AAE1B;;;;;;;;;CASC,GACD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,MAAM,EACNC,YAAY,EAIb;IACC,MAAMC,QAAmB,EAAE;IAE3B,KAAK,MAAMC,cAAcH,OAAOI,WAAW,IAAI,EAAE,CAAE;QACjDF,MAAMG,IAAI,IAAIC,yBAAyB;YAAEH;YAAYF;QAAa;IACpE;IAEA,KAAK,MAAMM,UAAUP,OAAOQ,OAAO,IAAI,EAAE,CAAE;QACzCN,MAAMG,IAAI,IAAII,qBAAqB;YAAEF;YAAQN;QAAa;IAC5D;IAEA,KAAK,MAAM,CAACS,WAAW,EAAEC,KAAK,EAAEC,OAAO,EAAEC,IAAI,EAAE,CAAC,IAAIhB,qBAAsB;QACxEK,MAAMG,IAAI,CAAC;YACTS,MAAM;YACNJ;YACAC;YACAC;YACAC;QACF;IACF;IAEA,KAAK,MAAM,CAACH,WAAWG,KAAK,IAAIE,OAAOC,OAAO,CAACf,aAAagB,KAAK,IAAI,CAAC,GAAI;QACxE,IAAIP,aAAaZ,eAAe;YAC9B;QACF;QACAI,MAAMG,IAAI,CAAC;YACTS,MAAM;YACNJ;YACAC,OAAOD;YACPE,SAASF;YACTG;QACF;IACF;IAEA,KAAK,MAAM,CAACH,WAAWQ,OAAO,IAAIH,OAAOC,OAAO,CAACf,aAAakB,OAAO,IAAI,CAAC,GAAI;QAC5EjB,MAAMG,IAAI,C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EAAE,CAAC0B,KAAK;IACvD,MAAMhC,QAAyB,EAAE;IAEjC,KAAK,MAAM,CAACkC,SAAS,EAAExB,OAAO,EAAEC,IAAI,EAAE,CAAC,IAAIlB,uBAAwB;QACjE,MAAM0C,qBAAqBU,oBAAoB9B,OAAO,CAACmB,QAAQ;QAC/D,IAAIC,uBAAuB,OAAO;YAChC;QACF;QACA,MAAMC,WAAW,OAAOD,uBAAuB,WAAWA,qBAAqBE;QAC/ErC,MAAMG,IAAI,CAAC;YACTS,MAAM;YACNJ,WAAW0B;YACXY,YAAYd;YACZvB,OAAO8B,WAAWL;YAClBxB;YACAC,MAAM;gBACJ,GAAGA,IAAI;gBACP6B,aAAaJ,UAAUI,eAAe7B,KAAK6B,WAAW;gBACtDC,kBACEL,UAAUK,oBACVI,oBAAoBJ,oBACpB9B,KAAK8B,gBAAgB;YACzB;QACF;IACF;IAEA,MAAME,gBAAgB9B,OAAOC,OAAO,CAAC+B,oBAAoB9B,SAAS,CAAC;IAGnE,KAAK,MAAM,CAACP,WAAWoC,WAAW,IAAID,cAAe;QACnD,IAAInC,aAAad,iBAAiB;YAChC;QACF;QACA,IAAI,CAACkD,YAAY;YACf;QACF;QACA5C,MAAMG,IAAI,CAAC;YACTS,MAAM;YACNJ;YACAsC,YAAYd;YACZvB,OAAOD;YACPE,SAASF;YACTG,MAAMiC;QACR;IACF;IAEA,OAAO5C;AACT;AAEA,MAAMuC,aAAa,CAACQ,IAAsBA,EAAEC,MAAM,CAAC,GAAGC,WAAW,KAAKF,EAAEG,KAAK,CAAC"}
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 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","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;AACnD,SACEC,+BAA+B,EAC/BC,wBAAwB,EACxBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,sBAAsB,EACtBC,eAAe,EACfC,oBAAoB,EACpBC,aAAa,QACR,oBAAmB;AAE1B;;;;;;;;CAQC,GACD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,MAAM,EACNC,YAAY,EAIb;IACC,MAAMC,QAAmB,EAAE;IAE3B,KAAK,MAAMC,cAAc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M;YACNH;YACAsC,YAAYpB;YACZd,OAAOgC,WAAW/B,WAAW,EAAEC,SAASN;YACxCC,SAASD;YACTE,MAAM;gBAAE,GAAGkC,UAAU;gBAAE7B,QAAQ6B,WAAW7B,MAAM,IAAI3B;YAAc;QACpE;IACF;IAEA,OAAOY;AACT"}
package/dist/stdio.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Stdio adapter for the Payload MCP server.
3
3
  *
4
- * Do not use in production. There's no auth; whoever can spawn the process gets
5
- * full access to your local data.
4
+ * Pass PAYLOAD_MCP_AUTHORIZATION when stdio should authenticate with the same
5
+ * Payload auth header as HTTP. In development, PAYLOAD_MCP_OVERRIDE_ACCESS=true
6
+ * skips access control for local setup.
6
7
  */
7
8
  export declare const runMcpStdio: () => Promise<void>;
8
9
  //# sourceMappingURL=stdio.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CA4EhD,CAAA"}
1
+ {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAa,OAAO,CAAC,IAAI,CAyFhD,CAAA"}
package/dist/stdio.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { createLocalReq, getPayload } from 'payload';
4
4
  import { findConfig } from 'payload/node';
5
+ import { getAuthorizedMCP } from './endpoint/access.js';
5
6
  import { buildMcpServer } from './mcp/buildMcpServer.js';
6
7
  import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js';
7
8
  import { getPluginConfig } from './utils/getPluginConfig.js';
@@ -9,8 +10,9 @@ import { resolveProjectRoot } from './utils/resolveProjectRoot.js';
9
10
  /**
10
11
  * Stdio adapter for the Payload MCP server.
11
12
  *
12
- * Do not use in production. There's no auth; whoever can spawn the process gets
13
- * full access to your local data.
13
+ * Pass PAYLOAD_MCP_AUTHORIZATION when stdio should authenticate with the same
14
+ * Payload auth header as HTTP. In development, PAYLOAD_MCP_OVERRIDE_ACCESS=true
15
+ * skips access control for local setup.
14
16
  */ export const runMcpStdio = async ()=>{
15
17
  /**
16
18
  * If MCP clients spawn stdio servers from an arbitrary working directory,
@@ -52,13 +54,30 @@ import { resolveProjectRoot } from './utils/resolveProjectRoot.js';
52
54
  fakePluginFn.sanitizedOptions = pluginConfig;
53
55
  (payload.config.plugins ??= []).push(fakePluginFn);
54
56
  }
55
- const authorizedMCP = {
56
- items: pluginConfig.items,
57
- overrideAccess: true,
58
- user: null
59
- };
60
- const req = await createLocalReq({}, payload);
57
+ const overrideAccessEnv = process.env.PAYLOAD_MCP_OVERRIDE_ACCESS;
58
+ let overrideAccess = false;
59
+ if (overrideAccessEnv === 'true') {
60
+ overrideAccess = true;
61
+ } else if (overrideAccessEnv && overrideAccessEnv !== 'false') {
62
+ throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS must be "true" or "false".');
63
+ }
64
+ if (overrideAccess && process.env.NODE_ENV !== 'development') {
65
+ throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS is only available in development.');
66
+ }
67
+ const headers = new Headers();
68
+ if (process.env.PAYLOAD_MCP_AUTHORIZATION) {
69
+ headers.set('Authorization', process.env.PAYLOAD_MCP_AUTHORIZATION);
70
+ }
71
+ const req = await createLocalReq({
72
+ req: {
73
+ headers
74
+ }
75
+ }, payload);
61
76
  req.payloadAPI = 'MCP';
77
+ const authorizedMCP = await getAuthorizedMCP({
78
+ overrideAccess,
79
+ req
80
+ });
62
81
  const server = buildMcpServer({
63
82
  authorizedMCP,
64
83
  pluginConfig,
package/dist/stdio.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["import type { MaybePromise, Plugin, SanitizedConfig } from 'payload'\n\n/* eslint-disable no-console */\nimport { StdioServerTransport } from '@modelcontextprotocol/server'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createLocalReq, getPayload } from 'payload'\nimport { findConfig } from 'payload/node'\n\nimport type { AuthorizedMCP, SanitizedMCPPluginConfig } from './types.js'\n\nimport { buildMcpServer } from './mcp/buildMcpServer.js'\nimport { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'\nimport { getPluginConfig } from './utils/getPluginConfig.js'\nimport { resolveProjectRoot } from './utils/resolveProjectRoot.js'\n\n/**\n * Stdio adapter for the Payload MCP server.\n *\n * Do not use in production. There's no auth; whoever can spawn the process gets\n * full access to your local data.\n */\nexport const runMcpStdio = async (): Promise<void> => {\n /**\n * If MCP clients spawn stdio servers from an arbitrary working directory,\n * Payload's cwd-anchored `findConfig()` can't locate the project on\n * its own. This module always lives inside the project's `node_modules`, so\n * we derive the project root from its own path and `chdir` into it.\n *\n * An absolute `PAYLOAD_CONFIG_PATH` still overrides everything; unusual\n * layouts (e.g. a monorepo where the package is hoisted above the app) can\n * fall back to it. See the implementation of findConfig for details.\n */\n const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))\n if (projectRoot) {\n process.chdir(projectRoot)\n }\n\n const configPath = findConfig()\n const configModule = await import(pathToFileURL(configPath).toString())\n const config = (await (configModule.default ?? configModule)) as MaybePromise<SanitizedConfig>\n\n const payload = await getPayload({ config })\n\n /**\n * If the user added `mcpPlugin({...})` to their `plugins` array, read the\n * sanitized config they registered. Otherwise fall back to the defaults. That way,\n * the mcp works on any project that has `@payloadcms/plugin-mcp` installed,\n * even if the plugin is not added to the plugins array.\n */\n let pluginConfig: SanitizedMCPPluginConfig\n try {\n pluginConfig = getPluginConfig({ config: payload.config })\n } catch {\n pluginConfig = sanitizeMCPConfig({ config: payload.config, pluginConfig: {} })\n\n const fakePluginFn: Plugin = (config) => config\n fakePluginFn.slug = '@payloadcms/plugin-mcp'\n // @ts-expect-error\n fakePluginFn.sanitizedOptions = pluginConfig\n\n // Push to payload config, to ensure consecutive calls to `getPluginConfig()` work\n ;(payload.config.plugins ??= []).push(fakePluginFn)\n }\n\n const authorizedMCP: AuthorizedMCP = {\n items: pluginConfig.items,\n overrideAccess: true,\n user: null,\n }\n\n const req = await createLocalReq({}, payload)\n req.payloadAPI = 'MCP' as const\n\n const server = buildMcpServer({ authorizedMCP, pluginConfig, req })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n // Process now lives until stdin closes. Wire graceful shutdown so DB\n // connections (and any other Payload-managed resources) get released.\n const shutdown = async (code = 0) => {\n try {\n await server.close()\n } catch (err) {\n console.error('[payload-mcp] error closing server:', err)\n }\n try {\n await payload.destroy()\n } catch (err) {\n console.error('[payload-mcp] error destroying payload:', err)\n }\n process.exit(code)\n }\n\n process.on('SIGINT', () => void shutdown(0))\n process.on('SIGTERM', () => void shutdown(0))\n process.stdin.on('close', () => void shutdown(0))\n}\n"],"names":["StdioServerTransport","fileURLToPath","pathToFileURL","createLocalReq","getPayload","findConfig","buildMcpServer","sanitizeMCPConfig","getPluginConfig","resolveProjectRoot","runMcpStdio","projectRoot","url","process","chdir","configPath","configModule","toString","config","default","payload","pluginConfig","fakePluginFn","slug","sanitizedOptions","plugins","push","authorizedMCP","items","overrideAccess","user","req","payloadAPI","server","transport","connect","shutdown","code","close","err","console","error","destroy","exit","on","stdin"],"mappings":"AAEA,6BAA6B,GAC7B,SAASA,oBAAoB,QAAQ,+BAA8B;AACnE,SAASC,aAAa,EAAEC,aAAa,QAAQ,WAAU;AACvD,SAASC,cAAc,EAAEC,UAAU,QAAQ,UAAS;AACpD,SAASC,UAAU,QAAQ,eAAc;AAIzC,SAASC,cAAc,QAAQ,0BAAyB;AACxD,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,gCAA+B;AAElE;;;;;CAKC,GACD,OAAO,MAAMC,cAAc;IACzB;;;;;;;;;GASC,GACD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8B,IAAI,CAACN;IACf;IAEAxB,QAAQ+B,EAAE,CAAC,UAAU,IAAM,KAAKR,SAAS;IACzCvB,QAAQ+B,EAAE,CAAC,WAAW,IAAM,KAAKR,SAAS;IAC1CvB,QAAQgC,KAAK,CAACD,EAAE,CAAC,SAAS,IAAM,KAAKR,SAAS;AAChD,EAAC"}
1
+ {"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["import type { MaybePromise, Plugin, SanitizedConfig } from 'payload'\n\n/* eslint-disable no-console */\nimport { StdioServerTransport } from '@modelcontextprotocol/server'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createLocalReq, getPayload } from 'payload'\nimport { findConfig } from 'payload/node'\n\nimport type { SanitizedMCPPluginConfig } from './types.js'\n\nimport { getAuthorizedMCP } from './endpoint/access.js'\nimport { buildMcpServer } from './mcp/buildMcpServer.js'\nimport { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'\nimport { getPluginConfig } from './utils/getPluginConfig.js'\nimport { resolveProjectRoot } from './utils/resolveProjectRoot.js'\n\n/**\n * Stdio adapter for the Payload MCP server.\n *\n * Pass PAYLOAD_MCP_AUTHORIZATION when stdio should authenticate with the same\n * Payload auth header as HTTP. In development, PAYLOAD_MCP_OVERRIDE_ACCESS=true\n * skips access control for local setup.\n */\nexport const runMcpStdio = async (): Promise<void> => {\n /**\n * If MCP clients spawn stdio servers from an arbitrary working directory,\n * Payload's cwd-anchored `findConfig()` can't locate the project on\n * its own. This module always lives inside the project's `node_modules`, so\n * we derive the project root from its own path and `chdir` into it.\n *\n * An absolute `PAYLOAD_CONFIG_PATH` still overrides everything; unusual\n * layouts (e.g. a monorepo where the package is hoisted above the app) can\n * fall back to it. See the implementation of findConfig for details.\n */\n const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))\n if (projectRoot) {\n process.chdir(projectRoot)\n }\n\n const configPath = findConfig()\n const configModule = await import(pathToFileURL(configPath).toString())\n const config = (await (configModule.default ?? configModule)) as MaybePromise<SanitizedConfig>\n\n const payload = await getPayload({ config })\n\n /**\n * If the user added `mcpPlugin({...})` to their `plugins` array, read the\n * sanitized config they registered. Otherwise fall back to the defaults. That way,\n * the mcp works on any project that has `@payloadcms/plugin-mcp` installed,\n * even if the plugin is not added to the plugins array.\n */\n let pluginConfig: SanitizedMCPPluginConfig\n try {\n pluginConfig = getPluginConfig({ config: payload.config })\n } catch {\n pluginConfig = sanitizeMCPConfig({ config: payload.config, pluginConfig: {} })\n\n const fakePluginFn: Plugin = (config) => config\n fakePluginFn.slug = '@payloadcms/plugin-mcp'\n // @ts-expect-error\n fakePluginFn.sanitizedOptions = pluginConfig\n\n // Push to payload config, to ensure consecutive calls to `getPluginConfig()` work\n ;(payload.config.plugins ??= []).push(fakePluginFn)\n }\n\n const overrideAccessEnv = process.env.PAYLOAD_MCP_OVERRIDE_ACCESS\n let overrideAccess = false\n\n if (overrideAccessEnv === 'true') {\n overrideAccess = true\n } else if (overrideAccessEnv && overrideAccessEnv !== 'false') {\n throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS must be \"true\" or \"false\".')\n }\n\n if (overrideAccess && process.env.NODE_ENV !== 'development') {\n throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS is only available in development.')\n }\n\n const headers = new Headers()\n if (process.env.PAYLOAD_MCP_AUTHORIZATION) {\n headers.set('Authorization', process.env.PAYLOAD_MCP_AUTHORIZATION)\n }\n\n const req = await createLocalReq({ req: { headers } }, payload)\n req.payloadAPI = 'MCP' as const\n const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })\n\n const server = buildMcpServer({ authorizedMCP, pluginConfig, req })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n\n // Process now lives until stdin closes. Wire graceful shutdown so DB\n // connections (and any other Payload-managed resources) get released.\n const shutdown = async (code = 0) => {\n try {\n await server.close()\n } catch (err) {\n console.error('[payload-mcp] error closing server:', err)\n }\n try {\n await payload.destroy()\n } catch (err) {\n console.error('[payload-mcp] error destroying payload:', err)\n }\n process.exit(code)\n }\n\n process.on('SIGINT', () => void shutdown(0))\n process.on('SIGTERM', () => void shutdown(0))\n process.stdin.on('close', () => void shutdown(0))\n}\n"],"names":["StdioServerTransport","fileURLToPath","pathToFileURL","createLocalReq","getPayload","findConfig","getAuthorizedMCP","buildMcpServer","sanitizeMCPConfig","getPluginConfig","resolveProjectRoot","runMcpStdio","projectRoot","url","process","chdir","configPath","configModule","toString","config","default","payload","pluginConfig","fakePluginFn","slug","sanitizedOptions","plugins","push","overrideAccessEnv","env","PAYLOAD_MCP_OVERRIDE_ACCESS","overrideAccess","Error","NODE_ENV","headers","Headers","PAYLOAD_MCP_AUTHORIZATION","set","req","payloadAPI","authorizedMCP","server","transport","connect","shutdown","code","close","err","console","error","destroy","exit","on","stdin"],"mappings":"AAEA,6BAA6B,GAC7B,SAASA,oBAAoB,QAAQ,+BAA8B;AACnE,SAASC,aAAa,EAAEC,aAAa,QAAQ,WAAU;AACvD,SAASC,cAAc,EAAEC,UAAU,QAAQ,UAAS;AACpD,SAASC,UAAU,QAAQ,eAAc;AAIzC,SAASC,gBAAgB,QAAQ,uBAAsB;AACvD,SAASC,cAAc,QAAQ,0BAAyB;AACxD,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,eAAe,QAAQ,6BAA4B;AAC5D,SAASC,kBAAkB,QAAQ,gCAA+B;AAElE;;;;;;CAMC,GACD,OAAO,MAAMC,cAAc;IACzB;;;;;;;;;GASC,GACD,MAAMC,cAAcF,mBAAmBT,cAAc,YAAYY,GAAG;IACpE,IAAID,aAAa;QACfE,QAAQC,KAAK,CAACH;IAChB;IAEA,MAAMI,aAAaX;IACnB,MAAMY,eAAe,MAAM,MAAM,CAACf,cAAcc,YAAYE,QAAQ;IACpE,MAAMC,SAAU,MAAOF,CAAAA,aAAaG,OAAO,IAAIH,YAAW;IAE1D,MAAMI,UAAU,MAAMjB,WAAW;QAAEe;IAAO;IAE1C;;;;;GAKC,GACD,IAAIG;IACJ,IAAI;QACFA,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ACF,MAAM1B,QAAQ6B,OAAO;QACvB,EAAE,OAAOH,KAAK;YACZC,QAAQC,KAAK,CAAC,2CAA2CF;QAC3D;QACAjC,QAAQqC,IAAI,CAACN;IACf;IAEA/B,QAAQsC,EAAE,CAAC,UAAU,IAAM,KAAKR,SAAS;IACzC9B,QAAQsC,EAAE,CAAC,WAAW,IAAM,KAAKR,SAAS;IAC1C9B,QAAQuC,KAAK,CAACD,EAAE,CAAC,SAAS,IAAM,KAAKR,SAAS;AAChD,EAAC"}
package/dist/types.d.ts CHANGED
@@ -1,34 +1,15 @@
1
- import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON } from '@modelcontextprotocol/server';
2
- import type { AuthCollectionSlug, CollectionConfig, CollectionSlug, DefaultDocumentIDType, GlobalSlug, MaybePromise, PayloadRequest, TypedUser } from 'payload';
1
+ import type { CallToolResult, ContentBlock, JsonSchemaType, McpServer, ResourceTemplate, ServerContext, StandardSchemaWithJSON, ToolAnnotations } from '@modelcontextprotocol/server';
2
+ import type { AuthCollectionSlug, CollectionSlug, GlobalSlug, MaybePromise, PayloadRequest, SanitizedPermissions, TypedUser } from 'payload';
3
+ import type { GetAuthorizedMCPArgs } from './endpoint/access.js';
3
4
  import type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName } from './mcp/builtinTools.js';
4
5
  export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName };
5
- /** Re-exported from `@modelcontextprotocol/server` — the JSON Schema shape the MCP runtime validates against. */
6
- export type { JsonSchemaType, StandardSchemaWithJSON };
6
+ /** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */
7
+ export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations };
7
8
  /**
8
9
  * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
9
10
  * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
10
11
  */
11
12
  export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON;
12
- /**
13
- * Serializable mirror of `SanitizedMCPPluginConfig` for client components —
14
- * the full sanitized config carries functions (tool handlers, etc.) that can't
15
- * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
16
- * passed to the `AccessField` component via `clientProps`.
17
- *
18
- * @internal
19
- */
20
- export type ClientMCPPluginConfig = {
21
- items: Array<{
22
- collectionSlug?: string;
23
- configKey: string;
24
- description?: string;
25
- globalSlug?: string;
26
- /** Admin-UI bucket for collection/global tools: built-in CRUD, auth, or custom. */
27
- group?: 'auth' | 'custom' | 'operations';
28
- label: string;
29
- type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool';
30
- }>;
31
- };
32
13
  export type MCPToolResponse = {
33
14
  content: ContentBlock[];
34
15
  /**
@@ -44,6 +25,16 @@ export type MCPResponseOverride = (response: MCPToolResponse, doc: Record<string
44
25
  * its inferred output; anything else falls back to `Record<string, unknown>`.
45
26
  */
46
27
  export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON ? StandardSchemaWithJSON extends TSchema ? Record<string, unknown> : StandardSchemaWithJSON.InferOutput<TSchema> : Record<string, unknown>;
28
+ export type MCPAccessArgs = {
29
+ permissions?: SanitizedPermissions;
30
+ req: PayloadRequest;
31
+ };
32
+ export type CollectionMCPAccessArgs = {
33
+ collectionSlug: CollectionSlug;
34
+ } & MCPAccessArgs;
35
+ export type GlobalMCPAccessArgs = {
36
+ globalSlug: GlobalSlug;
37
+ } & MCPAccessArgs;
47
38
  export type ToolHandlerArgs<TSchema = undefined> = {
48
39
  authorizedMCP: AuthorizedMCP;
49
40
  input: TypedInput<TSchema>;
@@ -57,6 +48,8 @@ export type GlobalToolHandlerArgs<TSchema = undefined> = {
57
48
  globalSlug: GlobalSlug;
58
49
  } & ToolHandlerArgs<TSchema>;
59
50
  export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
51
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
52
+ annotations?: ToolAnnotations;
60
53
  description: string;
61
54
  handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
62
55
  input?: TSchema;
@@ -66,19 +59,30 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
66
59
  overrideResponse?: MCPResponseOverride;
67
60
  };
68
61
  export type CollectionTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
62
+ access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
69
63
  handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
70
64
  input?: TSchema;
71
- } & Pick<Tool, 'description' | 'overrideResponse'>;
65
+ } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>;
72
66
  export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
67
+ access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
73
68
  handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>;
74
69
  input?: TSchema;
75
- } & Pick<Tool, 'description' | 'overrideResponse'>;
70
+ } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>;
76
71
  /**
77
72
  * Configures (or disables) a built-in tool without replacing it.
78
73
  * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
79
74
  * required handler) from being silently accepted at a built-in key slot.
80
75
  */
81
- export type MCPBuiltInToolOverride = {
76
+ export type MCPBuiltInCollectionToolOverride = {
77
+ access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>;
78
+ annotations?: ToolAnnotations;
79
+ description?: string;
80
+ handler?: never;
81
+ overrideResponse?: MCPResponseOverride;
82
+ };
83
+ export type MCPBuiltInGlobalToolOverride = {
84
+ access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>;
85
+ annotations?: ToolAnnotations;
82
86
  description?: string;
83
87
  handler?: never;
84
88
  overrideResponse?: MCPResponseOverride;
@@ -90,19 +94,19 @@ export type MCPBuiltInToolOverride = {
90
94
  */
91
95
  export type MCPTopLevelToolEntry = Tool;
92
96
  export type MCPCollectionToolsMap = {
93
- [customToolName: string]: boolean | CollectionTool | MCPBuiltInToolOverride | undefined;
97
+ [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined;
94
98
  } & {
95
- [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride;
99
+ [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride;
96
100
  };
97
101
  export type MCPAuthCollectionToolsMap = {
98
- [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | true;
102
+ [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true;
99
103
  } & MCPCollectionToolsMap;
100
104
  /** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
101
105
  export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug ? MCPAuthCollectionToolsMap : MCPCollectionToolsMap;
102
106
  export type MCPGlobalToolsMap = {
103
- [customToolName: string]: boolean | GlobalTool | MCPBuiltInToolOverride | undefined;
107
+ [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined;
104
108
  } & {
105
- [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride;
109
+ [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride;
106
110
  };
107
111
  export type MCPTopLevelToolsMap = Record<string, Tool>;
108
112
  export type PromptHandlerArgs<TSchema = undefined> = {
@@ -111,6 +115,7 @@ export type PromptHandlerArgs<TSchema = undefined> = {
111
115
  serverContext: ServerContext;
112
116
  };
113
117
  export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
118
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
114
119
  argsSchema: TSchema;
115
120
  description: string;
116
121
  handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
@@ -132,6 +137,7 @@ export type ResourceHandlerArgs = {
132
137
  uri: URL;
133
138
  };
134
139
  export type Resource = {
140
+ access?: (args: MCPAccessArgs) => MaybePromise<boolean>;
135
141
  description: string;
136
142
  handler: (args: ResourceHandlerArgs) => MaybePromise<{
137
143
  contents: Array<{
@@ -165,7 +171,7 @@ export type MCPPluginConfig = {
165
171
  collections?: {
166
172
  [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>;
167
173
  };
168
- /** Skip MCP registration. The API key collection is still added (so DB / types stay stable). */
174
+ /** Skip MCP endpoint registration. */
169
175
  disabled?: boolean;
170
176
  globals?: {
171
177
  [Slug in GlobalSlug]?: MCPPluginGlobalConfig;
@@ -174,75 +180,29 @@ export type MCPPluginConfig = {
174
180
  serverOptions?: MCPServerOptions;
175
181
  verboseLogs?: boolean;
176
182
  };
177
- overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig;
178
- /** Replace the default API-key auth with a custom resolver. */
179
- overrideAuth?: (args: {
180
- getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>;
181
- getAuthorizedMCP: (args: {
182
- apiKeyDoc: MCPAPIKeysDoc;
183
- }) => AuthorizedMCP;
183
+ /** Replace the default MCP authorization resolver. */
184
+ overrideGetAuthorizedMCP?: (args: {
184
185
  pluginConfig: SanitizedMCPPluginConfig;
185
- req: PayloadRequest;
186
- }) => MaybePromise<AuthorizedMCP>;
186
+ } & GetAuthorizedMCPArgs) => MaybePromise<AuthorizedMCP>;
187
187
  prompts?: Record<string, Prompt>;
188
188
  resources?: Record<string, Resource>;
189
189
  /** Cross-cutting tools (not scoped to any collection or global). */
190
190
  tools?: MCPTopLevelToolsMap;
191
- userCollection?: CollectionSlug;
192
191
  };
193
192
  export type SanitizedMCPPluginConfig = {
194
193
  items: MCPItem[];
195
- userCollection: CollectionSlug;
196
- } & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>;
194
+ } & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideGetAuthorizedMCP'>;
197
195
  export type MCPServerOptions = {
198
196
  options?: ConstructorParameters<typeof McpServer>[1];
199
197
  serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>;
200
198
  };
201
199
  /**
202
- * Nested access tree as stored in the collection.
203
- * A `false` leaf disables that tool; missing keys defer to
204
- * defaults (built-in CRUD is on, opt-in tools are off).
205
- */
206
- export type MCPAPIKeysDocAccessTree = {
207
- collections?: {
208
- [CollectionSlug: CollectionSlug]: {
209
- [ToolKey: string]: boolean;
210
- };
211
- };
212
- globals?: {
213
- [GlobalSlug: GlobalSlug]: {
214
- [ToolKey: string]: boolean;
215
- };
216
- };
217
- prompts?: {
218
- [PromptKey: string]: boolean;
219
- };
220
- resources?: {
221
- [ResourceKey: string]: boolean;
222
- };
223
- tools?: {
224
- [ToolKey: string]: boolean;
225
- };
226
- };
227
- /**
228
- * Stored on `payload-mcp-api-keys` docs
229
- */
230
- export type MCPAPIKeysDoc = {
231
- access: MCPAPIKeysDocAccessTree;
232
- apiKey?: string;
233
- apiKeyIndex?: string;
234
- id: DefaultDocumentIDType;
235
- lastUsed?: string;
236
- overrideAccess?: boolean;
237
- user: null | TypedUser;
238
- };
239
- /**
240
- * One MCP primitive plus the metadata needed for access checks, admin UI, and
200
+ * One MCP primitive plus the metadata needed for config-driven filtering and
241
201
  * registration.
242
202
  *
243
- * - `configKey`: the config/API-key identifier, e.g. `find` or `echo`.
203
+ * - `configKey`: the config identifier, e.g. `find` or `echo`.
244
204
  * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
245
- * - `label`: human-readable admin checkbox text.
205
+ * - `label`: human-readable display text.
246
206
  */
247
207
  export type MCPItemBase = {
248
208
  configKey: string;
@@ -270,10 +230,10 @@ export type MCPItem = ({
270
230
  type: 'tool';
271
231
  } & MCPItemBase) | CollectionMCPItem | GlobalMCPItem;
272
232
  /**
273
- * The caller's identity + the MCP items they can use for this request. Returned
274
- * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
275
- * receive this via `args.authorizedMCP` so they can spread
276
- * `localAPIDefaults(authorizedMCP)` into every local API call.
233
+ * The caller's identity + the MCP items authorized for this request. Disabled
234
+ * items and items blocked by access callbacks or Payload operation access are
235
+ * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
236
+ * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
277
237
  */
278
238
  export type AuthorizedMCP = {
279
239
  items: MCPItem[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EACvB,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,SAAS,EACV,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAE9B,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,CAAA;AAEzF,iHAAiH;AACjH,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAA;AAEtD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,sBAAsB,CAAA;AAErE;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,KAAK,CAAC;QACX,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,mFAAmF;QACnF,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,YAAY,CAAA;QACxC,KAAK,EAAE,MAAM,CAAA;QACb,IAAI,E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,EAAE,QAAQ,CAAA;CACf,GAAG,WAAW,CAAC,GAChB,CAAC;IACC,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,WAAW,CAAC,GAChB,CAAC;IACC,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,WAAW,CAAC,GAChB,iBAAiB,GACjB,aAAa,CAAA;AAEjB;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CACvB,CAAA"}
package/dist/types.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * The caller's identity + the MCP items they can use for this request. Returned
3
- * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
4
- * receive this via `args.authorizedMCP` so they can spread
5
- * `localAPIDefaults(authorizedMCP)` into every local API call.
2
+ * The caller's identity + the MCP items authorized for this request. Disabled
3
+ * items and items blocked by access callbacks or Payload operation access are
4
+ * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
5
+ * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
6
6
  */ export { };
7
7
 
8
8
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n TypedUser,\n} from 'payload'\n\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — the JSON Schema shape the MCP runtime validates against. */\nexport type { JsonSchemaType, StandardSchemaWithJSON }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\n/**\n * Serializable mirror of `SanitizedMCPPluginConfig` for client components —\n * the full sanitized config carries functions (tool handlers, etc.) that can't\n * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and\n * passed to the `AccessField` component via `clientProps`.\n *\n * @internal\n */\nexport type ClientMCPPluginConfig = {\n items: Array<{\n collectionSlug?: string\n configKey: string\n description?: string\n globalSlug?: string\n /** Admin-UI bucket for collection/global tools: built-in CRUD, auth, or custom. */\n group?: 'auth' | 'custom' | 'operations'\n label: string\n type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'\n }>\n}\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInToolOverride = {\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP registration. The API key collection is still added (so DB / types stay stable). */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n /** Replace the default API-key auth with a custom resolver. */\n overrideAuth?: (args: {\n getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>\n getAuthorizedMCP: (args: { apiKeyDoc: MCPAPIKeysDoc }) => AuthorizedMCP\n pluginConfig: SanitizedMCPPluginConfig\n req: PayloadRequest\n }) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n userCollection?: CollectionSlug\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n userCollection: CollectionSlug\n} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * Nested access tree as stored in the collection.\n * A `false` leaf disables that tool; missing keys defer to\n * defaults (built-in CRUD is on, opt-in tools are off).\n */\nexport type MCPAPIKeysDocAccessTree = {\n collections?: {\n [CollectionSlug: CollectionSlug]: {\n [ToolKey: string]: boolean\n }\n }\n globals?: {\n [GlobalSlug: GlobalSlug]: {\n [ToolKey: string]: boolean\n }\n }\n prompts?: {\n [PromptKey: string]: boolean\n }\n resources?: {\n [ResourceKey: string]: boolean\n }\n tools?: {\n [ToolKey: string]: boolean\n }\n}\n\n/**\n * Stored on `payload-mcp-api-keys` docs\n */\nexport type MCPAPIKeysDoc = {\n access: MCPAPIKeysDocAccessTree\n apiKey?: string\n apiKeyIndex?: string\n id: DefaultDocumentIDType\n lastUsed?: string\n overrideAccess?: boolean\n user: null | TypedUser\n}\n\n/**\n * One MCP primitive plus the metadata needed for access checks, admin UI, and\n * registration.\n *\n * - `configKey`: the config/API-key identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable admin checkbox text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The caller's identity + the MCP items they can use for this request. Returned\n * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers\n * receive this via `args.authorizedMCP` so they can spread\n * `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAgVA;;;;;CAKC,GACD,WAIC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n ToolAnnotations,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionSlug,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n SanitizedPermissions,\n TypedUser,\n} from 'payload'\n\nimport type { GetAuthorizedMCPArgs } from './endpoint/access.js'\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */\nexport type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type MCPAccessArgs = {\n permissions?: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type CollectionMCPAccessArgs = {\n collectionSlug: CollectionSlug\n} & MCPAccessArgs\n\nexport type GlobalMCPAccessArgs = {\n globalSlug: GlobalSlug\n} & MCPAccessArgs\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n } & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInCollectionToolOverride = {\n access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\nexport type MCPBuiltInGlobalToolOverride = {\n access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>\n annotations?: ToolAnnotations\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n access?: (args: MCPAccessArgs) => MaybePromise<boolean>\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP endpoint registration. */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n /** Replace the default MCP authorization resolver. */\n overrideGetAuthorizedMCP?: (\n args: {\n pluginConfig: SanitizedMCPPluginConfig\n } & GetAuthorizedMCPArgs,\n ) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideGetAuthorizedMCP'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * One MCP primitive plus the metadata needed for config-driven filtering and\n * registration.\n *\n * - `configKey`: the config identifier, e.g. `find` or `echo`.\n * - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.\n * - `label`: human-readable display text.\n */\nexport type MCPItemBase = {\n configKey: string\n label: string\n mcpName: string\n}\n\nexport type CollectionMCPItem = {\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n} & MCPItemBase\n\nexport type GlobalMCPItem = {\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n} & MCPItemBase\n\nexport type MCPItem =\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n | CollectionMCPItem\n | GlobalMCPItem\n\n/**\n * The caller's identity + the MCP items authorized for this request. Disabled\n * items and items blocked by access callbacks or Payload operation access are\n * absent from `items`. Tool handlers receive this via `args.authorizedMCP` so\n * they can spread `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AA6SA;;;;;CAKC,GACD,WAIC"}
@@ -3,7 +3,7 @@ import type { SanitizedMCPPluginConfig } from '../types.js';
3
3
  /**
4
4
  * Returns the sanitized plugin config — the form produced by
5
5
  * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
6
- * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
6
+ * Callers downstream of plugin init can rely on `items` and other defaults
7
7
  * being fully resolved.
8
8
  */
9
9
  export declare const getPluginConfig: (args: {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Returns the sanitized plugin config — the form produced by
3
3
  * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
4
- * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
4
+ * Callers downstream of plugin init can rely on `items` and other defaults
5
5
  * being fully resolved.
6
6
  */ export const getPluginConfig = ({ config })=>{
7
7
  const plugin = config.plugins?.find((plugin)=>plugin.slug === '@payloadcms/plugin-mcp');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/getPluginConfig.ts"],"sourcesContent":["import type { PluginsMap, SanitizedConfig } from 'payload'\n\nimport type { SanitizedMCPPluginConfig } from '../types.js'\n\n/**\n * Returns the sanitized plugin config — the form produced by\n * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.\n * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.\n * being fully resolved.\n */\nexport const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({\n config,\n}) => {\n const plugin = config.plugins?.find(\n (plugin) => plugin.slug === '@payloadcms/plugin-mcp',\n ) as PluginsMap['@payloadcms/plugin-mcp']\n\n if (!plugin) {\n throw new Error('MCP Plugin not found in config.plugins.')\n }\n\n // @ts-expect-error\n return plugin.sanitizedOptions\n}\n"],"names":["getPluginConfig","config","plugin","plugins","find","slug","Error","sanitizedOptions"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,kBAAmF,CAAC,EAC/FC,MAAM,EACP;IACC,MAAMC,SAASD,OAAOE,OAAO,EAAEC,KAC7B,CAACF,SAAWA,OAAOG,IAAI,KAAK;IAG9B,IAAI,CAACH,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,mBAAmB;IACnB,OAAOJ,OAAOK,gBAAgB;AAChC,EAAC"}
1
+ {"version":3,"sources":["../../src/utils/getPluginConfig.ts"],"sourcesContent":["import type { PluginsMap, SanitizedConfig } from 'payload'\n\nimport type { SanitizedMCPPluginConfig } from '../types.js'\n\n/**\n * Returns the sanitized plugin config — the form produced by\n * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.\n * Callers downstream of plugin init can rely on `items` and other defaults\n * being fully resolved.\n */\nexport const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({\n config,\n}) => {\n const plugin = config.plugins?.find(\n (plugin) => plugin.slug === '@payloadcms/plugin-mcp',\n ) as PluginsMap['@payloadcms/plugin-mcp']\n\n if (!plugin) {\n throw new Error('MCP Plugin not found in config.plugins.')\n }\n\n // @ts-expect-error\n return plugin.sanitizedOptions\n}\n"],"names":["getPluginConfig","config","plugin","plugins","find","slug","Error","sanitizedOptions"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,kBAAmF,CAAC,EAC/FC,MAAM,EACP;IACC,MAAMC,SAASD,OAAOE,OAAO,EAAEC,KAC7B,CAACF,SAAWA,OAAOG,IAAI,KAAK;IAG9B,IAAI,CAACH,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,mBAAmB;IACnB,OAAOJ,OAAOK,gBAAgB;AAChC,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "4.0.0-internal.688c4d0",
3
+ "version": "4.0.0-internal.bc5cf8c",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
6
  "plugin",
@@ -21,9 +21,6 @@
21
21
  "url": "https://payloadcms.com"
22
22
  }
23
23
  ],
24
- "sideEffects": [
25
- "*.css"
26
- ],
27
24
  "type": "module",
28
25
  "exports": {
29
26
  ".": {
@@ -40,6 +37,11 @@
40
37
  "import": "./dist/stdio.js",
41
38
  "types": "./dist/stdio.d.ts",
42
39
  "default": "./dist/stdio.js"
40
+ },
41
+ "./internal": {
42
+ "import": "./dist/internal.js",
43
+ "types": "./dist/internal.d.ts",
44
+ "default": "./dist/internal.js"
43
45
  }
44
46
  },
45
47
  "main": "./dist/index.js",
@@ -56,20 +58,14 @@
56
58
  "@cfworker/json-schema": "^4.1.1",
57
59
  "@modelcontextprotocol/server": "2.0.0-alpha.2",
58
60
  "tsx": "4.22.4",
59
- "zod": "^4.0.0",
60
- "@payloadcms/translations": "4.0.0-internal.688c4d0"
61
+ "zod": "^4.0.0"
61
62
  },
62
63
  "devDependencies": {
63
- "@types/react": "19.2.14",
64
- "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
65
- "payload": "4.0.0-internal.688c4d0",
66
64
  "@payloadcms/eslint-config": "3.28.0",
67
- "@payloadcms/ui": "4.0.0-internal.688c4d0"
65
+ "payload": "4.0.0-internal.bc5cf8c"
68
66
  },
69
67
  "peerDependencies": {
70
- "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
71
- "@payloadcms/ui": "4.0.0-internal.688c4d0",
72
- "payload": "4.0.0-internal.688c4d0"
68
+ "payload": "4.0.0-internal.bc5cf8c"
73
69
  },
74
70
  "//deps_notes": {
75
71
  "zod": "zod is a hard dependency of @modelcontextprotocol/server, thus we can safely use it without it impacting bundle size. Make extra sure the zod version here matches exactly what's defined in the dependencies of @modelcontextprotocol/server to avoid duplicate versions being installed.",
@@ -0,0 +1,3 @@
1
+ import type { MCPAccessArgs } from './types.js'
2
+
3
+ export const defaultAccess = ({ req }: MCPAccessArgs): boolean => Boolean(req.user)