@payloadcms/plugin-mcp 4.0.0-internal.688c4d0 → 4.0.0-internal.bc5cf8c
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/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 +17 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +81 -103
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +11 -0
- 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.map +1 -1
- package/dist/index.js +1 -49
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +2 -0
- 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 +69 -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 +65 -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 +12 -19
- 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 +9 -0
- 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 +97 -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 +93 -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 +43 -22
- 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 +84 -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 +99 -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 +12 -0
- 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 +82 -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 +14 -21
- 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 -5
- 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 +65 -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 +17 -20
- 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 +80 -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 +95 -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 +12 -0
- 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 +78 -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 +12 -19
- package/dist/mcp/builtin/globals/updateTool.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 +68 -27
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -2
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +27 -8
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +50 -90
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -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/package.json +9 -13
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +87 -112
- package/src/endpoint/index.ts +14 -1
- package/src/exports/client.ts +2 -4
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +1 -55
- package/src/mcp/buildMcpServer.ts +8 -1
- package/src/mcp/builtin/collections/authTools.ts +45 -9
- package/src/mcp/builtin/collections/countTool.ts +74 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +70 -0
- package/src/mcp/builtin/collections/createTool.ts +13 -13
- package/src/mcp/builtin/collections/deleteTool.ts +10 -0
- package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +120 -0
- package/src/mcp/builtin/collections/findTool.ts +56 -16
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +18 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
- package/src/mcp/builtin/collections/updateTool.ts +14 -14
- package/src/mcp/builtin/getConfigInfoTool.ts +29 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/globals/findTool.ts +25 -16
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +13 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +100 -0
- package/src/mcp/builtin/globals/updateTool.ts +14 -14
- package/src/mcp/builtinTools.ts +72 -16
- package/src/mcp/sanitizeMCPConfig.ts +47 -30
- package/src/stdio.ts +23 -8
- package/src/types.ts +57 -92
- 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 -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/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
|
@@ -0,0 +1,155 @@
|
|
|
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 { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
9
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
10
|
+
|
|
11
|
+
const DEFAULT_DESCRIPTION =
|
|
12
|
+
'Find document versions in any version-enabled collection by passing the collection slug and optional where clause.'
|
|
13
|
+
|
|
14
|
+
export const findVersionsTool = defineCollectionTool({
|
|
15
|
+
access: (args) =>
|
|
16
|
+
defaultAccess(args) &&
|
|
17
|
+
Boolean(args.permissions?.collections?.[args.collectionSlug]?.readVersions),
|
|
18
|
+
annotations: {
|
|
19
|
+
destructiveHint: false,
|
|
20
|
+
idempotentHint: true,
|
|
21
|
+
openWorldHint: false,
|
|
22
|
+
readOnlyHint: true,
|
|
23
|
+
title: 'Find Versions',
|
|
24
|
+
},
|
|
25
|
+
description: DEFAULT_DESCRIPTION,
|
|
26
|
+
input: z.object({
|
|
27
|
+
depth: z
|
|
28
|
+
.number()
|
|
29
|
+
.int()
|
|
30
|
+
.min(0)
|
|
31
|
+
.max(10)
|
|
32
|
+
.describe('How many levels deep to populate relationships in version documents')
|
|
33
|
+
.optional()
|
|
34
|
+
.default(0),
|
|
35
|
+
fallbackLocale: z
|
|
36
|
+
.string()
|
|
37
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
38
|
+
.optional(),
|
|
39
|
+
limit: z
|
|
40
|
+
.number()
|
|
41
|
+
.int()
|
|
42
|
+
.min(1)
|
|
43
|
+
.max(100)
|
|
44
|
+
.describe('Maximum number of versions to return (default: 10, max: 100)')
|
|
45
|
+
.optional()
|
|
46
|
+
.default(10),
|
|
47
|
+
locale: z
|
|
48
|
+
.string()
|
|
49
|
+
.describe(
|
|
50
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
51
|
+
)
|
|
52
|
+
.optional(),
|
|
53
|
+
page: z
|
|
54
|
+
.number()
|
|
55
|
+
.int()
|
|
56
|
+
.min(1)
|
|
57
|
+
.describe('Page number for pagination (default: 1)')
|
|
58
|
+
.optional()
|
|
59
|
+
.default(1),
|
|
60
|
+
pagination: z
|
|
61
|
+
.boolean()
|
|
62
|
+
.describe('Optional: set to false to skip the count query overhead')
|
|
63
|
+
.optional(),
|
|
64
|
+
populate: z
|
|
65
|
+
.record(z.string(), z.unknown())
|
|
66
|
+
.describe(
|
|
67
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
68
|
+
)
|
|
69
|
+
.optional(),
|
|
70
|
+
select: z
|
|
71
|
+
.record(z.string(), z.unknown())
|
|
72
|
+
.describe(
|
|
73
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.title": true}',
|
|
74
|
+
)
|
|
75
|
+
.optional(),
|
|
76
|
+
showHiddenFields: z
|
|
77
|
+
.boolean()
|
|
78
|
+
.describe('Optional: include hidden fields in returned version documents')
|
|
79
|
+
.optional(),
|
|
80
|
+
sort: z
|
|
81
|
+
.string()
|
|
82
|
+
.describe('Field to sort by (e.g., "-updatedAt", "-version.updatedAt" for descending)')
|
|
83
|
+
.optional(),
|
|
84
|
+
trash: z
|
|
85
|
+
.boolean()
|
|
86
|
+
.describe('Optional: include versions for soft-deleted documents when trash is enabled')
|
|
87
|
+
.optional(),
|
|
88
|
+
where: whereSchema
|
|
89
|
+
.describe(
|
|
90
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.title":{"contains":"test"}}',
|
|
91
|
+
)
|
|
92
|
+
.optional(),
|
|
93
|
+
}),
|
|
94
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
95
|
+
const payload = req.payload
|
|
96
|
+
const logger = getLogger({ payload })
|
|
97
|
+
const {
|
|
98
|
+
depth,
|
|
99
|
+
fallbackLocale,
|
|
100
|
+
limit,
|
|
101
|
+
locale,
|
|
102
|
+
page,
|
|
103
|
+
pagination,
|
|
104
|
+
populate,
|
|
105
|
+
select,
|
|
106
|
+
showHiddenFields,
|
|
107
|
+
sort,
|
|
108
|
+
trash,
|
|
109
|
+
where,
|
|
110
|
+
} = input
|
|
111
|
+
|
|
112
|
+
logger.info(`Finding versions in collection: ${collectionSlug}, limit: ${limit}, page: ${page}`)
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
const result = await payload.findVersions({
|
|
116
|
+
collection: collectionSlug,
|
|
117
|
+
depth,
|
|
118
|
+
limit,
|
|
119
|
+
page,
|
|
120
|
+
req,
|
|
121
|
+
...localAPIDefaults(authorizedMCP),
|
|
122
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
123
|
+
...(locale ? { locale } : {}),
|
|
124
|
+
...(pagination !== undefined ? { pagination } : {}),
|
|
125
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
126
|
+
...(select ? { select: select as SelectType } : {}),
|
|
127
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
128
|
+
...(sort ? { sort } : {}),
|
|
129
|
+
...(trash !== undefined ? { trash } : {}),
|
|
130
|
+
...(where ? { where } : {}),
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: `Versions for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
doc: result as unknown as Record<string, unknown>,
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
144
|
+
logger.error(`Error finding versions in ${collectionSlug}: ${errorMessage}`)
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: 'text',
|
|
149
|
+
text: `❌ **Error finding versions in collection "${collectionSlug}":** ${errorMessage}`,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
isError: true,
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
1
2
|
import { defineCollectionTool } from '../../../defineTool.js'
|
|
2
3
|
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
3
4
|
|
|
4
5
|
export const getCollectionSchemaTool = defineCollectionTool({
|
|
6
|
+
access: (args) => {
|
|
7
|
+
const permissions = args.permissions?.collections?.[args.collectionSlug]
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
defaultAccess(args) &&
|
|
11
|
+
Boolean(
|
|
12
|
+
permissions?.create || permissions?.delete || permissions?.read || permissions?.update,
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
},
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
title: 'Get Collection Schema',
|
|
22
|
+
},
|
|
5
23
|
description: 'Get the input schema for creating or updating documents in a collection.',
|
|
6
24
|
}).handler(({ collectionSlug, req }) => {
|
|
7
25
|
const inputSchema = getCollectionInputSchema({ collectionSlug, req })
|
|
@@ -0,0 +1,108 @@
|
|
|
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 { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DESCRIPTION =
|
|
11
|
+
'Restore a document from a previous version in any version-enabled collection.'
|
|
12
|
+
|
|
13
|
+
export const restoreVersionTool = defineCollectionTool({
|
|
14
|
+
access: (args) =>
|
|
15
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: true,
|
|
18
|
+
idempotentHint: false,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: false,
|
|
21
|
+
title: 'Restore Version',
|
|
22
|
+
},
|
|
23
|
+
description: DEFAULT_DESCRIPTION,
|
|
24
|
+
input: z.object({
|
|
25
|
+
id: z.string().describe('The ID of the version to restore'),
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(0)
|
|
30
|
+
.max(10)
|
|
31
|
+
.describe('How many levels deep to populate relationships in response')
|
|
32
|
+
.optional()
|
|
33
|
+
.default(0),
|
|
34
|
+
draft: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.describe('Whether to restore the version as a draft')
|
|
37
|
+
.optional()
|
|
38
|
+
.default(false),
|
|
39
|
+
fallbackLocale: z
|
|
40
|
+
.string()
|
|
41
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
42
|
+
.optional(),
|
|
43
|
+
locale: z
|
|
44
|
+
.string()
|
|
45
|
+
.describe('Optional: locale code to restore in (e.g., "en", "es")')
|
|
46
|
+
.optional(),
|
|
47
|
+
populate: z
|
|
48
|
+
.record(z.string(), z.unknown())
|
|
49
|
+
.describe(
|
|
50
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
51
|
+
)
|
|
52
|
+
.optional(),
|
|
53
|
+
select: z
|
|
54
|
+
.record(z.string(), z.unknown())
|
|
55
|
+
.describe(
|
|
56
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
57
|
+
)
|
|
58
|
+
.optional(),
|
|
59
|
+
showHiddenFields: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.describe('Optional: include hidden fields in the restored document response')
|
|
62
|
+
.optional(),
|
|
63
|
+
}),
|
|
64
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
65
|
+
const payload = req.payload
|
|
66
|
+
const logger = getLogger({ payload })
|
|
67
|
+
const { id, depth, draft, fallbackLocale, locale, populate, select, showHiddenFields } = input
|
|
68
|
+
|
|
69
|
+
logger.info(`Restoring version in collection: ${collectionSlug} with ID: ${id}`)
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const result = await payload.restoreVersion({
|
|
73
|
+
id,
|
|
74
|
+
collection: collectionSlug,
|
|
75
|
+
depth,
|
|
76
|
+
draft,
|
|
77
|
+
req,
|
|
78
|
+
...localAPIDefaults(authorizedMCP),
|
|
79
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
80
|
+
...(locale ? { locale } : {}),
|
|
81
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
82
|
+
...(select ? { select: select as SelectType } : {}),
|
|
83
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: 'text',
|
|
90
|
+
text: `Version "${id}" restored successfully in collection "${collectionSlug}"!\nRestored document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
doc: result as Record<string, unknown>,
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
97
|
+
logger.error(`Error restoring version ${id} in ${collectionSlug}: ${errorMessage}`)
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: `❌ **Error restoring version "${id}" in collection "${collectionSlug}":** ${errorMessage}`,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
isError: true,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
@@ -2,6 +2,7 @@ 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 {
|
|
@@ -19,6 +20,15 @@ const DEFAULT_DESCRIPTION =
|
|
|
19
20
|
'Update documents in any collection by passing the collection slug and data.'
|
|
20
21
|
|
|
21
22
|
export const updateDocumentTool = defineCollectionTool({
|
|
23
|
+
access: (args) =>
|
|
24
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
25
|
+
annotations: {
|
|
26
|
+
destructiveHint: true,
|
|
27
|
+
idempotentHint: false,
|
|
28
|
+
openWorldHint: false,
|
|
29
|
+
readOnlyHint: false,
|
|
30
|
+
title: 'Update Document',
|
|
31
|
+
},
|
|
22
32
|
description: DEFAULT_DESCRIPTION,
|
|
23
33
|
input: z.object({
|
|
24
34
|
id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),
|
|
@@ -55,9 +65,9 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
55
65
|
.optional()
|
|
56
66
|
.default(false),
|
|
57
67
|
select: z
|
|
58
|
-
.string()
|
|
68
|
+
.record(z.string(), z.unknown())
|
|
59
69
|
.describe(
|
|
60
|
-
|
|
70
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
61
71
|
)
|
|
62
72
|
.optional(),
|
|
63
73
|
where: whereSchema
|
|
@@ -112,16 +122,6 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
112
122
|
|
|
113
123
|
const whereClause: Where = where ?? {}
|
|
114
124
|
|
|
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
125
|
if (id) {
|
|
126
126
|
const result = await payload.update({
|
|
127
127
|
id,
|
|
@@ -136,7 +136,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
136
136
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
137
137
|
...(locale ? { locale } : {}),
|
|
138
138
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
139
|
-
...(
|
|
139
|
+
...(select ? { select: select as SelectType } : {}),
|
|
140
140
|
})
|
|
141
141
|
|
|
142
142
|
return {
|
|
@@ -163,7 +163,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
163
163
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
164
164
|
...(locale ? { locale } : {}),
|
|
165
165
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
166
|
-
...(
|
|
166
|
+
...(select ? { select: select as SelectType } : {}),
|
|
167
167
|
})
|
|
168
168
|
|
|
169
169
|
const docs = result.docs || []
|
|
@@ -3,19 +3,41 @@ import { getAccessResults, isEntityHidden } from 'payload'
|
|
|
3
3
|
import { defineTool } from '../../defineTool.js'
|
|
4
4
|
|
|
5
5
|
export const getConfigInfoTool = defineTool({
|
|
6
|
+
annotations: {
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: true,
|
|
9
|
+
openWorldHint: false,
|
|
10
|
+
readOnlyHint: true,
|
|
11
|
+
title: 'Config Info',
|
|
12
|
+
},
|
|
6
13
|
description: 'List the Payload collection and global slugs visible to this MCP client.',
|
|
7
14
|
}).handler(async ({ authorizedMCP, req }) => {
|
|
8
|
-
const user = authorizedMCP.user
|
|
9
|
-
const permissions =
|
|
15
|
+
const user = authorizedMCP.user
|
|
16
|
+
const permissions = authorizedMCP.overrideAccess
|
|
17
|
+
? null
|
|
18
|
+
: await getAccessResults({ req: { ...req, user } })
|
|
19
|
+
const authorizedCollectionSlugs = new Set<string>()
|
|
20
|
+
const authorizedGlobalSlugs = new Set<string>()
|
|
21
|
+
|
|
22
|
+
for (const item of authorizedMCP.items) {
|
|
23
|
+
if (item.type === 'collectionTool') {
|
|
24
|
+
authorizedCollectionSlugs.add(item.collectionSlug)
|
|
25
|
+
} else if (item.type === 'globalTool') {
|
|
26
|
+
authorizedGlobalSlugs.add(item.globalSlug)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
10
29
|
|
|
11
30
|
const collections: string[] = []
|
|
12
31
|
const globals: string[] = []
|
|
13
32
|
|
|
14
33
|
for (const collection of req.payload.config.collections) {
|
|
34
|
+
if (!authorizedCollectionSlugs.has(collection.slug)) {
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
15
37
|
if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {
|
|
16
38
|
continue
|
|
17
39
|
}
|
|
18
|
-
if (
|
|
40
|
+
if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {
|
|
19
41
|
continue
|
|
20
42
|
}
|
|
21
43
|
|
|
@@ -23,10 +45,13 @@ export const getConfigInfoTool = defineTool({
|
|
|
23
45
|
}
|
|
24
46
|
|
|
25
47
|
for (const global of req.payload.config.globals) {
|
|
48
|
+
if (!authorizedGlobalSlugs.has(global.slug)) {
|
|
49
|
+
continue
|
|
50
|
+
}
|
|
26
51
|
if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {
|
|
27
52
|
continue
|
|
28
53
|
}
|
|
29
|
-
if (
|
|
54
|
+
if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {
|
|
30
55
|
continue
|
|
31
56
|
}
|
|
32
57
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
4
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
5
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
6
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
7
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
8
|
+
|
|
9
|
+
const DEFAULT_DESCRIPTION =
|
|
10
|
+
'Count global versions in any version-enabled global by passing the global slug and optional where clause.'
|
|
11
|
+
|
|
12
|
+
export const countGlobalVersionsTool = defineGlobalTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
idempotentHint: true,
|
|
18
|
+
openWorldHint: false,
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
title: 'Count Global Versions',
|
|
21
|
+
},
|
|
22
|
+
description: DEFAULT_DESCRIPTION,
|
|
23
|
+
input: z.object({
|
|
24
|
+
locale: z.string().describe('Optional: locale code to count versions in').optional(),
|
|
25
|
+
where: whereSchema
|
|
26
|
+
.describe(
|
|
27
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}',
|
|
28
|
+
)
|
|
29
|
+
.optional(),
|
|
30
|
+
}),
|
|
31
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
32
|
+
const payload = req.payload
|
|
33
|
+
const logger = getLogger({ payload })
|
|
34
|
+
const { locale, where } = input
|
|
35
|
+
|
|
36
|
+
logger.info(`Counting versions for global: ${globalSlug}`)
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const result = await payload.countGlobalVersions({
|
|
40
|
+
global: globalSlug,
|
|
41
|
+
req,
|
|
42
|
+
...localAPIDefaults(authorizedMCP),
|
|
43
|
+
...(locale ? { locale } : {}),
|
|
44
|
+
...(where ? { where } : {}),
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
text: `Global "${globalSlug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
doc: result,
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
58
|
+
logger.error(`Error counting versions for global ${globalSlug}: ${errorMessage}`)
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `❌ **Error counting versions for global "${globalSlug}":** ${errorMessage}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
isError: true,
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { SelectType } from 'payload'
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
6
|
import { defineGlobalTool } from '../../../defineTool.js'
|
|
6
7
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
8
|
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
@@ -9,6 +10,15 @@ import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
|
9
10
|
const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'
|
|
10
11
|
|
|
11
12
|
export const findGlobalTool = defineGlobalTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.read),
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
idempotentHint: true,
|
|
18
|
+
openWorldHint: false,
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
title: 'Find Global',
|
|
21
|
+
},
|
|
12
22
|
description: DEFAULT_DESCRIPTION,
|
|
13
23
|
input: z.object({
|
|
14
24
|
depth: z
|
|
@@ -29,10 +39,16 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
29
39
|
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
30
40
|
)
|
|
31
41
|
.optional(),
|
|
42
|
+
populate: z
|
|
43
|
+
.record(z.string(), z.unknown())
|
|
44
|
+
.describe(
|
|
45
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
46
|
+
)
|
|
47
|
+
.optional(),
|
|
32
48
|
select: z
|
|
33
|
-
.string()
|
|
49
|
+
.record(z.string(), z.unknown())
|
|
34
50
|
.describe(
|
|
35
|
-
|
|
51
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
36
52
|
)
|
|
37
53
|
.optional(),
|
|
38
54
|
}),
|
|
@@ -40,7 +56,7 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
40
56
|
const payload = req.payload
|
|
41
57
|
const logger = getLogger({ payload })
|
|
42
58
|
|
|
43
|
-
const { depth, fallbackLocale, locale, select } = input
|
|
59
|
+
const { depth, fallbackLocale, locale, populate, select } = input
|
|
44
60
|
|
|
45
61
|
logger.info(
|
|
46
62
|
`Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`,
|
|
@@ -53,24 +69,17 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
53
69
|
...localAPIDefaults(authorizedMCP),
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
let selectClause: SelectType | undefined
|
|
57
|
-
if (select) {
|
|
58
|
-
try {
|
|
59
|
-
selectClause = JSON.parse(select) as SelectType
|
|
60
|
-
} catch {
|
|
61
|
-
logger.warn(`Invalid select clause JSON for global: ${select}`)
|
|
62
|
-
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
72
|
if (locale) {
|
|
67
73
|
findOptions.locale = locale
|
|
68
74
|
}
|
|
69
75
|
if (fallbackLocale) {
|
|
70
76
|
findOptions.fallbackLocale = fallbackLocale
|
|
71
77
|
}
|
|
72
|
-
if (
|
|
73
|
-
findOptions.select =
|
|
78
|
+
if (select) {
|
|
79
|
+
findOptions.select = select as SelectType
|
|
80
|
+
}
|
|
81
|
+
if (populate) {
|
|
82
|
+
findOptions.populate = populate as PopulateType
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
const result = await payload.findGlobal(findOptions)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
6
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
7
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
8
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_DESCRIPTION =
|
|
11
|
+
'Find a specific global version in any version-enabled global by passing the global slug and version ID.'
|
|
12
|
+
|
|
13
|
+
export const findGlobalVersionByIDTool = defineGlobalTool({
|
|
14
|
+
access: (args) =>
|
|
15
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
title: 'Find Global Version By ID',
|
|
22
|
+
},
|
|
23
|
+
description: DEFAULT_DESCRIPTION,
|
|
24
|
+
input: z.object({
|
|
25
|
+
id: z.string().describe('The ID of the global 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 global 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.siteName": true}',
|
|
54
|
+
)
|
|
55
|
+
.optional(),
|
|
56
|
+
showHiddenFields: z
|
|
57
|
+
.boolean()
|
|
58
|
+
.describe('Optional: include hidden fields in the returned global version document')
|
|
59
|
+
.optional(),
|
|
60
|
+
}),
|
|
61
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
62
|
+
const payload = req.payload
|
|
63
|
+
const logger = getLogger({ payload })
|
|
64
|
+
const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields } = input
|
|
65
|
+
|
|
66
|
+
logger.info(`Finding version for global: ${globalSlug} with ID: ${id}`)
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const result = await payload.findGlobalVersionByID({
|
|
70
|
+
id,
|
|
71
|
+
slug: globalSlug,
|
|
72
|
+
depth,
|
|
73
|
+
req,
|
|
74
|
+
...localAPIDefaults(authorizedMCP),
|
|
75
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
76
|
+
...(locale ? { locale } : {}),
|
|
77
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
78
|
+
...(select ? { select: select as SelectType } : {}),
|
|
79
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
type: 'text',
|
|
86
|
+
text: `Version "${id}" from global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
doc: result as unknown as Record<string, unknown>,
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
93
|
+
logger.error(`Error finding version ${id} for global ${globalSlug}: ${errorMessage}`)
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: `❌ **Error finding version "${id}" for global "${globalSlug}":** ${errorMessage}`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
isError: true,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
})
|