@payloadcms/plugin-mcp 4.0.0-internal.5b1e7cd → 4.0.0-internal.688c4d0
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.
- package/bin.js +39 -0
- package/dist/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/collection/getAccessField.d.ts +12 -0
- package/dist/collection/getAccessField.d.ts.map +1 -0
- package/dist/collection/getAccessField.js +72 -0
- package/dist/collection/getAccessField.js.map +1 -0
- package/dist/collection/index.d.ts +6 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +105 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/components/APIKeyField/index.client.d.ts +9 -0
- package/dist/components/APIKeyField/index.client.d.ts.map +1 -0
- package/dist/components/APIKeyField/index.client.js +85 -0
- package/dist/components/APIKeyField/index.client.js.map +1 -0
- package/dist/components/APIKeyField/index.css +105 -0
- package/dist/components/APIKeysEmptyState/index.client.d.ts +4 -0
- package/dist/components/APIKeysEmptyState/index.client.d.ts.map +1 -0
- package/dist/components/APIKeysEmptyState/index.client.js +21 -0
- package/dist/components/APIKeysEmptyState/index.client.js.map +1 -0
- package/dist/components/AccessField/index.client.d.ts +10 -0
- package/dist/components/AccessField/index.client.d.ts.map +1 -0
- package/dist/components/AccessField/index.client.js +247 -0
- package/dist/components/AccessField/index.client.js.map +1 -0
- package/dist/components/AccessField/index.css +99 -0
- package/dist/components/SettingsMenu/index.client.d.ts +8 -0
- package/dist/components/SettingsMenu/index.client.d.ts.map +1 -0
- package/dist/components/SettingsMenu/index.client.js +29 -0
- package/dist/components/SettingsMenu/index.client.js.map +1 -0
- package/dist/defineTool.d.ts +26 -0
- package/dist/defineTool.d.ts.map +1 -0
- package/dist/defineTool.js +37 -0
- package/dist/defineTool.js.map +1 -0
- package/dist/endpoint/access.d.ts +10 -0
- package/dist/endpoint/access.d.ts.map +1 -0
- package/dist/endpoint/access.js +122 -0
- package/dist/endpoint/access.js.map +1 -0
- package/dist/endpoint/index.d.ts +3 -0
- package/dist/endpoint/index.d.ts.map +1 -0
- package/dist/endpoint/index.js +36 -0
- package/dist/endpoint/index.js.map +1 -0
- package/dist/exports/client.d.ts +5 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +7 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -67
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +19 -0
- package/dist/mcp/buildMcpServer.d.ts.map +1 -0
- package/dist/mcp/buildMcpServer.js +199 -0
- package/dist/mcp/buildMcpServer.js.map +1 -0
- package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/authTools.js +250 -0
- package/dist/mcp/builtin/collections/authTools.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/createTool.js +94 -0
- package/dist/mcp/builtin/collections/createTool.js.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.js +102 -0
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findTool.js +144 -0
- package/dist/mcp/builtin/collections/findTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.js +199 -0
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findTool.js +76 -0
- package/dist/mcp/builtin/globals/findTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +94 -0
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
- package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
- package/dist/mcp/builtin/validateEntityData.js +82 -0
- package/dist/mcp/builtin/validateEntityData.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +105 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -0
- package/dist/mcp/builtinTools.js +107 -0
- package/dist/mcp/builtinTools.js.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.js +188 -0
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
- package/dist/stdio.d.ts +8 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +89 -0
- package/dist/stdio.js.map +1 -0
- package/dist/translations/index.d.ts +11 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +92 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/languages/ar.d.ts +31 -0
- package/dist/translations/languages/ar.d.ts.map +1 -0
- package/dist/translations/languages/ar.js +34 -0
- package/dist/translations/languages/ar.js.map +1 -0
- package/dist/translations/languages/az.d.ts +31 -0
- package/dist/translations/languages/az.d.ts.map +1 -0
- package/dist/translations/languages/az.js +34 -0
- package/dist/translations/languages/az.js.map +1 -0
- package/dist/translations/languages/bg.d.ts +31 -0
- package/dist/translations/languages/bg.d.ts.map +1 -0
- package/dist/translations/languages/bg.js +34 -0
- package/dist/translations/languages/bg.js.map +1 -0
- package/dist/translations/languages/bnBd.d.ts +31 -0
- package/dist/translations/languages/bnBd.d.ts.map +1 -0
- package/dist/translations/languages/bnBd.js +34 -0
- package/dist/translations/languages/bnBd.js.map +1 -0
- package/dist/translations/languages/bnIn.d.ts +31 -0
- package/dist/translations/languages/bnIn.d.ts.map +1 -0
- package/dist/translations/languages/bnIn.js +34 -0
- package/dist/translations/languages/bnIn.js.map +1 -0
- package/dist/translations/languages/ca.d.ts +31 -0
- package/dist/translations/languages/ca.d.ts.map +1 -0
- package/dist/translations/languages/ca.js +34 -0
- package/dist/translations/languages/ca.js.map +1 -0
- package/dist/translations/languages/cs.d.ts +31 -0
- package/dist/translations/languages/cs.d.ts.map +1 -0
- package/dist/translations/languages/cs.js +34 -0
- package/dist/translations/languages/cs.js.map +1 -0
- package/dist/translations/languages/da.d.ts +31 -0
- package/dist/translations/languages/da.d.ts.map +1 -0
- package/dist/translations/languages/da.js +34 -0
- package/dist/translations/languages/da.js.map +1 -0
- package/dist/translations/languages/de.d.ts +31 -0
- package/dist/translations/languages/de.d.ts.map +1 -0
- package/dist/translations/languages/de.js +34 -0
- package/dist/translations/languages/de.js.map +1 -0
- package/dist/translations/languages/en.d.ts +31 -0
- package/dist/translations/languages/en.d.ts.map +1 -0
- package/dist/translations/languages/en.js +34 -0
- package/dist/translations/languages/en.js.map +1 -0
- package/dist/translations/languages/es.d.ts +31 -0
- package/dist/translations/languages/es.d.ts.map +1 -0
- package/dist/translations/languages/es.js +34 -0
- package/dist/translations/languages/es.js.map +1 -0
- package/dist/translations/languages/et.d.ts +31 -0
- package/dist/translations/languages/et.d.ts.map +1 -0
- package/dist/translations/languages/et.js +34 -0
- package/dist/translations/languages/et.js.map +1 -0
- package/dist/translations/languages/fa.d.ts +31 -0
- package/dist/translations/languages/fa.d.ts.map +1 -0
- package/dist/translations/languages/fa.js +34 -0
- package/dist/translations/languages/fa.js.map +1 -0
- package/dist/translations/languages/fr.d.ts +31 -0
- package/dist/translations/languages/fr.d.ts.map +1 -0
- package/dist/translations/languages/fr.js +34 -0
- package/dist/translations/languages/fr.js.map +1 -0
- package/dist/translations/languages/he.d.ts +31 -0
- package/dist/translations/languages/he.d.ts.map +1 -0
- package/dist/translations/languages/he.js +34 -0
- package/dist/translations/languages/he.js.map +1 -0
- package/dist/translations/languages/hr.d.ts +31 -0
- package/dist/translations/languages/hr.d.ts.map +1 -0
- package/dist/translations/languages/hr.js +34 -0
- package/dist/translations/languages/hr.js.map +1 -0
- package/dist/translations/languages/hu.d.ts +31 -0
- package/dist/translations/languages/hu.d.ts.map +1 -0
- package/dist/translations/languages/hu.js +34 -0
- package/dist/translations/languages/hu.js.map +1 -0
- package/dist/translations/languages/hy.d.ts +31 -0
- package/dist/translations/languages/hy.d.ts.map +1 -0
- package/dist/translations/languages/hy.js +34 -0
- package/dist/translations/languages/hy.js.map +1 -0
- package/dist/translations/languages/id.d.ts +31 -0
- package/dist/translations/languages/id.d.ts.map +1 -0
- package/dist/translations/languages/id.js +34 -0
- package/dist/translations/languages/id.js.map +1 -0
- package/dist/translations/languages/is.d.ts +31 -0
- package/dist/translations/languages/is.d.ts.map +1 -0
- package/dist/translations/languages/is.js +34 -0
- package/dist/translations/languages/is.js.map +1 -0
- package/dist/translations/languages/it.d.ts +31 -0
- package/dist/translations/languages/it.d.ts.map +1 -0
- package/dist/translations/languages/it.js +34 -0
- package/dist/translations/languages/it.js.map +1 -0
- package/dist/translations/languages/ja.d.ts +31 -0
- package/dist/translations/languages/ja.d.ts.map +1 -0
- package/dist/translations/languages/ja.js +34 -0
- package/dist/translations/languages/ja.js.map +1 -0
- package/dist/translations/languages/ko.d.ts +31 -0
- package/dist/translations/languages/ko.d.ts.map +1 -0
- package/dist/translations/languages/ko.js +34 -0
- package/dist/translations/languages/ko.js.map +1 -0
- package/dist/translations/languages/lt.d.ts +31 -0
- package/dist/translations/languages/lt.d.ts.map +1 -0
- package/dist/translations/languages/lt.js +34 -0
- package/dist/translations/languages/lt.js.map +1 -0
- package/dist/translations/languages/lv.d.ts +31 -0
- package/dist/translations/languages/lv.d.ts.map +1 -0
- package/dist/translations/languages/lv.js +34 -0
- package/dist/translations/languages/lv.js.map +1 -0
- package/dist/translations/languages/my.d.ts +31 -0
- package/dist/translations/languages/my.d.ts.map +1 -0
- package/dist/translations/languages/my.js +34 -0
- package/dist/translations/languages/my.js.map +1 -0
- package/dist/translations/languages/nb.d.ts +31 -0
- package/dist/translations/languages/nb.d.ts.map +1 -0
- package/dist/translations/languages/nb.js +34 -0
- package/dist/translations/languages/nb.js.map +1 -0
- package/dist/translations/languages/nl.d.ts +31 -0
- package/dist/translations/languages/nl.d.ts.map +1 -0
- package/dist/translations/languages/nl.js +34 -0
- package/dist/translations/languages/nl.js.map +1 -0
- package/dist/translations/languages/pl.d.ts +31 -0
- package/dist/translations/languages/pl.d.ts.map +1 -0
- package/dist/translations/languages/pl.js +34 -0
- package/dist/translations/languages/pl.js.map +1 -0
- package/dist/translations/languages/pt.d.ts +31 -0
- package/dist/translations/languages/pt.d.ts.map +1 -0
- package/dist/translations/languages/pt.js +34 -0
- package/dist/translations/languages/pt.js.map +1 -0
- package/dist/translations/languages/ro.d.ts +31 -0
- package/dist/translations/languages/ro.d.ts.map +1 -0
- package/dist/translations/languages/ro.js +34 -0
- package/dist/translations/languages/ro.js.map +1 -0
- package/dist/translations/languages/rs.d.ts +31 -0
- package/dist/translations/languages/rs.d.ts.map +1 -0
- package/dist/translations/languages/rs.js +34 -0
- package/dist/translations/languages/rs.js.map +1 -0
- package/dist/translations/languages/rsLatin.d.ts +31 -0
- package/dist/translations/languages/rsLatin.d.ts.map +1 -0
- package/dist/translations/languages/rsLatin.js +34 -0
- package/dist/translations/languages/rsLatin.js.map +1 -0
- package/dist/translations/languages/ru.d.ts +31 -0
- package/dist/translations/languages/ru.d.ts.map +1 -0
- package/dist/translations/languages/ru.js +34 -0
- package/dist/translations/languages/ru.js.map +1 -0
- package/dist/translations/languages/sk.d.ts +31 -0
- package/dist/translations/languages/sk.d.ts.map +1 -0
- package/dist/translations/languages/sk.js +34 -0
- package/dist/translations/languages/sk.js.map +1 -0
- package/dist/translations/languages/sl.d.ts +31 -0
- package/dist/translations/languages/sl.d.ts.map +1 -0
- package/dist/translations/languages/sl.js +34 -0
- package/dist/translations/languages/sl.js.map +1 -0
- package/dist/translations/languages/sv.d.ts +31 -0
- package/dist/translations/languages/sv.d.ts.map +1 -0
- package/dist/translations/languages/sv.js +34 -0
- package/dist/translations/languages/sv.js.map +1 -0
- package/dist/translations/languages/ta.d.ts +31 -0
- package/dist/translations/languages/ta.d.ts.map +1 -0
- package/dist/translations/languages/ta.js +34 -0
- package/dist/translations/languages/ta.js.map +1 -0
- package/dist/translations/languages/th.d.ts +31 -0
- package/dist/translations/languages/th.d.ts.map +1 -0
- package/dist/translations/languages/th.js +34 -0
- package/dist/translations/languages/th.js.map +1 -0
- package/dist/translations/languages/tr.d.ts +31 -0
- package/dist/translations/languages/tr.d.ts.map +1 -0
- package/dist/translations/languages/tr.js +34 -0
- package/dist/translations/languages/tr.js.map +1 -0
- package/dist/translations/languages/uk.d.ts +31 -0
- package/dist/translations/languages/uk.d.ts.map +1 -0
- package/dist/translations/languages/uk.js +34 -0
- package/dist/translations/languages/uk.js.map +1 -0
- package/dist/translations/languages/vi.d.ts +31 -0
- package/dist/translations/languages/vi.d.ts.map +1 -0
- package/dist/translations/languages/vi.js +34 -0
- package/dist/translations/languages/vi.js.map +1 -0
- package/dist/translations/languages/zh.d.ts +31 -0
- package/dist/translations/languages/zh.d.ts.map +1 -0
- package/dist/translations/languages/zh.js +34 -0
- package/dist/translations/languages/zh.js.map +1 -0
- package/dist/translations/languages/zhTw.d.ts +31 -0
- package/dist/translations/languages/zhTw.d.ts.map +1 -0
- package/dist/translations/languages/zhTw.js +34 -0
- package/dist/translations/languages/zhTw.js.map +1 -0
- package/dist/translations/types.d.ts +32 -0
- package/dist/translations/types.d.ts.map +1 -0
- package/dist/translations/types.js +3 -0
- package/dist/translations/types.js.map +1 -0
- package/dist/types.d.ts +255 -454
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getLogger.d.ts +10 -0
- package/dist/utils/getLogger.d.ts.map +1 -0
- package/dist/utils/getLogger.js +22 -0
- package/dist/utils/getLogger.js.map +1 -0
- package/dist/utils/getPluginConfig.d.ts +12 -0
- package/dist/utils/getPluginConfig.d.ts.map +1 -0
- package/dist/utils/getPluginConfig.js +15 -0
- package/dist/utils/getPluginConfig.js.map +1 -0
- package/dist/utils/localAPIDefaults.d.ts +20 -0
- package/dist/utils/localAPIDefaults.d.ts.map +1 -0
- package/dist/utils/localAPIDefaults.js +19 -0
- package/dist/utils/localAPIDefaults.js.map +1 -0
- package/dist/utils/resolveProjectRoot.d.ts +7 -0
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
- package/dist/utils/resolveProjectRoot.js +15 -0
- package/dist/utils/resolveProjectRoot.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
- package/dist/utils/toStandardSchema.d.ts +5 -0
- package/dist/utils/toStandardSchema.d.ts.map +1 -0
- package/dist/utils/toStandardSchema.js +4 -0
- package/dist/utils/toStandardSchema.js.map +1 -0
- package/dist/utils/whereSchema.d.ts +9 -0
- package/dist/utils/whereSchema.d.ts.map +1 -0
- package/dist/utils/whereSchema.js +13 -0
- package/dist/utils/whereSchema.js.map +1 -0
- package/package.json +36 -10
- package/src/@types/assets.d.ts +3 -0
- package/src/collection/getAccessField.ts +84 -0
- package/src/collection/index.ts +105 -0
- package/src/components/APIKeyField/index.client.tsx +73 -0
- package/src/components/APIKeyField/index.css +105 -0
- package/src/components/APIKeysEmptyState/index.client.tsx +36 -0
- package/src/components/AccessField/index.client.tsx +299 -0
- package/src/components/AccessField/index.css +99 -0
- package/src/components/SettingsMenu/index.client.tsx +34 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +144 -0
- package/src/endpoint/index.ts +35 -0
- package/src/exports/client.ts +5 -0
- package/src/index.ts +82 -86
- package/src/mcp/buildMcpServer.ts +257 -0
- package/src/mcp/builtin/collections/authTools.ts +233 -0
- package/src/mcp/builtin/collections/createTool.ts +112 -0
- package/src/mcp/builtin/collections/deleteTool.ts +116 -0
- package/src/mcp/builtin/collections/findTool.ts +177 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
- package/src/mcp/builtin/collections/updateTool.ts +211 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
- package/src/mcp/builtin/globals/findTool.ts +96 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
- package/src/mcp/builtin/globals/updateTool.ts +115 -0
- package/src/mcp/builtin/validateEntityData.ts +132 -0
- package/src/mcp/builtinTools.ts +98 -0
- package/src/mcp/sanitizeMCPConfig.ts +260 -0
- package/src/stdio.ts +98 -0
- package/src/translations/index.ts +108 -0
- package/src/translations/languages/ar.ts +35 -0
- package/src/translations/languages/az.ts +35 -0
- package/src/translations/languages/bg.ts +35 -0
- package/src/translations/languages/bnBd.ts +35 -0
- package/src/translations/languages/bnIn.ts +35 -0
- package/src/translations/languages/ca.ts +35 -0
- package/src/translations/languages/cs.ts +35 -0
- package/src/translations/languages/da.ts +35 -0
- package/src/translations/languages/de.ts +35 -0
- package/src/translations/languages/en.ts +35 -0
- package/src/translations/languages/es.ts +35 -0
- package/src/translations/languages/et.ts +35 -0
- package/src/translations/languages/fa.ts +35 -0
- package/src/translations/languages/fr.ts +35 -0
- package/src/translations/languages/he.ts +35 -0
- package/src/translations/languages/hr.ts +35 -0
- package/src/translations/languages/hu.ts +35 -0
- package/src/translations/languages/hy.ts +35 -0
- package/src/translations/languages/id.ts +35 -0
- package/src/translations/languages/is.ts +35 -0
- package/src/translations/languages/it.ts +35 -0
- package/src/translations/languages/ja.ts +35 -0
- package/src/translations/languages/ko.ts +35 -0
- package/src/translations/languages/lt.ts +35 -0
- package/src/translations/languages/lv.ts +35 -0
- package/src/translations/languages/my.ts +35 -0
- package/src/translations/languages/nb.ts +35 -0
- package/src/translations/languages/nl.ts +35 -0
- package/src/translations/languages/pl.ts +35 -0
- package/src/translations/languages/pt.ts +35 -0
- package/src/translations/languages/ro.ts +35 -0
- package/src/translations/languages/rs.ts +35 -0
- package/src/translations/languages/rsLatin.ts +35 -0
- package/src/translations/languages/ru.ts +35 -0
- package/src/translations/languages/sk.ts +35 -0
- package/src/translations/languages/sl.ts +35 -0
- package/src/translations/languages/sv.ts +35 -0
- package/src/translations/languages/ta.ts +35 -0
- package/src/translations/languages/th.ts +35 -0
- package/src/translations/languages/tr.ts +35 -0
- package/src/translations/languages/uk.ts +35 -0
- package/src/translations/languages/vi.ts +35 -0
- package/src/translations/languages/zh.ts +35 -0
- package/src/translations/languages/zhTw.ts +35 -0
- package/src/translations/types.ts +34 -0
- package/src/types.ts +295 -490
- package/src/utils/getLogger.ts +22 -0
- package/src/utils/getPluginConfig.ts +24 -0
- package/src/utils/localAPIDefaults.ts +22 -0
- package/src/utils/resolveProjectRoot.ts +17 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
- package/src/utils/toStandardSchema.ts +9 -0
- package/src/utils/whereSchema.ts +24 -0
- package/dist/collections/createApiKeysCollection.d.ts +0 -7
- package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
- package/dist/collections/createApiKeysCollection.js +0 -317
- package/dist/collections/createApiKeysCollection.js.map +0 -1
- package/dist/defaults.d.ts +0 -4
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js +0 -5
- package/dist/defaults.js.map +0 -1
- package/dist/endpoints/mcp.d.ts +0 -4
- package/dist/endpoints/mcp.d.ts.map +0 -1
- package/dist/endpoints/mcp.js +0 -71
- package/dist/endpoints/mcp.js.map +0 -1
- package/dist/mcp/createRequest.d.ts +0 -3
- package/dist/mcp/createRequest.d.ts.map +0 -1
- package/dist/mcp/createRequest.js +0 -14
- package/dist/mcp/createRequest.js.map +0 -1
- package/dist/mcp/getMcpHandler.d.ts +0 -4
- package/dist/mcp/getMcpHandler.d.ts.map +0 -1
- package/dist/mcp/getMcpHandler.js +0 -231
- package/dist/mcp/getMcpHandler.js.map +0 -1
- package/dist/mcp/helpers/config.d.ts +0 -22
- package/dist/mcp/helpers/config.d.ts.map +0 -1
- package/dist/mcp/helpers/config.js +0 -153
- package/dist/mcp/helpers/config.js.map +0 -1
- package/dist/mcp/helpers/fields.d.ts +0 -19
- package/dist/mcp/helpers/fields.d.ts.map +0 -1
- package/dist/mcp/helpers/fields.js +0 -102
- package/dist/mcp/helpers/fields.js.map +0 -1
- package/dist/mcp/helpers/fileValidation.d.ts +0 -67
- package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
- package/dist/mcp/helpers/fileValidation.js +0 -267
- package/dist/mcp/helpers/fileValidation.js.map +0 -1
- package/dist/mcp/registerTool.d.ts +0 -6
- package/dist/mcp/registerTool.d.ts.map +0 -1
- package/dist/mcp/registerTool.js +0 -18
- package/dist/mcp/registerTool.js.map +0 -1
- package/dist/mcp/tools/auth/auth.d.ts +0 -4
- package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
- package/dist/mcp/tools/auth/auth.js +0 -57
- package/dist/mcp/tools/auth/auth.js.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.js +0 -48
- package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
- package/dist/mcp/tools/auth/login.d.ts +0 -4
- package/dist/mcp/tools/auth/login.d.ts.map +0 -1
- package/dist/mcp/tools/auth/login.js +0 -51
- package/dist/mcp/tools/auth/login.js.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.js +0 -49
- package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
- package/dist/mcp/tools/auth/unlock.d.ts +0 -4
- package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
- package/dist/mcp/tools/auth/unlock.js +0 -48
- package/dist/mcp/tools/auth/unlock.js.map +0 -1
- package/dist/mcp/tools/auth/verify.d.ts +0 -4
- package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
- package/dist/mcp/tools/auth/verify.js +0 -45
- package/dist/mcp/tools/auth/verify.js.map +0 -1
- package/dist/mcp/tools/collection/create.d.ts +0 -10
- package/dist/mcp/tools/collection/create.d.ts.map +0 -1
- package/dist/mcp/tools/collection/create.js +0 -139
- package/dist/mcp/tools/collection/create.js.map +0 -1
- package/dist/mcp/tools/collection/delete.d.ts +0 -10
- package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
- package/dist/mcp/tools/collection/delete.js +0 -154
- package/dist/mcp/tools/collection/delete.js.map +0 -1
- package/dist/mcp/tools/collection/find.d.ts +0 -10
- package/dist/mcp/tools/collection/find.d.ts.map +0 -1
- package/dist/mcp/tools/collection/find.js +0 -165
- package/dist/mcp/tools/collection/find.js.map +0 -1
- package/dist/mcp/tools/collection/update.d.ts +0 -10
- package/dist/mcp/tools/collection/update.d.ts.map +0 -1
- package/dist/mcp/tools/collection/update.js +0 -209
- package/dist/mcp/tools/collection/update.js.map +0 -1
- package/dist/mcp/tools/config/find.d.ts +0 -10
- package/dist/mcp/tools/config/find.d.ts.map +0 -1
- package/dist/mcp/tools/config/find.js +0 -97
- package/dist/mcp/tools/config/find.js.map +0 -1
- package/dist/mcp/tools/config/update.d.ts +0 -10
- package/dist/mcp/tools/config/update.d.ts.map +0 -1
- package/dist/mcp/tools/config/update.js +0 -215
- package/dist/mcp/tools/config/update.js.map +0 -1
- package/dist/mcp/tools/global/find.d.ts +0 -5
- package/dist/mcp/tools/global/find.d.ts.map +0 -1
- package/dist/mcp/tools/global/find.js +0 -82
- package/dist/mcp/tools/global/find.js.map +0 -1
- package/dist/mcp/tools/global/update.d.ts +0 -6
- package/dist/mcp/tools/global/update.d.ts.map +0 -1
- package/dist/mcp/tools/global/update.js +0 -124
- package/dist/mcp/tools/global/update.js.map +0 -1
- package/dist/mcp/tools/job/create.d.ts +0 -10
- package/dist/mcp/tools/job/create.d.ts.map +0 -1
- package/dist/mcp/tools/job/create.js +0 -293
- package/dist/mcp/tools/job/create.js.map +0 -1
- package/dist/mcp/tools/job/run.d.ts +0 -10
- package/dist/mcp/tools/job/run.d.ts.map +0 -1
- package/dist/mcp/tools/job/run.js +0 -129
- package/dist/mcp/tools/job/run.js.map +0 -1
- package/dist/mcp/tools/job/update.d.ts +0 -11
- package/dist/mcp/tools/job/update.d.ts.map +0 -1
- package/dist/mcp/tools/job/update.js +0 -186
- package/dist/mcp/tools/job/update.js.map +0 -1
- package/dist/mcp/tools/resource/create.d.ts +0 -6
- package/dist/mcp/tools/resource/create.d.ts.map +0 -1
- package/dist/mcp/tools/resource/create.js +0 -124
- package/dist/mcp/tools/resource/create.js.map +0 -1
- package/dist/mcp/tools/resource/delete.d.ts +0 -5
- package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
- package/dist/mcp/tools/resource/delete.js +0 -151
- package/dist/mcp/tools/resource/delete.js.map +0 -1
- package/dist/mcp/tools/resource/find.d.ts +0 -5
- package/dist/mcp/tools/resource/find.d.ts.map +0 -1
- package/dist/mcp/tools/resource/find.js +0 -170
- package/dist/mcp/tools/resource/find.js.map +0 -1
- package/dist/mcp/tools/resource/update.d.ts +0 -6
- package/dist/mcp/tools/resource/update.d.ts.map +0 -1
- package/dist/mcp/tools/resource/update.js +0 -256
- package/dist/mcp/tools/resource/update.js.map +0 -1
- package/dist/mcp/tools/schemas.d.ts +0 -457
- package/dist/mcp/tools/schemas.d.ts.map +0 -1
- package/dist/mcp/tools/schemas.js +0 -243
- package/dist/mcp/tools/schemas.js.map +0 -1
- package/dist/utils/adminEntitySettings.d.ts +0 -17
- package/dist/utils/adminEntitySettings.d.ts.map +0 -1
- package/dist/utils/adminEntitySettings.js +0 -41
- package/dist/utils/adminEntitySettings.js.map +0 -1
- package/dist/utils/createApiKeyFields.d.ts +0 -15
- package/dist/utils/createApiKeyFields.d.ts.map +0 -1
- package/dist/utils/createApiKeyFields.js +0 -57
- package/dist/utils/createApiKeyFields.js.map +0 -1
- package/dist/utils/getEnabledSlugs.d.ts +0 -13
- package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
- package/dist/utils/getEnabledSlugs.js +0 -32
- package/dist/utils/getEnabledSlugs.js.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.js +0 -51
- package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
- package/src/collections/createApiKeysCollection.ts +0 -373
- package/src/defaults.ts +0 -3
- package/src/endpoints/mcp.ts +0 -91
- package/src/mcp/createRequest.ts +0 -13
- package/src/mcp/getMcpHandler.ts +0 -545
- package/src/mcp/helpers/config.ts +0 -213
- package/src/mcp/helpers/fields.ts +0 -154
- package/src/mcp/helpers/fileValidation.ts +0 -362
- package/src/mcp/registerTool.ts +0 -22
- package/src/mcp/tools/auth/auth.ts +0 -71
- package/src/mcp/tools/auth/forgotPassword.ts +0 -70
- package/src/mcp/tools/auth/login.ts +0 -72
- package/src/mcp/tools/auth/resetPassword.ts +0 -61
- package/src/mcp/tools/auth/unlock.ts +0 -64
- package/src/mcp/tools/auth/verify.ts +0 -57
- package/src/mcp/tools/collection/create.ts +0 -210
- package/src/mcp/tools/collection/delete.ts +0 -211
- package/src/mcp/tools/collection/find.ts +0 -224
- package/src/mcp/tools/collection/update.ts +0 -290
- package/src/mcp/tools/config/find.ts +0 -128
- package/src/mcp/tools/config/update.ts +0 -280
- package/src/mcp/tools/global/find.ts +0 -128
- package/src/mcp/tools/global/update.ts +0 -207
- package/src/mcp/tools/job/create.ts +0 -416
- package/src/mcp/tools/job/run.ts +0 -167
- package/src/mcp/tools/job/update.ts +0 -274
- package/src/mcp/tools/resource/create.ts +0 -211
- package/src/mcp/tools/resource/delete.ts +0 -218
- package/src/mcp/tools/resource/find.ts +0 -246
- package/src/mcp/tools/resource/update.ts +0 -383
- package/src/mcp/tools/schemas.ts +0 -520
- package/src/utils/adminEntitySettings.ts +0 -40
- package/src/utils/createApiKeyFields.ts +0 -72
- package/src/utils/getEnabledSlugs.ts +0 -42
- package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
- package/src/utils/schemaConversion/transformPointFields.ts +0 -55
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { CollectionSlug, PayloadRequest } from 'payload'
|
|
2
|
+
|
|
3
|
+
import type { MCPToolResponse } from '../../../types.js'
|
|
4
|
+
|
|
5
|
+
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
6
|
+
|
|
7
|
+
const getValidationErrors = (error: unknown): undefined | unknown[] => {
|
|
8
|
+
if (!error || typeof error !== 'object') {
|
|
9
|
+
return undefined
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const data = 'data' in error ? error.data : undefined
|
|
13
|
+
if (!data || typeof data !== 'object' || !('errors' in data) || !Array.isArray(data.errors)) {
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return data.errors
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isSchemaError = (error: unknown, message: string): boolean => {
|
|
21
|
+
if (getValidationErrors(error)) {
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const name = error && typeof error === 'object' && 'name' in error ? error.name : undefined
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
name === 'CastError' ||
|
|
29
|
+
name === 'ValidationError' ||
|
|
30
|
+
message.includes('Cast to ') ||
|
|
31
|
+
message.includes('validation failed')
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const formatCollectionError = ({
|
|
36
|
+
action,
|
|
37
|
+
collectionSlug,
|
|
38
|
+
error,
|
|
39
|
+
req,
|
|
40
|
+
}: {
|
|
41
|
+
action: 'creating' | 'updating'
|
|
42
|
+
collectionSlug: CollectionSlug
|
|
43
|
+
error: unknown
|
|
44
|
+
req: PayloadRequest
|
|
45
|
+
}): MCPToolResponse => {
|
|
46
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
47
|
+
const errors = getValidationErrors(error) ?? [{ message: errorMessage }]
|
|
48
|
+
|
|
49
|
+
if (!isSchemaError(error, errorMessage)) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: `Error ${action} document in collection "${collectionSlug}": ${errorMessage}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: true,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const schema = getCollectionInputSchema({ collectionSlug, req })
|
|
62
|
+
const schemaText = schema
|
|
63
|
+
? `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``
|
|
64
|
+
: ''
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
text: `Error ${action} document in collection "${collectionSlug}": ${errorMessage}${schemaText}`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
isError: true,
|
|
74
|
+
...(schema
|
|
75
|
+
? {
|
|
76
|
+
structuredContent: {
|
|
77
|
+
collectionSlug,
|
|
78
|
+
errors,
|
|
79
|
+
schema,
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
2
|
+
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
3
|
+
|
|
4
|
+
export const getCollectionSchemaTool = defineCollectionTool({
|
|
5
|
+
description: 'Get the input schema for creating or updating documents in a collection.',
|
|
6
|
+
}).handler(({ collectionSlug, req }) => {
|
|
7
|
+
const inputSchema = getCollectionInputSchema({ collectionSlug, req })
|
|
8
|
+
|
|
9
|
+
if (!inputSchema) {
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: 'text', text: `Error: Collection "${collectionSlug}" not found` }],
|
|
12
|
+
isError: true,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: 'text',
|
|
20
|
+
text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
structuredContent: {
|
|
24
|
+
collectionSlug,
|
|
25
|
+
schema: inputSchema,
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { SelectType, Where } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
+
import {
|
|
8
|
+
getCollectionVirtualFieldNames,
|
|
9
|
+
stripVirtualFields,
|
|
10
|
+
} from '../../../utils/getVirtualFieldNames.js'
|
|
11
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
12
|
+
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
13
|
+
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
14
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
15
|
+
import { validateCollectionData } from '../validateEntityData.js'
|
|
16
|
+
import { formatCollectionError } from './formatCollectionError.js'
|
|
17
|
+
|
|
18
|
+
const DEFAULT_DESCRIPTION =
|
|
19
|
+
'Update documents in any collection by passing the collection slug and data.'
|
|
20
|
+
|
|
21
|
+
export const updateDocumentTool = defineCollectionTool({
|
|
22
|
+
description: DEFAULT_DESCRIPTION,
|
|
23
|
+
input: z.object({
|
|
24
|
+
id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),
|
|
25
|
+
data: z.record(z.string(), z.unknown()).describe('The fields to update'),
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.describe('How many levels deep to populate relationships')
|
|
29
|
+
.optional()
|
|
30
|
+
.default(0),
|
|
31
|
+
draft: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.describe('Whether to update the document as a draft')
|
|
34
|
+
.optional()
|
|
35
|
+
.default(false),
|
|
36
|
+
fallbackLocale: z
|
|
37
|
+
.string()
|
|
38
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
39
|
+
.optional(),
|
|
40
|
+
filePath: z.string().describe('File path for file uploads').optional(),
|
|
41
|
+
locale: z
|
|
42
|
+
.string()
|
|
43
|
+
.describe(
|
|
44
|
+
'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
|
|
45
|
+
)
|
|
46
|
+
.optional(),
|
|
47
|
+
overrideLock: z
|
|
48
|
+
.boolean()
|
|
49
|
+
.describe('Whether to override document locks')
|
|
50
|
+
.optional()
|
|
51
|
+
.default(true),
|
|
52
|
+
overwriteExistingFiles: z
|
|
53
|
+
.boolean()
|
|
54
|
+
.describe('Whether to overwrite existing files')
|
|
55
|
+
.optional()
|
|
56
|
+
.default(false),
|
|
57
|
+
select: z
|
|
58
|
+
.string()
|
|
59
|
+
.describe(
|
|
60
|
+
"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'",
|
|
61
|
+
)
|
|
62
|
+
.optional(),
|
|
63
|
+
where: whereSchema
|
|
64
|
+
.describe(
|
|
65
|
+
'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
66
|
+
)
|
|
67
|
+
.optional(),
|
|
68
|
+
}),
|
|
69
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
70
|
+
const payload = req.payload
|
|
71
|
+
const logger = getLogger({ payload })
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
id,
|
|
75
|
+
data,
|
|
76
|
+
depth,
|
|
77
|
+
draft,
|
|
78
|
+
fallbackLocale,
|
|
79
|
+
filePath,
|
|
80
|
+
locale,
|
|
81
|
+
overrideLock,
|
|
82
|
+
overwriteExistingFiles,
|
|
83
|
+
select,
|
|
84
|
+
where,
|
|
85
|
+
} = input
|
|
86
|
+
|
|
87
|
+
logger.info(
|
|
88
|
+
`Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
if (!id && !where) {
|
|
93
|
+
return {
|
|
94
|
+
content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
|
|
99
|
+
const inputData = stripVirtualFields(data, virtualFieldNames)
|
|
100
|
+
const validationError = validateCollectionData({
|
|
101
|
+
collectionSlug,
|
|
102
|
+
data: inputData,
|
|
103
|
+
partial: true,
|
|
104
|
+
req,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
if (validationError) {
|
|
108
|
+
return validationError
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const parsedData = transformPointDataToPayload(inputData)
|
|
112
|
+
|
|
113
|
+
const whereClause: Where = where ?? {}
|
|
114
|
+
|
|
115
|
+
let selectClause: SelectType | undefined
|
|
116
|
+
if (select) {
|
|
117
|
+
try {
|
|
118
|
+
selectClause = JSON.parse(select) as SelectType
|
|
119
|
+
} catch {
|
|
120
|
+
logger.warn(`Invalid select clause JSON: ${select}`)
|
|
121
|
+
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (id) {
|
|
126
|
+
const result = await payload.update({
|
|
127
|
+
id,
|
|
128
|
+
collection: collectionSlug,
|
|
129
|
+
data: parsedData,
|
|
130
|
+
depth,
|
|
131
|
+
draft,
|
|
132
|
+
overrideLock,
|
|
133
|
+
req,
|
|
134
|
+
...localAPIDefaults(authorizedMCP),
|
|
135
|
+
...(filePath ? { filePath } : {}),
|
|
136
|
+
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
137
|
+
...(locale ? { locale } : {}),
|
|
138
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
139
|
+
...(selectClause ? { select: selectClause } : {}),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
type: 'text',
|
|
146
|
+
text: `Document updated successfully in collection "${collectionSlug}"!\nUpdated document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
doc: result as Record<string, unknown>,
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const result = await payload.update({
|
|
154
|
+
collection: collectionSlug,
|
|
155
|
+
data: parsedData,
|
|
156
|
+
depth,
|
|
157
|
+
draft,
|
|
158
|
+
overrideLock,
|
|
159
|
+
req,
|
|
160
|
+
where: whereClause,
|
|
161
|
+
...localAPIDefaults(authorizedMCP),
|
|
162
|
+
...(filePath ? { filePath } : {}),
|
|
163
|
+
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
164
|
+
...(locale ? { locale } : {}),
|
|
165
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
166
|
+
...(selectClause ? { select: selectClause } : {}),
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
const docs = result.docs || []
|
|
170
|
+
const errors = result.errors || []
|
|
171
|
+
|
|
172
|
+
let responseText = `Multiple documents updated in collection "${collectionSlug}"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`
|
|
173
|
+
if (docs.length > 0) {
|
|
174
|
+
responseText += `\n\nUpdated documents:\n\`\`\`json\n${JSON.stringify(docs)}\n\`\`\``
|
|
175
|
+
}
|
|
176
|
+
if (errors.length > 0) {
|
|
177
|
+
responseText += `\n\nErrors:\n\`\`\`json\n${JSON.stringify(errors)}\n\`\`\``
|
|
178
|
+
|
|
179
|
+
const errorSchema = getCollectionInputSchema({ collectionSlug, req })
|
|
180
|
+
|
|
181
|
+
if (errorSchema) {
|
|
182
|
+
responseText += `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(errorSchema)}\n\`\`\``
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
content: [{ type: 'text', text: responseText }],
|
|
187
|
+
doc: { docs, errors } as unknown as Record<string, unknown>,
|
|
188
|
+
isError: true,
|
|
189
|
+
...(errorSchema
|
|
190
|
+
? {
|
|
191
|
+
structuredContent: {
|
|
192
|
+
collectionSlug,
|
|
193
|
+
docs,
|
|
194
|
+
errors,
|
|
195
|
+
schema: errorSchema,
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
: {}),
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
content: [{ type: 'text', text: responseText }],
|
|
204
|
+
doc: { docs, errors } as unknown as Record<string, unknown>,
|
|
205
|
+
}
|
|
206
|
+
} catch (error) {
|
|
207
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
208
|
+
logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)
|
|
209
|
+
return formatCollectionError({ action: 'updating', collectionSlug, error, req })
|
|
210
|
+
}
|
|
211
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getAccessResults, isEntityHidden } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { defineTool } from '../../defineTool.js'
|
|
4
|
+
|
|
5
|
+
export const getConfigInfoTool = defineTool({
|
|
6
|
+
description: 'List the Payload collection and global slugs visible to this MCP client.',
|
|
7
|
+
}).handler(async ({ authorizedMCP, req }) => {
|
|
8
|
+
const user = authorizedMCP.user ?? req.user ?? null
|
|
9
|
+
const permissions = user ? await getAccessResults({ req: { ...req, user } }) : null
|
|
10
|
+
|
|
11
|
+
const collections: string[] = []
|
|
12
|
+
const globals: string[] = []
|
|
13
|
+
|
|
14
|
+
for (const collection of req.payload.config.collections) {
|
|
15
|
+
if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {
|
|
16
|
+
continue
|
|
17
|
+
}
|
|
18
|
+
if (user && !permissions?.collections?.[collection.slug]?.read) {
|
|
19
|
+
continue
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
collections.push(collection.slug)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const global of req.payload.config.globals) {
|
|
26
|
+
if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {
|
|
27
|
+
continue
|
|
28
|
+
}
|
|
29
|
+
if (user && !permissions?.globals?.[global.slug]?.read) {
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
globals.push(global.slug)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: `Collections: ${collections.join(', ') || 'none'}\nGlobals: ${globals.join(', ') || 'none'}`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}
|
|
44
|
+
})
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
6
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
8
|
+
|
|
9
|
+
const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'
|
|
10
|
+
|
|
11
|
+
export const findGlobalTool = defineGlobalTool({
|
|
12
|
+
description: DEFAULT_DESCRIPTION,
|
|
13
|
+
input: z.object({
|
|
14
|
+
depth: z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.min(0)
|
|
18
|
+
.max(10)
|
|
19
|
+
.describe('Depth of population for relationships')
|
|
20
|
+
.optional()
|
|
21
|
+
.default(0),
|
|
22
|
+
fallbackLocale: z
|
|
23
|
+
.string()
|
|
24
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
25
|
+
.optional(),
|
|
26
|
+
locale: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe(
|
|
29
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
32
|
+
select: z
|
|
33
|
+
.string()
|
|
34
|
+
.describe(
|
|
35
|
+
"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'",
|
|
36
|
+
)
|
|
37
|
+
.optional(),
|
|
38
|
+
}),
|
|
39
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
40
|
+
const payload = req.payload
|
|
41
|
+
const logger = getLogger({ payload })
|
|
42
|
+
|
|
43
|
+
const { depth, fallbackLocale, locale, select } = input
|
|
44
|
+
|
|
45
|
+
logger.info(
|
|
46
|
+
`Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const findOptions: Parameters<typeof payload.findGlobal>[0] = {
|
|
51
|
+
slug: globalSlug,
|
|
52
|
+
depth,
|
|
53
|
+
...localAPIDefaults(authorizedMCP),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let selectClause: SelectType | undefined
|
|
57
|
+
if (select) {
|
|
58
|
+
try {
|
|
59
|
+
selectClause = JSON.parse(select) as SelectType
|
|
60
|
+
} catch {
|
|
61
|
+
logger.warn(`Invalid select clause JSON for global: ${select}`)
|
|
62
|
+
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (locale) {
|
|
67
|
+
findOptions.locale = locale
|
|
68
|
+
}
|
|
69
|
+
if (fallbackLocale) {
|
|
70
|
+
findOptions.fallbackLocale = fallbackLocale
|
|
71
|
+
}
|
|
72
|
+
if (selectClause) {
|
|
73
|
+
findOptions.select = selectClause
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = await payload.findGlobal(findOptions)
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: `Global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
doc: result as Record<string, unknown>,
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
89
|
+
logger.error(`Error reading global ${globalSlug}: ${errorMessage}`)
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{ type: 'text', text: `❌ **Error reading global "${globalSlug}":** ${errorMessage}` },
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
2
|
+
import { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
3
|
+
|
|
4
|
+
export const getGlobalSchemaTool = defineGlobalTool({
|
|
5
|
+
description: 'Get the input schema for updating a global.',
|
|
6
|
+
}).handler(({ globalSlug, req }) => {
|
|
7
|
+
const inputSchema = getGlobalInputSchema({ globalSlug, req })
|
|
8
|
+
|
|
9
|
+
if (!inputSchema) {
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: 'text', text: `Error: Global "${globalSlug}" not found` }],
|
|
12
|
+
isError: true,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: 'text',
|
|
20
|
+
text: `Schema for global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
structuredContent: {
|
|
24
|
+
globalSlug,
|
|
25
|
+
schema: inputSchema,
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
6
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
+
import {
|
|
8
|
+
getGlobalVirtualFieldNames,
|
|
9
|
+
stripVirtualFields,
|
|
10
|
+
} from '../../../utils/getVirtualFieldNames.js'
|
|
11
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
12
|
+
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
13
|
+
import { validateGlobalData } from '../validateEntityData.js'
|
|
14
|
+
|
|
15
|
+
const DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.'
|
|
16
|
+
|
|
17
|
+
export const updateGlobalTool = defineGlobalTool({
|
|
18
|
+
description: DEFAULT_DESCRIPTION,
|
|
19
|
+
input: z.object({
|
|
20
|
+
data: z.record(z.string(), z.unknown()).describe('The global fields to update'),
|
|
21
|
+
depth: z
|
|
22
|
+
.number()
|
|
23
|
+
.describe('Optional: Depth of relationships to populate')
|
|
24
|
+
.optional()
|
|
25
|
+
.default(0),
|
|
26
|
+
draft: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.describe('Optional: Whether to save as draft (default: false)')
|
|
29
|
+
.optional()
|
|
30
|
+
.default(false),
|
|
31
|
+
fallbackLocale: z
|
|
32
|
+
.string()
|
|
33
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
34
|
+
.optional(),
|
|
35
|
+
locale: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe(
|
|
38
|
+
'Optional: locale code to update data in (e.g., "en", "es"). Use "all" to update all locales for localized fields',
|
|
39
|
+
)
|
|
40
|
+
.optional(),
|
|
41
|
+
select: z
|
|
42
|
+
.string()
|
|
43
|
+
.describe(
|
|
44
|
+
"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"siteName\": true}'",
|
|
45
|
+
)
|
|
46
|
+
.optional(),
|
|
47
|
+
}),
|
|
48
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
49
|
+
const payload = req.payload
|
|
50
|
+
const logger = getLogger({ payload })
|
|
51
|
+
|
|
52
|
+
const { data, depth, draft, fallbackLocale, locale, select } = input
|
|
53
|
+
|
|
54
|
+
logger.info(
|
|
55
|
+
`Updating global: ${globalSlug}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, globalSlug)
|
|
60
|
+
const inputData = stripVirtualFields(data, virtualFieldNames)
|
|
61
|
+
const validationError = validateGlobalData({ data: inputData, globalSlug, req })
|
|
62
|
+
|
|
63
|
+
if (validationError) {
|
|
64
|
+
return validationError
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const parsedData = transformPointDataToPayload(inputData)
|
|
68
|
+
|
|
69
|
+
let selectClause: SelectType | undefined
|
|
70
|
+
if (select) {
|
|
71
|
+
try {
|
|
72
|
+
selectClause = JSON.parse(select) as SelectType
|
|
73
|
+
} catch {
|
|
74
|
+
logger.warn(`Invalid select clause JSON for global: ${select}`)
|
|
75
|
+
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const updateOptions: Parameters<typeof payload.updateGlobal>[0] = {
|
|
80
|
+
slug: globalSlug,
|
|
81
|
+
data: parsedData,
|
|
82
|
+
depth,
|
|
83
|
+
draft,
|
|
84
|
+
...localAPIDefaults(authorizedMCP),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (locale) {
|
|
88
|
+
updateOptions.locale = locale
|
|
89
|
+
}
|
|
90
|
+
if (fallbackLocale) {
|
|
91
|
+
updateOptions.fallbackLocale = fallbackLocale
|
|
92
|
+
}
|
|
93
|
+
if (selectClause) {
|
|
94
|
+
updateOptions.select = selectClause
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const result = await payload.updateGlobal(updateOptions)
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `Global "${globalSlug}" updated successfully!\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
doc: result as Record<string, unknown>,
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
110
|
+
logger.error(`Error updating global ${globalSlug}: ${errorMessage}`)
|
|
111
|
+
return {
|
|
112
|
+
content: [{ type: 'text', text: `Error updating global "${globalSlug}": ${errorMessage}` }],
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|