@payloadcms/plugin-mcp 4.0.0-canary.2 → 4.0.0-canary.20261117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/defaultAccess.d.ts +3 -0
- package/dist/defaultAccess.d.ts.map +1 -0
- package/dist/defaultAccess.js +3 -0
- package/dist/defaultAccess.js.map +1 -0
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +29 -6
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +133 -100
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +121 -16
- package/dist/endpoint/index.js.map +1 -1
- package/dist/endpoint/oauth.d.ts +37 -0
- package/dist/endpoint/oauth.d.ts.map +1 -0
- package/dist/endpoint/oauth.js +105 -0
- package/dist/endpoint/oauth.js.map +1 -0
- package/dist/endpoint/oauthLoginToken.d.ts +27 -0
- package/dist/endpoint/oauthLoginToken.d.ts.map +1 -0
- package/dist/endpoint/oauthLoginToken.js +86 -0
- package/dist/endpoint/oauthLoginToken.js.map +1 -0
- package/dist/endpoint/oauthServer.d.ts +28 -0
- package/dist/endpoint/oauthServer.d.ts.map +1 -0
- package/dist/endpoint/oauthServer.js +455 -0
- package/dist/endpoint/oauthServer.js.map +1 -0
- 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/exports/rsc.d.ts +2 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -55
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +6 -6
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +70 -34
- 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 +123 -61
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countTool.js +63 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +60 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +109 -66
- 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 +56 -45
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +90 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +88 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +77 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +58 -56
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +74 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +84 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +78 -10
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +69 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +75 -102
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
- package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
- package/dist/mcp/builtin/formatEntityError.js +55 -0
- package/dist/mcp/builtin/formatEntityError.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +30 -10
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +60 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +26 -35
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +68 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +78 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +56 -10
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +70 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +38 -54
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +75 -12
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +75 -13
- 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 +76 -27
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +86 -47
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +224 -95
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getPluginConfig.d.ts +1 -1
- package/dist/utils/getPluginConfig.js +1 -1
- package/dist/utils/getPluginConfig.js.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/seal.d.ts +17 -0
- package/dist/utils/seal.d.ts.map +1 -0
- package/dist/utils/seal.js +24 -0
- package/dist/utils/seal.js.map +1 -0
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/dist/utils/toStandardSchema.js.map +1 -1
- package/dist/views/Authorize/AllowButtons/index.d.ts +18 -0
- package/dist/views/Authorize/AllowButtons/index.d.ts.map +1 -0
- package/dist/views/Authorize/AllowButtons/index.js +88 -0
- package/dist/views/Authorize/AllowButtons/index.js.map +1 -0
- package/dist/views/Authorize/index.css +19 -0
- package/dist/views/Authorize/index.d.ts +9 -0
- package/dist/views/Authorize/index.d.ts.map +1 -0
- package/dist/views/Authorize/index.js +98 -0
- package/dist/views/Authorize/index.js.map +1 -0
- package/package.json +34 -38
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +149 -109
- package/src/endpoint/index.ts +103 -15
- package/src/endpoint/oauth.ts +108 -0
- package/src/endpoint/oauthLoginToken.ts +100 -0
- package/src/endpoint/oauthServer.ts +472 -0
- package/src/exports/client.ts +2 -4
- package/src/exports/internal.ts +1 -0
- package/src/exports/rsc.ts +1 -0
- package/src/index.ts +53 -63
- package/src/mcp/buildMcpServer.ts +88 -51
- package/src/mcp/builtin/collections/authTools.ts +124 -77
- package/src/mcp/builtin/collections/countTool.ts +61 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/collections/createTool.ts +113 -82
- package/src/mcp/builtin/collections/deleteTool.ts +49 -66
- package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +127 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
- package/src/mcp/builtin/collections/findTool.ts +54 -97
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +70 -7
- package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
- package/src/mcp/builtin/collections/updateTool.ts +72 -110
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/formatEntityError.ts +77 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +29 -5
- package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/globals/findTool.ts +27 -57
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +52 -7
- package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
- package/src/mcp/builtin/globals/updateTool.ts +49 -72
- package/src/mcp/builtinTools.ts +81 -18
- package/src/mcp/sanitizeMCPConfig.ts +53 -30
- package/src/stdio.ts +80 -47
- package/src/types.ts +232 -99
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/seal.ts +46 -0
- package/src/utils/toStandardSchema.ts +1 -1
- package/src/views/Authorize/AllowButtons/index.tsx +97 -0
- package/src/views/Authorize/index.css +19 -0
- package/src/views/Authorize/index.tsx +100 -0
- 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/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
- package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
- package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
- package/dist/mcp/builtin/validateEntityData.js +0 -82
- package/dist/mcp/builtin/validateEntityData.js.map +0 -1
- package/dist/translations/index.d.ts +0 -11
- package/dist/translations/index.d.ts.map +0 -1
- package/dist/translations/index.js +0 -92
- package/dist/translations/index.js.map +0 -1
- package/dist/translations/languages/ar.d.ts +0 -31
- package/dist/translations/languages/ar.d.ts.map +0 -1
- package/dist/translations/languages/ar.js +0 -34
- package/dist/translations/languages/ar.js.map +0 -1
- package/dist/translations/languages/az.d.ts +0 -31
- package/dist/translations/languages/az.d.ts.map +0 -1
- package/dist/translations/languages/az.js +0 -34
- package/dist/translations/languages/az.js.map +0 -1
- package/dist/translations/languages/bg.d.ts +0 -31
- package/dist/translations/languages/bg.d.ts.map +0 -1
- package/dist/translations/languages/bg.js +0 -34
- package/dist/translations/languages/bg.js.map +0 -1
- package/dist/translations/languages/bnBd.d.ts +0 -31
- package/dist/translations/languages/bnBd.d.ts.map +0 -1
- package/dist/translations/languages/bnBd.js +0 -34
- package/dist/translations/languages/bnBd.js.map +0 -1
- package/dist/translations/languages/bnIn.d.ts +0 -31
- package/dist/translations/languages/bnIn.d.ts.map +0 -1
- package/dist/translations/languages/bnIn.js +0 -34
- package/dist/translations/languages/bnIn.js.map +0 -1
- package/dist/translations/languages/ca.d.ts +0 -31
- package/dist/translations/languages/ca.d.ts.map +0 -1
- package/dist/translations/languages/ca.js +0 -34
- package/dist/translations/languages/ca.js.map +0 -1
- package/dist/translations/languages/cs.d.ts +0 -31
- package/dist/translations/languages/cs.d.ts.map +0 -1
- package/dist/translations/languages/cs.js +0 -34
- package/dist/translations/languages/cs.js.map +0 -1
- package/dist/translations/languages/da.d.ts +0 -31
- package/dist/translations/languages/da.d.ts.map +0 -1
- package/dist/translations/languages/da.js +0 -34
- package/dist/translations/languages/da.js.map +0 -1
- package/dist/translations/languages/de.d.ts +0 -31
- package/dist/translations/languages/de.d.ts.map +0 -1
- package/dist/translations/languages/de.js +0 -34
- package/dist/translations/languages/de.js.map +0 -1
- package/dist/translations/languages/en.d.ts +0 -31
- package/dist/translations/languages/en.d.ts.map +0 -1
- package/dist/translations/languages/en.js +0 -34
- package/dist/translations/languages/en.js.map +0 -1
- package/dist/translations/languages/es.d.ts +0 -31
- package/dist/translations/languages/es.d.ts.map +0 -1
- package/dist/translations/languages/es.js +0 -34
- package/dist/translations/languages/es.js.map +0 -1
- package/dist/translations/languages/et.d.ts +0 -31
- package/dist/translations/languages/et.d.ts.map +0 -1
- package/dist/translations/languages/et.js +0 -34
- package/dist/translations/languages/et.js.map +0 -1
- package/dist/translations/languages/fa.d.ts +0 -31
- package/dist/translations/languages/fa.d.ts.map +0 -1
- package/dist/translations/languages/fa.js +0 -34
- package/dist/translations/languages/fa.js.map +0 -1
- package/dist/translations/languages/fr.d.ts +0 -31
- package/dist/translations/languages/fr.d.ts.map +0 -1
- package/dist/translations/languages/fr.js +0 -34
- package/dist/translations/languages/fr.js.map +0 -1
- package/dist/translations/languages/he.d.ts +0 -31
- package/dist/translations/languages/he.d.ts.map +0 -1
- package/dist/translations/languages/he.js +0 -34
- package/dist/translations/languages/he.js.map +0 -1
- package/dist/translations/languages/hr.d.ts +0 -31
- package/dist/translations/languages/hr.d.ts.map +0 -1
- package/dist/translations/languages/hr.js +0 -34
- package/dist/translations/languages/hr.js.map +0 -1
- package/dist/translations/languages/hu.d.ts +0 -31
- package/dist/translations/languages/hu.d.ts.map +0 -1
- package/dist/translations/languages/hu.js +0 -34
- package/dist/translations/languages/hu.js.map +0 -1
- package/dist/translations/languages/hy.d.ts +0 -31
- package/dist/translations/languages/hy.d.ts.map +0 -1
- package/dist/translations/languages/hy.js +0 -34
- package/dist/translations/languages/hy.js.map +0 -1
- package/dist/translations/languages/id.d.ts +0 -31
- package/dist/translations/languages/id.d.ts.map +0 -1
- package/dist/translations/languages/id.js +0 -34
- package/dist/translations/languages/id.js.map +0 -1
- package/dist/translations/languages/is.d.ts +0 -31
- package/dist/translations/languages/is.d.ts.map +0 -1
- package/dist/translations/languages/is.js +0 -34
- package/dist/translations/languages/is.js.map +0 -1
- package/dist/translations/languages/it.d.ts +0 -31
- package/dist/translations/languages/it.d.ts.map +0 -1
- package/dist/translations/languages/it.js +0 -34
- package/dist/translations/languages/it.js.map +0 -1
- package/dist/translations/languages/ja.d.ts +0 -31
- package/dist/translations/languages/ja.d.ts.map +0 -1
- package/dist/translations/languages/ja.js +0 -34
- package/dist/translations/languages/ja.js.map +0 -1
- package/dist/translations/languages/ko.d.ts +0 -31
- package/dist/translations/languages/ko.d.ts.map +0 -1
- package/dist/translations/languages/ko.js +0 -34
- package/dist/translations/languages/ko.js.map +0 -1
- package/dist/translations/languages/lt.d.ts +0 -31
- package/dist/translations/languages/lt.d.ts.map +0 -1
- package/dist/translations/languages/lt.js +0 -34
- package/dist/translations/languages/lt.js.map +0 -1
- package/dist/translations/languages/lv.d.ts +0 -31
- package/dist/translations/languages/lv.d.ts.map +0 -1
- package/dist/translations/languages/lv.js +0 -34
- package/dist/translations/languages/lv.js.map +0 -1
- package/dist/translations/languages/my.d.ts +0 -31
- package/dist/translations/languages/my.d.ts.map +0 -1
- package/dist/translations/languages/my.js +0 -34
- package/dist/translations/languages/my.js.map +0 -1
- package/dist/translations/languages/nb.d.ts +0 -31
- package/dist/translations/languages/nb.d.ts.map +0 -1
- package/dist/translations/languages/nb.js +0 -34
- package/dist/translations/languages/nb.js.map +0 -1
- package/dist/translations/languages/nl.d.ts +0 -31
- package/dist/translations/languages/nl.d.ts.map +0 -1
- package/dist/translations/languages/nl.js +0 -34
- package/dist/translations/languages/nl.js.map +0 -1
- package/dist/translations/languages/pl.d.ts +0 -31
- package/dist/translations/languages/pl.d.ts.map +0 -1
- package/dist/translations/languages/pl.js +0 -34
- package/dist/translations/languages/pl.js.map +0 -1
- package/dist/translations/languages/pt.d.ts +0 -31
- package/dist/translations/languages/pt.d.ts.map +0 -1
- package/dist/translations/languages/pt.js +0 -34
- package/dist/translations/languages/pt.js.map +0 -1
- package/dist/translations/languages/ro.d.ts +0 -31
- package/dist/translations/languages/ro.d.ts.map +0 -1
- package/dist/translations/languages/ro.js +0 -34
- package/dist/translations/languages/ro.js.map +0 -1
- package/dist/translations/languages/rs.d.ts +0 -31
- package/dist/translations/languages/rs.d.ts.map +0 -1
- package/dist/translations/languages/rs.js +0 -34
- package/dist/translations/languages/rs.js.map +0 -1
- package/dist/translations/languages/rsLatin.d.ts +0 -31
- package/dist/translations/languages/rsLatin.d.ts.map +0 -1
- package/dist/translations/languages/rsLatin.js +0 -34
- package/dist/translations/languages/rsLatin.js.map +0 -1
- package/dist/translations/languages/ru.d.ts +0 -31
- package/dist/translations/languages/ru.d.ts.map +0 -1
- package/dist/translations/languages/ru.js +0 -34
- package/dist/translations/languages/ru.js.map +0 -1
- package/dist/translations/languages/sk.d.ts +0 -31
- package/dist/translations/languages/sk.d.ts.map +0 -1
- package/dist/translations/languages/sk.js +0 -34
- package/dist/translations/languages/sk.js.map +0 -1
- package/dist/translations/languages/sl.d.ts +0 -31
- package/dist/translations/languages/sl.d.ts.map +0 -1
- package/dist/translations/languages/sl.js +0 -34
- package/dist/translations/languages/sl.js.map +0 -1
- package/dist/translations/languages/sv.d.ts +0 -31
- package/dist/translations/languages/sv.d.ts.map +0 -1
- package/dist/translations/languages/sv.js +0 -34
- package/dist/translations/languages/sv.js.map +0 -1
- package/dist/translations/languages/ta.d.ts +0 -31
- package/dist/translations/languages/ta.d.ts.map +0 -1
- package/dist/translations/languages/ta.js +0 -34
- package/dist/translations/languages/ta.js.map +0 -1
- package/dist/translations/languages/th.d.ts +0 -31
- package/dist/translations/languages/th.d.ts.map +0 -1
- package/dist/translations/languages/th.js +0 -34
- package/dist/translations/languages/th.js.map +0 -1
- package/dist/translations/languages/tr.d.ts +0 -31
- package/dist/translations/languages/tr.d.ts.map +0 -1
- package/dist/translations/languages/tr.js +0 -34
- package/dist/translations/languages/tr.js.map +0 -1
- package/dist/translations/languages/uk.d.ts +0 -31
- package/dist/translations/languages/uk.d.ts.map +0 -1
- package/dist/translations/languages/uk.js +0 -34
- package/dist/translations/languages/uk.js.map +0 -1
- package/dist/translations/languages/vi.d.ts +0 -31
- package/dist/translations/languages/vi.d.ts.map +0 -1
- package/dist/translations/languages/vi.js +0 -34
- package/dist/translations/languages/vi.js.map +0 -1
- package/dist/translations/languages/zh.d.ts +0 -31
- package/dist/translations/languages/zh.d.ts.map +0 -1
- package/dist/translations/languages/zh.js +0 -34
- package/dist/translations/languages/zh.js.map +0 -1
- package/dist/translations/languages/zhTw.d.ts +0 -31
- package/dist/translations/languages/zhTw.d.ts.map +0 -1
- package/dist/translations/languages/zhTw.js +0 -34
- package/dist/translations/languages/zhTw.js.map +0 -1
- package/dist/translations/types.d.ts +0 -32
- package/dist/translations/types.d.ts.map +0 -1
- package/dist/translations/types.js +0 -3
- package/dist/translations/types.js.map +0 -1
- package/dist/utils/getVirtualFieldNames.d.ts +0 -14
- package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
- package/dist/utils/getVirtualFieldNames.js +0 -35
- package/dist/utils/getVirtualFieldNames.js.map +0 -1
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -11
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
- package/dist/utils/transformPointDataToPayload.d.ts +0 -7
- package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
- package/dist/utils/transformPointDataToPayload.js +0 -28
- package/dist/utils/transformPointDataToPayload.js.map +0 -1
- package/dist/utils/whereSchema.d.ts +0 -9
- package/dist/utils/whereSchema.d.ts.map +0 -1
- package/dist/utils/whereSchema.js +0 -13
- package/dist/utils/whereSchema.js.map +0 -1
- package/src/collection/getAccessField.ts +0 -84
- package/src/collection/index.ts +0 -105
- package/src/components/APIKeyField/index.client.tsx +0 -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/mcp/builtin/collections/formatCollectionError.ts +0 -84
- package/src/mcp/builtin/validateEntityData.ts +0 -132
- package/src/translations/index.ts +0 -108
- package/src/translations/languages/ar.ts +0 -35
- package/src/translations/languages/az.ts +0 -35
- package/src/translations/languages/bg.ts +0 -35
- package/src/translations/languages/bnBd.ts +0 -35
- package/src/translations/languages/bnIn.ts +0 -35
- package/src/translations/languages/ca.ts +0 -35
- package/src/translations/languages/cs.ts +0 -35
- package/src/translations/languages/da.ts +0 -35
- package/src/translations/languages/de.ts +0 -35
- package/src/translations/languages/en.ts +0 -35
- package/src/translations/languages/es.ts +0 -35
- package/src/translations/languages/et.ts +0 -35
- package/src/translations/languages/fa.ts +0 -35
- package/src/translations/languages/fr.ts +0 -35
- package/src/translations/languages/he.ts +0 -35
- package/src/translations/languages/hr.ts +0 -35
- package/src/translations/languages/hu.ts +0 -35
- package/src/translations/languages/hy.ts +0 -35
- package/src/translations/languages/id.ts +0 -35
- package/src/translations/languages/is.ts +0 -35
- package/src/translations/languages/it.ts +0 -35
- package/src/translations/languages/ja.ts +0 -35
- package/src/translations/languages/ko.ts +0 -35
- package/src/translations/languages/lt.ts +0 -35
- package/src/translations/languages/lv.ts +0 -35
- package/src/translations/languages/my.ts +0 -35
- package/src/translations/languages/nb.ts +0 -35
- package/src/translations/languages/nl.ts +0 -35
- package/src/translations/languages/pl.ts +0 -35
- package/src/translations/languages/pt.ts +0 -35
- package/src/translations/languages/ro.ts +0 -35
- package/src/translations/languages/rs.ts +0 -35
- package/src/translations/languages/rsLatin.ts +0 -35
- package/src/translations/languages/ru.ts +0 -35
- package/src/translations/languages/sk.ts +0 -35
- package/src/translations/languages/sl.ts +0 -35
- package/src/translations/languages/sv.ts +0 -35
- package/src/translations/languages/ta.ts +0 -35
- package/src/translations/languages/th.ts +0 -35
- package/src/translations/languages/tr.ts +0 -35
- package/src/translations/languages/uk.ts +0 -35
- package/src/translations/languages/vi.ts +0 -35
- package/src/translations/languages/zh.ts +0 -35
- package/src/translations/languages/zhTw.ts +0 -35
- package/src/translations/types.ts +0 -34
- package/src/utils/getVirtualFieldNames.ts +0 -53
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
- package/src/utils/transformPointDataToPayload.ts +0 -40
- package/src/utils/whereSchema.ts +0 -24
package/src/types.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CallToolResult,
|
|
3
3
|
ContentBlock,
|
|
4
|
+
Implementation,
|
|
4
5
|
JsonSchemaType,
|
|
5
|
-
|
|
6
|
+
McpServerOptions,
|
|
6
7
|
ResourceTemplate,
|
|
7
8
|
ServerContext,
|
|
8
9
|
StandardSchemaWithJSON,
|
|
10
|
+
ToolAnnotations,
|
|
9
11
|
} from '@modelcontextprotocol/server'
|
|
10
12
|
import type {
|
|
11
13
|
AuthCollectionSlug,
|
|
12
|
-
CollectionConfig,
|
|
13
14
|
CollectionSlug,
|
|
14
|
-
DefaultDocumentIDType,
|
|
15
15
|
GlobalSlug,
|
|
16
16
|
MaybePromise,
|
|
17
17
|
PayloadRequest,
|
|
18
|
-
|
|
18
|
+
SanitizedPermissions,
|
|
19
19
|
} from 'payload'
|
|
20
20
|
|
|
21
|
+
import type { GetAuthorizedMCPArgs } from './endpoint/access.js'
|
|
21
22
|
import type {
|
|
22
23
|
MCPCollectionAuthToolName,
|
|
23
24
|
MCPCollectionBuiltinName,
|
|
@@ -26,36 +27,16 @@ import type {
|
|
|
26
27
|
|
|
27
28
|
export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }
|
|
28
29
|
|
|
29
|
-
/** Re-exported from `@modelcontextprotocol/server` —
|
|
30
|
-
export type { JsonSchemaType, StandardSchemaWithJSON }
|
|
30
|
+
/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */
|
|
31
|
+
export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
|
|
34
|
-
* JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
35
|
+
* JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
36
|
+
* Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.
|
|
35
37
|
*/
|
|
36
38
|
export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON
|
|
37
39
|
|
|
38
|
-
/**
|
|
39
|
-
* Serializable mirror of `SanitizedMCPPluginConfig` for client components —
|
|
40
|
-
* the full sanitized config carries functions (tool handlers, etc.) that can't
|
|
41
|
-
* cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
|
|
42
|
-
* passed to the `AccessField` component via `clientProps`.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export type ClientMCPPluginConfig = {
|
|
47
|
-
items: Array<{
|
|
48
|
-
collectionSlug?: string
|
|
49
|
-
configKey: string
|
|
50
|
-
description?: string
|
|
51
|
-
globalSlug?: string
|
|
52
|
-
/** Admin-UI bucket for collection/global tools: built-in CRUD, auth, or custom. */
|
|
53
|
-
group?: 'auth' | 'custom' | 'operations'
|
|
54
|
-
label: string
|
|
55
|
-
type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'
|
|
56
|
-
}>
|
|
57
|
-
}
|
|
58
|
-
|
|
59
40
|
export type MCPToolResponse = {
|
|
60
41
|
content: ContentBlock[]
|
|
61
42
|
/**
|
|
@@ -72,6 +53,13 @@ export type MCPResponseOverride = (
|
|
|
72
53
|
req: PayloadRequest,
|
|
73
54
|
) => MCPToolResponse
|
|
74
55
|
|
|
56
|
+
export type MCPAfterToolCallHook = (args: {
|
|
57
|
+
input: unknown
|
|
58
|
+
req: PayloadRequest
|
|
59
|
+
response: MCPToolResponse
|
|
60
|
+
toolName: string
|
|
61
|
+
}) => MaybePromise<MCPToolResponse>
|
|
62
|
+
|
|
75
63
|
/**
|
|
76
64
|
* The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets
|
|
77
65
|
* its inferred output; anything else falls back to `Record<string, unknown>`.
|
|
@@ -82,6 +70,19 @@ export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON
|
|
|
82
70
|
: StandardSchemaWithJSON.InferOutput<TSchema>
|
|
83
71
|
: Record<string, unknown>
|
|
84
72
|
|
|
73
|
+
export type MCPAccessArgs = {
|
|
74
|
+
permissions?: SanitizedPermissions
|
|
75
|
+
req: PayloadRequest
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type CollectionMCPAccessArgs = {
|
|
79
|
+
slug: CollectionSlug
|
|
80
|
+
} & MCPAccessArgs
|
|
81
|
+
|
|
82
|
+
export type GlobalMCPAccessArgs = {
|
|
83
|
+
slug: GlobalSlug
|
|
84
|
+
} & MCPAccessArgs
|
|
85
|
+
|
|
85
86
|
export type ToolHandlerArgs<TSchema = undefined> = {
|
|
86
87
|
authorizedMCP: AuthorizedMCP
|
|
87
88
|
input: TypedInput<TSchema>
|
|
@@ -90,14 +91,21 @@ export type ToolHandlerArgs<TSchema = undefined> = {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
export type CollectionToolHandlerArgs<TSchema = undefined> = {
|
|
93
|
-
|
|
94
|
+
slug: CollectionSlug
|
|
94
95
|
} & ToolHandlerArgs<TSchema>
|
|
95
96
|
|
|
96
97
|
export type GlobalToolHandlerArgs<TSchema = undefined> = {
|
|
97
|
-
|
|
98
|
+
slug: GlobalSlug
|
|
98
99
|
} & ToolHandlerArgs<TSchema>
|
|
99
100
|
|
|
100
101
|
export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
|
|
102
|
+
/**
|
|
103
|
+
* Runs while authorizing each MCP request, before the tool is advertised or called. Return
|
|
104
|
+
* `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`
|
|
105
|
+
* is enabled.
|
|
106
|
+
*/
|
|
107
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
108
|
+
annotations?: ToolAnnotations
|
|
101
109
|
description: string
|
|
102
110
|
handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
103
111
|
input?: TSchema
|
|
@@ -110,22 +118,54 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
|
|
|
110
118
|
export type CollectionTool<
|
|
111
119
|
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
112
120
|
> = {
|
|
121
|
+
/**
|
|
122
|
+
* Runs while authorizing each MCP request for this collection. Return `false` to reject calls
|
|
123
|
+
* to this tool for the collection. The shared tool is not advertised when no collections allow
|
|
124
|
+
* it, but can remain advertised when it is available for another collection. This is skipped
|
|
125
|
+
* when `overrideAccess` is enabled.
|
|
126
|
+
*/
|
|
127
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
113
128
|
handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
114
129
|
input?: TSchema
|
|
115
|
-
} & Pick<Tool, 'description' | 'overrideResponse'>
|
|
130
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
116
131
|
|
|
117
132
|
export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =
|
|
118
133
|
{
|
|
134
|
+
/**
|
|
135
|
+
* Runs while authorizing each MCP request for this global. Return `false` to reject calls to
|
|
136
|
+
* this tool for the global. The shared tool is not advertised when no globals allow it, but
|
|
137
|
+
* can remain advertised when it is available for another global. This is skipped when
|
|
138
|
+
* `overrideAccess` is enabled.
|
|
139
|
+
*/
|
|
140
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
119
141
|
handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
120
142
|
input?: TSchema
|
|
121
|
-
} & Pick<Tool, 'description' | 'overrideResponse'>
|
|
143
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
122
144
|
|
|
123
145
|
/**
|
|
124
146
|
* Configures (or disables) a built-in tool without replacing it.
|
|
125
147
|
* `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
|
|
126
148
|
* required handler) from being silently accepted at a built-in key slot.
|
|
127
149
|
*/
|
|
128
|
-
export type
|
|
150
|
+
export type MCPBuiltInCollectionToolOverride = {
|
|
151
|
+
/**
|
|
152
|
+
* Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
|
|
153
|
+
* this collection. This is skipped when `overrideAccess` is enabled.
|
|
154
|
+
*/
|
|
155
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
156
|
+
annotations?: ToolAnnotations
|
|
157
|
+
description?: string
|
|
158
|
+
handler?: never
|
|
159
|
+
overrideResponse?: MCPResponseOverride
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type MCPBuiltInGlobalToolOverride = {
|
|
163
|
+
/**
|
|
164
|
+
* Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
|
|
165
|
+
* this global. This is skipped when `overrideAccess` is enabled.
|
|
166
|
+
*/
|
|
167
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
168
|
+
annotations?: ToolAnnotations
|
|
129
169
|
description?: string
|
|
130
170
|
handler?: never
|
|
131
171
|
overrideResponse?: MCPResponseOverride
|
|
@@ -139,13 +179,13 @@ export type MCPBuiltInToolOverride = {
|
|
|
139
179
|
export type MCPTopLevelToolEntry = Tool
|
|
140
180
|
|
|
141
181
|
export type MCPCollectionToolsMap = {
|
|
142
|
-
[customToolName: string]: boolean | CollectionTool |
|
|
182
|
+
[customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined
|
|
143
183
|
} & {
|
|
144
|
-
[K in MCPCollectionBuiltinName]?: false |
|
|
184
|
+
[K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride
|
|
145
185
|
}
|
|
146
186
|
|
|
147
187
|
export type MCPAuthCollectionToolsMap = {
|
|
148
|
-
[K in MCPCollectionAuthToolName]?:
|
|
188
|
+
[K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true
|
|
149
189
|
} & MCPCollectionToolsMap
|
|
150
190
|
|
|
151
191
|
/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
|
|
@@ -154,9 +194,9 @@ export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends
|
|
|
154
194
|
: MCPCollectionToolsMap
|
|
155
195
|
|
|
156
196
|
export type MCPGlobalToolsMap = {
|
|
157
|
-
[customToolName: string]: boolean | GlobalTool |
|
|
197
|
+
[customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined
|
|
158
198
|
} & {
|
|
159
|
-
[K in MCPGlobalBuiltinName]?: false |
|
|
199
|
+
[K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride
|
|
160
200
|
}
|
|
161
201
|
|
|
162
202
|
export type MCPTopLevelToolsMap = Record<string, Tool>
|
|
@@ -168,6 +208,12 @@ export type PromptHandlerArgs<TSchema = undefined> = {
|
|
|
168
208
|
}
|
|
169
209
|
|
|
170
210
|
export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
|
|
211
|
+
/**
|
|
212
|
+
* Runs while authorizing each MCP request, before the prompt is advertised or used. Return
|
|
213
|
+
* `false` to make the prompt unavailable for that request. This is skipped when
|
|
214
|
+
* `overrideAccess` is enabled.
|
|
215
|
+
*/
|
|
216
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
171
217
|
argsSchema: TSchema
|
|
172
218
|
description: string
|
|
173
219
|
handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
|
|
@@ -185,6 +231,12 @@ export type ResourceHandlerArgs = {
|
|
|
185
231
|
}
|
|
186
232
|
|
|
187
233
|
export type Resource = {
|
|
234
|
+
/**
|
|
235
|
+
* Runs while authorizing each MCP request, before the resource is advertised or read. Return
|
|
236
|
+
* `false` to make the resource unavailable for that request. This is skipped when
|
|
237
|
+
* `overrideAccess` is enabled.
|
|
238
|
+
*/
|
|
239
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
188
240
|
description: string
|
|
189
241
|
handler: (args: ResourceHandlerArgs) => MaybePromise<{
|
|
190
242
|
contents: Array<{ text: string; uri: string }>
|
|
@@ -215,90 +267,174 @@ export type MCPPluginGlobalConfig = {
|
|
|
215
267
|
* actually works with.
|
|
216
268
|
*/
|
|
217
269
|
export type MCPPluginConfig = {
|
|
270
|
+
/**
|
|
271
|
+
* Decides who can use MCP at all. Runs on every MCP request once the user is authenticated,
|
|
272
|
+
* before the `access` callbacks of tools, prompts, and resources, and when a user allows an MCP
|
|
273
|
+
* client on the built-in OAuth server's sign-in page. Return `false` to answer MCP requests with
|
|
274
|
+
* `403` and to refuse to sign the client in. This is skipped when `overrideAccess` is enabled.
|
|
275
|
+
* `overrideGetAuthorizedMCP` replaces it on MCP requests.
|
|
276
|
+
*
|
|
277
|
+
* It only applies to MCP, not to Payload's REST or GraphQL APIs, so it doesn't replace access
|
|
278
|
+
* control on collections and globals.
|
|
279
|
+
*
|
|
280
|
+
* @default no check, so tools, prompts, and resources decide on their own
|
|
281
|
+
*/
|
|
282
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
218
283
|
collections?: {
|
|
219
284
|
[Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>
|
|
220
285
|
}
|
|
221
|
-
/** Skip MCP registration.
|
|
286
|
+
/** Skip MCP endpoint registration. */
|
|
222
287
|
disabled?: boolean
|
|
223
288
|
globals?: {
|
|
224
289
|
[Slug in GlobalSlug]?: MCPPluginGlobalConfig
|
|
225
290
|
}
|
|
291
|
+
hooks?: {
|
|
292
|
+
/** Transform a tool response after its handler returns */
|
|
293
|
+
afterToolCall?: MCPAfterToolCallHook[]
|
|
294
|
+
}
|
|
226
295
|
mcp?: {
|
|
296
|
+
/**
|
|
297
|
+
* Largest HTTP request body, in bytes, that the MCP endpoint accepts. Larger requests
|
|
298
|
+
* are answered with `413`. Base64 file uploads count toward this limit.
|
|
299
|
+
*
|
|
300
|
+
* @default 4194304 (4 MiB, the MCP SDK default)
|
|
301
|
+
*/
|
|
302
|
+
maxRequestBodySize?: number
|
|
227
303
|
serverOptions?: MCPServerOptions
|
|
228
304
|
verboseLogs?: boolean
|
|
229
305
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
306
|
+
/**
|
|
307
|
+
* How MCP clients sign in. MCP requests without an authenticated user get a `401` that points
|
|
308
|
+
* to the protected resource metadata (RFC 9728). Set to `false` to only accept API keys and
|
|
309
|
+
* anonymous requests.
|
|
310
|
+
*
|
|
311
|
+
* @default { type: 'builtin' }
|
|
312
|
+
*/
|
|
313
|
+
oauth?: false | MCPOAuthConfig
|
|
314
|
+
/**
|
|
315
|
+
* Replace the default MCP authorization resolver.
|
|
316
|
+
*
|
|
317
|
+
* This hook replaces the default authentication flow, including the plugin's `access`. It must
|
|
318
|
+
* set `req.user` to the authenticated Payload user, or to `null` for an anonymous caller, before
|
|
319
|
+
* returning.
|
|
320
|
+
*/
|
|
321
|
+
overrideGetAuthorizedMCP?: (
|
|
322
|
+
args: {
|
|
323
|
+
pluginConfig: SanitizedMCPPluginConfig
|
|
324
|
+
} & GetAuthorizedMCPArgs,
|
|
325
|
+
) => MaybePromise<AuthorizedMCP>
|
|
238
326
|
prompts?: Record<string, Prompt>
|
|
239
327
|
resources?: Record<string, Resource>
|
|
240
328
|
/** Cross-cutting tools (not scoped to any collection or global). */
|
|
241
329
|
tools?: MCPTopLevelToolsMap
|
|
242
|
-
userCollection?: CollectionSlug
|
|
243
330
|
}
|
|
244
331
|
|
|
245
|
-
export type
|
|
246
|
-
items: MCPItem[]
|
|
247
|
-
userCollection: CollectionSlug
|
|
248
|
-
} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>
|
|
249
|
-
|
|
250
|
-
export type MCPServerOptions = {
|
|
251
|
-
options?: ConstructorParameters<typeof McpServer>[1]
|
|
252
|
-
serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>
|
|
253
|
-
}
|
|
332
|
+
export type MCPOAuthConfig = MCPBuiltinOAuthConfig | MCPExternalOAuthConfig
|
|
254
333
|
|
|
255
334
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* defaults (built-in CRUD is on, opt-in tools are off).
|
|
335
|
+
* This Payload app is the authorization server. Users sign in to the admin panel and allow the
|
|
336
|
+
* MCP client, which then gets an access token for them.
|
|
259
337
|
*/
|
|
260
|
-
export type
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
338
|
+
export type MCPBuiltinOAuthConfig = {
|
|
339
|
+
/**
|
|
340
|
+
* Creates the tokens the MCP client gets when the user clicks Allow. `req` is the user's own
|
|
341
|
+
* browser request, so `req.user` is the user who allowed it. Pass `authenticate` too if
|
|
342
|
+
* Payload's auth strategies don't accept the access token.
|
|
343
|
+
*
|
|
344
|
+
* @default a Payload login token for that user that only works for MCP, with a refresh token when
|
|
345
|
+
* the collection uses sessions. Its session is labelled with the client's name.
|
|
346
|
+
*/
|
|
347
|
+
issueToken?: (args: {
|
|
348
|
+
/** The MCP client the user allowed, with the address it returns to. */
|
|
349
|
+
client: { name: string; redirectURI: string }
|
|
350
|
+
req: PayloadRequest
|
|
351
|
+
}) => MaybePromise<MCPOAuthTokens>
|
|
352
|
+
/**
|
|
353
|
+
* Trades a refresh token from `issueToken`, or from an earlier refresh, for new tokens. Return
|
|
354
|
+
* `null` when it's no longer valid, and the client sends the user through sign-in again. `req`
|
|
355
|
+
* is the MCP client's request, without a user. Only used together with `issueToken`.
|
|
356
|
+
*
|
|
357
|
+
* OAuth requires noticing copied refresh tokens: return a new refresh token every time, and
|
|
358
|
+
* revoke the tokens when an already used refresh token comes back.
|
|
359
|
+
*
|
|
360
|
+
* It also runs when the client trades its authorization code, on the refresh token from
|
|
361
|
+
* `issueToken`, with `reuseInterval: 0`. OAuth requires a code to work only once, so refuse that
|
|
362
|
+
* refresh token if it was used before, even moments ago.
|
|
363
|
+
*/
|
|
364
|
+
refreshToken?: (args: {
|
|
365
|
+
refreshToken: string
|
|
366
|
+
req: PayloadRequest
|
|
367
|
+
/**
|
|
368
|
+
* How long a refresh token that was just used may still be accepted, in milliseconds, e.g. for
|
|
369
|
+
* clients that refresh twice at once. `0` means not at all. When it's missing, use your usual
|
|
370
|
+
* leeway.
|
|
371
|
+
*/
|
|
372
|
+
reuseInterval?: number
|
|
373
|
+
}) => MaybePromise<MCPOAuthTokens | null>
|
|
374
|
+
type: 'builtin'
|
|
375
|
+
} & MCPOAuthSharedConfig
|
|
376
|
+
|
|
377
|
+
export type MCPOAuthTokens = {
|
|
378
|
+
accessToken: string
|
|
379
|
+
/** Seconds until the access token expires. */
|
|
380
|
+
expiresIn?: number
|
|
381
|
+
/** Lets the client get new tokens without the user, through `refreshToken`. */
|
|
382
|
+
refreshToken?: string
|
|
280
383
|
}
|
|
281
384
|
|
|
282
|
-
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
385
|
+
/** Another service, e.g. your identity provider, is the authorization server. */
|
|
386
|
+
export type MCPExternalOAuthConfig = {
|
|
387
|
+
/**
|
|
388
|
+
* The authorization servers that issue access tokens for MCP clients. Clients require each one
|
|
389
|
+
* to exactly match the `issuer` in that server's metadata, so pass a function when the exact
|
|
390
|
+
* value is only known at runtime, e.g. from the server's OpenID configuration or per host.
|
|
391
|
+
*/
|
|
392
|
+
authorizationServers: ((args: { req: PayloadRequest }) => MaybePromise<string[]>) | string[]
|
|
393
|
+
/**
|
|
394
|
+
* Scopes MCP clients should request, e.g. `['openid', 'email', 'profile']`. Without them,
|
|
395
|
+
* clients request none, which some authorization servers reject or answer with a token that
|
|
396
|
+
* doesn't identify the user.
|
|
397
|
+
*/
|
|
398
|
+
scopes?: string[]
|
|
399
|
+
type: 'external'
|
|
400
|
+
} & MCPOAuthSharedConfig
|
|
401
|
+
|
|
402
|
+
type MCPOAuthSharedConfig = {
|
|
403
|
+
/**
|
|
404
|
+
* Called on MCP requests with a bearer token that Payload's auth strategies didn't accept.
|
|
405
|
+
* Return the Payload user, including its `collection`, or `null` to answer with the OAuth challenge.
|
|
406
|
+
*/
|
|
407
|
+
authenticate?: (args: {
|
|
408
|
+
req: PayloadRequest
|
|
409
|
+
token: string
|
|
410
|
+
}) => MaybePromise<PayloadRequest['user']>
|
|
411
|
+
/**
|
|
412
|
+
* The URL clients call to reach the MCP endpoint. The metadata link and the built-in
|
|
413
|
+
* authorization server's issuer are based on it.
|
|
414
|
+
*
|
|
415
|
+
* @default the absolute URL of `/api/mcp`, based on `serverURL` or the request URL
|
|
416
|
+
*/
|
|
417
|
+
resource?: ((args: { req: PayloadRequest }) => string) | string
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export type SanitizedMCPPluginConfig = {
|
|
421
|
+
items: MCPItem[]
|
|
422
|
+
/** `undefined` when OAuth is turned off. */
|
|
423
|
+
oauth?: MCPOAuthConfig
|
|
424
|
+
} & Pick<MCPPluginConfig, 'access' | 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>
|
|
425
|
+
|
|
426
|
+
export type MCPServerOptions = {
|
|
427
|
+
options?: McpServerOptions
|
|
428
|
+
serverInfo?: Partial<Implementation>
|
|
293
429
|
}
|
|
294
430
|
|
|
295
431
|
/**
|
|
296
|
-
* One MCP primitive plus the metadata needed for
|
|
432
|
+
* One MCP primitive plus the metadata needed for config-driven filtering and
|
|
297
433
|
* registration.
|
|
298
434
|
*
|
|
299
|
-
* - `configKey`: the config
|
|
435
|
+
* - `configKey`: the config identifier, e.g. `find` or `echo`.
|
|
300
436
|
* - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
|
|
301
|
-
* - `label`: human-readable
|
|
437
|
+
* - `label`: human-readable display text.
|
|
302
438
|
*/
|
|
303
439
|
export type MCPItemBase = {
|
|
304
440
|
configKey: string
|
|
@@ -335,13 +471,10 @@ export type MCPItem =
|
|
|
335
471
|
| GlobalMCPItem
|
|
336
472
|
|
|
337
473
|
/**
|
|
338
|
-
* The
|
|
339
|
-
*
|
|
340
|
-
* receive this via `args.authorizedMCP` so they can spread
|
|
341
|
-
* `localAPIDefaults(authorizedMCP)` into every local API call.
|
|
474
|
+
* The MCP items and access mode authorized for this request. The authenticated user is available
|
|
475
|
+
* as `req.user`.
|
|
342
476
|
*/
|
|
343
477
|
export type AuthorizedMCP = {
|
|
344
478
|
items: MCPItem[]
|
|
345
479
|
overrideAccess: boolean
|
|
346
|
-
user: null | TypedUser
|
|
347
480
|
}
|
|
@@ -5,7 +5,7 @@ import type { SanitizedMCPPluginConfig } from '../types.js'
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the sanitized plugin config — the form produced by
|
|
7
7
|
* `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
|
|
8
|
-
* Callers downstream of plugin init can rely on `items
|
|
8
|
+
* Callers downstream of plugin init can rely on `items` and other defaults
|
|
9
9
|
* being fully resolved.
|
|
10
10
|
*/
|
|
11
11
|
export const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Encrypts data for the client to hold, so it doesn't need to be stored. `type` keeps one kind
|
|
5
|
+
* from being used as another, e.g. a client ID as an authorization code.
|
|
6
|
+
*/
|
|
7
|
+
export const seal = ({
|
|
8
|
+
type,
|
|
9
|
+
data,
|
|
10
|
+
expiresInSeconds,
|
|
11
|
+
req,
|
|
12
|
+
}: {
|
|
13
|
+
data: object
|
|
14
|
+
expiresInSeconds?: number
|
|
15
|
+
req: PayloadRequest
|
|
16
|
+
type: string
|
|
17
|
+
}): string =>
|
|
18
|
+
req.payload.encrypt(
|
|
19
|
+
JSON.stringify({
|
|
20
|
+
...data,
|
|
21
|
+
type,
|
|
22
|
+
exp: expiresInSeconds && Date.now() + expiresInSeconds * 1000,
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
export const unseal = <T>({
|
|
27
|
+
type,
|
|
28
|
+
req,
|
|
29
|
+
value,
|
|
30
|
+
}: {
|
|
31
|
+
req: PayloadRequest
|
|
32
|
+
type: string
|
|
33
|
+
value: null | string
|
|
34
|
+
}): T | undefined => {
|
|
35
|
+
// Only the v1 format is authenticated. Older formats decrypt anything without an error.
|
|
36
|
+
if (!value?.startsWith('v1:')) {
|
|
37
|
+
return undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const data = JSON.parse(req.payload.decrypt(value, { secret: req.payload.config.secret }))
|
|
42
|
+
return data.type === type && (!data.exp || data.exp > Date.now()) ? data : undefined
|
|
43
|
+
} catch {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -5,5 +5,5 @@ import type { ToolInputSchema } from '../types.js'
|
|
|
5
5
|
/** Normalize a tool/prompt input to a Standard Schema. Raw JSON Schema gets wrapped; Standard Schema instances pass through. */
|
|
6
6
|
export const toStandardSchema = (schema: ToolInputSchema): StandardSchemaWithJSON =>
|
|
7
7
|
typeof schema === 'object' && schema !== null && '~standard' in schema
|
|
8
|
-
?
|
|
8
|
+
? schema
|
|
9
9
|
: fromJsonSchema(schema)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { Button } from '@payloadcms/ui'
|
|
4
|
+
import React, { useEffect, useState, useSyncExternalStore } from 'react'
|
|
5
|
+
|
|
6
|
+
const baseClass = 'mcp-authorize'
|
|
7
|
+
|
|
8
|
+
/** How long the page must have been in front of the user before the buttons work, in ms. */
|
|
9
|
+
const enableDelay = 1000
|
|
10
|
+
|
|
11
|
+
// Whether the page is inside a frame never changes, so there's nothing to subscribe to
|
|
12
|
+
const subscribe = () => () => {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The Allow and Deny buttons, protected against clicks the user didn't mean for this page:
|
|
16
|
+
*
|
|
17
|
+
* - Inside a frame they aren't shown, so other sites can't frame the page and trick users into
|
|
18
|
+
* clicking them. The server can't tell, so they're missing until the browser has checked.
|
|
19
|
+
* - They're disabled until the page has been visible and focused for a moment. Otherwise another
|
|
20
|
+
* site could open the page under the user's cursor while they double-click something else, so
|
|
21
|
+
* the second click lands on Allow. Leaving the page disables them again. Waiting works for every
|
|
22
|
+
* way of clicking, unlike requiring a mouse movement or key press first.
|
|
23
|
+
*
|
|
24
|
+
* @see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-17#section-7.11 for why the
|
|
25
|
+
* OAuth server must prevent clickjacking
|
|
26
|
+
* @see https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html#defending-against-doubleclickjacking
|
|
27
|
+
* for the double-click attack and its mitigation
|
|
28
|
+
*/
|
|
29
|
+
export function AllowButtons() {
|
|
30
|
+
const isTopLevel = useSyncExternalStore(
|
|
31
|
+
subscribe,
|
|
32
|
+
() => window.top === window.self,
|
|
33
|
+
() => false,
|
|
34
|
+
)
|
|
35
|
+
const [isEnabled, setIsEnabled] = useState(false)
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
let timeout: ReturnType<typeof setTimeout> | undefined
|
|
39
|
+
|
|
40
|
+
const enableAfterDelay = () => {
|
|
41
|
+
clearTimeout(timeout)
|
|
42
|
+
if (document.visibilityState === 'visible' && document.hasFocus()) {
|
|
43
|
+
timeout = setTimeout(() => setIsEnabled(true), enableDelay)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const disable = () => {
|
|
47
|
+
clearTimeout(timeout)
|
|
48
|
+
setIsEnabled(false)
|
|
49
|
+
}
|
|
50
|
+
const onVisibilityChange = () => {
|
|
51
|
+
if (document.visibilityState === 'visible') {
|
|
52
|
+
enableAfterDelay()
|
|
53
|
+
} else {
|
|
54
|
+
disable()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enableAfterDelay()
|
|
59
|
+
window.addEventListener('focus', enableAfterDelay)
|
|
60
|
+
window.addEventListener('blur', disable)
|
|
61
|
+
document.addEventListener('visibilitychange', onVisibilityChange)
|
|
62
|
+
|
|
63
|
+
return () => {
|
|
64
|
+
clearTimeout(timeout)
|
|
65
|
+
window.removeEventListener('focus', enableAfterDelay)
|
|
66
|
+
window.removeEventListener('blur', disable)
|
|
67
|
+
document.removeEventListener('visibilitychange', onVisibilityChange)
|
|
68
|
+
}
|
|
69
|
+
}, [])
|
|
70
|
+
|
|
71
|
+
if (!isTopLevel) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div className={`${baseClass}__actions`}>
|
|
77
|
+
<Button
|
|
78
|
+
buttonStyle="primary"
|
|
79
|
+
disabled={!isEnabled}
|
|
80
|
+
extraButtonProps={{ name: 'decision', value: 'allow' }}
|
|
81
|
+
margin={false}
|
|
82
|
+
type="submit"
|
|
83
|
+
>
|
|
84
|
+
Allow
|
|
85
|
+
</Button>
|
|
86
|
+
<Button
|
|
87
|
+
buttonStyle="secondary"
|
|
88
|
+
disabled={!isEnabled}
|
|
89
|
+
extraButtonProps={{ name: 'decision', value: 'deny' }}
|
|
90
|
+
margin={false}
|
|
91
|
+
type="submit"
|
|
92
|
+
>
|
|
93
|
+
Deny
|
|
94
|
+
</Button>
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.mcp-authorize {
|
|
3
|
+
overflow-wrap: anywhere;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.mcp-authorize__brand {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
width: 100%;
|
|
10
|
+
margin-block-end: var(--spacer-5);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.mcp-authorize__actions {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
gap: var(--spacer-2);
|
|
18
|
+
}
|
|
19
|
+
}
|