@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,148 @@
|
|
|
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
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
10
|
+
|
|
11
|
+
const DEFAULT_DESCRIPTION =
|
|
12
|
+
'Find global versions in any version-enabled global by passing the global slug and optional where clause.'
|
|
13
|
+
|
|
14
|
+
export const findGlobalVersionsTool = defineGlobalTool({
|
|
15
|
+
access: (args) =>
|
|
16
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
|
|
17
|
+
annotations: {
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: true,
|
|
20
|
+
openWorldHint: false,
|
|
21
|
+
readOnlyHint: true,
|
|
22
|
+
title: 'Find Global Versions',
|
|
23
|
+
},
|
|
24
|
+
description: DEFAULT_DESCRIPTION,
|
|
25
|
+
input: z.object({
|
|
26
|
+
depth: z
|
|
27
|
+
.number()
|
|
28
|
+
.int()
|
|
29
|
+
.min(0)
|
|
30
|
+
.max(10)
|
|
31
|
+
.describe('How many levels deep to populate relationships in global version documents')
|
|
32
|
+
.optional()
|
|
33
|
+
.default(0),
|
|
34
|
+
fallbackLocale: z
|
|
35
|
+
.string()
|
|
36
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
37
|
+
.optional(),
|
|
38
|
+
limit: z
|
|
39
|
+
.number()
|
|
40
|
+
.int()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(100)
|
|
43
|
+
.describe('Maximum number of versions to return (default: 10, max: 100)')
|
|
44
|
+
.optional()
|
|
45
|
+
.default(10),
|
|
46
|
+
locale: z
|
|
47
|
+
.string()
|
|
48
|
+
.describe(
|
|
49
|
+
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
50
|
+
)
|
|
51
|
+
.optional(),
|
|
52
|
+
page: z
|
|
53
|
+
.number()
|
|
54
|
+
.int()
|
|
55
|
+
.min(1)
|
|
56
|
+
.describe('Page number for pagination (default: 1)')
|
|
57
|
+
.optional()
|
|
58
|
+
.default(1),
|
|
59
|
+
pagination: z
|
|
60
|
+
.boolean()
|
|
61
|
+
.describe('Optional: set to false to skip the count query overhead')
|
|
62
|
+
.optional(),
|
|
63
|
+
populate: z
|
|
64
|
+
.record(z.string(), z.unknown())
|
|
65
|
+
.describe(
|
|
66
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
67
|
+
)
|
|
68
|
+
.optional(),
|
|
69
|
+
select: z
|
|
70
|
+
.record(z.string(), z.unknown())
|
|
71
|
+
.describe(
|
|
72
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.siteName": true}',
|
|
73
|
+
)
|
|
74
|
+
.optional(),
|
|
75
|
+
showHiddenFields: z
|
|
76
|
+
.boolean()
|
|
77
|
+
.describe('Optional: include hidden fields in returned global version documents')
|
|
78
|
+
.optional(),
|
|
79
|
+
sort: z
|
|
80
|
+
.string()
|
|
81
|
+
.describe('Field to sort by (e.g., "-updatedAt", "-version.updatedAt" for descending)')
|
|
82
|
+
.optional(),
|
|
83
|
+
where: whereSchema
|
|
84
|
+
.describe(
|
|
85
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}',
|
|
86
|
+
)
|
|
87
|
+
.optional(),
|
|
88
|
+
}),
|
|
89
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
90
|
+
const payload = req.payload
|
|
91
|
+
const logger = getLogger({ payload })
|
|
92
|
+
const {
|
|
93
|
+
depth,
|
|
94
|
+
fallbackLocale,
|
|
95
|
+
limit,
|
|
96
|
+
locale,
|
|
97
|
+
page,
|
|
98
|
+
pagination,
|
|
99
|
+
populate,
|
|
100
|
+
select,
|
|
101
|
+
showHiddenFields,
|
|
102
|
+
sort,
|
|
103
|
+
where,
|
|
104
|
+
} = input
|
|
105
|
+
|
|
106
|
+
logger.info(`Finding versions for global: ${globalSlug}, limit: ${limit}, page: ${page}`)
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
const result = await payload.findGlobalVersions({
|
|
110
|
+
slug: globalSlug,
|
|
111
|
+
depth,
|
|
112
|
+
limit,
|
|
113
|
+
page,
|
|
114
|
+
req,
|
|
115
|
+
...localAPIDefaults(authorizedMCP),
|
|
116
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
117
|
+
...(locale ? { locale } : {}),
|
|
118
|
+
...(pagination !== undefined ? { pagination } : {}),
|
|
119
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
120
|
+
...(select ? { select: select as SelectType } : {}),
|
|
121
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
122
|
+
...(sort ? { sort } : {}),
|
|
123
|
+
...(where ? { where } : {}),
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
content: [
|
|
128
|
+
{
|
|
129
|
+
type: 'text',
|
|
130
|
+
text: `Versions for global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
doc: result as unknown as Record<string, unknown>,
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
137
|
+
logger.error(`Error finding versions for global ${globalSlug}: ${errorMessage}`)
|
|
138
|
+
return {
|
|
139
|
+
content: [
|
|
140
|
+
{
|
|
141
|
+
type: 'text',
|
|
142
|
+
text: `❌ **Error finding versions for global "${globalSlug}":** ${errorMessage}`,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
isError: true,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
})
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
1
2
|
import { defineGlobalTool } from '../../../defineTool.js'
|
|
2
3
|
import { getGlobalInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
3
4
|
|
|
4
5
|
export const getGlobalSchemaTool = defineGlobalTool({
|
|
6
|
+
access: (args) => {
|
|
7
|
+
const permissions = args.permissions?.globals?.[args.globalSlug]
|
|
8
|
+
|
|
9
|
+
return defaultAccess(args) && Boolean(permissions?.read || permissions?.update)
|
|
10
|
+
},
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
idempotentHint: true,
|
|
14
|
+
openWorldHint: false,
|
|
15
|
+
readOnlyHint: true,
|
|
16
|
+
title: 'Get Global Schema',
|
|
17
|
+
},
|
|
5
18
|
description: 'Get the input schema for updating a global.',
|
|
6
19
|
}).handler(({ globalSlug, req }) => {
|
|
7
20
|
const inputSchema = getGlobalInputSchema({ globalSlug, req })
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { PopulateType } 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
|
+
'Restore a global from a previous version in any version-enabled global.'
|
|
12
|
+
|
|
13
|
+
export const restoreGlobalVersionTool = defineGlobalTool({
|
|
14
|
+
access: (args) =>
|
|
15
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: true,
|
|
18
|
+
idempotentHint: false,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: false,
|
|
21
|
+
title: 'Restore Global Version',
|
|
22
|
+
},
|
|
23
|
+
description: DEFAULT_DESCRIPTION,
|
|
24
|
+
input: z.object({
|
|
25
|
+
id: z.string().describe('The ID of the global 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
|
+
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('Optional: locale code to restore in (e.g., "en", "es")')
|
|
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(),
|
|
48
|
+
showHiddenFields: z
|
|
49
|
+
.boolean()
|
|
50
|
+
.describe('Optional: include hidden fields in the restored global response')
|
|
51
|
+
.optional(),
|
|
52
|
+
}),
|
|
53
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
54
|
+
const payload = req.payload
|
|
55
|
+
const logger = getLogger({ payload })
|
|
56
|
+
const { id, depth, fallbackLocale, locale, populate, showHiddenFields } = input
|
|
57
|
+
|
|
58
|
+
logger.info(`Restoring version for global: ${globalSlug} with ID: ${id}`)
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const result = await payload.restoreGlobalVersion({
|
|
62
|
+
id,
|
|
63
|
+
slug: globalSlug,
|
|
64
|
+
depth,
|
|
65
|
+
req,
|
|
66
|
+
...localAPIDefaults(authorizedMCP),
|
|
67
|
+
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
68
|
+
...(locale ? { locale } : {}),
|
|
69
|
+
...(populate ? { populate: populate as PopulateType } : {}),
|
|
70
|
+
...(showHiddenFields !== undefined ? { showHiddenFields } : {}),
|
|
71
|
+
})
|
|
72
|
+
const resultObject = result as Record<string, unknown>
|
|
73
|
+
const restoredGlobal =
|
|
74
|
+
resultObject.version && typeof resultObject.version === 'object'
|
|
75
|
+
? (resultObject.version as Record<string, unknown>)
|
|
76
|
+
: resultObject
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: `Version "${id}" restored successfully for global "${globalSlug}"!\nRestored global:\n\`\`\`json\n${JSON.stringify(restoredGlobal)}\n\`\`\``,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
doc: restoredGlobal,
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
89
|
+
logger.error(`Error restoring version ${id} for global ${globalSlug}: ${errorMessage}`)
|
|
90
|
+
return {
|
|
91
|
+
content: [
|
|
92
|
+
{
|
|
93
|
+
type: 'text',
|
|
94
|
+
text: `❌ **Error restoring version "${id}" for global "${globalSlug}":** ${errorMessage}`,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
isError: true,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
})
|
|
@@ -2,6 +2,7 @@ import type { 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 {
|
|
@@ -15,6 +16,15 @@ import { validateGlobalData } from '../validateEntityData.js'
|
|
|
15
16
|
const DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.'
|
|
16
17
|
|
|
17
18
|
export const updateGlobalTool = defineGlobalTool({
|
|
19
|
+
access: (args) =>
|
|
20
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),
|
|
21
|
+
annotations: {
|
|
22
|
+
destructiveHint: true,
|
|
23
|
+
idempotentHint: false,
|
|
24
|
+
openWorldHint: false,
|
|
25
|
+
readOnlyHint: false,
|
|
26
|
+
title: 'Update Global',
|
|
27
|
+
},
|
|
18
28
|
description: DEFAULT_DESCRIPTION,
|
|
19
29
|
input: z.object({
|
|
20
30
|
data: z.record(z.string(), z.unknown()).describe('The global fields to update'),
|
|
@@ -39,9 +49,9 @@ export const updateGlobalTool = defineGlobalTool({
|
|
|
39
49
|
)
|
|
40
50
|
.optional(),
|
|
41
51
|
select: z
|
|
42
|
-
.string()
|
|
52
|
+
.record(z.string(), z.unknown())
|
|
43
53
|
.describe(
|
|
44
|
-
|
|
54
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"siteName": true}',
|
|
45
55
|
)
|
|
46
56
|
.optional(),
|
|
47
57
|
}),
|
|
@@ -66,16 +76,6 @@ export const updateGlobalTool = defineGlobalTool({
|
|
|
66
76
|
|
|
67
77
|
const parsedData = transformPointDataToPayload(inputData)
|
|
68
78
|
|
|
69
|
-
let selectClause: SelectType | undefined
|
|
70
|
-
if (select) {
|
|
71
|
-
try {
|
|
72
|
-
selectClause = JSON.parse(select) as SelectType
|
|
73
|
-
} catch {
|
|
74
|
-
logger.warn(`Invalid select clause JSON for global: ${select}`)
|
|
75
|
-
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
79
|
const updateOptions: Parameters<typeof payload.updateGlobal>[0] = {
|
|
80
80
|
slug: globalSlug,
|
|
81
81
|
data: parsedData,
|
|
@@ -90,8 +90,8 @@ export const updateGlobalTool = defineGlobalTool({
|
|
|
90
90
|
if (fallbackLocale) {
|
|
91
91
|
updateOptions.fallbackLocale = fallbackLocale
|
|
92
92
|
}
|
|
93
|
-
if (
|
|
94
|
-
updateOptions.select =
|
|
93
|
+
if (select) {
|
|
94
|
+
updateOptions.select = select as SelectType
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
const result = await payload.updateGlobal(updateOptions)
|
package/src/mcp/builtinTools.ts
CHANGED
|
@@ -8,19 +8,43 @@ import {
|
|
|
8
8
|
unlockCollectionTool,
|
|
9
9
|
verifyCollectionTool,
|
|
10
10
|
} from './builtin/collections/authTools.js'
|
|
11
|
+
import { countDocumentsTool } from './builtin/collections/countTool.js'
|
|
12
|
+
import { countVersionsTool } from './builtin/collections/countVersionsTool.js'
|
|
11
13
|
import { createDocumentTool } from './builtin/collections/createTool.js'
|
|
12
14
|
import { deleteDocumentsTool } from './builtin/collections/deleteTool.js'
|
|
15
|
+
import { duplicateDocumentTool } from './builtin/collections/duplicateTool.js'
|
|
16
|
+
import { findDistinctTool } from './builtin/collections/findDistinctTool.js'
|
|
13
17
|
import { findDocumentsTool } from './builtin/collections/findTool.js'
|
|
18
|
+
import { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js'
|
|
19
|
+
import { findVersionsTool } from './builtin/collections/findVersionsTool.js'
|
|
14
20
|
import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'
|
|
21
|
+
import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js'
|
|
15
22
|
import { updateDocumentTool } from './builtin/collections/updateTool.js'
|
|
16
23
|
import { getConfigInfoTool } from './builtin/getConfigInfoTool.js'
|
|
24
|
+
import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js'
|
|
17
25
|
import { findGlobalTool } from './builtin/globals/findTool.js'
|
|
26
|
+
import { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js'
|
|
27
|
+
import { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js'
|
|
18
28
|
import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'
|
|
29
|
+
import { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js'
|
|
19
30
|
import { updateGlobalTool } from './builtin/globals/updateTool.js'
|
|
20
31
|
|
|
32
|
+
type CollectionBuiltin = {
|
|
33
|
+
mcpName: string
|
|
34
|
+
requiresDuplicateEnabled?: boolean
|
|
35
|
+
requiresVersions?: boolean
|
|
36
|
+
tool: CollectionTool
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type GlobalBuiltin = {
|
|
40
|
+
mcpName: string
|
|
41
|
+
requiresVersions?: boolean
|
|
42
|
+
tool: GlobalTool
|
|
43
|
+
}
|
|
44
|
+
|
|
21
45
|
export const TOOL_BUILTINS = {
|
|
22
|
-
getConfigInfo: {
|
|
23
|
-
} satisfies Record<string, {
|
|
46
|
+
getConfigInfo: { mcpName: 'getConfigInfo', tool: getConfigInfoTool },
|
|
47
|
+
} satisfies Record<string, { mcpName: string; tool: Tool }>
|
|
24
48
|
|
|
25
49
|
/**
|
|
26
50
|
* The static built-in collection CRUD tools. Keys here are the source of truth
|
|
@@ -28,44 +52,76 @@ export const TOOL_BUILTINS = {
|
|
|
28
52
|
* automatically.
|
|
29
53
|
*/
|
|
30
54
|
export const COLLECTION_BUILTINS = {
|
|
55
|
+
count: { mcpName: 'countDocuments', tool: countDocumentsTool },
|
|
56
|
+
countVersions: { mcpName: 'countVersions', requiresVersions: true, tool: countVersionsTool },
|
|
31
57
|
create: { mcpName: 'createDocument', tool: createDocumentTool },
|
|
32
58
|
delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },
|
|
59
|
+
duplicate: {
|
|
60
|
+
mcpName: 'duplicateDocument',
|
|
61
|
+
requiresDuplicateEnabled: true,
|
|
62
|
+
tool: duplicateDocumentTool,
|
|
63
|
+
},
|
|
33
64
|
find: { mcpName: 'findDocuments', tool: findDocumentsTool },
|
|
65
|
+
findDistinct: { mcpName: 'findDistinct', tool: findDistinctTool },
|
|
66
|
+
findVersionByID: {
|
|
67
|
+
mcpName: 'findVersionByID',
|
|
68
|
+
requiresVersions: true,
|
|
69
|
+
tool: findVersionByIDTool,
|
|
70
|
+
},
|
|
71
|
+
findVersions: { mcpName: 'findVersions', requiresVersions: true, tool: findVersionsTool },
|
|
34
72
|
getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },
|
|
73
|
+
restoreVersion: { mcpName: 'restoreVersion', requiresVersions: true, tool: restoreVersionTool },
|
|
35
74
|
update: { mcpName: 'updateDocument', tool: updateDocumentTool },
|
|
36
|
-
} satisfies Record<string,
|
|
75
|
+
} satisfies Record<string, CollectionBuiltin>
|
|
37
76
|
|
|
38
77
|
/**
|
|
39
|
-
* The static auth tools surfaced under auth-enabled collections.
|
|
40
|
-
*
|
|
41
|
-
* for `MCPCollectionAuthToolName`.
|
|
78
|
+
* The static auth tools surfaced under auth-enabled collections. Keys are the
|
|
79
|
+
* source of truth for `MCPCollectionAuthToolName`.
|
|
42
80
|
*/
|
|
43
81
|
export const COLLECTION_AUTH_BUILTINS = {
|
|
44
|
-
auth: {
|
|
82
|
+
auth: { mcpName: 'auth', tool: authCollectionTool },
|
|
45
83
|
forgotPassword: {
|
|
46
|
-
label: 'Forgot Password',
|
|
47
84
|
mcpName: 'forgotPassword',
|
|
48
85
|
tool: forgotPasswordCollectionTool,
|
|
49
86
|
},
|
|
50
|
-
login: {
|
|
87
|
+
login: { mcpName: 'login', tool: loginCollectionTool },
|
|
51
88
|
resetPassword: {
|
|
52
|
-
label: 'Reset Password',
|
|
53
89
|
mcpName: 'resetPassword',
|
|
54
90
|
tool: resetPasswordCollectionTool,
|
|
55
91
|
},
|
|
56
|
-
unlock: {
|
|
57
|
-
verify: {
|
|
58
|
-
} satisfies Record<string, {
|
|
92
|
+
unlock: { mcpName: 'unlock', tool: unlockCollectionTool },
|
|
93
|
+
verify: { mcpName: 'verify', tool: verifyCollectionTool },
|
|
94
|
+
} satisfies Record<string, { mcpName: string; tool: CollectionTool }>
|
|
59
95
|
|
|
60
96
|
/**
|
|
61
97
|
* The static built-in global tools. Keys are the source of truth for
|
|
62
98
|
* `MCPGlobalBuiltinName`.
|
|
63
99
|
*/
|
|
64
100
|
export const GLOBAL_BUILTINS = {
|
|
101
|
+
countGlobalVersions: {
|
|
102
|
+
mcpName: 'countGlobalVersions',
|
|
103
|
+
requiresVersions: true,
|
|
104
|
+
tool: countGlobalVersionsTool,
|
|
105
|
+
},
|
|
65
106
|
find: { mcpName: 'findGlobal', tool: findGlobalTool },
|
|
107
|
+
findGlobalVersionByID: {
|
|
108
|
+
mcpName: 'findGlobalVersionByID',
|
|
109
|
+
requiresVersions: true,
|
|
110
|
+
tool: findGlobalVersionByIDTool,
|
|
111
|
+
},
|
|
112
|
+
findGlobalVersions: {
|
|
113
|
+
mcpName: 'findGlobalVersions',
|
|
114
|
+
requiresVersions: true,
|
|
115
|
+
tool: findGlobalVersionsTool,
|
|
116
|
+
},
|
|
66
117
|
getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },
|
|
118
|
+
restoreGlobalVersion: {
|
|
119
|
+
mcpName: 'restoreGlobalVersion',
|
|
120
|
+
requiresVersions: true,
|
|
121
|
+
tool: restoreGlobalVersionTool,
|
|
122
|
+
},
|
|
67
123
|
update: { mcpName: 'updateGlobal', tool: updateGlobalTool },
|
|
68
|
-
} satisfies Record<string,
|
|
124
|
+
} satisfies Record<string, GlobalBuiltin>
|
|
69
125
|
|
|
70
126
|
export type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS
|
|
71
127
|
|
|
@@ -86,7 +142,7 @@ export const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS) as Array<
|
|
|
86
142
|
>
|
|
87
143
|
|
|
88
144
|
export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<
|
|
89
|
-
[MCPCollectionBuiltinName,
|
|
145
|
+
[MCPCollectionBuiltinName, CollectionBuiltin]
|
|
90
146
|
>
|
|
91
147
|
|
|
92
148
|
export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<
|
|
@@ -94,5 +150,5 @@ export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BU
|
|
|
94
150
|
>
|
|
95
151
|
|
|
96
152
|
export const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<
|
|
97
|
-
[MCPGlobalBuiltinName,
|
|
153
|
+
[MCPGlobalBuiltinName, GlobalBuiltin]
|
|
98
154
|
>
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
SanitizedMCPPluginConfig,
|
|
18
18
|
} from '../types.js'
|
|
19
19
|
|
|
20
|
+
import { defaultAccess } from '../defaultAccess.js'
|
|
20
21
|
import {
|
|
21
22
|
COLLECTION_AUTH_BUILTIN_ENTRIES,
|
|
22
23
|
COLLECTION_AUTH_BUILTINS,
|
|
@@ -33,7 +34,6 @@ import {
|
|
|
33
34
|
* - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
|
|
34
35
|
* tool maps into a single `items` array.
|
|
35
36
|
* - Applies built-in tools for collections and globals, respecting opt-out user overrides.
|
|
36
|
-
* - Applies the `userCollection` default
|
|
37
37
|
*
|
|
38
38
|
* Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
|
|
39
39
|
* ?.options` holds the sanitized result
|
|
@@ -55,13 +55,13 @@ export const sanitizeMCPConfig = ({
|
|
|
55
55
|
items.push(...sanitizeGlobalConfig({ global, pluginConfig }))
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
for (const [configKey, {
|
|
58
|
+
for (const [configKey, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {
|
|
59
59
|
items.push({
|
|
60
60
|
type: 'tool',
|
|
61
61
|
configKey,
|
|
62
|
-
label,
|
|
62
|
+
label: tool.annotations?.title ?? configKey,
|
|
63
63
|
mcpName,
|
|
64
|
-
tool,
|
|
64
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
65
65
|
})
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -72,9 +72,9 @@ export const sanitizeMCPConfig = ({
|
|
|
72
72
|
items.push({
|
|
73
73
|
type: 'tool',
|
|
74
74
|
configKey,
|
|
75
|
-
label: configKey,
|
|
75
|
+
label: tool.annotations?.title ?? configKey,
|
|
76
76
|
mcpName: configKey,
|
|
77
|
-
tool,
|
|
77
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ export const sanitizeMCPConfig = ({
|
|
|
84
84
|
configKey,
|
|
85
85
|
label: prompt.title ?? configKey,
|
|
86
86
|
mcpName: configKey,
|
|
87
|
-
prompt,
|
|
87
|
+
prompt: { ...prompt, access: prompt.access ?? defaultAccess },
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -94,21 +94,15 @@ export const sanitizeMCPConfig = ({
|
|
|
94
94
|
configKey,
|
|
95
95
|
label: resource.title ?? configKey,
|
|
96
96
|
mcpName: configKey,
|
|
97
|
-
resource,
|
|
97
|
+
resource: { ...resource, access: resource.access ?? defaultAccess },
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.
|
|
102
|
-
const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))
|
|
103
|
-
|
|
104
101
|
return {
|
|
105
102
|
disabled: pluginConfig.disabled,
|
|
106
103
|
items,
|
|
107
104
|
mcp: pluginConfig.mcp,
|
|
108
|
-
|
|
109
|
-
overrideAuth: pluginConfig.overrideAuth,
|
|
110
|
-
userCollection:
|
|
111
|
-
pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',
|
|
105
|
+
overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP,
|
|
112
106
|
}
|
|
113
107
|
}
|
|
114
108
|
|
|
@@ -119,27 +113,43 @@ const sanitizeCollectionConfig = ({
|
|
|
119
113
|
collection: CollectionConfig | SanitizedCollectionConfig
|
|
120
114
|
pluginConfig: MCPPluginConfig
|
|
121
115
|
}): CollectionMCPItem[] => {
|
|
122
|
-
if (collection.slug === 'payload-mcp-api-keys') {
|
|
123
|
-
return []
|
|
124
|
-
}
|
|
125
116
|
const slug = collection.slug
|
|
126
117
|
const collectionPluginConfig = pluginConfig.collections?.[slug]
|
|
127
118
|
const items: CollectionMCPItem[] = []
|
|
119
|
+
/**
|
|
120
|
+
* Payload disables duplicate for auth collections by default unless the
|
|
121
|
+
* collection explicitly opts back in with `disableDuplicate: false`.
|
|
122
|
+
*/
|
|
123
|
+
const isDuplicateDisabled =
|
|
124
|
+
collection.disableDuplicate === true ||
|
|
125
|
+
(Boolean(collection.auth) && collection.disableDuplicate !== false)
|
|
128
126
|
|
|
129
|
-
for (const [
|
|
127
|
+
for (const [
|
|
128
|
+
toolKey,
|
|
129
|
+
{ mcpName, requiresDuplicateEnabled, requiresVersions, tool },
|
|
130
|
+
] of COLLECTION_BUILTIN_ENTRIES) {
|
|
131
|
+
if (requiresVersions && !collection.versions) {
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
if (requiresDuplicateEnabled && isDuplicateDisabled) {
|
|
135
|
+
continue
|
|
136
|
+
}
|
|
130
137
|
const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]
|
|
131
138
|
if (matchedConfigEntry === false) {
|
|
132
139
|
continue
|
|
133
140
|
}
|
|
134
141
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
142
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
135
143
|
items.push({
|
|
136
144
|
type: 'collectionTool',
|
|
137
145
|
collectionSlug: slug,
|
|
138
146
|
configKey: toolKey,
|
|
139
|
-
label:
|
|
147
|
+
label: annotations.title ?? toolKey,
|
|
140
148
|
mcpName,
|
|
141
149
|
tool: {
|
|
142
150
|
...tool,
|
|
151
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
152
|
+
annotations,
|
|
143
153
|
description: override?.description ?? tool.description,
|
|
144
154
|
overrideResponse:
|
|
145
155
|
override?.overrideResponse ??
|
|
@@ -150,21 +160,24 @@ const sanitizeCollectionConfig = ({
|
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
if (collection.auth) {
|
|
153
|
-
for (const [authToolKey, {
|
|
163
|
+
for (const [authToolKey, { mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {
|
|
154
164
|
const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]
|
|
155
165
|
if (!matchedConfigEntry) {
|
|
156
166
|
continue
|
|
157
167
|
}
|
|
158
168
|
// `true` means "enable, no override"; only the object form carries fields.
|
|
159
169
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
170
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
160
171
|
items.push({
|
|
161
172
|
type: 'collectionTool',
|
|
162
173
|
collectionSlug: slug,
|
|
163
174
|
configKey: authToolKey,
|
|
164
|
-
label,
|
|
175
|
+
label: annotations.title ?? authToolKey,
|
|
165
176
|
mcpName,
|
|
166
177
|
tool: {
|
|
167
178
|
...tool,
|
|
179
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
180
|
+
annotations,
|
|
168
181
|
description: override?.description ?? tool.description,
|
|
169
182
|
overrideResponse:
|
|
170
183
|
override?.overrideResponse ??
|
|
@@ -191,9 +204,9 @@ const sanitizeCollectionConfig = ({
|
|
|
191
204
|
type: 'collectionTool',
|
|
192
205
|
collectionSlug: slug,
|
|
193
206
|
configKey,
|
|
194
|
-
label: configKey,
|
|
207
|
+
label: customTool.annotations?.title ?? configKey,
|
|
195
208
|
mcpName: configKey,
|
|
196
|
-
tool: customTool,
|
|
209
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
197
210
|
})
|
|
198
211
|
}
|
|
199
212
|
|
|
@@ -211,20 +224,26 @@ const sanitizeGlobalConfig = ({
|
|
|
211
224
|
const globalPluginConfig = pluginConfig.globals?.[slug]
|
|
212
225
|
const items: GlobalMCPItem[] = []
|
|
213
226
|
|
|
214
|
-
for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
227
|
+
for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
228
|
+
if (requiresVersions && !global.versions) {
|
|
229
|
+
continue
|
|
230
|
+
}
|
|
215
231
|
const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]
|
|
216
232
|
if (matchedConfigEntry === false) {
|
|
217
233
|
continue
|
|
218
234
|
}
|
|
219
235
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
236
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
220
237
|
items.push({
|
|
221
238
|
type: 'globalTool',
|
|
222
239
|
configKey: toolKey,
|
|
223
240
|
globalSlug: slug,
|
|
224
|
-
label:
|
|
241
|
+
label: annotations.title ?? toolKey,
|
|
225
242
|
mcpName,
|
|
226
243
|
tool: {
|
|
227
244
|
...tool,
|
|
245
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
246
|
+
annotations,
|
|
228
247
|
description: override?.description ?? tool.description,
|
|
229
248
|
overrideResponse:
|
|
230
249
|
override?.overrideResponse ??
|
|
@@ -248,13 +267,11 @@ const sanitizeGlobalConfig = ({
|
|
|
248
267
|
type: 'globalTool',
|
|
249
268
|
configKey,
|
|
250
269
|
globalSlug: slug,
|
|
251
|
-
label: configKey,
|
|
270
|
+
label: customTool.annotations?.title ?? configKey,
|
|
252
271
|
mcpName: configKey,
|
|
253
|
-
tool: customTool,
|
|
272
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
254
273
|
})
|
|
255
274
|
}
|
|
256
275
|
|
|
257
276
|
return items
|
|
258
277
|
}
|
|
259
|
-
|
|
260
|
-
const capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1)
|