@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
package/src/endpoint/access.ts
CHANGED
|
@@ -1,144 +1,119 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PayloadRequest, SanitizedPermissions } from 'payload'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { UnauthorizedError } from 'payload'
|
|
3
|
+
import { getAccessResults, UnauthorizedError } from 'payload'
|
|
5
4
|
|
|
6
|
-
import type { AuthorizedMCP,
|
|
5
|
+
import type { AuthorizedMCP, MCPItem } from '../types.js'
|
|
7
6
|
|
|
8
|
-
import { getLogger } from '../utils/getLogger.js'
|
|
9
7
|
import { getPluginConfig } from '../utils/getPluginConfig.js'
|
|
10
8
|
|
|
9
|
+
export type GetAuthorizedMCPArgs = {
|
|
10
|
+
overrideAccess: boolean
|
|
11
|
+
req: PayloadRequest
|
|
12
|
+
}
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
|
-
* Resolves the
|
|
13
|
-
*
|
|
15
|
+
* Resolves the MCP caller and returns the MCP surface authorized for that request.
|
|
16
|
+
*
|
|
17
|
+
* Authorization has two layers:
|
|
18
|
+
* 1. Payload collection/global permissions determine whether built-in operation tools are shown.
|
|
19
|
+
* 2. MCP `access` callbacks can further hide any configured tool, prompt, or resource.
|
|
20
|
+
*
|
|
21
|
+
* Like Payload core operations, `overrideAccess` skips both layers.
|
|
14
22
|
*/
|
|
15
|
-
export const getAuthorizedMCP: (args:
|
|
23
|
+
export const getAuthorizedMCP: (args: GetAuthorizedMCPArgs) => Promise<AuthorizedMCP> = async ({
|
|
24
|
+
overrideAccess,
|
|
16
25
|
req,
|
|
17
26
|
}) => {
|
|
18
|
-
const logger = getLogger({ payload: req.payload })
|
|
19
27
|
const pluginConfig = getPluginConfig({ config: req.payload.config })
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const buildAuthorized = (apiKeyDoc: MCPAPIKeysDoc): AuthorizedMCP => ({
|
|
25
|
-
items: pluginConfig.items.filter((item) => {
|
|
26
|
-
switch (item.type) {
|
|
27
|
-
case 'collectionTool':
|
|
28
|
-
return apiKeyDoc.access.collections?.[item.collectionSlug]?.[item.configKey] !== false
|
|
29
|
-
case 'globalTool':
|
|
30
|
-
return apiKeyDoc.access.globals?.[item.globalSlug]?.[item.configKey] !== false
|
|
31
|
-
case 'prompt':
|
|
32
|
-
return apiKeyDoc.access.prompts?.[item.configKey] !== false
|
|
33
|
-
case 'resource':
|
|
34
|
-
return apiKeyDoc.access.resources?.[item.configKey] !== false
|
|
35
|
-
case 'tool':
|
|
36
|
-
return apiKeyDoc.access.tools?.[item.configKey] !== false
|
|
37
|
-
}
|
|
38
|
-
}),
|
|
39
|
-
overrideAccess:
|
|
40
|
-
typeof apiKeyDoc.overrideAccess === 'boolean' ? apiKeyDoc.overrideAccess : false,
|
|
41
|
-
user: apiKeyDoc.user,
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
if (pluginConfig.overrideAuth) {
|
|
45
|
-
return await pluginConfig.overrideAuth({
|
|
46
|
-
getAPIKeyDoc: (overrideApiKey) => getAPIKeyDoc({ logger, overrideApiKey, pluginConfig, req }),
|
|
47
|
-
getAuthorizedMCP: ({ apiKeyDoc }) => buildAuthorized(apiKeyDoc),
|
|
29
|
+
if (pluginConfig.overrideGetAuthorizedMCP) {
|
|
30
|
+
return await pluginConfig.overrideGetAuthorizedMCP({
|
|
31
|
+
overrideAccess,
|
|
48
32
|
pluginConfig,
|
|
49
33
|
req,
|
|
50
34
|
})
|
|
51
35
|
}
|
|
52
36
|
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
if (req.headers) {
|
|
38
|
+
const headers = new Headers(req.headers)
|
|
39
|
+
const hasAuthorization = headers.has('Authorization')
|
|
40
|
+
|
|
41
|
+
headers.set('DisableAutologin', 'true')
|
|
42
|
+
req.user = (await req.payload.auth({ headers, req })).user
|
|
43
|
+
|
|
44
|
+
if (hasAuthorization && !req.user) {
|
|
45
|
+
throw new UnauthorizedError(req.t)
|
|
46
|
+
}
|
|
61
47
|
}
|
|
62
48
|
|
|
63
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
items: await filterMCPItems({
|
|
51
|
+
items: pluginConfig.items,
|
|
52
|
+
overrideAccess,
|
|
53
|
+
req,
|
|
54
|
+
}),
|
|
55
|
+
overrideAccess,
|
|
56
|
+
user: req.user,
|
|
57
|
+
}
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
pluginConfig,
|
|
60
|
+
export const filterMCPItems = async ({
|
|
61
|
+
items,
|
|
62
|
+
overrideAccess,
|
|
70
63
|
req,
|
|
71
64
|
}: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
pluginConfig: ReturnType<typeof getPluginConfig>
|
|
65
|
+
items: MCPItem[]
|
|
66
|
+
overrideAccess: boolean
|
|
75
67
|
req: PayloadRequest
|
|
76
|
-
}): Promise<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
overrideApiKey ?? (hasBearerToken ? authHeader?.replace('Bearer ', '').trim() || null : null)
|
|
82
|
-
|
|
83
|
-
if (!apiKey) {
|
|
84
|
-
throw new UnauthorizedError()
|
|
68
|
+
}): Promise<MCPItem[]> => {
|
|
69
|
+
// Match Payload core: overrideAccess bypasses access evaluation instead of
|
|
70
|
+
// forcing each access function to return true.
|
|
71
|
+
if (overrideAccess) {
|
|
72
|
+
return items
|
|
85
73
|
}
|
|
86
74
|
|
|
87
|
-
const
|
|
88
|
-
.createHmac('sha256', req.payload.secret)
|
|
89
|
-
.update(apiKey)
|
|
90
|
-
.digest('hex')
|
|
91
|
-
|
|
92
|
-
const doc = await req.payload.db.findOne<MCPAPIKeysDoc>({
|
|
93
|
-
collection: 'payload-mcp-api-keys',
|
|
94
|
-
req,
|
|
95
|
-
where: {
|
|
96
|
-
apiKeyIndex: { equals: sha256APIKeyIndex },
|
|
97
|
-
},
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
if (!doc || !doc.user) {
|
|
101
|
-
throw new UnauthorizedError()
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
logger.info('API Key is valid')
|
|
75
|
+
const authorizedItems: MCPItem[] = []
|
|
105
76
|
|
|
106
|
-
const
|
|
107
|
-
const userID =
|
|
108
|
-
typeof userRef === 'object' && userRef !== null && 'id' in userRef
|
|
109
|
-
? userRef.id
|
|
110
|
-
: (userRef as unknown as DefaultDocumentIDType)
|
|
77
|
+
const permissions = await getAccessResults({ req })
|
|
111
78
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
req,
|
|
118
|
-
})) as null | TypedUser
|
|
119
|
-
|
|
120
|
-
if (!user) {
|
|
121
|
-
throw new UnauthorizedError()
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
if (!(await checkItemAccess({ item, permissions, req }))) {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
authorizedItems.push(item)
|
|
122
84
|
}
|
|
123
85
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
id: doc.id,
|
|
127
|
-
collection: 'payload-mcp-api-keys',
|
|
128
|
-
data: { lastUsed: new Date().toISOString() },
|
|
129
|
-
req,
|
|
130
|
-
returning: false,
|
|
131
|
-
})
|
|
132
|
-
} catch (err) {
|
|
133
|
-
logger.warn({ err, msg: 'Failed to update MCP API key last-used timestamp' })
|
|
134
|
-
}
|
|
86
|
+
return authorizedItems
|
|
87
|
+
}
|
|
135
88
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Runs MCP item access callbacks
|
|
91
|
+
*/
|
|
92
|
+
const checkItemAccess = async ({
|
|
93
|
+
item,
|
|
94
|
+
permissions,
|
|
95
|
+
req,
|
|
96
|
+
}: {
|
|
97
|
+
item: MCPItem
|
|
98
|
+
permissions?: SanitizedPermissions
|
|
99
|
+
req: PayloadRequest
|
|
100
|
+
}): Promise<boolean> => {
|
|
101
|
+
switch (item.type) {
|
|
102
|
+
case 'collectionTool':
|
|
103
|
+
return (
|
|
104
|
+
!item.tool.access ||
|
|
105
|
+
(await item.tool.access({ collectionSlug: item.collectionSlug, permissions, req }))
|
|
106
|
+
)
|
|
107
|
+
case 'globalTool':
|
|
108
|
+
return (
|
|
109
|
+
!item.tool.access ||
|
|
110
|
+
(await item.tool.access({ globalSlug: item.globalSlug, permissions, req }))
|
|
111
|
+
)
|
|
112
|
+
case 'prompt':
|
|
113
|
+
return !item.prompt.access || (await item.prompt.access({ permissions, req }))
|
|
114
|
+
case 'resource':
|
|
115
|
+
return !item.resource.access || (await item.resource.access({ permissions, req }))
|
|
116
|
+
case 'tool':
|
|
117
|
+
return !item.tool.access || (await item.tool.access({ permissions, req }))
|
|
143
118
|
}
|
|
144
119
|
}
|
package/src/endpoint/index.ts
CHANGED
|
@@ -13,7 +13,20 @@ export const mcpEndpoint: PayloadHandler = async (req) => {
|
|
|
13
13
|
req.payloadAPI = 'MCP' as const
|
|
14
14
|
|
|
15
15
|
const pluginConfig = getPluginConfig({ config: req.payload.config })
|
|
16
|
-
const
|
|
16
|
+
const overrideAccessParam = new URL(req.url).searchParams.get('overrideAccess')
|
|
17
|
+
|
|
18
|
+
if (overrideAccessParam !== null && process.env.NODE_ENV !== 'development') {
|
|
19
|
+
throw new APIError('MCP overrideAccess is only available in development.', 400)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let overrideAccess = false
|
|
23
|
+
if (overrideAccessParam === 'true') {
|
|
24
|
+
overrideAccess = true
|
|
25
|
+
} else if (overrideAccessParam !== null && overrideAccessParam !== 'false') {
|
|
26
|
+
throw new APIError('MCP overrideAccess must be "true" or "false".', 400)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
|
|
17
30
|
|
|
18
31
|
const server = buildMcpServer({ authorizedMCP, pluginConfig, req })
|
|
19
32
|
|
package/src/exports/client.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export { APIKeysEmptyState } from '../components/APIKeysEmptyState/index.client.js'
|
|
5
|
-
export { MCPSettingsMenu } from '../components/SettingsMenu/index.client.js'
|
|
2
|
+
|
|
3
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { filterMCPItems, getAuthorizedMCP } from '../endpoint/access.js'
|
package/src/index.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { definePlugin } from 'payload'
|
|
2
2
|
|
|
3
|
-
import { defaultUserCollection, definePlugin } from 'payload'
|
|
4
|
-
|
|
5
|
-
import type { PluginDefaultTranslationsObject } from './translations/types.js'
|
|
6
3
|
import type { AuthorizedMCP, MCPPluginConfig, SanitizedMCPPluginConfig } from './types.js'
|
|
7
4
|
|
|
8
|
-
import { getAPIKeysCollection } from './collection/index.js'
|
|
9
5
|
import { mcpEndpoint } from './endpoint/index.js'
|
|
10
6
|
import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'
|
|
11
|
-
import { translations } from './translations/index.js'
|
|
12
7
|
|
|
13
8
|
declare module 'payload' {
|
|
14
9
|
export interface PayloadRequest {
|
|
@@ -28,15 +23,6 @@ export const mcpPlugin = definePlugin<MCPPluginConfig>({
|
|
|
28
23
|
slug: '@payloadcms/plugin-mcp',
|
|
29
24
|
order: 10,
|
|
30
25
|
plugin: ({ config, plugins, ...rawConfig }) => {
|
|
31
|
-
// If a project has no auth collection yet, add the default users collection
|
|
32
|
-
// so the relationship target and default `userCollection` exist.
|
|
33
|
-
if (!config.admin?.user) {
|
|
34
|
-
const firstCollectionWithAuth = (config.collections ?? []).find(({ auth }) => Boolean(auth))
|
|
35
|
-
if (!firstCollectionWithAuth) {
|
|
36
|
-
;(config.collections ??= []).push(defaultUserCollection)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
26
|
const pluginConfig = sanitizeMCPConfig({ config, pluginConfig: rawConfig })
|
|
41
27
|
|
|
42
28
|
// Stash the sanitized config on plugin options so `getPluginConfig()` reads it.
|
|
@@ -46,52 +32,12 @@ export const mcpPlugin = definePlugin<MCPPluginConfig>({
|
|
|
46
32
|
registered.sanitizedOptions = pluginConfig as unknown as typeof registered.options
|
|
47
33
|
}
|
|
48
34
|
|
|
49
|
-
;(config.collections ??= []).push(getAPIKeysCollection({ pluginConfig }))
|
|
50
|
-
|
|
51
|
-
if (!config.i18n) {
|
|
52
|
-
config.i18n = {}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!config.i18n.translations) {
|
|
56
|
-
config.i18n.translations = {}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const supportedLanguageKeys = config.i18n.supportedLanguages
|
|
60
|
-
? Object.keys(config.i18n.supportedLanguages)
|
|
61
|
-
: ['en']
|
|
62
|
-
|
|
63
|
-
for (const lang of supportedLanguageKeys) {
|
|
64
|
-
const pluginEntry = translations[lang as keyof typeof translations]
|
|
65
|
-
if (!pluginEntry) {
|
|
66
|
-
continue
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const typedLocale = lang as AcceptedLanguages
|
|
70
|
-
const existing = (config.i18n.translations[typedLocale] ?? {}) as Record<string, unknown>
|
|
71
|
-
config.i18n.translations[typedLocale] = {
|
|
72
|
-
...existing,
|
|
73
|
-
'plugin-mcp': pluginEntry.translations['plugin-mcp'],
|
|
74
|
-
} as PluginDefaultTranslationsObject
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Keep the API-keys collection registered even when disabled, so DB schema
|
|
78
|
-
// and generated types don't drift between enabled/disabled environments.
|
|
79
35
|
if (pluginConfig.disabled) {
|
|
80
36
|
return config
|
|
81
37
|
}
|
|
82
38
|
|
|
83
39
|
return {
|
|
84
40
|
...config,
|
|
85
|
-
admin: {
|
|
86
|
-
...config.admin,
|
|
87
|
-
components: {
|
|
88
|
-
...config.admin?.components,
|
|
89
|
-
userMenuSettingsItems: [
|
|
90
|
-
...(config.admin?.components?.userMenuSettingsItems ?? []),
|
|
91
|
-
'@payloadcms/plugin-mcp/client#MCPSettingsMenu',
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
41
|
endpoints: [
|
|
96
42
|
...(config.endpoints ?? []),
|
|
97
43
|
// Payload prefixes /api, so the full path is /api/mcp.
|
|
@@ -109,7 +109,12 @@ export const buildMcpServer = ({
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const handlerArgs = {
|
|
112
|
+
const handlerArgs = {
|
|
113
|
+
authorizedMCP,
|
|
114
|
+
input: toolInput,
|
|
115
|
+
req,
|
|
116
|
+
serverContext,
|
|
117
|
+
}
|
|
113
118
|
const response = await (match.type === 'collectionTool'
|
|
114
119
|
? match.tool.handler({ ...handlerArgs, collectionSlug: slug })
|
|
115
120
|
: match.tool.handler({ ...handlerArgs, globalSlug: slug }))
|
|
@@ -137,6 +142,7 @@ export const buildMcpServer = ({
|
|
|
137
142
|
server.registerTool(
|
|
138
143
|
item.mcpName,
|
|
139
144
|
{
|
|
145
|
+
annotations: item.tool.annotations,
|
|
140
146
|
description: item.tool.description,
|
|
141
147
|
inputSchema: toStandardSchema(inputSchema),
|
|
142
148
|
},
|
|
@@ -193,6 +199,7 @@ export const buildMcpServer = ({
|
|
|
193
199
|
server.registerTool(
|
|
194
200
|
item.mcpName,
|
|
195
201
|
{
|
|
202
|
+
annotations: tool.annotations,
|
|
196
203
|
description: tool.description,
|
|
197
204
|
inputSchema: tool.input ? toStandardSchema(tool.input) : undefined,
|
|
198
205
|
},
|
|
@@ -32,13 +32,18 @@ const wrapError =
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const authCollectionTool = defineCollectionTool({
|
|
35
|
+
annotations: {
|
|
36
|
+
destructiveHint: false,
|
|
37
|
+
idempotentHint: true,
|
|
38
|
+
openWorldHint: false,
|
|
39
|
+
readOnlyHint: true,
|
|
40
|
+
title: 'Check Auth Status',
|
|
41
|
+
},
|
|
35
42
|
description: 'Checks authentication status for the current user.',
|
|
36
43
|
input: z.object({
|
|
37
44
|
headers: z
|
|
38
|
-
.string()
|
|
39
|
-
.describe(
|
|
40
|
-
'Optional JSON string containing custom headers to send with the authentication request',
|
|
41
|
-
)
|
|
45
|
+
.record(z.string(), z.string())
|
|
46
|
+
.describe('Optional custom headers to send with the authentication request')
|
|
42
47
|
.optional(),
|
|
43
48
|
}),
|
|
44
49
|
}).handler(async ({ collectionSlug, input, req }) => {
|
|
@@ -46,11 +51,7 @@ export const authCollectionTool = defineCollectionTool({
|
|
|
46
51
|
try {
|
|
47
52
|
let authHeaders = new Headers()
|
|
48
53
|
if (input.headers) {
|
|
49
|
-
|
|
50
|
-
authHeaders = new Headers(JSON.parse(input.headers) as Record<string, string>)
|
|
51
|
-
} catch {
|
|
52
|
-
logger.warn(`Invalid headers JSON for auth: ${input.headers}, using empty headers`)
|
|
53
|
-
}
|
|
54
|
+
authHeaders = new Headers(input.headers)
|
|
54
55
|
}
|
|
55
56
|
const result = await req.payload.auth({ headers: authHeaders })
|
|
56
57
|
return {
|
|
@@ -70,6 +71,13 @@ export const authCollectionTool = defineCollectionTool({
|
|
|
70
71
|
})
|
|
71
72
|
|
|
72
73
|
export const forgotPasswordCollectionTool = defineCollectionTool({
|
|
74
|
+
annotations: {
|
|
75
|
+
destructiveHint: false,
|
|
76
|
+
idempotentHint: false,
|
|
77
|
+
openWorldHint: true,
|
|
78
|
+
readOnlyHint: false,
|
|
79
|
+
title: 'Forgot Password',
|
|
80
|
+
},
|
|
73
81
|
description: 'Sends a password reset email to a user.',
|
|
74
82
|
input: z.object({
|
|
75
83
|
disableEmail: z
|
|
@@ -104,6 +112,13 @@ export const forgotPasswordCollectionTool = defineCollectionTool({
|
|
|
104
112
|
})
|
|
105
113
|
|
|
106
114
|
export const loginCollectionTool = defineCollectionTool({
|
|
115
|
+
annotations: {
|
|
116
|
+
destructiveHint: false,
|
|
117
|
+
idempotentHint: false,
|
|
118
|
+
openWorldHint: false,
|
|
119
|
+
readOnlyHint: false,
|
|
120
|
+
title: 'User Login',
|
|
121
|
+
},
|
|
107
122
|
description: 'Authenticates a user with email and password.',
|
|
108
123
|
input: z.object({
|
|
109
124
|
depth: z
|
|
@@ -148,6 +163,13 @@ export const loginCollectionTool = defineCollectionTool({
|
|
|
148
163
|
})
|
|
149
164
|
|
|
150
165
|
export const resetPasswordCollectionTool = defineCollectionTool({
|
|
166
|
+
annotations: {
|
|
167
|
+
destructiveHint: false,
|
|
168
|
+
idempotentHint: false,
|
|
169
|
+
openWorldHint: false,
|
|
170
|
+
readOnlyHint: false,
|
|
171
|
+
title: 'Reset Password',
|
|
172
|
+
},
|
|
151
173
|
description: 'Resets a user password with a reset token.',
|
|
152
174
|
input: z.object({
|
|
153
175
|
password: z.string().describe('The new password for the user'),
|
|
@@ -178,6 +200,13 @@ export const resetPasswordCollectionTool = defineCollectionTool({
|
|
|
178
200
|
})
|
|
179
201
|
|
|
180
202
|
export const unlockCollectionTool = defineCollectionTool({
|
|
203
|
+
annotations: {
|
|
204
|
+
destructiveHint: false,
|
|
205
|
+
idempotentHint: true,
|
|
206
|
+
openWorldHint: false,
|
|
207
|
+
readOnlyHint: false,
|
|
208
|
+
title: 'Unlock Account',
|
|
209
|
+
},
|
|
181
210
|
description: 'Unlocks a user account that has been locked due to failed login attempts.',
|
|
182
211
|
input: z.object({ email: emailSchema }),
|
|
183
212
|
}).handler(async ({ collectionSlug, input, req }) => {
|
|
@@ -205,6 +234,13 @@ export const unlockCollectionTool = defineCollectionTool({
|
|
|
205
234
|
})
|
|
206
235
|
|
|
207
236
|
export const verifyCollectionTool = defineCollectionTool({
|
|
237
|
+
annotations: {
|
|
238
|
+
destructiveHint: false,
|
|
239
|
+
idempotentHint: false,
|
|
240
|
+
openWorldHint: false,
|
|
241
|
+
readOnlyHint: false,
|
|
242
|
+
title: 'Email Verification',
|
|
243
|
+
},
|
|
208
244
|
description: 'Verifies a user email with a verification token.',
|
|
209
245
|
input: z.object({
|
|
210
246
|
token: z.string().describe('The verification token sent to the user email'),
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
4
|
+
import { defineCollectionTool } 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 documents in any collection by passing the collection slug and optional where clause.'
|
|
11
|
+
|
|
12
|
+
export const countDocumentsTool = defineCollectionTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.read),
|
|
15
|
+
annotations: {
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
idempotentHint: true,
|
|
18
|
+
openWorldHint: false,
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
title: 'Count Documents',
|
|
21
|
+
},
|
|
22
|
+
description: DEFAULT_DESCRIPTION,
|
|
23
|
+
input: z.object({
|
|
24
|
+
locale: z.string().describe('Optional: locale code to count documents in').optional(),
|
|
25
|
+
trash: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.describe('Optional: include soft-deleted documents when trash is enabled on the collection')
|
|
28
|
+
.optional(),
|
|
29
|
+
where: whereSchema
|
|
30
|
+
.describe(
|
|
31
|
+
'Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
32
|
+
)
|
|
33
|
+
.optional(),
|
|
34
|
+
}),
|
|
35
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
36
|
+
const payload = req.payload
|
|
37
|
+
const logger = getLogger({ payload })
|
|
38
|
+
const { locale, trash, where } = input
|
|
39
|
+
|
|
40
|
+
logger.info(`Counting documents in collection: ${collectionSlug}`)
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const result = await payload.count({
|
|
44
|
+
collection: collectionSlug,
|
|
45
|
+
req,
|
|
46
|
+
...localAPIDefaults(authorizedMCP),
|
|
47
|
+
...(locale ? { locale } : {}),
|
|
48
|
+
...(trash !== undefined ? { trash } : {}),
|
|
49
|
+
...(where ? { where } : {}),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
text: `Collection "${collectionSlug}" contains ${result.totalDocs} matching documents.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
doc: result,
|
|
60
|
+
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
63
|
+
logger.error(`Error counting documents in ${collectionSlug}: ${errorMessage}`)
|
|
64
|
+
return {
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `❌ **Error counting documents in collection "${collectionSlug}":** ${errorMessage}`,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
isError: true,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
4
|
+
import { defineCollectionTool } 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 document versions in any version-enabled collection by passing the collection slug and optional where clause.'
|
|
11
|
+
|
|
12
|
+
export const countVersionsTool = defineCollectionTool({
|
|
13
|
+
access: (args) =>
|
|
14
|
+
defaultAccess(args) &&
|
|
15
|
+
Boolean(args.permissions?.collections?.[args.collectionSlug]?.readVersions),
|
|
16
|
+
annotations: {
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
readOnlyHint: true,
|
|
21
|
+
title: 'Count Versions',
|
|
22
|
+
},
|
|
23
|
+
description: DEFAULT_DESCRIPTION,
|
|
24
|
+
input: z.object({
|
|
25
|
+
locale: z.string().describe('Optional: locale code to count versions in').optional(),
|
|
26
|
+
where: whereSchema
|
|
27
|
+
.describe(
|
|
28
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.title":{"contains":"test"}}',
|
|
29
|
+
)
|
|
30
|
+
.optional(),
|
|
31
|
+
}),
|
|
32
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
33
|
+
const payload = req.payload
|
|
34
|
+
const logger = getLogger({ payload })
|
|
35
|
+
const { locale, where } = input
|
|
36
|
+
|
|
37
|
+
logger.info(`Counting versions in collection: ${collectionSlug}`)
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const result = await payload.countVersions({
|
|
41
|
+
collection: collectionSlug,
|
|
42
|
+
req,
|
|
43
|
+
...localAPIDefaults(authorizedMCP),
|
|
44
|
+
...(locale ? { locale } : {}),
|
|
45
|
+
...(where ? { where } : {}),
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: `Collection "${collectionSlug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
doc: result,
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
59
|
+
logger.error(`Error counting versions in ${collectionSlug}: ${errorMessage}`)
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'text',
|
|
64
|
+
text: `❌ **Error counting versions in collection "${collectionSlug}":** ${errorMessage}`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
isError: true,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|