@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,233 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import type { MCPToolResponse } from '../../../types.js'
|
|
4
|
+
|
|
5
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Auth tools surfaced under `collections.<auth-collection>.tools`. Opt-in: they
|
|
10
|
+
* default off (an LLM with `login` access can probe passwords; not something
|
|
11
|
+
* to expose by default). Enable in plugin config via `tools: { login: true }`
|
|
12
|
+
* (or `{ description: '...' }`).
|
|
13
|
+
*
|
|
14
|
+
* `auth` (check current token) doesn't actually depend on the collection at
|
|
15
|
+
* runtime — `payload.auth({ headers })` is global — but it's grouped under the
|
|
16
|
+
* users collection so all auth-shaped tools live in one place.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const emailSchema = z.string().email().describe('The user email address')
|
|
20
|
+
|
|
21
|
+
const wrapError =
|
|
22
|
+
(name: string) =>
|
|
23
|
+
({ collectionSlug, message }: { collectionSlug: string; message: string }): MCPToolResponse => {
|
|
24
|
+
return {
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
type: 'text',
|
|
28
|
+
text: `❌ **Error in ${name}** on ${collectionSlug}: ${message}`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const authCollectionTool = defineCollectionTool({
|
|
35
|
+
description: 'Checks authentication status for the current user.',
|
|
36
|
+
input: z.object({
|
|
37
|
+
headers: z
|
|
38
|
+
.string()
|
|
39
|
+
.describe(
|
|
40
|
+
'Optional JSON string containing custom headers to send with the authentication request',
|
|
41
|
+
)
|
|
42
|
+
.optional(),
|
|
43
|
+
}),
|
|
44
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
45
|
+
const logger = getLogger({ payload: req.payload })
|
|
46
|
+
try {
|
|
47
|
+
let authHeaders = new Headers()
|
|
48
|
+
if (input.headers) {
|
|
49
|
+
try {
|
|
50
|
+
authHeaders = new Headers(JSON.parse(input.headers) as Record<string, string>)
|
|
51
|
+
} catch {
|
|
52
|
+
logger.warn(`Invalid headers JSON for auth: ${input.headers}, using empty headers`)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const result = await req.payload.auth({ headers: authHeaders })
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `# Authentication Status\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
doc: result as unknown as Record<string, unknown>,
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
67
|
+
logger.error(`Error in auth tool on ${collectionSlug}: ${errorMessage}`)
|
|
68
|
+
return wrapError('auth')({ collectionSlug, message: errorMessage })
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
export const forgotPasswordCollectionTool = defineCollectionTool({
|
|
73
|
+
description: 'Sends a password reset email to a user.',
|
|
74
|
+
input: z.object({
|
|
75
|
+
disableEmail: z
|
|
76
|
+
.boolean()
|
|
77
|
+
.describe('Whether to disable sending the email (for testing)')
|
|
78
|
+
.optional()
|
|
79
|
+
.default(false),
|
|
80
|
+
email: emailSchema,
|
|
81
|
+
}),
|
|
82
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
83
|
+
const logger = getLogger({ payload: req.payload })
|
|
84
|
+
try {
|
|
85
|
+
const result = await req.payload.forgotPassword({
|
|
86
|
+
collection: collectionSlug,
|
|
87
|
+
data: { email: input.email },
|
|
88
|
+
disableEmail: input.disableEmail,
|
|
89
|
+
})
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: `# Forgot Password Email Sent\n\n**Collection:** ${collectionSlug}\n**Email:** ${input.email}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
doc: { result } as Record<string, unknown>,
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
101
|
+
logger.error(`Error in forgotPassword tool on ${collectionSlug}: ${errorMessage}`)
|
|
102
|
+
return wrapError('forgotPassword')({ collectionSlug, message: errorMessage })
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
export const loginCollectionTool = defineCollectionTool({
|
|
107
|
+
description: 'Authenticates a user with email and password.',
|
|
108
|
+
input: z.object({
|
|
109
|
+
depth: z
|
|
110
|
+
.number()
|
|
111
|
+
.int()
|
|
112
|
+
.min(0)
|
|
113
|
+
.max(10)
|
|
114
|
+
.describe('Depth of population for relationships')
|
|
115
|
+
.optional()
|
|
116
|
+
.default(0),
|
|
117
|
+
email: emailSchema,
|
|
118
|
+
password: z.string().describe('The user password'),
|
|
119
|
+
showHiddenFields: z
|
|
120
|
+
.boolean()
|
|
121
|
+
.describe('Whether to show hidden fields in the response')
|
|
122
|
+
.optional()
|
|
123
|
+
.default(false),
|
|
124
|
+
}),
|
|
125
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
126
|
+
const logger = getLogger({ payload: req.payload })
|
|
127
|
+
try {
|
|
128
|
+
const result = await req.payload.login({
|
|
129
|
+
collection: collectionSlug,
|
|
130
|
+
data: { email: input.email, password: input.password },
|
|
131
|
+
depth: input.depth,
|
|
132
|
+
showHiddenFields: input.showHiddenFields,
|
|
133
|
+
})
|
|
134
|
+
return {
|
|
135
|
+
content: [
|
|
136
|
+
{
|
|
137
|
+
type: 'text',
|
|
138
|
+
text: `# Login Successful\n\n**User:** ${input.email}\n**Collection:** ${collectionSlug}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
doc: result as unknown as Record<string, unknown>,
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
145
|
+
logger.error(`Error in login tool on ${collectionSlug}: ${errorMessage}`)
|
|
146
|
+
return wrapError('login')({ collectionSlug, message: errorMessage })
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
export const resetPasswordCollectionTool = defineCollectionTool({
|
|
151
|
+
description: 'Resets a user password with a reset token.',
|
|
152
|
+
input: z.object({
|
|
153
|
+
password: z.string().describe('The new password for the user'),
|
|
154
|
+
token: z.string().describe('The password reset token sent to the user email'),
|
|
155
|
+
}),
|
|
156
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
157
|
+
const logger = getLogger({ payload: req.payload })
|
|
158
|
+
try {
|
|
159
|
+
const result = await req.payload.resetPassword({
|
|
160
|
+
collection: collectionSlug,
|
|
161
|
+
data: { password: input.password, token: input.token },
|
|
162
|
+
overrideAccess: true,
|
|
163
|
+
})
|
|
164
|
+
return {
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: 'text',
|
|
168
|
+
text: `# Password Reset Successful\n\n**Collection:** ${collectionSlug}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
doc: result as unknown as Record<string, unknown>,
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {
|
|
174
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
175
|
+
logger.error(`Error in resetPassword tool on ${collectionSlug}: ${errorMessage}`)
|
|
176
|
+
return wrapError('resetPassword')({ collectionSlug, message: errorMessage })
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
export const unlockCollectionTool = defineCollectionTool({
|
|
181
|
+
description: 'Unlocks a user account that has been locked due to failed login attempts.',
|
|
182
|
+
input: z.object({ email: emailSchema }),
|
|
183
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
184
|
+
const logger = getLogger({ payload: req.payload })
|
|
185
|
+
try {
|
|
186
|
+
const result = await req.payload.unlock({
|
|
187
|
+
collection: collectionSlug,
|
|
188
|
+
data: { email: input.email },
|
|
189
|
+
overrideAccess: true,
|
|
190
|
+
})
|
|
191
|
+
return {
|
|
192
|
+
content: [
|
|
193
|
+
{
|
|
194
|
+
type: 'text',
|
|
195
|
+
text: `# Account Unlocked\n\n**Collection:** ${collectionSlug}\n**Email:** ${input.email}\n**Result:** ${result ? 'Success' : 'Failed'}`,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
doc: { result } as Record<string, unknown>,
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
202
|
+
logger.error(`Error in unlock tool on ${collectionSlug}: ${errorMessage}`)
|
|
203
|
+
return wrapError('unlock')({ collectionSlug, message: errorMessage })
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
export const verifyCollectionTool = defineCollectionTool({
|
|
208
|
+
description: 'Verifies a user email with a verification token.',
|
|
209
|
+
input: z.object({
|
|
210
|
+
token: z.string().describe('The verification token sent to the user email'),
|
|
211
|
+
}),
|
|
212
|
+
}).handler(async ({ collectionSlug, input, req }) => {
|
|
213
|
+
const logger = getLogger({ payload: req.payload })
|
|
214
|
+
try {
|
|
215
|
+
const result = await req.payload.verifyEmail({
|
|
216
|
+
collection: collectionSlug,
|
|
217
|
+
token: input.token,
|
|
218
|
+
})
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: 'text',
|
|
223
|
+
text: `# Email Verification Successful\n\n**Collection:** ${collectionSlug}\n**Result:** ${result ? 'Success' : 'Failed'}`,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
doc: { result } as Record<string, unknown>,
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
230
|
+
logger.error(`Error in verify tool on ${collectionSlug}: ${errorMessage}`)
|
|
231
|
+
return wrapError('verify')({ collectionSlug, message: errorMessage })
|
|
232
|
+
}
|
|
233
|
+
})
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { SelectType } 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 { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
13
|
+
import { validateCollectionData } from '../validateEntityData.js'
|
|
14
|
+
import { formatCollectionError } from './formatCollectionError.js'
|
|
15
|
+
|
|
16
|
+
const DEFAULT_DESCRIPTION =
|
|
17
|
+
'Create a document in any collection by passing the collection slug and data.'
|
|
18
|
+
|
|
19
|
+
export const createDocumentTool = defineCollectionTool({
|
|
20
|
+
description: DEFAULT_DESCRIPTION,
|
|
21
|
+
input: z.object({
|
|
22
|
+
data: z.record(z.string(), z.unknown()).describe('The document fields to create'),
|
|
23
|
+
depth: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(0)
|
|
27
|
+
.max(10)
|
|
28
|
+
.describe('How many levels deep to populate relationships in response')
|
|
29
|
+
.optional()
|
|
30
|
+
.default(0),
|
|
31
|
+
draft: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.describe('Whether to create 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
|
+
locale: z
|
|
41
|
+
.string()
|
|
42
|
+
.describe(
|
|
43
|
+
'Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale',
|
|
44
|
+
)
|
|
45
|
+
.optional(),
|
|
46
|
+
select: z
|
|
47
|
+
.string()
|
|
48
|
+
.describe(
|
|
49
|
+
"Optional: define exactly which fields you'd like to return (JSON), e.g., '{\"title\": true}'",
|
|
50
|
+
)
|
|
51
|
+
.optional(),
|
|
52
|
+
}),
|
|
53
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
54
|
+
const payload = req.payload
|
|
55
|
+
const logger = getLogger({ payload })
|
|
56
|
+
|
|
57
|
+
const { data, depth, draft, fallbackLocale, locale, select } = input
|
|
58
|
+
|
|
59
|
+
logger.info(
|
|
60
|
+
`Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
|
|
65
|
+
const inputData = stripVirtualFields(data, virtualFieldNames)
|
|
66
|
+
const validationError = validateCollectionData({ collectionSlug, data: inputData, req })
|
|
67
|
+
|
|
68
|
+
if (validationError) {
|
|
69
|
+
return validationError
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const parsedData = transformPointDataToPayload(inputData)
|
|
73
|
+
|
|
74
|
+
let selectClause: SelectType | undefined
|
|
75
|
+
if (select) {
|
|
76
|
+
try {
|
|
77
|
+
selectClause = JSON.parse(select) as SelectType
|
|
78
|
+
} catch {
|
|
79
|
+
logger.warn(`Invalid select clause JSON: ${select}`)
|
|
80
|
+
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const result = await payload.create({
|
|
85
|
+
collection: collectionSlug,
|
|
86
|
+
data: parsedData,
|
|
87
|
+
depth,
|
|
88
|
+
draft,
|
|
89
|
+
req,
|
|
90
|
+
...localAPIDefaults(authorizedMCP),
|
|
91
|
+
...(locale ? { locale } : {}),
|
|
92
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
93
|
+
...(selectClause ? { select: selectClause } : {}),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`)
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: `Document created successfully in collection "${collectionSlug}"!\nCreated document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
doc: result as Record<string, unknown>,
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
109
|
+
logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`)
|
|
110
|
+
return formatCollectionError({ action: 'creating', collectionSlug, error, req })
|
|
111
|
+
}
|
|
112
|
+
})
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
4
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
5
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
6
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
7
|
+
|
|
8
|
+
const DEFAULT_DESCRIPTION =
|
|
9
|
+
'Delete documents in any collection by passing the collection slug and ID or where clause.'
|
|
10
|
+
|
|
11
|
+
export const deleteDocumentsTool = defineCollectionTool({
|
|
12
|
+
description: DEFAULT_DESCRIPTION,
|
|
13
|
+
input: z.object({
|
|
14
|
+
id: z
|
|
15
|
+
.union([z.string(), z.number()])
|
|
16
|
+
.describe('Optional: specific document ID to delete')
|
|
17
|
+
.optional(),
|
|
18
|
+
depth: z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.min(0)
|
|
22
|
+
.max(10)
|
|
23
|
+
.describe('Depth of population for relationships in response')
|
|
24
|
+
.optional()
|
|
25
|
+
.default(0),
|
|
26
|
+
fallbackLocale: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
29
|
+
.optional(),
|
|
30
|
+
locale: z
|
|
31
|
+
.string()
|
|
32
|
+
.describe(
|
|
33
|
+
'Optional: locale code for the operation (e.g., "en", "es"). Defaults to the default locale',
|
|
34
|
+
)
|
|
35
|
+
.optional(),
|
|
36
|
+
where: whereSchema
|
|
37
|
+
.describe(
|
|
38
|
+
'Optional: where clause to delete multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
39
|
+
)
|
|
40
|
+
.optional(),
|
|
41
|
+
}),
|
|
42
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
43
|
+
const payload = req.payload
|
|
44
|
+
const logger = getLogger({ payload })
|
|
45
|
+
|
|
46
|
+
const { id, depth, fallbackLocale, locale, where } = input
|
|
47
|
+
|
|
48
|
+
logger.info(
|
|
49
|
+
`Deleting document from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
if (!id && !where) {
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const deleteOptions: Record<string, unknown> = {
|
|
60
|
+
collection: collectionSlug,
|
|
61
|
+
depth,
|
|
62
|
+
req,
|
|
63
|
+
...localAPIDefaults(authorizedMCP),
|
|
64
|
+
...(locale && { locale }),
|
|
65
|
+
...(fallbackLocale && { fallbackLocale }),
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (id) {
|
|
69
|
+
deleteOptions.id = id
|
|
70
|
+
} else {
|
|
71
|
+
deleteOptions.where = where
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const result = await payload.delete(deleteOptions as Parameters<typeof payload.delete>[0])
|
|
75
|
+
|
|
76
|
+
if (id) {
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: 'text',
|
|
81
|
+
text: `Document deleted successfully from collection "${collectionSlug}"!\nDeleted document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
doc: result as Record<string, unknown>,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }
|
|
89
|
+
const docs = bulkResult.docs || []
|
|
90
|
+
const errors = bulkResult.errors || []
|
|
91
|
+
|
|
92
|
+
let responseText = `Document deleted successfully from collection "${collectionSlug}"!\nDeleted: ${docs.length} documents\nErrors: ${errors.length}\n---`
|
|
93
|
+
if (docs.length > 0) {
|
|
94
|
+
responseText += `\n\nDeleted documents:\n\`\`\`json\n${JSON.stringify(docs)}\n\`\`\``
|
|
95
|
+
}
|
|
96
|
+
if (errors.length > 0) {
|
|
97
|
+
responseText += `\n\nErrors:\n\`\`\`json\n${JSON.stringify(errors)}\n\`\`\``
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
content: [{ type: 'text', text: responseText }],
|
|
102
|
+
doc: { docs, errors } as unknown as Record<string, unknown>,
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
106
|
+
logger.error(`Error deleting document from ${collectionSlug}: ${errorMessage}`)
|
|
107
|
+
return {
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: 'text',
|
|
111
|
+
text: `Error deleting document from collection "${collectionSlug}": ${errorMessage}`,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
})
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
8
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DESCRIPTION =
|
|
11
|
+
'Find documents in any collection by passing the collection slug and optional ID or where clause.'
|
|
12
|
+
|
|
13
|
+
export const findDocumentsTool = defineCollectionTool({
|
|
14
|
+
description: DEFAULT_DESCRIPTION,
|
|
15
|
+
input: z.object({
|
|
16
|
+
id: z
|
|
17
|
+
.union([z.string(), z.number()])
|
|
18
|
+
.describe(
|
|
19
|
+
'Optional: specific document ID to retrieve. If not provided, returns all documents',
|
|
20
|
+
)
|
|
21
|
+
.optional(),
|
|
22
|
+
depth: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.min(0)
|
|
26
|
+
.max(10)
|
|
27
|
+
.describe('How many levels deep to populate relationships (default: 0)')
|
|
28
|
+
.optional()
|
|
29
|
+
.default(0),
|
|
30
|
+
draft: z
|
|
31
|
+
.boolean()
|
|
32
|
+
.describe(
|
|
33
|
+
'Optional: whether the document should be queried from the versions table/collection or not.',
|
|
34
|
+
)
|
|
35
|
+
.optional(),
|
|
36
|
+
fallbackLocale: z
|
|
37
|
+
.string()
|
|
38
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
39
|
+
.optional(),
|
|
40
|
+
limit: z
|
|
41
|
+
.number()
|
|
42
|
+
.int()
|
|
43
|
+
.min(1)
|
|
44
|
+
.max(100)
|
|
45
|
+
.describe('Maximum number of documents to return (default: 10, max: 100)')
|
|
46
|
+
.optional()
|
|
47
|
+
.default(10),
|
|
48
|
+
locale: z
|
|
49
|
+
.string()
|
|
50
|
+
.describe(
|
|
51
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
52
|
+
)
|
|
53
|
+
.optional(),
|
|
54
|
+
page: z
|
|
55
|
+
.number()
|
|
56
|
+
.int()
|
|
57
|
+
.min(1)
|
|
58
|
+
.describe('Page number for pagination (default: 1)')
|
|
59
|
+
.optional()
|
|
60
|
+
.default(1),
|
|
61
|
+
select: z
|
|
62
|
+
.string()
|
|
63
|
+
.describe(
|
|
64
|
+
"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'",
|
|
65
|
+
)
|
|
66
|
+
.optional(),
|
|
67
|
+
sort: z
|
|
68
|
+
.string()
|
|
69
|
+
.describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)')
|
|
70
|
+
.optional(),
|
|
71
|
+
where: whereSchema
|
|
72
|
+
.describe(
|
|
73
|
+
'Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
74
|
+
)
|
|
75
|
+
.optional(),
|
|
76
|
+
}),
|
|
77
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
78
|
+
const payload = req.payload
|
|
79
|
+
const logger = getLogger({ payload })
|
|
80
|
+
|
|
81
|
+
const { id, depth, draft, fallbackLocale, limit, locale, page, select, sort, where } = input
|
|
82
|
+
|
|
83
|
+
logger.info(
|
|
84
|
+
`Reading document from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
let selectClause: SelectType | undefined
|
|
89
|
+
if (select) {
|
|
90
|
+
try {
|
|
91
|
+
selectClause = JSON.parse(select) as SelectType
|
|
92
|
+
} catch {
|
|
93
|
+
logger.warn(`Invalid select clause JSON: ${select}`)
|
|
94
|
+
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (id) {
|
|
99
|
+
try {
|
|
100
|
+
const doc = await payload.findByID({
|
|
101
|
+
id,
|
|
102
|
+
collection: collectionSlug,
|
|
103
|
+
depth,
|
|
104
|
+
req,
|
|
105
|
+
...localAPIDefaults(authorizedMCP),
|
|
106
|
+
...(selectClause && { select: selectClause }),
|
|
107
|
+
...(locale && { locale }),
|
|
108
|
+
...(fallbackLocale && { fallbackLocale }),
|
|
109
|
+
...(draft !== undefined && { draft }),
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
content: [
|
|
114
|
+
{
|
|
115
|
+
type: 'text',
|
|
116
|
+
text: `Document from collection "${collectionSlug}":\n${JSON.stringify(doc)}`,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
doc: doc as Record<string, unknown>,
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
logger.warn(`Document not found with ID: ${id} in collection: ${collectionSlug}`)
|
|
123
|
+
return {
|
|
124
|
+
content: [
|
|
125
|
+
{
|
|
126
|
+
type: 'text',
|
|
127
|
+
text: `Error: Document with ID "${id}" not found in collection "${collectionSlug}"`,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const findOptions: Parameters<typeof payload.find>[0] = {
|
|
135
|
+
collection: collectionSlug,
|
|
136
|
+
depth,
|
|
137
|
+
limit,
|
|
138
|
+
page,
|
|
139
|
+
req,
|
|
140
|
+
...localAPIDefaults(authorizedMCP),
|
|
141
|
+
...(selectClause && { select: selectClause }),
|
|
142
|
+
...(locale && { locale }),
|
|
143
|
+
...(fallbackLocale && { fallbackLocale }),
|
|
144
|
+
...(draft !== undefined && { draft }),
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (sort) {
|
|
148
|
+
findOptions.sort = sort
|
|
149
|
+
}
|
|
150
|
+
if (where) {
|
|
151
|
+
findOptions.where = where
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const result = await payload.find(findOptions)
|
|
155
|
+
|
|
156
|
+
let responseText = `Collection: "${collectionSlug}"\nTotal: ${result.totalDocs} documents\nPage: ${result.page} of ${result.totalPages}\n`
|
|
157
|
+
for (const doc of result.docs) {
|
|
158
|
+
responseText += `\n\`\`\`json\n${JSON.stringify(doc)}\n\`\`\``
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
content: [{ type: 'text', text: responseText }],
|
|
163
|
+
doc: result as unknown as Record<string, unknown>,
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
167
|
+
logger.error(`Error reading documents from collection ${collectionSlug}: ${errorMessage}`)
|
|
168
|
+
return {
|
|
169
|
+
content: [
|
|
170
|
+
{
|
|
171
|
+
type: 'text',
|
|
172
|
+
text: `❌ **Error reading documents from collection "${collectionSlug}":** ${errorMessage}`,
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
})
|