@payloadcms/plugin-mcp 4.0.0-canary.3 → 4.0.0-canary.31
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/bin.js +7 -0
- 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/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- 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 -56
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +5 -5
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +67 -33
- 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 +79 -56
- 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 +63 -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 +60 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +105 -53
- 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 +46 -44
- 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 +90 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +123 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +86 -0
- package/dist/mcp/builtin/collections/fileInput.spec.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 +77 -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 +30 -47
- 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 +74 -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 +84 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +54 -9
- 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 +69 -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 +68 -86
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
- package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
- package/dist/mcp/builtin/formatEntityError.js +55 -0
- package/dist/mcp/builtin/formatEntityError.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +23 -10
- 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 +60 -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 +13 -17
- 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 +68 -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 +78 -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 +31 -8
- 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 +70 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +29 -36
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +73 -2
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +73 -3
- 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 +48 -17
- 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 +84 -46
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +95 -89
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.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/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +10 -18
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +79 -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 -62
- package/src/mcp/buildMcpServer.ts +85 -50
- package/src/mcp/builtin/collections/authTools.ts +77 -69
- package/src/mcp/builtin/collections/countTool.ts +61 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/collections/createTool.ts +112 -76
- package/src/mcp/builtin/collections/deleteTool.ts +38 -64
- package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +169 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
- package/src/mcp/builtin/collections/findTool.ts +27 -107
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +51 -6
- package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
- package/src/mcp/builtin/collections/updateTool.ts +65 -100
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/formatEntityError.ts +77 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +22 -5
- package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/globals/findTool.ts +15 -51
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +34 -6
- package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
- package/src/mcp/builtin/globals/updateTool.ts +40 -60
- package/src/mcp/builtinTools.ts +72 -6
- package/src/mcp/sanitizeMCPConfig.ts +36 -19
- package/src/stdio.ts +79 -46
- package/src/types.ts +103 -93
- package/src/utils/getPluginConfig.ts +1 -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 -24
- package/dist/components/SettingsMenu/index.client.js.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
- package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
- package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
- package/dist/mcp/builtin/validateEntityData.js +0 -82
- package/dist/mcp/builtin/validateEntityData.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/getVirtualFieldNames.d.ts +0 -14
- package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
- package/dist/utils/getVirtualFieldNames.js +0 -35
- package/dist/utils/getVirtualFieldNames.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/getEntityInputSchema.d.ts +0 -11
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
- package/dist/utils/schemaConversion/getEntityInputSchema.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/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
- package/dist/utils/transformPointDataToPayload.d.ts +0 -7
- package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
- package/dist/utils/transformPointDataToPayload.js +0 -28
- package/dist/utils/transformPointDataToPayload.js.map +0 -1
- package/dist/utils/whereSchema.d.ts +0 -9
- package/dist/utils/whereSchema.d.ts.map +0 -1
- package/dist/utils/whereSchema.js +0 -13
- package/dist/utils/whereSchema.js.map +0 -1
- package/src/collection/getAccessField.ts +0 -84
- package/src/collection/index.ts +0 -105
- package/src/components/APIKeyField/index.client.tsx +0 -68
- package/src/components/APIKeyField/index.css +0 -105
- package/src/components/APIKeysEmptyState/index.client.tsx +0 -33
- package/src/components/AccessField/index.client.tsx +0 -296
- package/src/components/AccessField/index.css +0 -99
- package/src/components/SettingsMenu/index.client.tsx +0 -30
- package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
- package/src/mcp/builtin/validateEntityData.ts +0 -132
- package/src/translations/index.ts +0 -105
- package/src/translations/languages/ar.ts +0 -38
- package/src/translations/languages/az.ts +0 -38
- package/src/translations/languages/bg.ts +0 -39
- package/src/translations/languages/bnBd.ts +0 -39
- package/src/translations/languages/bnIn.ts +0 -39
- package/src/translations/languages/ca.ts +0 -39
- package/src/translations/languages/cs.ts +0 -39
- package/src/translations/languages/da.ts +0 -38
- package/src/translations/languages/de.ts +0 -39
- package/src/translations/languages/en.ts +0 -39
- package/src/translations/languages/es.ts +0 -39
- package/src/translations/languages/et.ts +0 -38
- package/src/translations/languages/fa.ts +0 -39
- package/src/translations/languages/fr.ts +0 -39
- package/src/translations/languages/he.ts +0 -37
- package/src/translations/languages/hr.ts +0 -39
- package/src/translations/languages/hu.ts +0 -39
- package/src/translations/languages/hy.ts +0 -39
- package/src/translations/languages/id.ts +0 -39
- package/src/translations/languages/is.ts +0 -39
- package/src/translations/languages/it.ts +0 -39
- package/src/translations/languages/ja.ts +0 -39
- package/src/translations/languages/ko.ts +0 -39
- package/src/translations/languages/lt.ts +0 -39
- package/src/translations/languages/lv.ts +0 -38
- package/src/translations/languages/my.ts +0 -39
- package/src/translations/languages/nb.ts +0 -39
- package/src/translations/languages/nl.ts +0 -39
- package/src/translations/languages/pl.ts +0 -38
- package/src/translations/languages/pt.ts +0 -39
- package/src/translations/languages/ro.ts +0 -39
- package/src/translations/languages/rs.ts +0 -38
- package/src/translations/languages/rsLatin.ts +0 -38
- package/src/translations/languages/ru.ts +0 -39
- package/src/translations/languages/sk.ts +0 -39
- package/src/translations/languages/sl.ts +0 -38
- package/src/translations/languages/sv.ts +0 -39
- package/src/translations/languages/ta.ts +0 -39
- package/src/translations/languages/th.ts +0 -38
- package/src/translations/languages/tr.ts +0 -38
- package/src/translations/languages/uk.ts +0 -39
- package/src/translations/languages/vi.ts +0 -39
- package/src/translations/languages/zh.ts +0 -36
- package/src/translations/languages/zhTw.ts +0 -36
- package/src/translations/types.ts +0 -34
- package/src/utils/getVirtualFieldNames.ts +0 -53
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
- package/src/utils/transformPointDataToPayload.ts +0 -40
- package/src/utils/whereSchema.ts +0 -24
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Where } from 'payload'
|
|
2
2
|
|
|
3
|
-
import { z } from 'zod'
|
|
4
|
-
|
|
5
|
-
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
-
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
3
|
import {
|
|
4
|
+
getCollectionInputSchema,
|
|
8
5
|
getCollectionVirtualFieldNames,
|
|
6
|
+
parseDocumentID,
|
|
9
7
|
stripVirtualFields,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
8
|
+
transformPointDataToPayload,
|
|
9
|
+
updateDocumentInputSchema,
|
|
10
|
+
validateCollectionData,
|
|
11
|
+
} from 'payload'
|
|
12
|
+
|
|
13
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
14
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
15
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
16
|
+
import { formatEntityError } from '../formatEntityError.js'
|
|
17
|
+
import { fileInputSchema, resolveFile } from './fileInput.js'
|
|
17
18
|
|
|
18
19
|
const DEFAULT_DESCRIPTION =
|
|
19
|
-
'Update documents
|
|
20
|
+
'Update documents. Prefer uploadReference after upload, externalURL for URLs, or base64 for small local files.'
|
|
20
21
|
|
|
21
22
|
export const updateDocumentTool = defineCollectionTool({
|
|
23
|
+
access: (args) =>
|
|
24
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.update),
|
|
22
25
|
annotations: {
|
|
23
26
|
destructiveHint: true,
|
|
24
27
|
idempotentHint: false,
|
|
@@ -27,53 +30,8 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
27
30
|
title: 'Update Document',
|
|
28
31
|
},
|
|
29
32
|
description: DEFAULT_DESCRIPTION,
|
|
30
|
-
input:
|
|
31
|
-
|
|
32
|
-
data: z.record(z.string(), z.unknown()).describe('The fields to update'),
|
|
33
|
-
depth: z
|
|
34
|
-
.number()
|
|
35
|
-
.describe('How many levels deep to populate relationships')
|
|
36
|
-
.optional()
|
|
37
|
-
.default(0),
|
|
38
|
-
draft: z
|
|
39
|
-
.boolean()
|
|
40
|
-
.describe('Whether to update the document as a draft')
|
|
41
|
-
.optional()
|
|
42
|
-
.default(false),
|
|
43
|
-
fallbackLocale: z
|
|
44
|
-
.string()
|
|
45
|
-
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
46
|
-
.optional(),
|
|
47
|
-
filePath: z.string().describe('File path for file uploads').optional(),
|
|
48
|
-
locale: z
|
|
49
|
-
.string()
|
|
50
|
-
.describe(
|
|
51
|
-
'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
|
|
52
|
-
)
|
|
53
|
-
.optional(),
|
|
54
|
-
overrideLock: z
|
|
55
|
-
.boolean()
|
|
56
|
-
.describe('Whether to override document locks')
|
|
57
|
-
.optional()
|
|
58
|
-
.default(true),
|
|
59
|
-
overwriteExistingFiles: z
|
|
60
|
-
.boolean()
|
|
61
|
-
.describe('Whether to overwrite existing files')
|
|
62
|
-
.optional()
|
|
63
|
-
.default(false),
|
|
64
|
-
select: z
|
|
65
|
-
.record(z.string(), z.unknown())
|
|
66
|
-
.describe(
|
|
67
|
-
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
68
|
-
)
|
|
69
|
-
.optional(),
|
|
70
|
-
where: whereSchema
|
|
71
|
-
.describe(
|
|
72
|
-
'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
73
|
-
)
|
|
74
|
-
.optional(),
|
|
75
|
-
}),
|
|
76
|
-
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
33
|
+
input: updateDocumentInputSchema({ file: fileInputSchema }),
|
|
34
|
+
}).handler(async ({ slug, authorizedMCP, input, req }) => {
|
|
77
35
|
const payload = req.payload
|
|
78
36
|
const logger = getLogger({ payload })
|
|
79
37
|
|
|
@@ -83,97 +41,104 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
83
41
|
depth,
|
|
84
42
|
draft,
|
|
85
43
|
fallbackLocale,
|
|
86
|
-
|
|
44
|
+
file: fileInput,
|
|
45
|
+
limit,
|
|
87
46
|
locale,
|
|
88
47
|
overrideLock,
|
|
89
|
-
|
|
48
|
+
populate,
|
|
49
|
+
publishAllLocales,
|
|
50
|
+
returning,
|
|
90
51
|
select,
|
|
52
|
+
sort,
|
|
53
|
+
trash,
|
|
54
|
+
unpublishAllLocales,
|
|
91
55
|
where,
|
|
92
56
|
} = input
|
|
93
57
|
|
|
94
58
|
logger.info(
|
|
95
|
-
`Updating document in collection: ${
|
|
59
|
+
`Updating document in collection: ${slug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,
|
|
96
60
|
)
|
|
97
61
|
|
|
98
62
|
try {
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
|
|
63
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, slug)
|
|
106
64
|
const inputData = stripVirtualFields(data, virtualFieldNames)
|
|
107
|
-
|
|
108
|
-
|
|
65
|
+
validateCollectionData({
|
|
66
|
+
slug,
|
|
109
67
|
data: inputData,
|
|
110
68
|
partial: true,
|
|
111
69
|
req,
|
|
112
70
|
})
|
|
113
71
|
|
|
114
|
-
if (validationError) {
|
|
115
|
-
return validationError
|
|
116
|
-
}
|
|
117
|
-
|
|
118
72
|
const parsedData = transformPointDataToPayload(inputData)
|
|
73
|
+
const file = await resolveFile({ slug, input: fileInput, req })
|
|
119
74
|
|
|
120
75
|
const whereClause: Where = where ?? {}
|
|
121
76
|
|
|
122
|
-
if (id) {
|
|
77
|
+
if (id !== undefined) {
|
|
123
78
|
const result = await payload.update({
|
|
124
|
-
id,
|
|
125
|
-
collection:
|
|
79
|
+
id: parseDocumentID({ id, collectionSlug: slug, payload }),
|
|
80
|
+
collection: slug,
|
|
126
81
|
data: parsedData,
|
|
127
82
|
depth,
|
|
128
83
|
draft,
|
|
84
|
+
fallbackLocale,
|
|
85
|
+
locale,
|
|
86
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
129
87
|
overrideLock,
|
|
88
|
+
populate,
|
|
89
|
+
publishAllLocales,
|
|
130
90
|
req,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
...(
|
|
135
|
-
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
136
|
-
...(select ? { select: select as SelectType } : {}),
|
|
91
|
+
select: returning ? select : { id: true },
|
|
92
|
+
trash,
|
|
93
|
+
unpublishAllLocales,
|
|
94
|
+
...(file ? { file } : {}),
|
|
137
95
|
})
|
|
138
96
|
|
|
97
|
+
const responseResult = returning ? result : { id: result.id }
|
|
98
|
+
|
|
139
99
|
return {
|
|
140
100
|
content: [
|
|
141
101
|
{
|
|
142
102
|
type: 'text',
|
|
143
|
-
text: `Document updated successfully in collection "${
|
|
103
|
+
text: `Document updated successfully in collection "${slug}"!\nResult:\n\`\`\`json\n${JSON.stringify(responseResult)}\n\`\`\``,
|
|
144
104
|
},
|
|
145
105
|
],
|
|
146
|
-
doc:
|
|
106
|
+
doc: responseResult as Record<string, unknown>,
|
|
147
107
|
}
|
|
148
108
|
}
|
|
149
109
|
|
|
150
110
|
const result = await payload.update({
|
|
151
|
-
collection:
|
|
111
|
+
collection: slug,
|
|
152
112
|
data: parsedData,
|
|
153
113
|
depth,
|
|
154
114
|
draft,
|
|
115
|
+
fallbackLocale,
|
|
116
|
+
limit,
|
|
117
|
+
locale,
|
|
118
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
155
119
|
overrideLock,
|
|
120
|
+
populate,
|
|
121
|
+
publishAllLocales,
|
|
156
122
|
req,
|
|
123
|
+
select: returning ? select : { id: true },
|
|
124
|
+
sort,
|
|
125
|
+
trash,
|
|
126
|
+
unpublishAllLocales,
|
|
157
127
|
where: whereClause,
|
|
158
|
-
...
|
|
159
|
-
...(filePath ? { filePath } : {}),
|
|
160
|
-
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
161
|
-
...(locale ? { locale } : {}),
|
|
162
|
-
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
163
|
-
...(select ? { select: select as SelectType } : {}),
|
|
128
|
+
...(file ? { file } : {}),
|
|
164
129
|
})
|
|
165
130
|
|
|
166
|
-
const docs = result.docs
|
|
131
|
+
const docs = returning ? result.docs : result.docs.map(({ id }) => ({ id }))
|
|
167
132
|
const errors = result.errors || []
|
|
168
133
|
|
|
169
|
-
let responseText = `Multiple documents updated in collection "${
|
|
134
|
+
let responseText = `Multiple documents updated in collection "${slug}"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`
|
|
170
135
|
if (docs.length > 0) {
|
|
171
136
|
responseText += `\n\nUpdated documents:\n\`\`\`json\n${JSON.stringify(docs)}\n\`\`\``
|
|
172
137
|
}
|
|
173
138
|
if (errors.length > 0) {
|
|
174
139
|
responseText += `\n\nErrors:\n\`\`\`json\n${JSON.stringify(errors)}\n\`\`\``
|
|
175
140
|
|
|
176
|
-
const errorSchema = getCollectionInputSchema({ collectionSlug, req })
|
|
141
|
+
const errorSchema = getCollectionInputSchema({ collectionSlug: slug, req })
|
|
177
142
|
|
|
178
143
|
if (errorSchema) {
|
|
179
144
|
responseText += `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(errorSchema)}\n\`\`\``
|
|
@@ -186,7 +151,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
186
151
|
...(errorSchema
|
|
187
152
|
? {
|
|
188
153
|
structuredContent: {
|
|
189
|
-
|
|
154
|
+
slug,
|
|
190
155
|
docs,
|
|
191
156
|
errors,
|
|
192
157
|
schema: errorSchema,
|
|
@@ -202,7 +167,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
202
167
|
}
|
|
203
168
|
} catch (error) {
|
|
204
169
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
205
|
-
logger.error(`Error updating document in ${
|
|
206
|
-
return
|
|
170
|
+
logger.error(`Error updating document in ${slug}: ${errorMessage}`)
|
|
171
|
+
return formatEntityError({ slug, action: 'updating', entity: 'collection', error, req })
|
|
207
172
|
}
|
|
208
173
|
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { strictObject, z } from 'payload'
|
|
2
|
+
import { getUploadInstructions as getPayloadUploadInstructions } from 'payload/internal'
|
|
3
|
+
|
|
4
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
+
|
|
7
|
+
export const getUploadInstructionsTool = defineCollectionTool({
|
|
8
|
+
access: (args) =>
|
|
9
|
+
defaultAccess(args) &&
|
|
10
|
+
Boolean(
|
|
11
|
+
args.permissions?.collections?.[args.slug]?.create ||
|
|
12
|
+
args.permissions?.collections?.[args.slug]?.update,
|
|
13
|
+
),
|
|
14
|
+
annotations: {
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: false,
|
|
19
|
+
title: 'Get Upload Instructions',
|
|
20
|
+
},
|
|
21
|
+
description:
|
|
22
|
+
'Prepare uploads for createDocuments or updateDocument. This does not upload bytes; finish the returned action before use.',
|
|
23
|
+
input: strictObject({
|
|
24
|
+
docPrefix: z.optional(z.string()).check(z.describe('Document folder or prefix.')),
|
|
25
|
+
filename: z.string().check(z.describe('The original file name.')),
|
|
26
|
+
filesize: z.int().check(z.nonnegative(), z.describe('The file size in bytes.')),
|
|
27
|
+
mimeType: z.string().check(z.describe('The file MIME type.')),
|
|
28
|
+
}),
|
|
29
|
+
}).handler(async ({ slug, authorizedMCP, input, req }) => {
|
|
30
|
+
try {
|
|
31
|
+
const instructions = await getPayloadUploadInstructions({
|
|
32
|
+
...input,
|
|
33
|
+
collectionSlug: slug,
|
|
34
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
35
|
+
req,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const nextStep =
|
|
39
|
+
instructions.type === 'http'
|
|
40
|
+
? 'Upload bytes with instructions.request. After success, pass { source: "uploadReference", file: instructions.file }.'
|
|
41
|
+
: `Call "${instructions.name}" with file and data. After success, pass { source: "uploadReference", file: instructions.file }.`
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Upload instructions for collection "${slug}":\n\`\`\`json\n${JSON.stringify(instructions)}\n\`\`\`\n${nextStep}`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
structuredContent: { instructions },
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : 'Unknown error'
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: `Error getting upload instructions for collection "${slug}": ${message}`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
isError: true,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { CollectionSlug, GlobalSlug, PayloadRequest } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { getCollectionInputSchema, getGlobalInputSchema, ValidationError } from 'payload'
|
|
4
|
+
|
|
5
|
+
import type { MCPToolResponse } from '../../types.js'
|
|
6
|
+
|
|
7
|
+
export const formatEntityError = ({
|
|
8
|
+
slug,
|
|
9
|
+
action,
|
|
10
|
+
entity,
|
|
11
|
+
error,
|
|
12
|
+
req,
|
|
13
|
+
}:
|
|
14
|
+
| {
|
|
15
|
+
action: 'creating' | 'duplicating' | 'updating'
|
|
16
|
+
entity: 'collection'
|
|
17
|
+
error: unknown
|
|
18
|
+
req: PayloadRequest
|
|
19
|
+
slug: CollectionSlug
|
|
20
|
+
}
|
|
21
|
+
| {
|
|
22
|
+
action: 'updating'
|
|
23
|
+
entity: 'global'
|
|
24
|
+
error: unknown
|
|
25
|
+
req: PayloadRequest
|
|
26
|
+
slug: GlobalSlug
|
|
27
|
+
}): MCPToolResponse => {
|
|
28
|
+
const message = error instanceof Error ? error.message : 'Unknown error'
|
|
29
|
+
const target = entity === 'collection' ? `document in collection "${slug}"` : `global "${slug}"`
|
|
30
|
+
|
|
31
|
+
if (!isValidationError(error, message)) {
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: 'text', text: `Error ${action} ${target}: ${message}` }],
|
|
34
|
+
isError: true,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const schema =
|
|
39
|
+
entity === 'collection'
|
|
40
|
+
? getCollectionInputSchema({ collectionSlug: slug, req })
|
|
41
|
+
: getGlobalInputSchema({ globalSlug: slug, req })
|
|
42
|
+
const errors = error instanceof ValidationError ? error.data.errors : [{ message }]
|
|
43
|
+
const validationMessage = errors
|
|
44
|
+
.map((issue) => `${'path' in issue ? `${issue.path}: ` : ''}${issue.message}`)
|
|
45
|
+
.join('\n')
|
|
46
|
+
const schemaText = schema
|
|
47
|
+
? `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``
|
|
48
|
+
: ''
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{ type: 'text', text: `Error ${action} ${target}: ${validationMessage}${schemaText}` },
|
|
53
|
+
],
|
|
54
|
+
isError: true,
|
|
55
|
+
...(schema
|
|
56
|
+
? {
|
|
57
|
+
structuredContent: {
|
|
58
|
+
slug,
|
|
59
|
+
errors,
|
|
60
|
+
schema,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
: {}),
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const isValidationError = (error: unknown, message: string): boolean => {
|
|
68
|
+
if (error instanceof ValidationError) {
|
|
69
|
+
return true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const name = error && typeof error === 'object' && 'name' in error ? error.name : undefined
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
name === 'CastError' || message.includes('Cast to ') || message.includes('validation failed')
|
|
76
|
+
)
|
|
77
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAccessResults, isEntityHidden } from 'payload'
|
|
1
|
+
import { getAccessResults, getConfigInfoInputSchema, isEntityHidden } from 'payload'
|
|
2
2
|
|
|
3
3
|
import { defineTool } from '../../defineTool.js'
|
|
4
4
|
|
|
@@ -11,18 +11,32 @@ export const getConfigInfoTool = defineTool({
|
|
|
11
11
|
title: 'Config Info',
|
|
12
12
|
},
|
|
13
13
|
description: 'List the Payload collection and global slugs visible to this MCP client.',
|
|
14
|
+
input: getConfigInfoInputSchema,
|
|
14
15
|
}).handler(async ({ authorizedMCP, req }) => {
|
|
15
|
-
const user =
|
|
16
|
-
const permissions =
|
|
16
|
+
const user = req.user
|
|
17
|
+
const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({ req })
|
|
18
|
+
const authorizedCollectionSlugs = new Set<string>()
|
|
19
|
+
const authorizedGlobalSlugs = new Set<string>()
|
|
20
|
+
|
|
21
|
+
for (const item of authorizedMCP.items) {
|
|
22
|
+
if (item.type === 'collectionTool') {
|
|
23
|
+
authorizedCollectionSlugs.add(item.collectionSlug)
|
|
24
|
+
} else if (item.type === 'globalTool') {
|
|
25
|
+
authorizedGlobalSlugs.add(item.globalSlug)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
17
28
|
|
|
18
29
|
const collections: string[] = []
|
|
19
30
|
const globals: string[] = []
|
|
20
31
|
|
|
21
32
|
for (const collection of req.payload.config.collections) {
|
|
33
|
+
if (!authorizedCollectionSlugs.has(collection.slug)) {
|
|
34
|
+
continue
|
|
35
|
+
}
|
|
22
36
|
if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {
|
|
23
37
|
continue
|
|
24
38
|
}
|
|
25
|
-
if (
|
|
39
|
+
if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {
|
|
26
40
|
continue
|
|
27
41
|
}
|
|
28
42
|
|
|
@@ -30,10 +44,13 @@ export const getConfigInfoTool = defineTool({
|
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
for (const global of req.payload.config.globals) {
|
|
47
|
+
if (!authorizedGlobalSlugs.has(global.slug)) {
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
33
50
|
if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {
|
|
34
51
|
continue
|
|
35
52
|
}
|
|
36
|
-
if (
|
|
53
|
+
if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {
|
|
37
54
|
continue
|
|
38
55
|
}
|
|
39
56
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { countGlobalVersionsInputSchema } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
4
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
5
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
6
|
+
|
|
7
|
+
const DEFAULT_DESCRIPTION =
|
|
8
|
+
'Count global versions in any version-enabled global by passing the global slug and optional where clause.'
|
|
9
|
+
|
|
10
|
+
export const countGlobalVersionsTool = defineGlobalTool({
|
|
11
|
+
access: (args) =>
|
|
12
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
|
|
13
|
+
annotations: {
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
idempotentHint: true,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
readOnlyHint: true,
|
|
18
|
+
title: 'Count Global Versions',
|
|
19
|
+
},
|
|
20
|
+
description: DEFAULT_DESCRIPTION,
|
|
21
|
+
input: countGlobalVersionsInputSchema,
|
|
22
|
+
}).handler(async ({ slug, authorizedMCP, input, req }) => {
|
|
23
|
+
const payload = req.payload
|
|
24
|
+
const logger = getLogger({ payload })
|
|
25
|
+
const { locale, where } = input
|
|
26
|
+
|
|
27
|
+
logger.info(`Counting versions for global: ${slug}`)
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const result = await payload.countGlobalVersions({
|
|
31
|
+
global: slug,
|
|
32
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
33
|
+
req,
|
|
34
|
+
...(locale ? { locale } : {}),
|
|
35
|
+
...(where ? { where } : {}),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: `Global "${slug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
doc: result,
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
49
|
+
logger.error(`Error counting versions for global ${slug}: ${errorMessage}`)
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: `❌ **Error counting versions for global "${slug}":** ${errorMessage}`,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
isError: true,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { z } from 'zod'
|
|
1
|
+
import { findGlobalInputSchema } from 'payload'
|
|
4
2
|
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
4
|
import { defineGlobalTool } from '../../../defineTool.js'
|
|
6
5
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
8
6
|
|
|
9
7
|
const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'
|
|
10
8
|
|
|
11
9
|
export const findGlobalTool = defineGlobalTool({
|
|
10
|
+
access: (args) => defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.read),
|
|
12
11
|
annotations: {
|
|
13
12
|
destructiveHint: false,
|
|
14
13
|
idempotentHint: true,
|
|
@@ -17,86 +16,51 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
17
16
|
title: 'Find Global',
|
|
18
17
|
},
|
|
19
18
|
description: DEFAULT_DESCRIPTION,
|
|
20
|
-
input:
|
|
21
|
-
|
|
22
|
-
.number()
|
|
23
|
-
.int()
|
|
24
|
-
.min(0)
|
|
25
|
-
.max(10)
|
|
26
|
-
.describe('Depth of population for relationships')
|
|
27
|
-
.optional()
|
|
28
|
-
.default(0),
|
|
29
|
-
fallbackLocale: z
|
|
30
|
-
.string()
|
|
31
|
-
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
32
|
-
.optional(),
|
|
33
|
-
locale: z
|
|
34
|
-
.string()
|
|
35
|
-
.describe(
|
|
36
|
-
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
37
|
-
)
|
|
38
|
-
.optional(),
|
|
39
|
-
populate: z
|
|
40
|
-
.record(z.string(), z.unknown())
|
|
41
|
-
.describe(
|
|
42
|
-
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
43
|
-
)
|
|
44
|
-
.optional(),
|
|
45
|
-
select: z
|
|
46
|
-
.record(z.string(), z.unknown())
|
|
47
|
-
.describe(
|
|
48
|
-
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
49
|
-
)
|
|
50
|
-
.optional(),
|
|
51
|
-
}),
|
|
52
|
-
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
19
|
+
input: findGlobalInputSchema,
|
|
20
|
+
}).handler(async ({ slug, authorizedMCP, input, req }) => {
|
|
53
21
|
const payload = req.payload
|
|
54
22
|
const logger = getLogger({ payload })
|
|
55
23
|
|
|
56
24
|
const { depth, fallbackLocale, locale, populate, select } = input
|
|
57
25
|
|
|
58
|
-
logger.info(
|
|
59
|
-
`Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`,
|
|
60
|
-
)
|
|
26
|
+
logger.info(`Reading global: ${slug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`)
|
|
61
27
|
|
|
62
28
|
try {
|
|
63
29
|
const findOptions: Parameters<typeof payload.findGlobal>[0] = {
|
|
64
|
-
slug
|
|
30
|
+
slug,
|
|
65
31
|
depth,
|
|
66
|
-
|
|
32
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
33
|
+
req,
|
|
67
34
|
}
|
|
68
35
|
|
|
69
36
|
if (locale) {
|
|
70
37
|
findOptions.locale = locale
|
|
71
38
|
}
|
|
72
|
-
if (fallbackLocale) {
|
|
39
|
+
if (fallbackLocale !== undefined) {
|
|
73
40
|
findOptions.fallbackLocale = fallbackLocale
|
|
74
41
|
}
|
|
75
42
|
if (select) {
|
|
76
|
-
findOptions.select = select
|
|
43
|
+
findOptions.select = select
|
|
77
44
|
}
|
|
78
45
|
if (populate) {
|
|
79
|
-
findOptions.populate = populate
|
|
46
|
+
findOptions.populate = populate
|
|
80
47
|
}
|
|
81
|
-
|
|
82
48
|
const result = await payload.findGlobal(findOptions)
|
|
83
49
|
|
|
84
50
|
return {
|
|
85
51
|
content: [
|
|
86
52
|
{
|
|
87
53
|
type: 'text',
|
|
88
|
-
text: `Global "${
|
|
54
|
+
text: `Global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
89
55
|
},
|
|
90
56
|
],
|
|
91
57
|
doc: result as Record<string, unknown>,
|
|
92
58
|
}
|
|
93
59
|
} catch (error) {
|
|
94
60
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
95
|
-
logger.error(`Error reading global ${
|
|
61
|
+
logger.error(`Error reading global ${slug}: ${errorMessage}`)
|
|
96
62
|
return {
|
|
97
|
-
content: [
|
|
98
|
-
{ type: 'text', text: `❌ **Error reading global "${globalSlug}":** ${errorMessage}` },
|
|
99
|
-
],
|
|
63
|
+
content: [{ type: 'text', text: `❌ **Error reading global "${slug}":** ${errorMessage}` }],
|
|
100
64
|
}
|
|
101
65
|
}
|
|
102
66
|
})
|