@payloadcms/plugin-mcp 4.0.0-internal.5b1e7cd → 4.0.0-internal.5d2e3d1

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 (446) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +39 -0
  3. package/dist/defaultAccess.d.ts +3 -0
  4. package/dist/defaultAccess.d.ts.map +1 -0
  5. package/dist/defaultAccess.js +3 -0
  6. package/dist/defaultAccess.js.map +1 -0
  7. package/dist/defineTool.d.ts +26 -0
  8. package/dist/defineTool.d.ts.map +1 -0
  9. package/dist/defineTool.js +37 -0
  10. package/dist/defineTool.js.map +1 -0
  11. package/dist/endpoint/access.d.ts +22 -0
  12. package/dist/endpoint/access.d.ts.map +1 -0
  13. package/dist/endpoint/access.js +130 -0
  14. package/dist/endpoint/access.js.map +1 -0
  15. package/dist/endpoint/index.d.ts +3 -0
  16. package/dist/endpoint/index.d.ts.map +1 -0
  17. package/dist/endpoint/index.js +141 -0
  18. package/dist/endpoint/index.js.map +1 -0
  19. package/dist/endpoint/oauth.d.ts +37 -0
  20. package/dist/endpoint/oauth.d.ts.map +1 -0
  21. package/dist/endpoint/oauth.js +105 -0
  22. package/dist/endpoint/oauth.js.map +1 -0
  23. package/dist/endpoint/oauthLoginToken.d.ts +23 -0
  24. package/dist/endpoint/oauthLoginToken.d.ts.map +1 -0
  25. package/dist/endpoint/oauthLoginToken.js +80 -0
  26. package/dist/endpoint/oauthLoginToken.js.map +1 -0
  27. package/dist/endpoint/oauthServer.d.ts +28 -0
  28. package/dist/endpoint/oauthServer.d.ts.map +1 -0
  29. package/dist/endpoint/oauthServer.js +423 -0
  30. package/dist/endpoint/oauthServer.js.map +1 -0
  31. package/dist/exports/client.d.ts +2 -0
  32. package/dist/exports/client.d.ts.map +1 -0
  33. package/dist/exports/client.js +4 -0
  34. package/dist/exports/client.js.map +1 -0
  35. package/dist/exports/internal.d.ts +2 -0
  36. package/dist/exports/internal.d.ts.map +1 -0
  37. package/dist/exports/internal.js +3 -0
  38. package/dist/exports/internal.js.map +1 -0
  39. package/dist/exports/rsc.d.ts +2 -0
  40. package/dist/exports/rsc.d.ts.map +1 -0
  41. package/dist/exports/rsc.js +3 -0
  42. package/dist/exports/rsc.js.map +1 -0
  43. package/dist/index.d.ts +14 -9
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +63 -67
  46. package/dist/index.js.map +1 -1
  47. package/dist/mcp/buildMcpServer.d.ts +19 -0
  48. package/dist/mcp/buildMcpServer.d.ts.map +1 -0
  49. package/dist/mcp/buildMcpServer.js +235 -0
  50. package/dist/mcp/buildMcpServer.js.map +1 -0
  51. package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
  52. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
  53. package/dist/mcp/builtin/collections/authTools.js +312 -0
  54. package/dist/mcp/builtin/collections/authTools.js.map +1 -0
  55. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  56. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  57. package/dist/mcp/builtin/collections/countTool.js +63 -0
  58. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  59. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  60. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  61. package/dist/mcp/builtin/collections/countVersionsTool.js +60 -0
  62. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  63. package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
  64. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
  65. package/dist/mcp/builtin/collections/createTool.js +137 -0
  66. package/dist/mcp/builtin/collections/createTool.js.map +1 -0
  67. package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
  68. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
  69. package/dist/mcp/builtin/collections/deleteTool.js +113 -0
  70. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
  71. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  72. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  73. package/dist/mcp/builtin/collections/duplicateTool.js +90 -0
  74. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  75. package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
  76. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  77. package/dist/mcp/builtin/collections/fileInput.js +88 -0
  78. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  79. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  80. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  81. package/dist/mcp/builtin/collections/findDistinctTool.js +77 -0
  82. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  83. package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
  84. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
  85. package/dist/mcp/builtin/collections/findTool.js +146 -0
  86. package/dist/mcp/builtin/collections/findTool.js.map +1 -0
  87. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  88. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  89. package/dist/mcp/builtin/collections/findVersionByIDTool.js +74 -0
  90. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  91. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  92. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  93. package/dist/mcp/builtin/collections/findVersionsTool.js +84 -0
  94. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  95. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  96. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  97. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +103 -0
  98. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  99. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  100. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  101. package/dist/mcp/builtin/collections/restoreVersionTool.js +69 -0
  102. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  103. package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
  104. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
  105. package/dist/mcp/builtin/collections/updateTool.js +172 -0
  106. package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
  107. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
  108. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
  109. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
  110. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
  111. package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
  112. package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
  113. package/dist/mcp/builtin/formatEntityError.js +55 -0
  114. package/dist/mcp/builtin/formatEntityError.js.map +1 -0
  115. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  116. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  117. package/dist/mcp/builtin/getConfigInfoTool.js +69 -0
  118. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  119. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  120. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  121. package/dist/mcp/builtin/globals/countVersionsTool.js +60 -0
  122. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  123. package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
  124. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
  125. package/dist/mcp/builtin/globals/findTool.js +67 -0
  126. package/dist/mcp/builtin/globals/findTool.js.map +1 -0
  127. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  128. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  129. package/dist/mcp/builtin/globals/findVersionByIDTool.js +68 -0
  130. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  131. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  132. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  133. package/dist/mcp/builtin/globals/findVersionsTool.js +78 -0
  134. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  135. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  136. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  137. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +81 -0
  138. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  139. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  140. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  141. package/dist/mcp/builtin/globals/restoreVersionTool.js +70 -0
  142. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  143. package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
  144. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
  145. package/dist/mcp/builtin/globals/updateTool.js +78 -0
  146. package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
  147. package/dist/mcp/builtinTools.d.ts +168 -0
  148. package/dist/mcp/builtinTools.d.ts.map +1 -0
  149. package/dist/mcp/builtinTools.js +169 -0
  150. package/dist/mcp/builtinTools.js.map +1 -0
  151. package/dist/mcp/sanitizeMCPConfig.d.ts +16 -0
  152. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
  153. package/dist/mcp/sanitizeMCPConfig.js +236 -0
  154. package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
  155. package/dist/stdio.d.ts +8 -0
  156. package/dist/stdio.d.ts.map +1 -0
  157. package/dist/stdio.js +128 -0
  158. package/dist/stdio.js.map +1 -0
  159. package/dist/types.d.ts +352 -441
  160. package/dist/types.d.ts.map +1 -1
  161. package/dist/types.js +4 -1
  162. package/dist/types.js.map +1 -1
  163. package/dist/utils/getLogger.d.ts +10 -0
  164. package/dist/utils/getLogger.d.ts.map +1 -0
  165. package/dist/utils/getLogger.js +22 -0
  166. package/dist/utils/getLogger.js.map +1 -0
  167. package/dist/utils/getPluginConfig.d.ts +12 -0
  168. package/dist/utils/getPluginConfig.d.ts.map +1 -0
  169. package/dist/utils/getPluginConfig.js +15 -0
  170. package/dist/utils/getPluginConfig.js.map +1 -0
  171. package/dist/utils/resolveProjectRoot.d.ts +7 -0
  172. package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
  173. package/dist/utils/resolveProjectRoot.js +15 -0
  174. package/dist/utils/resolveProjectRoot.js.map +1 -0
  175. package/dist/utils/seal.d.ts +17 -0
  176. package/dist/utils/seal.d.ts.map +1 -0
  177. package/dist/utils/seal.js +24 -0
  178. package/dist/utils/seal.js.map +1 -0
  179. package/dist/utils/toStandardSchema.d.ts +5 -0
  180. package/dist/utils/toStandardSchema.d.ts.map +1 -0
  181. package/dist/utils/toStandardSchema.js +4 -0
  182. package/dist/utils/toStandardSchema.js.map +1 -0
  183. package/dist/views/Authorize/AllowButtons/index.d.ts +18 -0
  184. package/dist/views/Authorize/AllowButtons/index.d.ts.map +1 -0
  185. package/dist/views/Authorize/AllowButtons/index.js +88 -0
  186. package/dist/views/Authorize/AllowButtons/index.js.map +1 -0
  187. package/dist/views/Authorize/index.css +19 -0
  188. package/dist/views/Authorize/index.d.ts +9 -0
  189. package/dist/views/Authorize/index.d.ts.map +1 -0
  190. package/dist/views/Authorize/index.js +86 -0
  191. package/dist/views/Authorize/index.js.map +1 -0
  192. package/package.json +48 -26
  193. package/src/defaultAccess.ts +3 -0
  194. package/src/defineTool.ts +44 -0
  195. package/src/endpoint/access.ts +153 -0
  196. package/src/endpoint/index.ts +123 -0
  197. package/src/endpoint/oauth.ts +108 -0
  198. package/src/endpoint/oauthLoginToken.ts +94 -0
  199. package/src/endpoint/oauthServer.ts +452 -0
  200. package/src/exports/client.ts +3 -0
  201. package/src/exports/internal.ts +1 -0
  202. package/src/exports/rsc.ts +1 -0
  203. package/src/index.ts +74 -88
  204. package/src/mcp/buildMcpServer.ts +294 -0
  205. package/src/mcp/builtin/collections/authTools.ts +280 -0
  206. package/src/mcp/builtin/collections/countTool.ts +61 -0
  207. package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
  208. package/src/mcp/builtin/collections/createTool.ts +143 -0
  209. package/src/mcp/builtin/collections/deleteTool.ts +99 -0
  210. package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
  211. package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
  212. package/src/mcp/builtin/collections/fileInput.ts +127 -0
  213. package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
  214. package/src/mcp/builtin/collections/findTool.ts +134 -0
  215. package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
  216. package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
  217. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +91 -0
  218. package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
  219. package/src/mcp/builtin/collections/updateTool.ts +173 -0
  220. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
  221. package/src/mcp/builtin/formatEntityError.ts +77 -0
  222. package/src/mcp/builtin/getConfigInfoTool.ts +68 -0
  223. package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
  224. package/src/mcp/builtin/globals/findTool.ts +66 -0
  225. package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
  226. package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
  227. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +73 -0
  228. package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
  229. package/src/mcp/builtin/globals/updateTool.ts +92 -0
  230. package/src/mcp/builtinTools.ts +161 -0
  231. package/src/mcp/sanitizeMCPConfig.ts +282 -0
  232. package/src/stdio.ts +131 -0
  233. package/src/types.ts +401 -481
  234. package/src/utils/getLogger.ts +22 -0
  235. package/src/utils/getPluginConfig.ts +24 -0
  236. package/src/utils/resolveProjectRoot.ts +17 -0
  237. package/src/utils/seal.ts +46 -0
  238. package/src/utils/toStandardSchema.ts +9 -0
  239. package/src/views/Authorize/AllowButtons/index.tsx +97 -0
  240. package/src/views/Authorize/index.css +19 -0
  241. package/src/views/Authorize/index.tsx +93 -0
  242. package/dist/collections/createApiKeysCollection.d.ts +0 -7
  243. package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
  244. package/dist/collections/createApiKeysCollection.js +0 -317
  245. package/dist/collections/createApiKeysCollection.js.map +0 -1
  246. package/dist/defaults.d.ts +0 -4
  247. package/dist/defaults.d.ts.map +0 -1
  248. package/dist/defaults.js +0 -5
  249. package/dist/defaults.js.map +0 -1
  250. package/dist/endpoints/mcp.d.ts +0 -4
  251. package/dist/endpoints/mcp.d.ts.map +0 -1
  252. package/dist/endpoints/mcp.js +0 -71
  253. package/dist/endpoints/mcp.js.map +0 -1
  254. package/dist/mcp/createRequest.d.ts +0 -3
  255. package/dist/mcp/createRequest.d.ts.map +0 -1
  256. package/dist/mcp/createRequest.js +0 -14
  257. package/dist/mcp/createRequest.js.map +0 -1
  258. package/dist/mcp/getMcpHandler.d.ts +0 -4
  259. package/dist/mcp/getMcpHandler.d.ts.map +0 -1
  260. package/dist/mcp/getMcpHandler.js +0 -231
  261. package/dist/mcp/getMcpHandler.js.map +0 -1
  262. package/dist/mcp/helpers/config.d.ts +0 -22
  263. package/dist/mcp/helpers/config.d.ts.map +0 -1
  264. package/dist/mcp/helpers/config.js +0 -153
  265. package/dist/mcp/helpers/config.js.map +0 -1
  266. package/dist/mcp/helpers/fields.d.ts +0 -19
  267. package/dist/mcp/helpers/fields.d.ts.map +0 -1
  268. package/dist/mcp/helpers/fields.js +0 -102
  269. package/dist/mcp/helpers/fields.js.map +0 -1
  270. package/dist/mcp/helpers/fileValidation.d.ts +0 -67
  271. package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
  272. package/dist/mcp/helpers/fileValidation.js +0 -267
  273. package/dist/mcp/helpers/fileValidation.js.map +0 -1
  274. package/dist/mcp/registerTool.d.ts +0 -6
  275. package/dist/mcp/registerTool.d.ts.map +0 -1
  276. package/dist/mcp/registerTool.js +0 -18
  277. package/dist/mcp/registerTool.js.map +0 -1
  278. package/dist/mcp/tools/auth/auth.d.ts +0 -4
  279. package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
  280. package/dist/mcp/tools/auth/auth.js +0 -57
  281. package/dist/mcp/tools/auth/auth.js.map +0 -1
  282. package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
  283. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
  284. package/dist/mcp/tools/auth/forgotPassword.js +0 -48
  285. package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
  286. package/dist/mcp/tools/auth/login.d.ts +0 -4
  287. package/dist/mcp/tools/auth/login.d.ts.map +0 -1
  288. package/dist/mcp/tools/auth/login.js +0 -51
  289. package/dist/mcp/tools/auth/login.js.map +0 -1
  290. package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
  291. package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
  292. package/dist/mcp/tools/auth/resetPassword.js +0 -49
  293. package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
  294. package/dist/mcp/tools/auth/unlock.d.ts +0 -4
  295. package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
  296. package/dist/mcp/tools/auth/unlock.js +0 -48
  297. package/dist/mcp/tools/auth/unlock.js.map +0 -1
  298. package/dist/mcp/tools/auth/verify.d.ts +0 -4
  299. package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
  300. package/dist/mcp/tools/auth/verify.js +0 -45
  301. package/dist/mcp/tools/auth/verify.js.map +0 -1
  302. package/dist/mcp/tools/collection/create.d.ts +0 -10
  303. package/dist/mcp/tools/collection/create.d.ts.map +0 -1
  304. package/dist/mcp/tools/collection/create.js +0 -139
  305. package/dist/mcp/tools/collection/create.js.map +0 -1
  306. package/dist/mcp/tools/collection/delete.d.ts +0 -10
  307. package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
  308. package/dist/mcp/tools/collection/delete.js +0 -154
  309. package/dist/mcp/tools/collection/delete.js.map +0 -1
  310. package/dist/mcp/tools/collection/find.d.ts +0 -10
  311. package/dist/mcp/tools/collection/find.d.ts.map +0 -1
  312. package/dist/mcp/tools/collection/find.js +0 -165
  313. package/dist/mcp/tools/collection/find.js.map +0 -1
  314. package/dist/mcp/tools/collection/update.d.ts +0 -10
  315. package/dist/mcp/tools/collection/update.d.ts.map +0 -1
  316. package/dist/mcp/tools/collection/update.js +0 -209
  317. package/dist/mcp/tools/collection/update.js.map +0 -1
  318. package/dist/mcp/tools/config/find.d.ts +0 -10
  319. package/dist/mcp/tools/config/find.d.ts.map +0 -1
  320. package/dist/mcp/tools/config/find.js +0 -97
  321. package/dist/mcp/tools/config/find.js.map +0 -1
  322. package/dist/mcp/tools/config/update.d.ts +0 -10
  323. package/dist/mcp/tools/config/update.d.ts.map +0 -1
  324. package/dist/mcp/tools/config/update.js +0 -215
  325. package/dist/mcp/tools/config/update.js.map +0 -1
  326. package/dist/mcp/tools/global/find.d.ts +0 -5
  327. package/dist/mcp/tools/global/find.d.ts.map +0 -1
  328. package/dist/mcp/tools/global/find.js +0 -82
  329. package/dist/mcp/tools/global/find.js.map +0 -1
  330. package/dist/mcp/tools/global/update.d.ts +0 -6
  331. package/dist/mcp/tools/global/update.d.ts.map +0 -1
  332. package/dist/mcp/tools/global/update.js +0 -124
  333. package/dist/mcp/tools/global/update.js.map +0 -1
  334. package/dist/mcp/tools/job/create.d.ts +0 -10
  335. package/dist/mcp/tools/job/create.d.ts.map +0 -1
  336. package/dist/mcp/tools/job/create.js +0 -293
  337. package/dist/mcp/tools/job/create.js.map +0 -1
  338. package/dist/mcp/tools/job/run.d.ts +0 -10
  339. package/dist/mcp/tools/job/run.d.ts.map +0 -1
  340. package/dist/mcp/tools/job/run.js +0 -129
  341. package/dist/mcp/tools/job/run.js.map +0 -1
  342. package/dist/mcp/tools/job/update.d.ts +0 -11
  343. package/dist/mcp/tools/job/update.d.ts.map +0 -1
  344. package/dist/mcp/tools/job/update.js +0 -186
  345. package/dist/mcp/tools/job/update.js.map +0 -1
  346. package/dist/mcp/tools/resource/create.d.ts +0 -6
  347. package/dist/mcp/tools/resource/create.d.ts.map +0 -1
  348. package/dist/mcp/tools/resource/create.js +0 -124
  349. package/dist/mcp/tools/resource/create.js.map +0 -1
  350. package/dist/mcp/tools/resource/delete.d.ts +0 -5
  351. package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
  352. package/dist/mcp/tools/resource/delete.js +0 -151
  353. package/dist/mcp/tools/resource/delete.js.map +0 -1
  354. package/dist/mcp/tools/resource/find.d.ts +0 -5
  355. package/dist/mcp/tools/resource/find.d.ts.map +0 -1
  356. package/dist/mcp/tools/resource/find.js +0 -170
  357. package/dist/mcp/tools/resource/find.js.map +0 -1
  358. package/dist/mcp/tools/resource/update.d.ts +0 -6
  359. package/dist/mcp/tools/resource/update.d.ts.map +0 -1
  360. package/dist/mcp/tools/resource/update.js +0 -256
  361. package/dist/mcp/tools/resource/update.js.map +0 -1
  362. package/dist/mcp/tools/schemas.d.ts +0 -457
  363. package/dist/mcp/tools/schemas.d.ts.map +0 -1
  364. package/dist/mcp/tools/schemas.js +0 -243
  365. package/dist/mcp/tools/schemas.js.map +0 -1
  366. package/dist/utils/adminEntitySettings.d.ts +0 -17
  367. package/dist/utils/adminEntitySettings.d.ts.map +0 -1
  368. package/dist/utils/adminEntitySettings.js +0 -41
  369. package/dist/utils/adminEntitySettings.js.map +0 -1
  370. package/dist/utils/createApiKeyFields.d.ts +0 -15
  371. package/dist/utils/createApiKeyFields.d.ts.map +0 -1
  372. package/dist/utils/createApiKeyFields.js +0 -57
  373. package/dist/utils/createApiKeyFields.js.map +0 -1
  374. package/dist/utils/getEnabledSlugs.d.ts +0 -13
  375. package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
  376. package/dist/utils/getEnabledSlugs.js +0 -32
  377. package/dist/utils/getEnabledSlugs.js.map +0 -1
  378. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  379. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  380. package/dist/utils/getVirtualFieldNames.js +0 -35
  381. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  382. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
  383. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
  384. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
  385. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
  386. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  387. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  388. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  389. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  390. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  391. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  392. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  393. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  394. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  395. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  396. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
  397. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  398. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  399. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  400. package/dist/utils/schemaConversion/transformPointFields.js +0 -51
  401. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  402. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  403. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  404. package/dist/utils/transformPointDataToPayload.js +0 -28
  405. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  406. package/src/collections/createApiKeysCollection.ts +0 -373
  407. package/src/defaults.ts +0 -3
  408. package/src/endpoints/mcp.ts +0 -91
  409. package/src/mcp/createRequest.ts +0 -13
  410. package/src/mcp/getMcpHandler.ts +0 -545
  411. package/src/mcp/helpers/config.ts +0 -213
  412. package/src/mcp/helpers/fields.ts +0 -154
  413. package/src/mcp/helpers/fileValidation.ts +0 -362
  414. package/src/mcp/registerTool.ts +0 -22
  415. package/src/mcp/tools/auth/auth.ts +0 -71
  416. package/src/mcp/tools/auth/forgotPassword.ts +0 -70
  417. package/src/mcp/tools/auth/login.ts +0 -72
  418. package/src/mcp/tools/auth/resetPassword.ts +0 -61
  419. package/src/mcp/tools/auth/unlock.ts +0 -64
  420. package/src/mcp/tools/auth/verify.ts +0 -57
  421. package/src/mcp/tools/collection/create.ts +0 -210
  422. package/src/mcp/tools/collection/delete.ts +0 -211
  423. package/src/mcp/tools/collection/find.ts +0 -224
  424. package/src/mcp/tools/collection/update.ts +0 -290
  425. package/src/mcp/tools/config/find.ts +0 -128
  426. package/src/mcp/tools/config/update.ts +0 -280
  427. package/src/mcp/tools/global/find.ts +0 -128
  428. package/src/mcp/tools/global/update.ts +0 -207
  429. package/src/mcp/tools/job/create.ts +0 -416
  430. package/src/mcp/tools/job/run.ts +0 -167
  431. package/src/mcp/tools/job/update.ts +0 -274
  432. package/src/mcp/tools/resource/create.ts +0 -211
  433. package/src/mcp/tools/resource/delete.ts +0 -218
  434. package/src/mcp/tools/resource/find.ts +0 -246
  435. package/src/mcp/tools/resource/update.ts +0 -383
  436. package/src/mcp/tools/schemas.ts +0 -520
  437. package/src/utils/adminEntitySettings.ts +0 -40
  438. package/src/utils/createApiKeyFields.ts +0 -72
  439. package/src/utils/getEnabledSlugs.ts +0 -42
  440. package/src/utils/getVirtualFieldNames.ts +0 -53
  441. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
  442. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
  443. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  444. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
  445. package/src/utils/schemaConversion/transformPointFields.ts +0 -55
  446. package/src/utils/transformPointDataToPayload.ts +0 -40
@@ -1,165 +0,0 @@
1
- import { readdirSync, readFileSync, statSync } from 'fs';
2
- import { extname, join } from 'path';
3
- import { toolSchemas } from '../schemas.js';
4
- export const readCollections = (req, verboseLogs, collectionsDirPath, collectionName, includeContent = false, includeCount = false)=>{
5
- const payload = req.payload;
6
- if (verboseLogs) {
7
- payload.logger.info(`[payload-mcp] Reading collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`);
8
- }
9
- try {
10
- // Read specific Collection (optional)
11
- if (collectionName) {
12
- const fileName = `${collectionName.charAt(0).toUpperCase() + collectionName.slice(1)}.ts`;
13
- const filePath = join(collectionsDirPath, fileName);
14
- if (!filePath.startsWith(collectionsDirPath)) {
15
- payload.logger.error(`[payload-mcp] Invalid collection name attempted: ${collectionName}`);
16
- return {
17
- content: [
18
- {
19
- type: 'text',
20
- text: 'Error: Invalid collection name'
21
- }
22
- ]
23
- };
24
- }
25
- try {
26
- const content = readFileSync(filePath, 'utf8');
27
- if (verboseLogs) {
28
- payload.logger.info(`[payload-mcp] Successfully read collection: ${collectionName}`);
29
- }
30
- return {
31
- content: [
32
- {
33
- type: 'text',
34
- text: `Collection: ${collectionName}
35
- File: ${fileName}
36
- ---
37
- ${content}`
38
- }
39
- ]
40
- };
41
- } catch (_error) {
42
- payload.logger.warn(`[payload-mcp] Collection not found: ${collectionName}`);
43
- return {
44
- content: [
45
- {
46
- type: 'text',
47
- text: `Error: Collection '${collectionName}' not found`
48
- }
49
- ]
50
- };
51
- }
52
- }
53
- // Read all Collections
54
- const files = readdirSync(collectionsDirPath).filter((file)=>extname(file) === '.ts').sort();
55
- if (verboseLogs) {
56
- payload.logger.info(`[payload-mcp] Found ${files.length} collection files in directory`);
57
- }
58
- if (files.length === 0) {
59
- payload.logger.warn('[payload-mcp] No collection files found in src/collections directory');
60
- return {
61
- content: [
62
- {
63
- type: 'text',
64
- text: 'No collection files found in src/collections directory'
65
- }
66
- ]
67
- };
68
- }
69
- const results = [];
70
- // Build complete table as a single markdown string
71
- let tableContent = `Found ${files.length} collection file(s):\n\n`;
72
- // Build table header
73
- let tableHeader = '| Collection | File | Size | Modified';
74
- let tableSeparator = '|------------|------|------|----------';
75
- if (includeCount) {
76
- tableHeader += ' | Documents';
77
- tableSeparator += ' |----------';
78
- }
79
- tableHeader += ' |';
80
- tableSeparator += ' |';
81
- tableContent += tableHeader + '\n';
82
- tableContent += tableSeparator + '\n';
83
- for (const file of files){
84
- const filePath = join(collectionsDirPath, file);
85
- const stats = statSync(filePath);
86
- const fileSize = stats.size;
87
- const lastModified = stats.mtime;
88
- const collectionName = file.replace('.ts', '');
89
- // Build table row
90
- let tableRow = `| **${collectionName}** | ${file} | ${fileSize.toLocaleString()} bytes | ${lastModified.toISOString()}`;
91
- // Add document count if requested
92
- if (includeCount) {
93
- try {
94
- // For now, we'll skip document counting since we don't have access to payload instance
95
- tableRow += ' | -';
96
- } catch (error) {
97
- tableRow += ` | Error: ${error.message}`;
98
- }
99
- }
100
- tableRow += ' |';
101
- tableContent += tableRow + '\n';
102
- if (includeContent) {
103
- try {
104
- const content = readFileSync(filePath, 'utf8');
105
- tableContent += `\n**${collectionName} Content:**\n\`\`\`typescript\n${content}\n\`\`\`\n\n`;
106
- } catch (error) {
107
- tableContent += `\nError reading content: ${error.message}\n\n`;
108
- }
109
- }
110
- }
111
- results.push({
112
- type: 'text',
113
- text: tableContent
114
- });
115
- return {
116
- content: results
117
- };
118
- } catch (error) {
119
- const errorMessage = error.message;
120
- payload.logger.error(`[payload-mcp] Error reading collections: ${errorMessage}`);
121
- return {
122
- content: [
123
- {
124
- type: 'text',
125
- text: `❌ **Error reading collections**: ${errorMessage}`
126
- }
127
- ]
128
- };
129
- }
130
- };
131
- // MCP Server tool registration
132
- export const findCollectionTool = (server, req, verboseLogs, collectionsDirPath)=>{
133
- const tool = (collectionName, includeContent = false, includeCount = false)=>{
134
- const payload = req.payload;
135
- if (verboseLogs) {
136
- payload.logger.info(`[payload-mcp] Finding collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`);
137
- }
138
- try {
139
- const result = readCollections(req, verboseLogs, collectionsDirPath, collectionName, includeContent, includeCount);
140
- if (verboseLogs) {
141
- payload.logger.info(`[payload-mcp] Collection search completed`);
142
- }
143
- return result;
144
- } catch (error) {
145
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
146
- payload.logger.error(`[payload-mcp] Error finding collections: ${errorMessage}`);
147
- return {
148
- content: [
149
- {
150
- type: 'text',
151
- text: `Error finding collections: ${errorMessage}`
152
- }
153
- ]
154
- };
155
- }
156
- };
157
- server.registerTool('findCollections', {
158
- description: toolSchemas.findCollections.description,
159
- inputSchema: toolSchemas.findCollections.parameters.shape
160
- }, ({ collectionName, includeContent, includeCount })=>{
161
- return tool(collectionName, includeContent, includeCount);
162
- });
163
- };
164
-
165
- //# sourceMappingURL=find.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/collection/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readdirSync, readFileSync, statSync } from 'fs'\nimport { extname, join } from 'path'\n\nimport { toolSchemas } from '../schemas.js'\n\nexport const readCollections = (\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n collectionName?: string,\n includeContent: boolean = false,\n includeCount: boolean = false,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Reading collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`,\n )\n }\n\n try {\n // Read specific Collection (optional)\n if (collectionName) {\n const fileName = `${collectionName.charAt(0).toUpperCase() + collectionName.slice(1)}.ts`\n const filePath = join(collectionsDirPath, fileName)\n\n if (!filePath.startsWith(collectionsDirPath)) {\n payload.logger.error(`[payload-mcp] Invalid collection name attempted: ${collectionName}`)\n return {\n content: [{ type: 'text' as const, text: 'Error: Invalid collection name' }],\n }\n }\n\n try {\n const content = readFileSync(filePath, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully read collection: ${collectionName}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Collection: ${collectionName}\nFile: ${fileName}\n---\n${content}`,\n },\n ],\n }\n } catch (_error) {\n payload.logger.warn(`[payload-mcp] Collection not found: ${collectionName}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error: Collection '${collectionName}' not found`,\n },\n ],\n }\n }\n }\n\n // Read all Collections\n const files = readdirSync(collectionsDirPath)\n .filter((file) => extname(file) === '.ts')\n .sort()\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found ${files.length} collection files in directory`)\n }\n\n if (files.length === 0) {\n payload.logger.warn('[payload-mcp] No collection files found in src/collections directory')\n return {\n content: [\n {\n type: 'text' as const,\n text: 'No collection files found in src/collections directory',\n },\n ],\n }\n }\n\n const results = []\n\n // Build complete table as a single markdown string\n let tableContent = `Found ${files.length} collection file(s):\\n\\n`\n\n // Build table header\n let tableHeader = '| Collection | File | Size | Modified'\n let tableSeparator = '|------------|------|------|----------'\n\n if (includeCount) {\n tableHeader += ' | Documents'\n tableSeparator += ' |----------'\n }\n tableHeader += ' |'\n tableSeparator += ' |'\n\n tableContent += tableHeader + '\\n'\n tableContent += tableSeparator + '\\n'\n\n for (const file of files) {\n const filePath = join(collectionsDirPath, file)\n const stats = statSync(filePath)\n const fileSize = stats.size\n const lastModified = stats.mtime\n\n const collectionName = file.replace('.ts', '')\n\n // Build table row\n let tableRow = `| **${collectionName}** | ${file} | ${fileSize.toLocaleString()} bytes | ${lastModified.toISOString()}`\n\n // Add document count if requested\n if (includeCount) {\n try {\n // For now, we'll skip document counting since we don't have access to payload instance\n tableRow += ' | -'\n } catch (error) {\n tableRow += ` | Error: ${(error as Error).message}`\n }\n }\n tableRow += ' |'\n\n tableContent += tableRow + '\\n'\n\n if (includeContent) {\n try {\n const content = readFileSync(filePath, 'utf8')\n tableContent += `\\n**${collectionName} Content:**\\n\\`\\`\\`typescript\\n${content}\\n\\`\\`\\`\\n\\n`\n } catch (error) {\n tableContent += `\\nError reading content: ${(error as Error).message}\\n\\n`\n }\n }\n }\n\n results.push({\n type: 'text' as const,\n text: tableContent,\n })\n\n return {\n content: results,\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error reading collections: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading collections**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// MCP Server tool registration\nexport const findCollectionTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n) => {\n const tool = (\n collectionName?: string,\n includeContent: boolean = false,\n includeCount: boolean = false,\n ) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Finding collections${collectionName ? ` for: ${collectionName}` : ''}, includeContent: ${includeContent}, includeCount: ${includeCount}`,\n )\n }\n\n try {\n const result = readCollections(\n req,\n verboseLogs,\n collectionsDirPath,\n collectionName,\n includeContent,\n includeCount,\n )\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Collection search completed`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(`[payload-mcp] Error finding collections: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error finding collections: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'findCollections',\n {\n description: toolSchemas.findCollections.description,\n inputSchema: toolSchemas.findCollections.parameters.shape,\n },\n ({ collectionName, includeContent, includeCount }) => {\n return tool(collectionName, includeContent, includeCount)\n },\n )\n}\n"],"names":["readdirSync","readFileSync","statSync","extname","join","toolSchemas","readCollections","req","verboseLogs","collectionsDirPath","collectionName","includeContent","includeCount","payload","logger","info","fileName","charAt","toUpperCase","slice","filePath","startsWith","error","content","type","text","_error","warn","files","filter","file","sort","length","results","tableContent","tableHeader","tableSeparator","stats","fileSize","size","lastModified","mtime","replace","tableRow","toLocaleString","toISOString","message","push","errorMessage","findCollectionTool","server","tool","result","Error","registerTool","description","findCollections","inputSchema","parameters","shape"],"mappings":"AAGA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,KAAI;AACxD,SAASC,OAAO,EAAEC,IAAI,QAAQ,OAAM;AAEpC,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,kBAAkB,CAC7BC,KACAC,aACAC,oBACAC,gBACAC,iBAA0B,KAAK,EAC/BC,eAAwB,KAAK;IAE7B,MAAMC,UAAUN,IAAIM,OAAO;IAE3B,IAAIL,aAAa;QACfK,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,iCAAiC,EAAEL,iBAAiB,CAAC,MAAM,EAAEA,gBAAgB,GAAG,GAAG,kBAAkB,EAAEC,eAAe,gBAAgB,EAAEC,cAAc;IAE3J;IAEA,IAAI;QACF,sCAAsC;QACtC,IAAIF,gBAAgB;YAClB,MAAMM,WAAW,GAAGN,eAAeO,MAAM,CAAC,GAAGC,WAAW,KAAKR,eAAeS,KAAK,CAAC,GAAG,GAAG,CAAC;YACzF,MAAMC,WAAWhB,KAAKK,oBAAoBO;YAE1C,IAAI,CAACI,SAASC,UAAU,CAACZ,qBAAqB;gBAC5CI,QAAQC,MAAM,CAAC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MAAM;oBACNC,MAAM,CAAC,iCAAiC,EAAEuB,cAAc;gBAC1D;aACD;QACH;IACF;AACF,EAAC;AAED,+BAA+B;AAC/B,OAAO,MAAMC,qBAAqB,CAChCC,QACA3C,KACAC,aACAC;IAEA,MAAM0C,OAAO,CACXzC,gBACAC,iBAA0B,KAAK,EAC/BC,eAAwB,KAAK;QAE7B,MAAMC,UAAUN,IAAIM,OAAO;QAE3B,IAAIL,aAAa;YACfK,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,iCAAiC,EAAEL,iBAAiB,CAAC,MAAM,EAAEA,gBAAgB,GAAG,GAAG,kBAAkB,EAAEC,eAAe,gBAAgB,EAAEC,cAAc;QAE3J;QAEA,IAAI;YACF,MAAMwC,SAAS9C,gBACbC,KACAC,aACAC,oBACAC,gBACAC,gBACAC;YAGF,IAAIJ,aAAa;gBACfK,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,yCAAyC,CAAC;YACjE;YAEA,OAAOqC;QACT,EAAE,OAAO9B,OAAO;YACd,MAAM0B,eAAe1B,iBAAiB+B,QAAQ/B,MAAMwB,OAAO,GAAG;YAC9DjC,QAAQC,MAAM,CAACQ,KAAK,CAAC,CAAC,yCAAyC,EAAE0B,cAAc;YAE/E,OAAO;gBACLzB,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,2BAA2B,EAAEuB,cAAc;oBACpD;iBACD;YACH;QACF;IACF;IAEAE,OAAOI,YAAY,CACjB,mBACA;QACEC,aAAalD,YAAYmD,eAAe,CAACD,WAAW;QACpDE,aAAapD,YAAYmD,eAAe,CAACE,UAAU,CAACC,KAAK;IAC3D,GACA,CAAC,EAAEjD,cAAc,EAAEC,cAAc,EAAEC,YAAY,EAAE;QAC/C,OAAOuC,KAAKzC,gBAAgBC,gBAAgBC;IAC9C;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const updateCollection: (req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string, configFilePath: string, collectionName: string, updateType: string, newFields?: any[], fieldNamesToRemove?: string[], fieldModifications?: any[], configUpdates?: any, newContent?: string) => Promise<{
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- }>;
9
- export declare const updateCollectionTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, collectionsDirPath: string, configFilePath: string) => void;
10
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/collection/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAa7C,eAAO,MAAM,gBAAgB,QACtB,cAAc,eACN,OAAO,sBACA,MAAM,kBACV,MAAM,kBACN,MAAM,cACV,MAAM,cACN,GAAG,EAAE,uBACI,MAAM,EAAE,uBACR,GAAG,EAAE,kBACV,GAAG,eACN,MAAM;;;;;EAuLpB,CAAA;AAED,eAAO,MAAM,oBAAoB,WACvB,SAAS,OACZ,cAAc,eACN,OAAO,sBACA,MAAM,kBACV,MAAM,SA0EvB,CAAA"}
@@ -1,209 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { addFieldsToCollection, modifyFieldsInCollection, removeFieldsFromCollection } from '../../helpers/fields.js';
4
- import { validateCollectionFile } from '../../helpers/fileValidation.js';
5
- import { toolSchemas } from '../schemas.js';
6
- export const updateCollection = async (req, verboseLogs, collectionsDirPath, configFilePath, collectionName, updateType, newFields, fieldNamesToRemove, fieldModifications, configUpdates, newContent)=>{
7
- const payload = req.payload;
8
- if (verboseLogs) {
9
- payload.logger.info(`[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`);
10
- }
11
- const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1);
12
- const fileName = `${capitalizedName}.ts`;
13
- const filePath = join(collectionsDirPath, fileName);
14
- // Security check: ensure we're working with the collections directory
15
- if (!filePath.startsWith(collectionsDirPath)) {
16
- payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${filePath}`);
17
- return {
18
- content: [
19
- {
20
- type: 'text',
21
- text: '❌ **Error**: Invalid collection path'
22
- }
23
- ]
24
- };
25
- }
26
- try {
27
- // Check if collection file exists
28
- let currentContent;
29
- try {
30
- currentContent = readFileSync(filePath, 'utf8');
31
- } catch (_ignore) {
32
- return {
33
- content: [
34
- {
35
- type: 'text',
36
- text: `❌ **Error**: Collection file not found: ${fileName}`
37
- }
38
- ]
39
- };
40
- }
41
- let updatedContent;
42
- let updateSummary = [];
43
- switch(updateType){
44
- case 'add_field':
45
- if (!newFields || newFields.length === 0) {
46
- return {
47
- content: [
48
- {
49
- type: 'text',
50
- text: '❌ **Error**: No fields provided for add_field update type'
51
- }
52
- ]
53
- };
54
- }
55
- updatedContent = addFieldsToCollection(currentContent, newFields);
56
- updateSummary = newFields.map((field)=>`Added field: ${field.name} (${field.type})`);
57
- break;
58
- case 'modify_field':
59
- if (!fieldModifications || fieldModifications.length === 0) {
60
- return {
61
- content: [
62
- {
63
- type: 'text',
64
- text: '❌ **Error**: No field modifications provided for modify_field update type'
65
- }
66
- ]
67
- };
68
- }
69
- updatedContent = modifyFieldsInCollection(currentContent, fieldModifications);
70
- updateSummary = fieldModifications.map((mod)=>`Modified field: ${mod.fieldName}`);
71
- break;
72
- case 'remove_field':
73
- if (!fieldNamesToRemove || fieldNamesToRemove.length === 0) {
74
- return {
75
- content: [
76
- {
77
- type: 'text',
78
- text: '❌ **Error**: No field names provided for remove_field update type'
79
- }
80
- ]
81
- };
82
- }
83
- updatedContent = removeFieldsFromCollection(currentContent, fieldNamesToRemove);
84
- updateSummary = fieldNamesToRemove.map((fieldName)=>`Removed field: ${fieldName}`);
85
- break;
86
- case 'replace_content':
87
- if (!newContent) {
88
- return {
89
- content: [
90
- {
91
- type: 'text',
92
- text: '❌ **Error**: No new content provided for replace_content update type'
93
- }
94
- ]
95
- };
96
- }
97
- updatedContent = newContent;
98
- updateSummary = [
99
- 'Replaced entire collection content'
100
- ];
101
- break;
102
- case 'update_config':
103
- if (!configUpdates) {
104
- return {
105
- content: [
106
- {
107
- type: 'text',
108
- text: '❌ **Error**: No config updates provided for update_config update type'
109
- }
110
- ]
111
- };
112
- }
113
- // For now, we'll use a simple approach since the config helper might not have this functionality
114
- updatedContent = currentContent;
115
- updateSummary = Object.keys(configUpdates).map((key)=>`Updated config: ${key}`);
116
- break;
117
- default:
118
- return {
119
- content: [
120
- {
121
- type: 'text',
122
- text: `❌ **Error**: Unknown update type: ${updateType}`
123
- }
124
- ]
125
- };
126
- }
127
- // Write the updated content back to the file
128
- writeFileSync(filePath, updatedContent, 'utf8');
129
- if (verboseLogs) {
130
- payload.logger.info(`[payload-mcp] Successfully updated collection file: ${filePath}`);
131
- }
132
- // Validate the updated file
133
- const validationResult = await validateCollectionFile(fileName);
134
- if (validationResult.error) {
135
- return {
136
- content: [
137
- {
138
- type: 'text',
139
- text: `❌ **Error**: Updated collection has validation issues:\n\n${validationResult.error}`
140
- }
141
- ]
142
- };
143
- }
144
- return {
145
- content: [
146
- {
147
- type: 'text',
148
- text: `✅ **Collection updated successfully!**
149
-
150
- **File**: \`${fileName}\`
151
- **Update Type**: ${updateType}
152
-
153
- **Changes Made**:
154
- ${updateSummary.map((summary)=>`- ${summary}`).join('\n')}
155
-
156
- **Updated Collection Code:**
157
- \`\`\`typescript
158
- ${updatedContent}
159
- \`\`\``
160
- }
161
- ]
162
- };
163
- } catch (error) {
164
- const errorMessage = error.message;
165
- payload.logger.error(`[payload-mcp] Error updating collection: ${errorMessage}`);
166
- return {
167
- content: [
168
- {
169
- type: 'text',
170
- text: `❌ **Error updating collection**: ${errorMessage}`
171
- }
172
- ]
173
- };
174
- }
175
- };
176
- export const updateCollectionTool = (server, req, verboseLogs, collectionsDirPath, configFilePath)=>{
177
- const tool = async ({ collectionName, configUpdates, fieldModifications, fieldNamesToRemove, newContent, newFields, updateType })=>{
178
- const payload = req.payload;
179
- if (verboseLogs) {
180
- payload.logger.info(`[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`);
181
- }
182
- try {
183
- const result = await updateCollection(req, verboseLogs, collectionsDirPath, configFilePath, collectionName, updateType, newFields, fieldNamesToRemove, fieldModifications, configUpdates, newContent);
184
- if (verboseLogs) {
185
- payload.logger.info(`[payload-mcp] Collection update completed for: ${collectionName}`);
186
- }
187
- return result;
188
- } catch (error) {
189
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
190
- payload.logger.error(`[payload-mcp] Error updating collection ${collectionName}: ${errorMessage}`);
191
- return {
192
- content: [
193
- {
194
- type: 'text',
195
- text: `Error updating collection "${collectionName}": ${errorMessage}`
196
- }
197
- ]
198
- };
199
- }
200
- };
201
- server.registerTool('updateCollection', {
202
- description: toolSchemas.updateCollection.description,
203
- inputSchema: toolSchemas.updateCollection.parameters.shape
204
- }, async (args)=>{
205
- return await tool(args);
206
- });
207
- };
208
-
209
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/collection/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport {\n addFieldsToCollection,\n modifyFieldsInCollection,\n removeFieldsFromCollection,\n} from '../../helpers/fields.js'\nimport { validateCollectionFile } from '../../helpers/fileValidation.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const updateCollection = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n collectionName: string,\n updateType: string,\n newFields?: any[],\n fieldNamesToRemove?: string[],\n fieldModifications?: any[],\n configUpdates?: any,\n newContent?: string,\n) => {\n const payload = req.payload\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`,\n )\n }\n\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n const fileName = `${capitalizedName}.ts`\n const filePath = join(collectionsDirPath, fileName)\n\n // Security check: ensure we're working with the collections directory\n if (!filePath.startsWith(collectionsDirPath)) {\n payload.logger.error(`[payload-mcp] Invalid collection path attempted: ${filePath}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: Invalid collection path',\n },\n ],\n }\n }\n\n try {\n // Check if collection file exists\n let currentContent: string\n try {\n currentContent = readFileSync(filePath, 'utf8')\n } catch (_ignore) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Collection file not found: ${fileName}`,\n },\n ],\n }\n }\n\n let updatedContent: string\n let updateSummary: string[] = []\n\n switch (updateType) {\n case 'add_field':\n if (!newFields || newFields.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No fields provided for add_field update type',\n },\n ],\n }\n }\n updatedContent = addFieldsToCollection(currentContent, newFields)\n updateSummary = newFields.map((field: any) => `Added field: ${field.name} (${field.type})`)\n break\n\n case 'modify_field':\n if (!fieldModifications || fieldModifications.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No field modifications provided for modify_field update type',\n },\n ],\n }\n }\n updatedContent = modifyFieldsInCollection(currentContent, fieldModifications)\n updateSummary = fieldModifications.map((mod: any) => `Modified field: ${mod.fieldName}`)\n break\n\n case 'remove_field':\n if (!fieldNamesToRemove || fieldNamesToRemove.length === 0) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No field names provided for remove_field update type',\n },\n ],\n }\n }\n updatedContent = removeFieldsFromCollection(currentContent, fieldNamesToRemove)\n updateSummary = fieldNamesToRemove.map((fieldName: string) => `Removed field: ${fieldName}`)\n break\n\n case 'replace_content':\n if (!newContent) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No new content provided for replace_content update type',\n },\n ],\n }\n }\n updatedContent = newContent\n updateSummary = ['Replaced entire collection content']\n break\n\n case 'update_config':\n if (!configUpdates) {\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: No config updates provided for update_config update type',\n },\n ],\n }\n }\n // For now, we'll use a simple approach since the config helper might not have this functionality\n updatedContent = currentContent\n updateSummary = Object.keys(configUpdates).map((key) => `Updated config: ${key}`)\n break\n\n default:\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Unknown update type: ${updateType}`,\n },\n ],\n }\n }\n\n // Write the updated content back to the file\n writeFileSync(filePath, updatedContent, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated collection file: ${filePath}`)\n }\n\n // Validate the updated file\n const validationResult = await validateCollectionFile(fileName)\n if (validationResult.error) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Updated collection has validation issues:\\n\\n${validationResult.error}`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `✅ **Collection updated successfully!**\n\n**File**: \\`${fileName}\\`\n**Update Type**: ${updateType}\n\n**Changes Made**:\n${updateSummary.map((summary) => `- ${summary}`).join('\\n')}\n\n**Updated Collection Code:**\n\\`\\`\\`typescript\n${updatedContent}\n\\`\\`\\``,\n },\n ],\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error updating collection: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error updating collection**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\nexport const updateCollectionTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n collectionsDirPath: string,\n configFilePath: string,\n) => {\n const tool = async ({\n collectionName,\n configUpdates,\n fieldModifications,\n fieldNamesToRemove,\n newContent,\n newFields,\n updateType,\n }: {\n collectionName: string\n configUpdates?: any\n fieldModifications?: any[]\n fieldNamesToRemove?: string[]\n newContent?: string\n newFields?: any[]\n updateType: string\n }) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating collection: ${collectionName}, updateType: ${updateType}`,\n )\n }\n\n try {\n const result = await updateCollection(\n req,\n verboseLogs,\n collectionsDirPath,\n configFilePath,\n collectionName,\n updateType,\n newFields,\n fieldNamesToRemove,\n fieldModifications,\n configUpdates,\n newContent,\n )\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Collection update completed for: ${collectionName}`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating collection ${collectionName}: ${errorMessage}`,\n )\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error updating collection \"${collectionName}\": ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'updateCollection',\n {\n description: toolSchemas.updateCollection.description,\n inputSchema: toolSchemas.updateCollection.parameters.shape,\n },\n async (args) => {\n return await tool(args)\n },\n )\n}\n"],"names":["readFileSync","writeFileSync","join","addFieldsToCollection","modifyFieldsInCollection","removeFieldsFromCollection","validateCollectionFile","toolSchemas","updateCollection","req","verboseLogs","collectionsDirPath","configFilePath","collectionName","updateType","newFields","fieldNamesToRemove","fieldModifications","configUpdates","newContent","payload","logger","info","capitalizedName","charAt","toUpperCase","slice","fileName","filePath","startsWith","error","content","type","text","currentContent","_ignore","updatedContent","updateSummary","length","map","field","name","mod","fieldName","Object","keys","key","validationResult","summary","errorMessage","message","updateCollectionTool","server","tool","result","Error","registerTool","description","inputSchema","parameters","shape","args"],"mappings":"AAGA,SAASA,YAAY,EAAEC,aAAa,QAAQ,KAAI;AAChD,SAASC,IAAI,QAAQ,OAAM;AAE3B,SACEC,qBAAqB,EACrBC,wBAAwB,EACxBC,0BAA0B,QACrB,0BAAyB;AAChC,SAASC,sBAAsB,QAAQ,kCAAiC;AACxE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mB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AM,CAACC,IAAI,CAAC,CAAC,+CAA+C,EAAET,gBAAgB;YACxF;YAEA,OAAOyC;QACT,EAAE,OAAOxB,OAAO;YACd,MAAMmB,eAAenB,iBAAiByB,QAAQzB,MAAMoB,OAAO,GAAG;YAC9D9B,QAAQC,MAAM,CAACS,KAAK,CAClB,CAAC,wCAAwC,EAAEjB,eAAe,EAAE,EAAEoC,cAAc;YAG9E,OAAO;gBACLlB,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,2BAA2B,EAAEpB,eAAe,GAAG,EAAEoC,cAAc;oBACxE;iBACD;YACH;QACF;IACF;IAEAG,OAAOI,YAAY,CACjB,oBACA;QACEC,aAAalD,YAAYC,gBAAgB,CAACiD,WAAW;QACrDC,aAAanD,YAAYC,gBAAgB,CAACmD,UAAU,CAACC,KAAK;IAC5D,GACA,OAAOC;QACL,OAAO,MAAMR,KAAKQ;IACpB;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const readConfigFile: (req: PayloadRequest, verboseLogs: boolean, configFilePath: string, includeMetadata?: boolean) => {
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- };
9
- export declare const findConfigTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, configFilePath: string) => void;
10
- //# sourceMappingURL=find.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/config/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,eAAO,MAAM,cAAc,QACpB,cAAc,eACN,OAAO,kBACJ,MAAM,oBACL,OAAO;;;;;CAmEzB,CAAA;AAGD,eAAO,MAAM,cAAc,WACjB,SAAS,OACZ,cAAc,eACN,OAAO,kBACJ,MAAM,SA0CvB,CAAA"}
@@ -1,97 +0,0 @@
1
- import { readFileSync, statSync } from 'fs';
2
- import { toolSchemas } from '../schemas.js';
3
- export const readConfigFile = (req, verboseLogs, configFilePath, includeMetadata = false)=>{
4
- const payload = req.payload;
5
- if (verboseLogs) {
6
- payload.logger.info(`[payload-mcp] Reading config file, includeMetadata: ${includeMetadata}`);
7
- }
8
- try {
9
- // Security check: ensure we're working with the specified config file
10
- if (!configFilePath.startsWith(process.cwd()) && !configFilePath.startsWith('/')) {
11
- payload.logger.error(`[payload-mcp] Invalid config path attempted: ${configFilePath}`);
12
- return {
13
- content: [
14
- {
15
- type: 'text',
16
- text: '❌ **Error**: Invalid config path'
17
- }
18
- ]
19
- };
20
- }
21
- const content = readFileSync(configFilePath, 'utf8');
22
- const stats = statSync(configFilePath);
23
- if (verboseLogs) {
24
- payload.logger.info(`[payload-mcp] Successfully read config file. Size: ${stats.size} bytes`);
25
- }
26
- let responseText = `# Payload Configuration
27
-
28
- **File**: \`${configFilePath}\``;
29
- if (includeMetadata) {
30
- responseText += `
31
- **Size**: ${stats.size.toLocaleString()} bytes
32
- **Modified**: ${stats.mtime.toISOString()}
33
- **Created**: ${stats.birthtime.toISOString()}`;
34
- }
35
- responseText += `
36
- ---
37
-
38
- **Configuration Content:**
39
- \`\`\`typescript
40
- ${content}
41
- \`\`\``;
42
- return {
43
- content: [
44
- {
45
- type: 'text',
46
- text: responseText
47
- }
48
- ]
49
- };
50
- } catch (error) {
51
- const errorMessage = error.message;
52
- payload.logger.error(`[payload-mcp] Error reading config file: ${errorMessage}`);
53
- return {
54
- content: [
55
- {
56
- type: 'text',
57
- text: `❌ **Error reading config file**: ${errorMessage}`
58
- }
59
- ]
60
- };
61
- }
62
- };
63
- // MCP Server tool registration
64
- export const findConfigTool = (server, req, verboseLogs, configFilePath)=>{
65
- const tool = (includeMetadata = false)=>{
66
- const payload = req.payload;
67
- if (verboseLogs) {
68
- payload.logger.info(`[payload-mcp] Finding config, includeMetadata: ${includeMetadata}`);
69
- }
70
- try {
71
- const result = readConfigFile(req, verboseLogs, configFilePath, includeMetadata);
72
- if (verboseLogs) {
73
- payload.logger.info(`[payload-mcp] Config search completed`);
74
- }
75
- return result;
76
- } catch (error) {
77
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
78
- payload.logger.error(`[payload-mcp] Error finding config: ${errorMessage}`);
79
- return {
80
- content: [
81
- {
82
- type: 'text',
83
- text: `Error finding config: ${errorMessage}`
84
- }
85
- ]
86
- };
87
- }
88
- };
89
- server.registerTool('findConfig', {
90
- description: toolSchemas.findConfig.description,
91
- inputSchema: toolSchemas.findConfig.parameters.shape
92
- }, ({ includeMetadata })=>{
93
- return tool(includeMetadata);
94
- });
95
- };
96
-
97
- //# sourceMappingURL=find.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/mcp/tools/config/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { readFileSync, statSync } from 'fs'\n\nimport { toolSchemas } from '../schemas.js'\n\nexport const readConfigFile = (\n req: PayloadRequest,\n verboseLogs: boolean,\n configFilePath: string,\n includeMetadata: boolean = false,\n) => {\n const payload = req.payload\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Reading config file, includeMetadata: ${includeMetadata}`)\n }\n\n try {\n // Security check: ensure we're working with the specified config file\n if (!configFilePath.startsWith(process.cwd()) && !configFilePath.startsWith('/')) {\n payload.logger.error(`[payload-mcp] Invalid config path attempted: ${configFilePath}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: Invalid config path',\n },\n ],\n }\n }\n\n const content = readFileSync(configFilePath, 'utf8')\n const stats = statSync(configFilePath)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully read config file. Size: ${stats.size} bytes`)\n }\n\n let responseText = `# Payload Configuration\n\n**File**: \\`${configFilePath}\\``\n\n if (includeMetadata) {\n responseText += `\n**Size**: ${stats.size.toLocaleString()} bytes\n**Modified**: ${stats.mtime.toISOString()}\n**Created**: ${stats.birthtime.toISOString()}`\n }\n\n responseText += `\n---\n\n**Configuration Content:**\n\\`\\`\\`typescript\n${content}\n\\`\\`\\``\n\n return {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error reading config file: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading config file**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// MCP Server tool registration\nexport const findConfigTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n configFilePath: string,\n) => {\n const tool = (includeMetadata: boolean = false) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Finding config, includeMetadata: ${includeMetadata}`)\n }\n\n try {\n const result = readConfigFile(req, verboseLogs, configFilePath, includeMetadata)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Config search completed`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(`[payload-mcp] Error finding config: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `Error finding config: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'findConfig',\n {\n description: toolSchemas.findConfig.description,\n inputSchema: toolSchemas.findConfig.parameters.shape,\n },\n ({ includeMetadata }) => {\n return tool(includeMetadata)\n },\n )\n}\n"],"names":["readFileSync","statSync","toolSchemas","readConfigFile","req","verboseLogs","configFilePath","includeMetadata","payload","logger","info","startsWith","process","cwd","error","content","type","text","stats","size","responseText","toLocaleString","mtime","toISOString","birthtime","errorMessage","message","findConfigTool","server","tool","result","Error","registerTool","description","findConfig","inputSchema","parameters","shape"],"mappings":"AAGA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,KAAI;AAE3C,SAASC,WAAW,Q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AAiC,EAAEQ,cAAc;gBAC1D;aACD;QACH;IACF;AACF,EAAC;AAED,+BAA+B;AAC/B,OAAO,MAAME,iBAAiB,CAC5BC,QACAxB,KACAC,aACAC;IAEA,MAAMuB,OAAO,CAACtB,kBAA2B,KAAK;QAC5C,MAAMC,UAAUJ,IAAII,OAAO;QAE3B,IAAIH,aAAa;YACfG,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,+CAA+C,EAAEH,iBAAiB;QACzF;QAEA,IAAI;YACF,MAAMuB,SAAS3B,eAAeC,KAAKC,aAAaC,gBAAgBC;YAEhE,IAAIF,aAAa;gBACfG,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,qCAAqC,CAAC;YAC7D;YAEA,OAAOoB;QACT,EAAE,OAAOhB,OAAO;YACd,MAAMW,eAAeX,iBAAiBiB,QAAQjB,MAAMY,OAAO,GAAG;YAC9DlB,QAAQC,MAAM,CAACK,KAAK,CAAC,CAAC,oCAAoC,EAAEW,cAAc;YAE1E,OAAO;gBACLV,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,sBAAsB,EAAEQ,cAAc;oBAC/C;iBACD;YACH;QACF;IACF;IAEAG,OAAOI,YAAY,CACjB,cACA;QACEC,aAAa/B,YAAYgC,UAAU,CAACD,WAAW;QAC/CE,aAAajC,YAAYgC,UAAU,CAACE,UAAU,CAACC,KAAK;IACtD,GACA,CAAC,EAAE9B,eAAe,EAAE;QAClB,OAAOsB,KAAKtB;IACd;AAEJ,EAAC"}
@@ -1,10 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { PayloadRequest } from 'payload';
3
- export declare const updateConfig: (req: PayloadRequest, verboseLogs: boolean, configFilePath: string, updateType: string, collectionName?: string, adminConfig?: any, databaseConfig?: any, pluginUpdates?: any, newContent?: string) => {
4
- content: {
5
- type: "text";
6
- text: string;
7
- }[];
8
- };
9
- export declare const updateConfigTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, configFilePath: string) => void;
10
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/config/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAa7C,eAAO,MAAM,YAAY,QAClB,cAAc,eACN,OAAO,kBACJ,MAAM,cACV,MAAM,mBACD,MAAM,gBACT,GAAG,mBACA,GAAG,kBACJ,GAAG,eACN,MAAM;;;;;CAwLpB,CAAA;AAED,eAAO,MAAM,gBAAgB,WACnB,SAAS,OACZ,cAAc,eACN,OAAO,kBACJ,MAAM,SAkEvB,CAAA"}