@payloadcms/plugin-mcp 4.0.0-internal.688c4d0 → 4.0.0-internal.697830c
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/LICENSE.md +1 -1
- package/dist/defaultAccess.d.ts +3 -0
- package/dist/defaultAccess.d.ts.map +1 -0
- package/dist/defaultAccess.js +3 -0
- package/dist/defaultAccess.js.map +1 -0
- package/dist/endpoint/access.d.ts +12 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +74 -103
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +68 -17
- package/dist/endpoint/index.js.map +1 -1
- package/dist/exports/client.d.ts +1 -4
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -4
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -0
- package/dist/exports/internal.js +3 -0
- package/dist/exports/internal.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -51
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +4 -4
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +34 -10
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/authTools.js +44 -6
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countTool.js +68 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +13 -21
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +10 -2
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +96 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +92 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +45 -25
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +83 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +98 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +32 -2
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +81 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +16 -24
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +27 -8
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +19 -22
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +79 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +94 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +32 -2
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +77 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +14 -21
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.js +1 -1
- package/dist/mcp/builtin/validateEntityData.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +69 -12
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +66 -10
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +69 -27
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +82 -45
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +100 -92
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/getPluginConfig.d.ts +1 -1
- package/dist/utils/getPluginConfig.js +1 -1
- package/dist/utils/getPluginConfig.js.map +1 -1
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/package.json +10 -16
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +80 -112
- package/src/endpoint/index.ts +58 -16
- package/src/exports/client.ts +2 -4
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +5 -59
- package/src/mcp/buildMcpServer.ts +48 -21
- package/src/mcp/builtin/collections/authTools.ts +45 -9
- package/src/mcp/builtin/collections/countTool.ts +73 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/collections/createTool.ts +14 -15
- package/src/mcp/builtin/collections/deleteTool.ts +11 -2
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +58 -19
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +37 -2
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +16 -17
- package/src/mcp/builtin/getConfigInfoTool.ts +27 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +27 -18
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +37 -2
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +16 -16
- package/src/mcp/builtin/validateEntityData.ts +1 -1
- package/src/mcp/builtinTools.ts +72 -16
- package/src/mcp/sanitizeMCPConfig.ts +48 -30
- package/src/stdio.ts +77 -45
- package/src/types.ts +108 -95
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/collection/getAccessField.d.ts +0 -12
- package/dist/collection/getAccessField.d.ts.map +0 -1
- package/dist/collection/getAccessField.js +0 -72
- package/dist/collection/getAccessField.js.map +0 -1
- package/dist/collection/index.d.ts +0 -6
- package/dist/collection/index.d.ts.map +0 -1
- package/dist/collection/index.js +0 -105
- package/dist/collection/index.js.map +0 -1
- package/dist/components/APIKeyField/index.client.d.ts +0 -9
- package/dist/components/APIKeyField/index.client.d.ts.map +0 -1
- package/dist/components/APIKeyField/index.client.js +0 -85
- package/dist/components/APIKeyField/index.client.js.map +0 -1
- package/dist/components/APIKeyField/index.css +0 -105
- package/dist/components/APIKeysEmptyState/index.client.d.ts +0 -4
- package/dist/components/APIKeysEmptyState/index.client.d.ts.map +0 -1
- package/dist/components/APIKeysEmptyState/index.client.js +0 -21
- package/dist/components/APIKeysEmptyState/index.client.js.map +0 -1
- package/dist/components/AccessField/index.client.d.ts +0 -10
- package/dist/components/AccessField/index.client.d.ts.map +0 -1
- package/dist/components/AccessField/index.client.js +0 -247
- package/dist/components/AccessField/index.client.js.map +0 -1
- package/dist/components/AccessField/index.css +0 -99
- package/dist/components/SettingsMenu/index.client.d.ts +0 -8
- package/dist/components/SettingsMenu/index.client.d.ts.map +0 -1
- package/dist/components/SettingsMenu/index.client.js +0 -29
- package/dist/components/SettingsMenu/index.client.js.map +0 -1
- package/dist/translations/index.d.ts +0 -11
- package/dist/translations/index.d.ts.map +0 -1
- package/dist/translations/index.js +0 -92
- package/dist/translations/index.js.map +0 -1
- package/dist/translations/languages/ar.d.ts +0 -31
- package/dist/translations/languages/ar.d.ts.map +0 -1
- package/dist/translations/languages/ar.js +0 -34
- package/dist/translations/languages/ar.js.map +0 -1
- package/dist/translations/languages/az.d.ts +0 -31
- package/dist/translations/languages/az.d.ts.map +0 -1
- package/dist/translations/languages/az.js +0 -34
- package/dist/translations/languages/az.js.map +0 -1
- package/dist/translations/languages/bg.d.ts +0 -31
- package/dist/translations/languages/bg.d.ts.map +0 -1
- package/dist/translations/languages/bg.js +0 -34
- package/dist/translations/languages/bg.js.map +0 -1
- package/dist/translations/languages/bnBd.d.ts +0 -31
- package/dist/translations/languages/bnBd.d.ts.map +0 -1
- package/dist/translations/languages/bnBd.js +0 -34
- package/dist/translations/languages/bnBd.js.map +0 -1
- package/dist/translations/languages/bnIn.d.ts +0 -31
- package/dist/translations/languages/bnIn.d.ts.map +0 -1
- package/dist/translations/languages/bnIn.js +0 -34
- package/dist/translations/languages/bnIn.js.map +0 -1
- package/dist/translations/languages/ca.d.ts +0 -31
- package/dist/translations/languages/ca.d.ts.map +0 -1
- package/dist/translations/languages/ca.js +0 -34
- package/dist/translations/languages/ca.js.map +0 -1
- package/dist/translations/languages/cs.d.ts +0 -31
- package/dist/translations/languages/cs.d.ts.map +0 -1
- package/dist/translations/languages/cs.js +0 -34
- package/dist/translations/languages/cs.js.map +0 -1
- package/dist/translations/languages/da.d.ts +0 -31
- package/dist/translations/languages/da.d.ts.map +0 -1
- package/dist/translations/languages/da.js +0 -34
- package/dist/translations/languages/da.js.map +0 -1
- package/dist/translations/languages/de.d.ts +0 -31
- package/dist/translations/languages/de.d.ts.map +0 -1
- package/dist/translations/languages/de.js +0 -34
- package/dist/translations/languages/de.js.map +0 -1
- package/dist/translations/languages/en.d.ts +0 -31
- package/dist/translations/languages/en.d.ts.map +0 -1
- package/dist/translations/languages/en.js +0 -34
- package/dist/translations/languages/en.js.map +0 -1
- package/dist/translations/languages/es.d.ts +0 -31
- package/dist/translations/languages/es.d.ts.map +0 -1
- package/dist/translations/languages/es.js +0 -34
- package/dist/translations/languages/es.js.map +0 -1
- package/dist/translations/languages/et.d.ts +0 -31
- package/dist/translations/languages/et.d.ts.map +0 -1
- package/dist/translations/languages/et.js +0 -34
- package/dist/translations/languages/et.js.map +0 -1
- package/dist/translations/languages/fa.d.ts +0 -31
- package/dist/translations/languages/fa.d.ts.map +0 -1
- package/dist/translations/languages/fa.js +0 -34
- package/dist/translations/languages/fa.js.map +0 -1
- package/dist/translations/languages/fr.d.ts +0 -31
- package/dist/translations/languages/fr.d.ts.map +0 -1
- package/dist/translations/languages/fr.js +0 -34
- package/dist/translations/languages/fr.js.map +0 -1
- package/dist/translations/languages/he.d.ts +0 -31
- package/dist/translations/languages/he.d.ts.map +0 -1
- package/dist/translations/languages/he.js +0 -34
- package/dist/translations/languages/he.js.map +0 -1
- package/dist/translations/languages/hr.d.ts +0 -31
- package/dist/translations/languages/hr.d.ts.map +0 -1
- package/dist/translations/languages/hr.js +0 -34
- package/dist/translations/languages/hr.js.map +0 -1
- package/dist/translations/languages/hu.d.ts +0 -31
- package/dist/translations/languages/hu.d.ts.map +0 -1
- package/dist/translations/languages/hu.js +0 -34
- package/dist/translations/languages/hu.js.map +0 -1
- package/dist/translations/languages/hy.d.ts +0 -31
- package/dist/translations/languages/hy.d.ts.map +0 -1
- package/dist/translations/languages/hy.js +0 -34
- package/dist/translations/languages/hy.js.map +0 -1
- package/dist/translations/languages/id.d.ts +0 -31
- package/dist/translations/languages/id.d.ts.map +0 -1
- package/dist/translations/languages/id.js +0 -34
- package/dist/translations/languages/id.js.map +0 -1
- package/dist/translations/languages/is.d.ts +0 -31
- package/dist/translations/languages/is.d.ts.map +0 -1
- package/dist/translations/languages/is.js +0 -34
- package/dist/translations/languages/is.js.map +0 -1
- package/dist/translations/languages/it.d.ts +0 -31
- package/dist/translations/languages/it.d.ts.map +0 -1
- package/dist/translations/languages/it.js +0 -34
- package/dist/translations/languages/it.js.map +0 -1
- package/dist/translations/languages/ja.d.ts +0 -31
- package/dist/translations/languages/ja.d.ts.map +0 -1
- package/dist/translations/languages/ja.js +0 -34
- package/dist/translations/languages/ja.js.map +0 -1
- package/dist/translations/languages/ko.d.ts +0 -31
- package/dist/translations/languages/ko.d.ts.map +0 -1
- package/dist/translations/languages/ko.js +0 -34
- package/dist/translations/languages/ko.js.map +0 -1
- package/dist/translations/languages/lt.d.ts +0 -31
- package/dist/translations/languages/lt.d.ts.map +0 -1
- package/dist/translations/languages/lt.js +0 -34
- package/dist/translations/languages/lt.js.map +0 -1
- package/dist/translations/languages/lv.d.ts +0 -31
- package/dist/translations/languages/lv.d.ts.map +0 -1
- package/dist/translations/languages/lv.js +0 -34
- package/dist/translations/languages/lv.js.map +0 -1
- package/dist/translations/languages/my.d.ts +0 -31
- package/dist/translations/languages/my.d.ts.map +0 -1
- package/dist/translations/languages/my.js +0 -34
- package/dist/translations/languages/my.js.map +0 -1
- package/dist/translations/languages/nb.d.ts +0 -31
- package/dist/translations/languages/nb.d.ts.map +0 -1
- package/dist/translations/languages/nb.js +0 -34
- package/dist/translations/languages/nb.js.map +0 -1
- package/dist/translations/languages/nl.d.ts +0 -31
- package/dist/translations/languages/nl.d.ts.map +0 -1
- package/dist/translations/languages/nl.js +0 -34
- package/dist/translations/languages/nl.js.map +0 -1
- package/dist/translations/languages/pl.d.ts +0 -31
- package/dist/translations/languages/pl.d.ts.map +0 -1
- package/dist/translations/languages/pl.js +0 -34
- package/dist/translations/languages/pl.js.map +0 -1
- package/dist/translations/languages/pt.d.ts +0 -31
- package/dist/translations/languages/pt.d.ts.map +0 -1
- package/dist/translations/languages/pt.js +0 -34
- package/dist/translations/languages/pt.js.map +0 -1
- package/dist/translations/languages/ro.d.ts +0 -31
- package/dist/translations/languages/ro.d.ts.map +0 -1
- package/dist/translations/languages/ro.js +0 -34
- package/dist/translations/languages/ro.js.map +0 -1
- package/dist/translations/languages/rs.d.ts +0 -31
- package/dist/translations/languages/rs.d.ts.map +0 -1
- package/dist/translations/languages/rs.js +0 -34
- package/dist/translations/languages/rs.js.map +0 -1
- package/dist/translations/languages/rsLatin.d.ts +0 -31
- package/dist/translations/languages/rsLatin.d.ts.map +0 -1
- package/dist/translations/languages/rsLatin.js +0 -34
- package/dist/translations/languages/rsLatin.js.map +0 -1
- package/dist/translations/languages/ru.d.ts +0 -31
- package/dist/translations/languages/ru.d.ts.map +0 -1
- package/dist/translations/languages/ru.js +0 -34
- package/dist/translations/languages/ru.js.map +0 -1
- package/dist/translations/languages/sk.d.ts +0 -31
- package/dist/translations/languages/sk.d.ts.map +0 -1
- package/dist/translations/languages/sk.js +0 -34
- package/dist/translations/languages/sk.js.map +0 -1
- package/dist/translations/languages/sl.d.ts +0 -31
- package/dist/translations/languages/sl.d.ts.map +0 -1
- package/dist/translations/languages/sl.js +0 -34
- package/dist/translations/languages/sl.js.map +0 -1
- package/dist/translations/languages/sv.d.ts +0 -31
- package/dist/translations/languages/sv.d.ts.map +0 -1
- package/dist/translations/languages/sv.js +0 -34
- package/dist/translations/languages/sv.js.map +0 -1
- package/dist/translations/languages/ta.d.ts +0 -31
- package/dist/translations/languages/ta.d.ts.map +0 -1
- package/dist/translations/languages/ta.js +0 -34
- package/dist/translations/languages/ta.js.map +0 -1
- package/dist/translations/languages/th.d.ts +0 -31
- package/dist/translations/languages/th.d.ts.map +0 -1
- package/dist/translations/languages/th.js +0 -34
- package/dist/translations/languages/th.js.map +0 -1
- package/dist/translations/languages/tr.d.ts +0 -31
- package/dist/translations/languages/tr.d.ts.map +0 -1
- package/dist/translations/languages/tr.js +0 -34
- package/dist/translations/languages/tr.js.map +0 -1
- package/dist/translations/languages/uk.d.ts +0 -31
- package/dist/translations/languages/uk.d.ts.map +0 -1
- package/dist/translations/languages/uk.js +0 -34
- package/dist/translations/languages/uk.js.map +0 -1
- package/dist/translations/languages/vi.d.ts +0 -31
- package/dist/translations/languages/vi.d.ts.map +0 -1
- package/dist/translations/languages/vi.js +0 -34
- package/dist/translations/languages/vi.js.map +0 -1
- package/dist/translations/languages/zh.d.ts +0 -31
- package/dist/translations/languages/zh.d.ts.map +0 -1
- package/dist/translations/languages/zh.js +0 -34
- package/dist/translations/languages/zh.js.map +0 -1
- package/dist/translations/languages/zhTw.d.ts +0 -31
- package/dist/translations/languages/zhTw.d.ts.map +0 -1
- package/dist/translations/languages/zhTw.js +0 -34
- package/dist/translations/languages/zhTw.js.map +0 -1
- package/dist/translations/types.d.ts +0 -32
- package/dist/translations/types.d.ts.map +0 -1
- package/dist/translations/types.js +0 -3
- package/dist/translations/types.js.map +0 -1
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/src/@types/assets.d.ts +0 -3
- package/src/collection/getAccessField.ts +0 -84
- package/src/collection/index.ts +0 -105
- package/src/components/APIKeyField/index.client.tsx +0 -73
- package/src/components/APIKeyField/index.css +0 -105
- package/src/components/APIKeysEmptyState/index.client.tsx +0 -36
- package/src/components/AccessField/index.client.tsx +0 -299
- package/src/components/AccessField/index.css +0 -99
- package/src/components/SettingsMenu/index.client.tsx +0 -34
- package/src/translations/index.ts +0 -108
- package/src/translations/languages/ar.ts +0 -35
- package/src/translations/languages/az.ts +0 -35
- package/src/translations/languages/bg.ts +0 -35
- package/src/translations/languages/bnBd.ts +0 -35
- package/src/translations/languages/bnIn.ts +0 -35
- package/src/translations/languages/ca.ts +0 -35
- package/src/translations/languages/cs.ts +0 -35
- package/src/translations/languages/da.ts +0 -35
- package/src/translations/languages/de.ts +0 -35
- package/src/translations/languages/en.ts +0 -35
- package/src/translations/languages/es.ts +0 -35
- package/src/translations/languages/et.ts +0 -35
- package/src/translations/languages/fa.ts +0 -35
- package/src/translations/languages/fr.ts +0 -35
- package/src/translations/languages/he.ts +0 -35
- package/src/translations/languages/hr.ts +0 -35
- package/src/translations/languages/hu.ts +0 -35
- package/src/translations/languages/hy.ts +0 -35
- package/src/translations/languages/id.ts +0 -35
- package/src/translations/languages/is.ts +0 -35
- package/src/translations/languages/it.ts +0 -35
- package/src/translations/languages/ja.ts +0 -35
- package/src/translations/languages/ko.ts +0 -35
- package/src/translations/languages/lt.ts +0 -35
- package/src/translations/languages/lv.ts +0 -35
- package/src/translations/languages/my.ts +0 -35
- package/src/translations/languages/nb.ts +0 -35
- package/src/translations/languages/nl.ts +0 -35
- package/src/translations/languages/pl.ts +0 -35
- package/src/translations/languages/pt.ts +0 -35
- package/src/translations/languages/ro.ts +0 -35
- package/src/translations/languages/rs.ts +0 -35
- package/src/translations/languages/rsLatin.ts +0 -35
- package/src/translations/languages/ru.ts +0 -35
- package/src/translations/languages/sk.ts +0 -35
- package/src/translations/languages/sl.ts +0 -35
- package/src/translations/languages/sv.ts +0 -35
- package/src/translations/languages/ta.ts +0 -35
- package/src/translations/languages/th.ts +0 -35
- package/src/translations/languages/tr.ts +0 -35
- package/src/translations/languages/uk.ts +0 -35
- package/src/translations/languages/vi.ts +0 -35
- package/src/translations/languages/zh.ts +0 -35
- package/src/translations/languages/zhTw.ts +0 -35
- package/src/translations/types.ts +0 -34
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import type { SelectType } from 'payload'
|
|
1
|
+
import type { JoinQuery, PopulateType, SelectType } from 'payload'
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
6
|
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
7
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
8
8
|
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
9
9
|
|
|
10
10
|
const DEFAULT_DESCRIPTION =
|
|
11
11
|
'Find documents in any collection by passing the collection slug and optional ID or where clause.'
|
|
12
12
|
|
|
13
13
|
export const findDocumentsTool = defineCollectionTool({
|
|
14
|
+
access: (args) =>
|
|
15
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.read),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
title: 'Find Documents',
|
|
22
|
+
},
|
|
14
23
|
description: DEFAULT_DESCRIPTION,
|
|
15
24
|
input: z.object({
|
|
16
25
|
id: z
|
|
@@ -37,6 +46,10 @@ export const findDocumentsTool = defineCollectionTool({
|
|
|
37
46
|
.string()
|
|
38
47
|
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
39
48
|
.optional(),
|
|
49
|
+
joins: z
|
|
50
|
+
.union([z.record(z.string(), z.unknown()), z.literal(false)])
|
|
51
|
+
.describe('Optional: configure join field queries, or pass false to disable all join fields.')
|
|
52
|
+
.optional(),
|
|
40
53
|
limit: z
|
|
41
54
|
.number()
|
|
42
55
|
.int()
|
|
@@ -58,16 +71,30 @@ export const findDocumentsTool = defineCollectionTool({
|
|
|
58
71
|
.describe('Page number for pagination (default: 1)')
|
|
59
72
|
.optional()
|
|
60
73
|
.default(1),
|
|
74
|
+
pagination: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.describe('Optional: set to false to skip the count query overhead')
|
|
77
|
+
.optional(),
|
|
78
|
+
populate: z
|
|
79
|
+
.record(z.string(), z.unknown())
|
|
80
|
+
.describe(
|
|
81
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
82
|
+
)
|
|
83
|
+
.optional(),
|
|
61
84
|
select: z
|
|
62
|
-
.string()
|
|
85
|
+
.record(z.string(), z.unknown())
|
|
63
86
|
.describe(
|
|
64
|
-
|
|
87
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
65
88
|
)
|
|
66
89
|
.optional(),
|
|
67
90
|
sort: z
|
|
68
91
|
.string()
|
|
69
92
|
.describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)')
|
|
70
93
|
.optional(),
|
|
94
|
+
trash: z
|
|
95
|
+
.boolean()
|
|
96
|
+
.describe('Optional: include soft-deleted documents when trash is enabled on the collection')
|
|
97
|
+
.optional(),
|
|
71
98
|
where: whereSchema
|
|
72
99
|
.describe(
|
|
73
100
|
'Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
@@ -78,35 +105,43 @@ export const findDocumentsTool = defineCollectionTool({
|
|
|
78
105
|
const payload = req.payload
|
|
79
106
|
const logger = getLogger({ payload })
|
|
80
107
|
|
|
81
|
-
const {
|
|
108
|
+
const {
|
|
109
|
+
id,
|
|
110
|
+
depth,
|
|
111
|
+
draft,
|
|
112
|
+
fallbackLocale,
|
|
113
|
+
joins,
|
|
114
|
+
limit,
|
|
115
|
+
locale,
|
|
116
|
+
page,
|
|
117
|
+
pagination,
|
|
118
|
+
populate,
|
|
119
|
+
select,
|
|
120
|
+
sort,
|
|
121
|
+
trash,
|
|
122
|
+
where,
|
|
123
|
+
} = input
|
|
82
124
|
|
|
83
125
|
logger.info(
|
|
84
126
|
`Reading document from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,
|
|
85
127
|
)
|
|
86
128
|
|
|
87
129
|
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
130
|
if (id) {
|
|
99
131
|
try {
|
|
100
132
|
const doc = await payload.findByID({
|
|
101
133
|
id,
|
|
102
134
|
collection: collectionSlug,
|
|
103
135
|
depth,
|
|
136
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
104
137
|
req,
|
|
105
|
-
...
|
|
106
|
-
...(
|
|
138
|
+
...(select && { select: select as SelectType }),
|
|
139
|
+
...(populate && { populate: populate as PopulateType }),
|
|
140
|
+
...(joins !== undefined && { joins: joins as JoinQuery }),
|
|
107
141
|
...(locale && { locale }),
|
|
108
142
|
...(fallbackLocale && { fallbackLocale }),
|
|
109
143
|
...(draft !== undefined && { draft }),
|
|
144
|
+
...(trash !== undefined && { trash }),
|
|
110
145
|
})
|
|
111
146
|
|
|
112
147
|
return {
|
|
@@ -135,13 +170,17 @@ export const findDocumentsTool = defineCollectionTool({
|
|
|
135
170
|
collection: collectionSlug,
|
|
136
171
|
depth,
|
|
137
172
|
limit,
|
|
173
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
138
174
|
page,
|
|
139
175
|
req,
|
|
140
|
-
...
|
|
141
|
-
...(
|
|
176
|
+
...(select && { select: select as SelectType }),
|
|
177
|
+
...(populate && { populate: populate as PopulateType }),
|
|
178
|
+
...(joins !== undefined && { joins: joins as JoinQuery }),
|
|
142
179
|
...(locale && { locale }),
|
|
143
180
|
...(fallbackLocale && { fallbackLocale }),
|
|
144
181
|
...(draft !== undefined && { draft }),
|
|
182
|
+
...(pagination !== undefined && { pagination }),
|
|
183
|
+
...(trash !== undefined && { trash }),
|
|
145
184
|
}
|
|
146
185
|
|
|
147
186
|
if (sort) {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
6
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
7
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
8
|
+
|
|
9
|
+
const DEFAULT_DESCRIPTION =
|
|
10
|
+
'Find a specific document version in any version-enabled collection by passing the collection slug and version ID.'
|
|
11
|
+
|
|
12
|
+
export const findVersionByIDTool = defineCollectionTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) &&
|
|
15
|
+
Boolean(args.permissions?.collections?.[args.collectionSlug]?.readVersions),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
title: 'Find Version By ID',
|
|
22
|
+
},
|
|
23
|
+
description: DEFAULT_DESCRIPTION,
|
|
24
|
+
input: z.object({
|
|
25
|
+
id: z.string().describe('The ID of the version to retrieve'),
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(0)
|
|
30
|
+
.max(10)
|
|
31
|
+
.describe('How many levels deep to populate relationships in the version document')
|
|
32
|
+
.optional()
|
|
33
|
+
.default(0),
|
|
34
|
+
fallbackLocale: z
|
|
35
|
+
.string()
|
|
36
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
37
|
+
.optional(),
|
|
38
|
+
locale: z
|
|
39
|
+
.string()
|
|
40
|
+
.describe(
|
|
41
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
42
|
+
)
|
|
43
|
+
.optional(),
|
|
44
|
+
populate: z
|
|
45
|
+
.record(z.string(), z.unknown())
|
|
46
|
+
.describe(
|
|
47
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
48
|
+
)
|
|
49
|
+
.optional(),
|
|
50
|
+
select: z
|
|
51
|
+
.record(z.string(), z.unknown())
|
|
52
|
+
.describe(
|
|
53
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.title": true}',
|
|
54
|
+
)
|
|
55
|
+
.optional(),
|
|
56
|
+
showHiddenFields: z
|
|
57
|
+
.boolean()
|
|
58
|
+
.describe('Optional: include hidden fields in the returned version document')
|
|
59
|
+
.optional(),
|
|
60
|
+
trash: z
|
|
61
|
+
.boolean()
|
|
62
|
+
.describe('Optional: include soft-deleted version documents when trash is enabled')
|
|
63
|
+
.optional(),
|
|
64
|
+
}),
|
|
65
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
66
|
+
const payload = req.payload
|
|
67
|
+
const logger = getLogger({ payload })
|
|
68
|
+
const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields, trash } = input
|
|
69
|
+
|
|
70
|
+
logger.info(`Finding version in collection: ${collectionSlug} with ID: ${id}`)
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const result = await payload.findVersionByID({
|
|
74
|
+
id,
|
|
75
|
+
collection: collectionSlug,
|
|
76
|
+
depth,
|
|
77
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
78
|
+
req,
|
|
79
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
80
|
+
...(locale ? { locale } : {}),
|
|
81
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
82
|
+
...(select ? { select: select as SelectType } : {}),
|
|
83
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
84
|
+
...(trash !== undefined ? { trash } : {}),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `Version "${id}" from collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
doc: result as unknown as Record<string, unknown>,
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
98
|
+
logger.error(`Error finding version ${id} in ${collectionSlug}: ${errorMessage}`)
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: `❌ **Error finding version "${id}" in collection "${collectionSlug}":** ${errorMessage}`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
isError: true,
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
6
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
7
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
8
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DESCRIPTION =
|
|
11
|
+
'Find document versions in any version-enabled collection by passing the collection slug and optional where clause.'
|
|
12
|
+
|
|
13
|
+
export const findVersionsTool = defineCollectionTool({
|
|
14
|
+
access: (args) =>
|
|
15
|
+
defaultAccess(args) &&
|
|
16
|
+
Boolean(args.permissions?.collections?.[args.collectionSlug]?.readVersions),
|
|
17
|
+
annotations: {
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: true,
|
|
20
|
+
openWorldHint: false,
|
|
21
|
+
readOnlyHint: true,
|
|
22
|
+
title: 'Find Versions',
|
|
23
|
+
},
|
|
24
|
+
description: DEFAULT_DESCRIPTION,
|
|
25
|
+
input: z.object({
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(0)
|
|
30
|
+
.max(10)
|
|
31
|
+
.describe('How many levels deep to populate relationships in version documents')
|
|
32
|
+
.optional()
|
|
33
|
+
.default(0),
|
|
34
|
+
fallbackLocale: z
|
|
35
|
+
.string()
|
|
36
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
37
|
+
.optional(),
|
|
38
|
+
limit: z
|
|
39
|
+
.number()
|
|
40
|
+
.int()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(100)
|
|
43
|
+
.describe('Maximum number of versions to return (default: 10, max: 100)')
|
|
44
|
+
.optional()
|
|
45
|
+
.default(10),
|
|
46
|
+
locale: z
|
|
47
|
+
.string()
|
|
48
|
+
.describe(
|
|
49
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
50
|
+
)
|
|
51
|
+
.optional(),
|
|
52
|
+
page: z
|
|
53
|
+
.number()
|
|
54
|
+
.int()
|
|
55
|
+
.min(1)
|
|
56
|
+
.describe('Page number for pagination (default: 1)')
|
|
57
|
+
.optional()
|
|
58
|
+
.default(1),
|
|
59
|
+
pagination: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.describe('Optional: set to false to skip the count query overhead')
|
|
62
|
+
.optional(),
|
|
63
|
+
populate: z
|
|
64
|
+
.record(z.string(), z.unknown())
|
|
65
|
+
.describe(
|
|
66
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
67
|
+
)
|
|
68
|
+
.optional(),
|
|
69
|
+
select: z
|
|
70
|
+
.record(z.string(), z.unknown())
|
|
71
|
+
.describe(
|
|
72
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.title": true}',
|
|
73
|
+
)
|
|
74
|
+
.optional(),
|
|
75
|
+
showHiddenFields: z
|
|
76
|
+
.boolean()
|
|
77
|
+
.describe('Optional: include hidden fields in returned version documents')
|
|
78
|
+
.optional(),
|
|
79
|
+
sort: z
|
|
80
|
+
.string()
|
|
81
|
+
.describe('Field to sort by (e.g., "-updatedAt", "-version.updatedAt" for descending)')
|
|
82
|
+
.optional(),
|
|
83
|
+
trash: z
|
|
84
|
+
.boolean()
|
|
85
|
+
.describe('Optional: include versions for soft-deleted documents when trash is enabled')
|
|
86
|
+
.optional(),
|
|
87
|
+
where: whereSchema
|
|
88
|
+
.describe(
|
|
89
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.title":{"contains":"test"}}',
|
|
90
|
+
)
|
|
91
|
+
.optional(),
|
|
92
|
+
}),
|
|
93
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
94
|
+
const payload = req.payload
|
|
95
|
+
const logger = getLogger({ payload })
|
|
96
|
+
const {
|
|
97
|
+
depth,
|
|
98
|
+
fallbackLocale,
|
|
99
|
+
limit,
|
|
100
|
+
locale,
|
|
101
|
+
page,
|
|
102
|
+
pagination,
|
|
103
|
+
populate,
|
|
104
|
+
select,
|
|
105
|
+
showHiddenFields,
|
|
106
|
+
sort,
|
|
107
|
+
trash,
|
|
108
|
+
where,
|
|
109
|
+
} = input
|
|
110
|
+
|
|
111
|
+
logger.info(`Finding versions in collection: ${collectionSlug}, limit: ${limit}, page: ${page}`)
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const result = await payload.findVersions({
|
|
115
|
+
collection: collectionSlug,
|
|
116
|
+
depth,
|
|
117
|
+
limit,
|
|
118
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
119
|
+
page,
|
|
120
|
+
req,
|
|
121
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
122
|
+
...(locale ? { locale } : {}),
|
|
123
|
+
...(pagination !== undefined ? { pagination } : {}),
|
|
124
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
125
|
+
...(select ? { select: select as SelectType } : {}),
|
|
126
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
127
|
+
...(sort ? { sort } : {}),
|
|
128
|
+
...(trash !== undefined ? { trash } : {}),
|
|
129
|
+
...(where ? { where } : {}),
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: 'text',
|
|
136
|
+
text: `Versions for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
doc: result as unknown as Record<string, unknown>,
|
|
140
|
+
}
|
|
141
|
+
} catch (error) {
|
|
142
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
143
|
+
logger.error(`Error finding versions in ${collectionSlug}: ${errorMessage}`)
|
|
144
|
+
return {
|
|
145
|
+
content: [
|
|
146
|
+
{
|
|
147
|
+
type: 'text',
|
|
148
|
+
text: `❌ **Error finding versions in collection "${collectionSlug}":** ${errorMessage}`,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
isError: true,
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
})
|
|
@@ -1,10 +1,45 @@
|
|
|
1
|
+
import { getAccessResults } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
1
4
|
import { defineCollectionTool } from '../../../defineTool.js'
|
|
2
5
|
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
3
6
|
|
|
4
7
|
export const getCollectionSchemaTool = defineCollectionTool({
|
|
8
|
+
access: (args) => {
|
|
9
|
+
const permissions = args.permissions?.collections?.[args.collectionSlug]
|
|
10
|
+
|
|
11
|
+
return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)
|
|
12
|
+
},
|
|
13
|
+
annotations: {
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
idempotentHint: true,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
title: 'Get Collection Schema',
|
|
19
|
+
},
|
|
5
20
|
description: 'Get the input schema for creating or updating documents in a collection.',
|
|
6
|
-
}).handler(({ collectionSlug, req }) => {
|
|
7
|
-
const
|
|
21
|
+
}).handler(async ({ authorizedMCP, collectionSlug, req }) => {
|
|
22
|
+
const permissions = authorizedMCP.overrideAccess
|
|
23
|
+
? null
|
|
24
|
+
: (await getAccessResults({ req })).collections?.[collectionSlug]
|
|
25
|
+
|
|
26
|
+
if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: `Error: MCP access to "getCollectionSchema" is not enabled for collection "${collectionSlug}"`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
isError: true,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const inputSchema = getCollectionInputSchema({
|
|
39
|
+
collectionSlug,
|
|
40
|
+
req,
|
|
41
|
+
...(permissions ? { permissions } : {}),
|
|
42
|
+
})
|
|
8
43
|
|
|
9
44
|
if (!inputSchema) {
|
|
10
45
|
return {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
6
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
7
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
8
|
+
|
|
9
|
+
const DEFAULT_DESCRIPTION =
|
|
10
|
+
'Restore a document from a previous version in any version-enabled collection.'
|
|
11
|
+
|
|
12
|
+
export const restoreVersionTool = defineCollectionTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: true,
|
|
17
|
+
idempotentHint: false,
|
|
18
|
+
openWorldHint: false,
|
|
19
|
+
readOnlyHint: false,
|
|
20
|
+
title: 'Restore Version',
|
|
21
|
+
},
|
|
22
|
+
description: DEFAULT_DESCRIPTION,
|
|
23
|
+
input: z.object({
|
|
24
|
+
id: z.string().describe('The ID of the version to restore'),
|
|
25
|
+
depth: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.min(0)
|
|
29
|
+
.max(10)
|
|
30
|
+
.describe('How many levels deep to populate relationships in response')
|
|
31
|
+
.optional()
|
|
32
|
+
.default(0),
|
|
33
|
+
draft: z
|
|
34
|
+
.boolean()
|
|
35
|
+
.describe('Whether to restore the version as a draft')
|
|
36
|
+
.optional()
|
|
37
|
+
.default(false),
|
|
38
|
+
fallbackLocale: z
|
|
39
|
+
.string()
|
|
40
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
41
|
+
.optional(),
|
|
42
|
+
locale: z
|
|
43
|
+
.string()
|
|
44
|
+
.describe('Optional: locale code to restore in (e.g., "en", "es")')
|
|
45
|
+
.optional(),
|
|
46
|
+
populate: z
|
|
47
|
+
.record(z.string(), z.unknown())
|
|
48
|
+
.describe(
|
|
49
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
50
|
+
)
|
|
51
|
+
.optional(),
|
|
52
|
+
select: z
|
|
53
|
+
.record(z.string(), z.unknown())
|
|
54
|
+
.describe(
|
|
55
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
56
|
+
)
|
|
57
|
+
.optional(),
|
|
58
|
+
showHiddenFields: z
|
|
59
|
+
.boolean()
|
|
60
|
+
.describe('Optional: include hidden fields in the restored document response')
|
|
61
|
+
.optional(),
|
|
62
|
+
}),
|
|
63
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
64
|
+
const payload = req.payload
|
|
65
|
+
const logger = getLogger({ payload })
|
|
66
|
+
const { id, depth, draft, fallbackLocale, locale, populate, select, showHiddenFields } = input
|
|
67
|
+
|
|
68
|
+
logger.info(`Restoring version in collection: ${collectionSlug} with ID: ${id}`)
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const result = await payload.restoreVersion({
|
|
72
|
+
id,
|
|
73
|
+
collection: collectionSlug,
|
|
74
|
+
depth,
|
|
75
|
+
draft,
|
|
76
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
77
|
+
req,
|
|
78
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
79
|
+
...(locale ? { locale } : {}),
|
|
80
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
81
|
+
...(select ? { select: select as SelectType } : {}),
|
|
82
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'text',
|
|
89
|
+
text: `Version "${id}" restored successfully in collection "${collectionSlug}"!\nRestored document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
doc: result as Record<string, unknown>,
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
96
|
+
logger.error(`Error restoring version ${id} in ${collectionSlug}: ${errorMessage}`)
|
|
97
|
+
return {
|
|
98
|
+
content: [
|
|
99
|
+
{
|
|
100
|
+
type: 'text',
|
|
101
|
+
text: `❌ **Error restoring version "${id}" in collection "${collectionSlug}":** ${errorMessage}`,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
isError: true,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
})
|
|
@@ -2,13 +2,13 @@ import type { SelectType, Where } from 'payload'
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
6
|
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
7
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
8
|
import {
|
|
8
9
|
getCollectionVirtualFieldNames,
|
|
9
10
|
stripVirtualFields,
|
|
10
11
|
} from '../../../utils/getVirtualFieldNames.js'
|
|
11
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
12
12
|
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
13
13
|
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
14
14
|
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
@@ -19,6 +19,15 @@ const DEFAULT_DESCRIPTION =
|
|
|
19
19
|
'Update documents in any collection by passing the collection slug and data.'
|
|
20
20
|
|
|
21
21
|
export const updateDocumentTool = defineCollectionTool({
|
|
22
|
+
access: (args) =>
|
|
23
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
24
|
+
annotations: {
|
|
25
|
+
destructiveHint: true,
|
|
26
|
+
idempotentHint: false,
|
|
27
|
+
openWorldHint: false,
|
|
28
|
+
readOnlyHint: false,
|
|
29
|
+
title: 'Update Document',
|
|
30
|
+
},
|
|
22
31
|
description: DEFAULT_DESCRIPTION,
|
|
23
32
|
input: z.object({
|
|
24
33
|
id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),
|
|
@@ -55,9 +64,9 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
55
64
|
.optional()
|
|
56
65
|
.default(false),
|
|
57
66
|
select: z
|
|
58
|
-
.string()
|
|
67
|
+
.record(z.string(), z.unknown())
|
|
59
68
|
.describe(
|
|
60
|
-
|
|
69
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
61
70
|
)
|
|
62
71
|
.optional(),
|
|
63
72
|
where: whereSchema
|
|
@@ -112,16 +121,6 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
112
121
|
|
|
113
122
|
const whereClause: Where = where ?? {}
|
|
114
123
|
|
|
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
124
|
if (id) {
|
|
126
125
|
const result = await payload.update({
|
|
127
126
|
id,
|
|
@@ -129,14 +128,14 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
129
128
|
data: parsedData,
|
|
130
129
|
depth,
|
|
131
130
|
draft,
|
|
131
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
132
132
|
overrideLock,
|
|
133
133
|
req,
|
|
134
|
-
...localAPIDefaults(authorizedMCP),
|
|
135
134
|
...(filePath ? { filePath } : {}),
|
|
136
135
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
137
136
|
...(locale ? { locale } : {}),
|
|
138
137
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
139
|
-
...(
|
|
138
|
+
...(select ? { select: select as SelectType } : {}),
|
|
140
139
|
})
|
|
141
140
|
|
|
142
141
|
return {
|
|
@@ -155,15 +154,15 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
155
154
|
data: parsedData,
|
|
156
155
|
depth,
|
|
157
156
|
draft,
|
|
157
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
158
158
|
overrideLock,
|
|
159
159
|
req,
|
|
160
160
|
where: whereClause,
|
|
161
|
-
...localAPIDefaults(authorizedMCP),
|
|
162
161
|
...(filePath ? { filePath } : {}),
|
|
163
162
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
164
163
|
...(locale ? { locale } : {}),
|
|
165
164
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
166
|
-
...(
|
|
165
|
+
...(select ? { select: select as SelectType } : {}),
|
|
167
166
|
})
|
|
168
167
|
|
|
169
168
|
const docs = result.docs || []
|