@payloadcms/plugin-mcp 4.0.0-internal.011fd46 → 4.0.0-internal.0b9bec1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/bin.js +7 -0
- package/dist/defaultAccess.d.ts +3 -0
- package/dist/defaultAccess.d.ts.map +1 -0
- package/dist/defaultAccess.js +3 -0
- package/dist/defaultAccess.js.map +1 -0
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +12 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +74 -103
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +68 -17
- package/dist/endpoint/index.js.map +1 -1
- package/dist/exports/client.d.ts +1 -4
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -4
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -0
- package/dist/exports/internal.js +3 -0
- package/dist/exports/internal.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -56
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +4 -4
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +32 -10
- package/dist/mcp/buildMcpServer.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 +68 -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 +64 -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 +93 -40
- 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 +3 -2
- 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 +96 -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 +124 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +86 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +92 -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 +5 -4
- 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 +83 -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 +98 -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 +49 -4
- 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 +81 -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 +26 -12
- 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/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +20 -8
- 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 +64 -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 +4 -2
- 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 +79 -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 +94 -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 +25 -2
- 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 +77 -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 +4 -2
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
- package/dist/mcp/builtin/validateEntityData.js +1 -1
- package/dist/mcp/builtin/validateEntityData.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +73 -2
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +73 -3
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +48 -17
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +84 -46
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +93 -87
- 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/schemaConversion/filterFieldsByAccess.d.ts +28 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +11 -17
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +80 -112
- package/src/endpoint/index.ts +58 -16
- package/src/exports/client.ts +2 -4
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +5 -62
- package/src/mcp/buildMcpServer.ts +46 -21
- package/src/mcp/builtin/collections/countTool.ts +73 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/collections/createTool.ts +93 -34
- package/src/mcp/builtin/collections/deleteTool.ts +4 -2
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +164 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +6 -4
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +48 -3
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +29 -10
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +20 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +5 -2
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +30 -2
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +5 -2
- package/src/mcp/builtin/validateEntityData.ts +1 -1
- package/src/mcp/builtinTools.ts +72 -6
- package/src/mcp/sanitizeMCPConfig.ts +36 -19
- package/src/stdio.ts +79 -46
- package/src/types.ts +101 -91
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- package/dist/collection/getAccessField.d.ts +0 -12
- package/dist/collection/getAccessField.d.ts.map +0 -1
- package/dist/collection/getAccessField.js +0 -72
- package/dist/collection/getAccessField.js.map +0 -1
- package/dist/collection/index.d.ts +0 -6
- package/dist/collection/index.d.ts.map +0 -1
- package/dist/collection/index.js +0 -105
- package/dist/collection/index.js.map +0 -1
- package/dist/components/APIKeyField/index.client.d.ts +0 -9
- package/dist/components/APIKeyField/index.client.d.ts.map +0 -1
- package/dist/components/APIKeyField/index.client.js +0 -85
- package/dist/components/APIKeyField/index.client.js.map +0 -1
- package/dist/components/APIKeyField/index.css +0 -105
- package/dist/components/APIKeysEmptyState/index.client.d.ts +0 -4
- package/dist/components/APIKeysEmptyState/index.client.d.ts.map +0 -1
- package/dist/components/APIKeysEmptyState/index.client.js +0 -21
- package/dist/components/APIKeysEmptyState/index.client.js.map +0 -1
- package/dist/components/AccessField/index.client.d.ts +0 -10
- package/dist/components/AccessField/index.client.d.ts.map +0 -1
- package/dist/components/AccessField/index.client.js +0 -247
- package/dist/components/AccessField/index.client.js.map +0 -1
- package/dist/components/AccessField/index.css +0 -99
- package/dist/components/SettingsMenu/index.client.d.ts +0 -8
- package/dist/components/SettingsMenu/index.client.d.ts.map +0 -1
- package/dist/components/SettingsMenu/index.client.js +0 -24
- package/dist/components/SettingsMenu/index.client.js.map +0 -1
- package/dist/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/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/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/src/collection/getAccessField.ts +0 -84
- package/src/collection/index.ts +0 -105
- package/src/components/APIKeyField/index.client.tsx +0 -68
- package/src/components/APIKeyField/index.css +0 -105
- package/src/components/APIKeysEmptyState/index.client.tsx +0 -33
- package/src/components/AccessField/index.client.tsx +0 -296
- package/src/components/AccessField/index.css +0 -99
- package/src/components/SettingsMenu/index.client.tsx +0 -30
- package/src/translations/index.ts +0 -105
- package/src/translations/languages/ar.ts +0 -38
- package/src/translations/languages/az.ts +0 -38
- package/src/translations/languages/bg.ts +0 -39
- package/src/translations/languages/bnBd.ts +0 -39
- package/src/translations/languages/bnIn.ts +0 -39
- package/src/translations/languages/ca.ts +0 -39
- package/src/translations/languages/cs.ts +0 -39
- package/src/translations/languages/da.ts +0 -38
- package/src/translations/languages/de.ts +0 -39
- package/src/translations/languages/en.ts +0 -39
- package/src/translations/languages/es.ts +0 -39
- package/src/translations/languages/et.ts +0 -38
- package/src/translations/languages/fa.ts +0 -39
- package/src/translations/languages/fr.ts +0 -39
- package/src/translations/languages/he.ts +0 -37
- package/src/translations/languages/hr.ts +0 -39
- package/src/translations/languages/hu.ts +0 -39
- package/src/translations/languages/hy.ts +0 -39
- package/src/translations/languages/id.ts +0 -39
- package/src/translations/languages/is.ts +0 -39
- package/src/translations/languages/it.ts +0 -39
- package/src/translations/languages/ja.ts +0 -39
- package/src/translations/languages/ko.ts +0 -39
- package/src/translations/languages/lt.ts +0 -39
- package/src/translations/languages/lv.ts +0 -38
- package/src/translations/languages/my.ts +0 -39
- package/src/translations/languages/nb.ts +0 -39
- package/src/translations/languages/nl.ts +0 -39
- package/src/translations/languages/pl.ts +0 -38
- package/src/translations/languages/pt.ts +0 -39
- package/src/translations/languages/ro.ts +0 -39
- package/src/translations/languages/rs.ts +0 -38
- package/src/translations/languages/rsLatin.ts +0 -38
- package/src/translations/languages/ru.ts +0 -39
- package/src/translations/languages/sk.ts +0 -39
- package/src/translations/languages/sl.ts +0 -38
- package/src/translations/languages/sv.ts +0 -39
- package/src/translations/languages/ta.ts +0 -39
- package/src/translations/languages/th.ts +0 -38
- package/src/translations/languages/tr.ts +0 -38
- package/src/translations/languages/uk.ts +0 -39
- package/src/translations/languages/vi.ts +0 -39
- package/src/translations/languages/zh.ts +0 -36
- package/src/translations/languages/zhTw.ts +0 -36
- package/src/translations/types.ts +0 -34
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
SanitizedMCPPluginConfig,
|
|
18
18
|
} from '../types.js'
|
|
19
19
|
|
|
20
|
+
import { defaultAccess } from '../defaultAccess.js'
|
|
20
21
|
import {
|
|
21
22
|
COLLECTION_AUTH_BUILTIN_ENTRIES,
|
|
22
23
|
COLLECTION_AUTH_BUILTINS,
|
|
@@ -33,7 +34,6 @@ import {
|
|
|
33
34
|
* - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
|
|
34
35
|
* tool maps into a single `items` array.
|
|
35
36
|
* - Applies built-in tools for collections and globals, respecting opt-out user overrides.
|
|
36
|
-
* - Applies the `userCollection` default
|
|
37
37
|
*
|
|
38
38
|
* Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
|
|
39
39
|
* ?.options` holds the sanitized result
|
|
@@ -61,7 +61,7 @@ export const sanitizeMCPConfig = ({
|
|
|
61
61
|
configKey,
|
|
62
62
|
label: tool.annotations?.title ?? configKey,
|
|
63
63
|
mcpName,
|
|
64
|
-
tool,
|
|
64
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
65
65
|
})
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -74,7 +74,7 @@ export const sanitizeMCPConfig = ({
|
|
|
74
74
|
configKey,
|
|
75
75
|
label: tool.annotations?.title ?? configKey,
|
|
76
76
|
mcpName: configKey,
|
|
77
|
-
tool,
|
|
77
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ export const sanitizeMCPConfig = ({
|
|
|
84
84
|
configKey,
|
|
85
85
|
label: prompt.title ?? configKey,
|
|
86
86
|
mcpName: configKey,
|
|
87
|
-
prompt,
|
|
87
|
+
prompt: { ...prompt, access: prompt.access ?? defaultAccess },
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -94,21 +94,16 @@ export const sanitizeMCPConfig = ({
|
|
|
94
94
|
configKey,
|
|
95
95
|
label: resource.title ?? configKey,
|
|
96
96
|
mcpName: configKey,
|
|
97
|
-
resource,
|
|
97
|
+
resource: { ...resource, access: resource.access ?? defaultAccess },
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.
|
|
102
|
-
const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))
|
|
103
|
-
|
|
104
101
|
return {
|
|
105
102
|
disabled: pluginConfig.disabled,
|
|
103
|
+
hooks: pluginConfig.hooks,
|
|
106
104
|
items,
|
|
107
105
|
mcp: pluginConfig.mcp,
|
|
108
|
-
|
|
109
|
-
overrideAuth: pluginConfig.overrideAuth,
|
|
110
|
-
userCollection:
|
|
111
|
-
pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',
|
|
106
|
+
overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP,
|
|
112
107
|
}
|
|
113
108
|
}
|
|
114
109
|
|
|
@@ -119,14 +114,30 @@ const sanitizeCollectionConfig = ({
|
|
|
119
114
|
collection: CollectionConfig | SanitizedCollectionConfig
|
|
120
115
|
pluginConfig: MCPPluginConfig
|
|
121
116
|
}): CollectionMCPItem[] => {
|
|
122
|
-
if (collection.slug === 'payload-mcp-api-keys') {
|
|
123
|
-
return []
|
|
124
|
-
}
|
|
125
117
|
const slug = collection.slug
|
|
126
118
|
const collectionPluginConfig = pluginConfig.collections?.[slug]
|
|
127
119
|
const items: CollectionMCPItem[] = []
|
|
120
|
+
/**
|
|
121
|
+
* Payload disables duplicate for auth collections by default unless the
|
|
122
|
+
* collection explicitly opts back in with `disableDuplicate: false`.
|
|
123
|
+
*/
|
|
124
|
+
const isDuplicateDisabled =
|
|
125
|
+
collection.disableDuplicate === true ||
|
|
126
|
+
(Boolean(collection.auth) && collection.disableDuplicate !== false)
|
|
128
127
|
|
|
129
|
-
for (const [
|
|
128
|
+
for (const [
|
|
129
|
+
toolKey,
|
|
130
|
+
{ mcpName, requiresDuplicateEnabled, requiresUpload, requiresVersions, tool },
|
|
131
|
+
] of COLLECTION_BUILTIN_ENTRIES) {
|
|
132
|
+
if (requiresVersions && !collection.versions) {
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
135
|
+
if (requiresDuplicateEnabled && isDuplicateDisabled) {
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
if (requiresUpload && !collection.upload) {
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
130
141
|
const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]
|
|
131
142
|
if (matchedConfigEntry === false) {
|
|
132
143
|
continue
|
|
@@ -141,6 +152,7 @@ const sanitizeCollectionConfig = ({
|
|
|
141
152
|
mcpName,
|
|
142
153
|
tool: {
|
|
143
154
|
...tool,
|
|
155
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
144
156
|
annotations,
|
|
145
157
|
description: override?.description ?? tool.description,
|
|
146
158
|
overrideResponse:
|
|
@@ -168,6 +180,7 @@ const sanitizeCollectionConfig = ({
|
|
|
168
180
|
mcpName,
|
|
169
181
|
tool: {
|
|
170
182
|
...tool,
|
|
183
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
171
184
|
annotations,
|
|
172
185
|
description: override?.description ?? tool.description,
|
|
173
186
|
overrideResponse:
|
|
@@ -197,7 +210,7 @@ const sanitizeCollectionConfig = ({
|
|
|
197
210
|
configKey,
|
|
198
211
|
label: customTool.annotations?.title ?? configKey,
|
|
199
212
|
mcpName: configKey,
|
|
200
|
-
tool: customTool,
|
|
213
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
201
214
|
})
|
|
202
215
|
}
|
|
203
216
|
|
|
@@ -215,7 +228,10 @@ const sanitizeGlobalConfig = ({
|
|
|
215
228
|
const globalPluginConfig = pluginConfig.globals?.[slug]
|
|
216
229
|
const items: GlobalMCPItem[] = []
|
|
217
230
|
|
|
218
|
-
for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
231
|
+
for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
232
|
+
if (requiresVersions && !global.versions) {
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
219
235
|
const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]
|
|
220
236
|
if (matchedConfigEntry === false) {
|
|
221
237
|
continue
|
|
@@ -230,6 +246,7 @@ const sanitizeGlobalConfig = ({
|
|
|
230
246
|
mcpName,
|
|
231
247
|
tool: {
|
|
232
248
|
...tool,
|
|
249
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
233
250
|
annotations,
|
|
234
251
|
description: override?.description ?? tool.description,
|
|
235
252
|
overrideResponse:
|
|
@@ -256,7 +273,7 @@ const sanitizeGlobalConfig = ({
|
|
|
256
273
|
globalSlug: slug,
|
|
257
274
|
label: customTool.annotations?.title ?? configKey,
|
|
258
275
|
mcpName: configKey,
|
|
259
|
-
tool: customTool,
|
|
276
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
260
277
|
})
|
|
261
278
|
}
|
|
262
279
|
|
package/src/stdio.ts
CHANGED
|
@@ -1,98 +1,131 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config, Plugin, SanitizedConfig } from 'payload'
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
|
-
import {
|
|
4
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio'
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
6
6
|
import { createLocalReq, getPayload } from 'payload'
|
|
7
|
-
import { findConfig } from 'payload/node'
|
|
7
|
+
import { findConfig, loadEnv } from 'payload/node'
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { SanitizedMCPPluginConfig } from './types.js'
|
|
10
10
|
|
|
11
|
+
import { getAuthorizedMCP } from './endpoint/access.js'
|
|
11
12
|
import { buildMcpServer } from './mcp/buildMcpServer.js'
|
|
12
13
|
import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'
|
|
13
14
|
import { getPluginConfig } from './utils/getPluginConfig.js'
|
|
14
15
|
import { resolveProjectRoot } from './utils/resolveProjectRoot.js'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Starts Payload's MCP server over stdin and stdout.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* Set `PAYLOAD_MCP_AUTHORIZATION` to authenticate. In development,
|
|
21
|
+
* `PAYLOAD_MCP_OVERRIDE_ACCESS=true` skips access checks.
|
|
21
22
|
*/
|
|
22
23
|
export const runMcpStdio = async (): Promise<void> => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Payload's cwd-anchored `findConfig()` can't locate the project on
|
|
26
|
-
* its own. This module always lives inside the project's `node_modules`, so
|
|
27
|
-
* we derive the project root from its own path and `chdir` into it.
|
|
28
|
-
*
|
|
29
|
-
* An absolute `PAYLOAD_CONFIG_PATH` still overrides everything; unusual
|
|
30
|
-
* layouts (e.g. a monorepo where the package is hoisted above the app) can
|
|
31
|
-
* fall back to it. See the implementation of findConfig for details.
|
|
32
|
-
*/
|
|
24
|
+
// MCP clients may start this command from another folder. Move to the Payload
|
|
25
|
+
// project so findConfig() can find the config.
|
|
33
26
|
const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))
|
|
34
27
|
if (projectRoot) {
|
|
35
28
|
process.chdir(projectRoot)
|
|
36
29
|
}
|
|
37
30
|
|
|
31
|
+
loadEnv()
|
|
38
32
|
const configPath = findConfig()
|
|
39
33
|
const configModule = await import(pathToFileURL(configPath).toString())
|
|
40
|
-
const config = (await (configModule.default ?? configModule)) as
|
|
41
|
-
|
|
42
|
-
const payload = await getPayload({ config })
|
|
34
|
+
const config = (await (configModule.default ?? configModule)) as SanitizedConfig
|
|
43
35
|
|
|
44
36
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
37
|
+
* stdout is only for MCP messages. The spec says the server must not write
|
|
38
|
+
* logs there and may write them to stderr instead.
|
|
39
|
+
*
|
|
40
|
+
* The 2.0 client library recovers from stray stdout logs, but that behavior is not
|
|
41
|
+
* guaranteed. Move Payload logs to stderr so Payload does not add invalid data
|
|
42
|
+
* to stdout. Keep options from configurable loggers. Replace pre-built loggers
|
|
43
|
+
* because their output cannot be redirected.
|
|
44
|
+
*
|
|
45
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#stdio
|
|
49
46
|
*/
|
|
47
|
+
const loggerConfig: { logger?: Config['logger'] } = config
|
|
48
|
+
if (
|
|
49
|
+
loggerConfig.logger &&
|
|
50
|
+
typeof loggerConfig.logger === 'object' &&
|
|
51
|
+
'options' in loggerConfig.logger
|
|
52
|
+
) {
|
|
53
|
+
loggerConfig.logger.destination = process.stderr
|
|
54
|
+
} else {
|
|
55
|
+
loggerConfig.logger = { destination: process.stderr, options: {} }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const payload = await getPayload({ config, cron: false, disableOnInit: true })
|
|
59
|
+
|
|
50
60
|
let pluginConfig: SanitizedMCPPluginConfig
|
|
51
61
|
try {
|
|
52
62
|
pluginConfig = getPluginConfig({ config: payload.config })
|
|
53
63
|
} catch {
|
|
64
|
+
// The command also works when mcpPlugin() is not in the Payload config.
|
|
54
65
|
pluginConfig = sanitizeMCPConfig({ config: payload.config, pluginConfig: {} })
|
|
55
66
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
const fallbackPlugin: Plugin = (config) => config
|
|
68
|
+
Object.assign(fallbackPlugin, {
|
|
69
|
+
slug: '@payloadcms/plugin-mcp',
|
|
70
|
+
sanitizedOptions: pluginConfig,
|
|
71
|
+
})
|
|
72
|
+
payload.config.plugins ??= []
|
|
73
|
+
payload.config.plugins.push(fallbackPlugin)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const overrideAccessEnv = process.env.PAYLOAD_MCP_OVERRIDE_ACCESS
|
|
77
|
+
let overrideAccess = false
|
|
78
|
+
|
|
79
|
+
if (overrideAccessEnv === 'true') {
|
|
80
|
+
overrideAccess = true
|
|
81
|
+
} else if (overrideAccessEnv && overrideAccessEnv !== 'false') {
|
|
82
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS must be "true" or "false".')
|
|
83
|
+
}
|
|
60
84
|
|
|
61
|
-
|
|
62
|
-
|
|
85
|
+
if (overrideAccess && process.env.NODE_ENV !== 'development') {
|
|
86
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS is only available in development.')
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
user: null,
|
|
89
|
+
const headers = new Headers()
|
|
90
|
+
if (process.env.PAYLOAD_MCP_AUTHORIZATION) {
|
|
91
|
+
headers.set('Authorization', process.env.PAYLOAD_MCP_AUTHORIZATION)
|
|
69
92
|
}
|
|
70
93
|
|
|
71
|
-
const req = await createLocalReq({}, payload)
|
|
94
|
+
const req = await createLocalReq({ req: { headers } }, payload)
|
|
72
95
|
req.payloadAPI = 'MCP' as const
|
|
96
|
+
const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
|
|
73
97
|
|
|
74
|
-
const
|
|
98
|
+
const stdioServer = serveStdio(() => buildMcpServer({ authorizedMCP, pluginConfig, req }), {
|
|
99
|
+
onerror: (err) => {
|
|
100
|
+
// MCP messages use stdout, so write SDK errors to stderr.
|
|
101
|
+
console.error('[payload-mcp] error serving MCP over stdio:', err)
|
|
102
|
+
},
|
|
103
|
+
})
|
|
75
104
|
|
|
76
|
-
|
|
77
|
-
|
|
105
|
+
// Close the MCP server and Payload when the client disconnects or the process stops.
|
|
106
|
+
let isShuttingDown = false
|
|
107
|
+
const shutdown = async () => {
|
|
108
|
+
if (isShuttingDown) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
isShuttingDown = true
|
|
78
112
|
|
|
79
|
-
// Process now lives until stdin closes. Wire graceful shutdown so DB
|
|
80
|
-
// connections (and any other Payload-managed resources) get released.
|
|
81
|
-
const shutdown = async (code = 0) => {
|
|
82
113
|
try {
|
|
83
|
-
await
|
|
114
|
+
await stdioServer.close()
|
|
84
115
|
} catch (err) {
|
|
85
116
|
console.error('[payload-mcp] error closing server:', err)
|
|
86
117
|
}
|
|
118
|
+
|
|
87
119
|
try {
|
|
88
120
|
await payload.destroy()
|
|
89
121
|
} catch (err) {
|
|
90
122
|
console.error('[payload-mcp] error destroying payload:', err)
|
|
91
123
|
}
|
|
92
|
-
|
|
124
|
+
|
|
125
|
+
process.exit(0)
|
|
93
126
|
}
|
|
94
127
|
|
|
95
|
-
process.
|
|
96
|
-
process.
|
|
97
|
-
process.stdin.
|
|
128
|
+
process.once('SIGINT', () => void shutdown())
|
|
129
|
+
process.once('SIGTERM', () => void shutdown())
|
|
130
|
+
process.stdin.once('close', () => void shutdown())
|
|
98
131
|
}
|
package/src/types.ts
CHANGED
|
@@ -10,15 +10,14 @@ import type {
|
|
|
10
10
|
} from '@modelcontextprotocol/server'
|
|
11
11
|
import type {
|
|
12
12
|
AuthCollectionSlug,
|
|
13
|
-
CollectionConfig,
|
|
14
13
|
CollectionSlug,
|
|
15
|
-
DefaultDocumentIDType,
|
|
16
14
|
GlobalSlug,
|
|
17
15
|
MaybePromise,
|
|
18
16
|
PayloadRequest,
|
|
19
|
-
|
|
17
|
+
SanitizedPermissions,
|
|
20
18
|
} from 'payload'
|
|
21
19
|
|
|
20
|
+
import type { GetAuthorizedMCPArgs } from './endpoint/access.js'
|
|
22
21
|
import type {
|
|
23
22
|
MCPCollectionAuthToolName,
|
|
24
23
|
MCPCollectionBuiltinName,
|
|
@@ -32,31 +31,11 @@ export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }
|
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
|
|
35
|
-
* JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
34
|
+
* JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
35
|
+
* Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.
|
|
36
36
|
*/
|
|
37
37
|
export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
* Serializable mirror of `SanitizedMCPPluginConfig` for client components —
|
|
41
|
-
* the full sanitized config carries functions (tool handlers, etc.) that can't
|
|
42
|
-
* cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
|
|
43
|
-
* passed to the `AccessField` component via `clientProps`.
|
|
44
|
-
*
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
export type ClientMCPPluginConfig = {
|
|
48
|
-
items: Array<{
|
|
49
|
-
collectionSlug?: string
|
|
50
|
-
configKey: string
|
|
51
|
-
description?: string
|
|
52
|
-
globalSlug?: string
|
|
53
|
-
/** Admin-UI bucket for collection/global tools: built-in CRUD, auth, or custom. */
|
|
54
|
-
group?: 'auth' | 'custom' | 'operations'
|
|
55
|
-
label: string
|
|
56
|
-
type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'
|
|
57
|
-
}>
|
|
58
|
-
}
|
|
59
|
-
|
|
60
39
|
export type MCPToolResponse = {
|
|
61
40
|
content: ContentBlock[]
|
|
62
41
|
/**
|
|
@@ -73,6 +52,13 @@ export type MCPResponseOverride = (
|
|
|
73
52
|
req: PayloadRequest,
|
|
74
53
|
) => MCPToolResponse
|
|
75
54
|
|
|
55
|
+
export type MCPAfterToolCallHook = (args: {
|
|
56
|
+
input: unknown
|
|
57
|
+
req: PayloadRequest
|
|
58
|
+
response: MCPToolResponse
|
|
59
|
+
toolName: string
|
|
60
|
+
}) => MaybePromise<MCPToolResponse>
|
|
61
|
+
|
|
76
62
|
/**
|
|
77
63
|
* The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets
|
|
78
64
|
* its inferred output; anything else falls back to `Record<string, unknown>`.
|
|
@@ -83,6 +69,19 @@ export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON
|
|
|
83
69
|
: StandardSchemaWithJSON.InferOutput<TSchema>
|
|
84
70
|
: Record<string, unknown>
|
|
85
71
|
|
|
72
|
+
export type MCPAccessArgs = {
|
|
73
|
+
permissions?: SanitizedPermissions
|
|
74
|
+
req: PayloadRequest
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type CollectionMCPAccessArgs = {
|
|
78
|
+
collectionSlug: CollectionSlug
|
|
79
|
+
} & MCPAccessArgs
|
|
80
|
+
|
|
81
|
+
export type GlobalMCPAccessArgs = {
|
|
82
|
+
globalSlug: GlobalSlug
|
|
83
|
+
} & MCPAccessArgs
|
|
84
|
+
|
|
86
85
|
export type ToolHandlerArgs<TSchema = undefined> = {
|
|
87
86
|
authorizedMCP: AuthorizedMCP
|
|
88
87
|
input: TypedInput<TSchema>
|
|
@@ -99,6 +98,12 @@ export type GlobalToolHandlerArgs<TSchema = undefined> = {
|
|
|
99
98
|
} & ToolHandlerArgs<TSchema>
|
|
100
99
|
|
|
101
100
|
export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
|
|
101
|
+
/**
|
|
102
|
+
* Runs while authorizing each MCP request, before the tool is advertised or called. Return
|
|
103
|
+
* `false` to make the tool unavailable for that request. This is skipped when `overrideAccess`
|
|
104
|
+
* is enabled.
|
|
105
|
+
*/
|
|
106
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
102
107
|
annotations?: ToolAnnotations
|
|
103
108
|
description: string
|
|
104
109
|
handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
@@ -112,12 +117,26 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
|
|
|
112
117
|
export type CollectionTool<
|
|
113
118
|
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
114
119
|
> = {
|
|
120
|
+
/**
|
|
121
|
+
* Runs while authorizing each MCP request for this collection. Return `false` to reject calls
|
|
122
|
+
* to this tool for the collection. The shared tool is not advertised when no collections allow
|
|
123
|
+
* it, but can remain advertised when it is available for another collection. This is skipped
|
|
124
|
+
* when `overrideAccess` is enabled.
|
|
125
|
+
*/
|
|
126
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
115
127
|
handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
116
128
|
input?: TSchema
|
|
117
129
|
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
118
130
|
|
|
119
131
|
export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =
|
|
120
132
|
{
|
|
133
|
+
/**
|
|
134
|
+
* Runs while authorizing each MCP request for this global. Return `false` to reject calls to
|
|
135
|
+
* this tool for the global. The shared tool is not advertised when no globals allow it, but
|
|
136
|
+
* can remain advertised when it is available for another global. This is skipped when
|
|
137
|
+
* `overrideAccess` is enabled.
|
|
138
|
+
*/
|
|
139
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
121
140
|
handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
122
141
|
input?: TSchema
|
|
123
142
|
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
@@ -127,7 +146,24 @@ export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSc
|
|
|
127
146
|
* `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
|
|
128
147
|
* required handler) from being silently accepted at a built-in key slot.
|
|
129
148
|
*/
|
|
130
|
-
export type
|
|
149
|
+
export type MCPBuiltInCollectionToolOverride = {
|
|
150
|
+
/**
|
|
151
|
+
* Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
|
|
152
|
+
* this collection. This is skipped when `overrideAccess` is enabled.
|
|
153
|
+
*/
|
|
154
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
155
|
+
annotations?: ToolAnnotations
|
|
156
|
+
description?: string
|
|
157
|
+
handler?: never
|
|
158
|
+
overrideResponse?: MCPResponseOverride
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export type MCPBuiltInGlobalToolOverride = {
|
|
162
|
+
/**
|
|
163
|
+
* Replaces the built-in tool's access check. Return `false` to make the tool unavailable for
|
|
164
|
+
* this global. This is skipped when `overrideAccess` is enabled.
|
|
165
|
+
*/
|
|
166
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
131
167
|
annotations?: ToolAnnotations
|
|
132
168
|
description?: string
|
|
133
169
|
handler?: never
|
|
@@ -142,13 +178,13 @@ export type MCPBuiltInToolOverride = {
|
|
|
142
178
|
export type MCPTopLevelToolEntry = Tool
|
|
143
179
|
|
|
144
180
|
export type MCPCollectionToolsMap = {
|
|
145
|
-
[customToolName: string]: boolean | CollectionTool |
|
|
181
|
+
[customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined
|
|
146
182
|
} & {
|
|
147
|
-
[K in MCPCollectionBuiltinName]?: false |
|
|
183
|
+
[K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride
|
|
148
184
|
}
|
|
149
185
|
|
|
150
186
|
export type MCPAuthCollectionToolsMap = {
|
|
151
|
-
[K in MCPCollectionAuthToolName]?:
|
|
187
|
+
[K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true
|
|
152
188
|
} & MCPCollectionToolsMap
|
|
153
189
|
|
|
154
190
|
/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
|
|
@@ -157,9 +193,9 @@ export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends
|
|
|
157
193
|
: MCPCollectionToolsMap
|
|
158
194
|
|
|
159
195
|
export type MCPGlobalToolsMap = {
|
|
160
|
-
[customToolName: string]: boolean | GlobalTool |
|
|
196
|
+
[customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined
|
|
161
197
|
} & {
|
|
162
|
-
[K in MCPGlobalBuiltinName]?: false |
|
|
198
|
+
[K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride
|
|
163
199
|
}
|
|
164
200
|
|
|
165
201
|
export type MCPTopLevelToolsMap = Record<string, Tool>
|
|
@@ -171,6 +207,12 @@ export type PromptHandlerArgs<TSchema = undefined> = {
|
|
|
171
207
|
}
|
|
172
208
|
|
|
173
209
|
export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
|
|
210
|
+
/**
|
|
211
|
+
* Runs while authorizing each MCP request, before the prompt is advertised or used. Return
|
|
212
|
+
* `false` to make the prompt unavailable for that request. This is skipped when
|
|
213
|
+
* `overrideAccess` is enabled.
|
|
214
|
+
*/
|
|
215
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
174
216
|
argsSchema: TSchema
|
|
175
217
|
description: string
|
|
176
218
|
handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
|
|
@@ -188,6 +230,12 @@ export type ResourceHandlerArgs = {
|
|
|
188
230
|
}
|
|
189
231
|
|
|
190
232
|
export type Resource = {
|
|
233
|
+
/**
|
|
234
|
+
* Runs while authorizing each MCP request, before the resource is advertised or read. Return
|
|
235
|
+
* `false` to make the resource unavailable for that request. This is skipped when
|
|
236
|
+
* `overrideAccess` is enabled.
|
|
237
|
+
*/
|
|
238
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
191
239
|
description: string
|
|
192
240
|
handler: (args: ResourceHandlerArgs) => MaybePromise<{
|
|
193
241
|
contents: Array<{ text: string; uri: string }>
|
|
@@ -221,34 +269,39 @@ export type MCPPluginConfig = {
|
|
|
221
269
|
collections?: {
|
|
222
270
|
[Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>
|
|
223
271
|
}
|
|
224
|
-
/** Skip MCP registration.
|
|
272
|
+
/** Skip MCP endpoint registration. */
|
|
225
273
|
disabled?: boolean
|
|
226
274
|
globals?: {
|
|
227
275
|
[Slug in GlobalSlug]?: MCPPluginGlobalConfig
|
|
228
276
|
}
|
|
277
|
+
hooks?: {
|
|
278
|
+
/** Transform a tool response after its handler returns */
|
|
279
|
+
afterToolCall?: MCPAfterToolCallHook[]
|
|
280
|
+
}
|
|
229
281
|
mcp?: {
|
|
230
282
|
serverOptions?: MCPServerOptions
|
|
231
283
|
verboseLogs?: boolean
|
|
232
284
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
285
|
+
/**
|
|
286
|
+
* Replace the default MCP authorization resolver.
|
|
287
|
+
*
|
|
288
|
+
* This hook replaces the default authentication flow. It must set `req.user` to the
|
|
289
|
+
* authenticated Payload user, or to `null` for an anonymous caller, before returning.
|
|
290
|
+
*/
|
|
291
|
+
overrideGetAuthorizedMCP?: (
|
|
292
|
+
args: {
|
|
293
|
+
pluginConfig: SanitizedMCPPluginConfig
|
|
294
|
+
} & GetAuthorizedMCPArgs,
|
|
295
|
+
) => MaybePromise<AuthorizedMCP>
|
|
241
296
|
prompts?: Record<string, Prompt>
|
|
242
297
|
resources?: Record<string, Resource>
|
|
243
298
|
/** Cross-cutting tools (not scoped to any collection or global). */
|
|
244
299
|
tools?: MCPTopLevelToolsMap
|
|
245
|
-
userCollection?: CollectionSlug
|
|
246
300
|
}
|
|
247
301
|
|
|
248
302
|
export type SanitizedMCPPluginConfig = {
|
|
249
303
|
items: MCPItem[]
|
|
250
|
-
|
|
251
|
-
} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>
|
|
304
|
+
} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>
|
|
252
305
|
|
|
253
306
|
export type MCPServerOptions = {
|
|
254
307
|
options?: ConstructorParameters<typeof McpServer>[1]
|
|
@@ -256,52 +309,12 @@ export type MCPServerOptions = {
|
|
|
256
309
|
}
|
|
257
310
|
|
|
258
311
|
/**
|
|
259
|
-
*
|
|
260
|
-
* A `false` leaf disables that tool; missing keys defer to
|
|
261
|
-
* defaults (built-in CRUD is on, opt-in tools are off).
|
|
262
|
-
*/
|
|
263
|
-
export type MCPAPIKeysDocAccessTree = {
|
|
264
|
-
collections?: {
|
|
265
|
-
[CollectionSlug: CollectionSlug]: {
|
|
266
|
-
[ToolKey: string]: boolean
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
globals?: {
|
|
270
|
-
[GlobalSlug: GlobalSlug]: {
|
|
271
|
-
[ToolKey: string]: boolean
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
prompts?: {
|
|
275
|
-
[PromptKey: string]: boolean
|
|
276
|
-
}
|
|
277
|
-
resources?: {
|
|
278
|
-
[ResourceKey: string]: boolean
|
|
279
|
-
}
|
|
280
|
-
tools?: {
|
|
281
|
-
[ToolKey: string]: boolean
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Stored on `payload-mcp-api-keys` docs
|
|
287
|
-
*/
|
|
288
|
-
export type MCPAPIKeysDoc = {
|
|
289
|
-
access: MCPAPIKeysDocAccessTree
|
|
290
|
-
apiKey?: string
|
|
291
|
-
apiKeyIndex?: string
|
|
292
|
-
id: DefaultDocumentIDType
|
|
293
|
-
lastUsed?: string
|
|
294
|
-
overrideAccess?: boolean
|
|
295
|
-
user: null | TypedUser
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* One MCP primitive plus the metadata needed for access checks, admin UI, and
|
|
312
|
+
* One MCP primitive plus the metadata needed for config-driven filtering and
|
|
300
313
|
* registration.
|
|
301
314
|
*
|
|
302
|
-
* - `configKey`: the config
|
|
315
|
+
* - `configKey`: the config identifier, e.g. `find` or `echo`.
|
|
303
316
|
* - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
|
|
304
|
-
* - `label`: human-readable
|
|
317
|
+
* - `label`: human-readable display text.
|
|
305
318
|
*/
|
|
306
319
|
export type MCPItemBase = {
|
|
307
320
|
configKey: string
|
|
@@ -338,13 +351,10 @@ export type MCPItem =
|
|
|
338
351
|
| GlobalMCPItem
|
|
339
352
|
|
|
340
353
|
/**
|
|
341
|
-
* The
|
|
342
|
-
*
|
|
343
|
-
* receive this via `args.authorizedMCP` so they can spread
|
|
344
|
-
* `localAPIDefaults(authorizedMCP)` into every local API call.
|
|
354
|
+
* The MCP items and access mode authorized for this request. The authenticated user is available
|
|
355
|
+
* as `req.user`.
|
|
345
356
|
*/
|
|
346
357
|
export type AuthorizedMCP = {
|
|
347
358
|
items: MCPItem[]
|
|
348
359
|
overrideAccess: boolean
|
|
349
|
-
user: null | TypedUser
|
|
350
360
|
}
|
|
@@ -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 = ({
|