@payloadcms/plugin-mcp 4.0.0-internal.38b7f1d → 4.0.0-internal.4804abd
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/bin.js +39 -0
- package/dist/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -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 +26 -0
- package/dist/defineTool.d.ts.map +1 -0
- package/dist/defineTool.js +37 -0
- package/dist/defineTool.js.map +1 -0
- package/dist/endpoint/access.d.ts +22 -0
- package/dist/endpoint/access.d.ts.map +1 -0
- package/dist/endpoint/access.js +100 -0
- package/dist/endpoint/access.js.map +1 -0
- package/dist/endpoint/index.d.ts +3 -0
- package/dist/endpoint/index.d.ts.map +1 -0
- package/dist/endpoint/index.js +47 -0
- package/dist/endpoint/index.js.map +1 -0
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -0
- package/dist/exports/client.js.map +1 -0
- 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 +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -67
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +19 -0
- package/dist/mcp/buildMcpServer.d.ts.map +1 -0
- package/dist/mcp/buildMcpServer.js +201 -0
- package/dist/mcp/buildMcpServer.js.map +1 -0
- package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/authTools.js +288 -0
- package/dist/mcp/builtin/collections/authTools.js.map +1 -0
- package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countTool.js +69 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +65 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/createTool.js +87 -0
- package/dist/mcp/builtin/collections/createTool.js.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.js +111 -0
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +97 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +93 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findTool.js +165 -0
- package/dist/mcp/builtin/collections/findTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +84 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +99 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +47 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +82 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.js +192 -0
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.js +71 -0
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +65 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findTool.js +73 -0
- package/dist/mcp/builtin/globals/findTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +80 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +95 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +47 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +78 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +87 -0
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
- package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
- package/dist/mcp/builtin/validateEntityData.js +82 -0
- package/dist/mcp/builtin/validateEntityData.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +162 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -0
- package/dist/mcp/builtinTools.js +163 -0
- package/dist/mcp/builtinTools.js.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts +16 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.js +229 -0
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
- package/dist/stdio.d.ts +9 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +108 -0
- package/dist/stdio.js.map +1 -0
- package/dist/types.d.ts +222 -461
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getLogger.d.ts +10 -0
- package/dist/utils/getLogger.d.ts.map +1 -0
- package/dist/utils/getLogger.js +22 -0
- package/dist/utils/getLogger.js.map +1 -0
- package/dist/utils/getPluginConfig.d.ts +12 -0
- package/dist/utils/getPluginConfig.d.ts.map +1 -0
- package/dist/utils/getPluginConfig.js +15 -0
- package/dist/utils/getPluginConfig.js.map +1 -0
- package/dist/utils/localAPIDefaults.d.ts +20 -0
- package/dist/utils/localAPIDefaults.d.ts.map +1 -0
- package/dist/utils/localAPIDefaults.js +19 -0
- package/dist/utils/localAPIDefaults.js.map +1 -0
- package/dist/utils/resolveProjectRoot.d.ts +7 -0
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
- package/dist/utils/resolveProjectRoot.js +15 -0
- package/dist/utils/resolveProjectRoot.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js +32 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +10 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +384 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +133 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
- package/dist/utils/toStandardSchema.d.ts +5 -0
- package/dist/utils/toStandardSchema.d.ts.map +1 -0
- package/dist/utils/toStandardSchema.js +4 -0
- package/dist/utils/toStandardSchema.js.map +1 -0
- package/dist/utils/whereSchema.d.ts +9 -0
- package/dist/utils/whereSchema.d.ts.map +1 -0
- package/dist/utils/whereSchema.js +13 -0
- package/dist/utils/whereSchema.js.map +1 -0
- package/package.json +32 -10
- package/src/@types/assets.d.ts +3 -0
- package/src/defaultAccess.ts +3 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +119 -0
- package/src/endpoint/index.ts +48 -0
- package/src/exports/client.ts +3 -0
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +29 -87
- package/src/mcp/buildMcpServer.ts +264 -0
- package/src/mcp/builtin/collections/authTools.ts +269 -0
- package/src/mcp/builtin/collections/countTool.ts +74 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +70 -0
- package/src/mcp/builtin/collections/createTool.ts +112 -0
- package/src/mcp/builtin/collections/deleteTool.ts +126 -0
- package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +120 -0
- package/src/mcp/builtin/collections/findTool.ts +217 -0
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +46 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
- package/src/mcp/builtin/collections/updateTool.ts +211 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +69 -0
- package/src/mcp/builtin/globals/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/globals/findTool.ts +105 -0
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +41 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +100 -0
- package/src/mcp/builtin/globals/updateTool.ts +115 -0
- package/src/mcp/builtin/validateEntityData.ts +132 -0
- package/src/mcp/builtinTools.ts +154 -0
- package/src/mcp/sanitizeMCPConfig.ts +277 -0
- package/src/stdio.ts +113 -0
- package/src/types.ts +263 -493
- package/src/utils/getLogger.ts +22 -0
- package/src/utils/getPluginConfig.ts +24 -0
- package/src/utils/localAPIDefaults.ts +22 -0
- package/src/utils/resolveProjectRoot.ts +17 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +62 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +96 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +432 -0
- package/src/utils/toStandardSchema.ts +9 -0
- package/src/utils/whereSchema.ts +24 -0
- package/dist/collections/createApiKeysCollection.d.ts +0 -7
- package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
- package/dist/collections/createApiKeysCollection.js +0 -317
- package/dist/collections/createApiKeysCollection.js.map +0 -1
- package/dist/defaults.d.ts +0 -4
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js +0 -5
- package/dist/defaults.js.map +0 -1
- package/dist/endpoints/mcp.d.ts +0 -4
- package/dist/endpoints/mcp.d.ts.map +0 -1
- package/dist/endpoints/mcp.js +0 -71
- package/dist/endpoints/mcp.js.map +0 -1
- package/dist/mcp/createRequest.d.ts +0 -3
- package/dist/mcp/createRequest.d.ts.map +0 -1
- package/dist/mcp/createRequest.js +0 -14
- package/dist/mcp/createRequest.js.map +0 -1
- package/dist/mcp/getMcpHandler.d.ts +0 -4
- package/dist/mcp/getMcpHandler.d.ts.map +0 -1
- package/dist/mcp/getMcpHandler.js +0 -231
- package/dist/mcp/getMcpHandler.js.map +0 -1
- package/dist/mcp/helpers/config.d.ts +0 -22
- package/dist/mcp/helpers/config.d.ts.map +0 -1
- package/dist/mcp/helpers/config.js +0 -153
- package/dist/mcp/helpers/config.js.map +0 -1
- package/dist/mcp/helpers/fields.d.ts +0 -19
- package/dist/mcp/helpers/fields.d.ts.map +0 -1
- package/dist/mcp/helpers/fields.js +0 -102
- package/dist/mcp/helpers/fields.js.map +0 -1
- package/dist/mcp/helpers/fileValidation.d.ts +0 -67
- package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
- package/dist/mcp/helpers/fileValidation.js +0 -267
- package/dist/mcp/helpers/fileValidation.js.map +0 -1
- package/dist/mcp/registerTool.d.ts +0 -6
- package/dist/mcp/registerTool.d.ts.map +0 -1
- package/dist/mcp/registerTool.js +0 -18
- package/dist/mcp/registerTool.js.map +0 -1
- package/dist/mcp/tools/auth/auth.d.ts +0 -4
- package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
- package/dist/mcp/tools/auth/auth.js +0 -57
- package/dist/mcp/tools/auth/auth.js.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.js +0 -48
- package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
- package/dist/mcp/tools/auth/login.d.ts +0 -4
- package/dist/mcp/tools/auth/login.d.ts.map +0 -1
- package/dist/mcp/tools/auth/login.js +0 -51
- package/dist/mcp/tools/auth/login.js.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.js +0 -49
- package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
- package/dist/mcp/tools/auth/unlock.d.ts +0 -4
- package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
- package/dist/mcp/tools/auth/unlock.js +0 -48
- package/dist/mcp/tools/auth/unlock.js.map +0 -1
- package/dist/mcp/tools/auth/verify.d.ts +0 -4
- package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
- package/dist/mcp/tools/auth/verify.js +0 -45
- package/dist/mcp/tools/auth/verify.js.map +0 -1
- package/dist/mcp/tools/collection/create.d.ts +0 -10
- package/dist/mcp/tools/collection/create.d.ts.map +0 -1
- package/dist/mcp/tools/collection/create.js +0 -139
- package/dist/mcp/tools/collection/create.js.map +0 -1
- package/dist/mcp/tools/collection/delete.d.ts +0 -10
- package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
- package/dist/mcp/tools/collection/delete.js +0 -154
- package/dist/mcp/tools/collection/delete.js.map +0 -1
- package/dist/mcp/tools/collection/find.d.ts +0 -10
- package/dist/mcp/tools/collection/find.d.ts.map +0 -1
- package/dist/mcp/tools/collection/find.js +0 -165
- package/dist/mcp/tools/collection/find.js.map +0 -1
- package/dist/mcp/tools/collection/update.d.ts +0 -10
- package/dist/mcp/tools/collection/update.d.ts.map +0 -1
- package/dist/mcp/tools/collection/update.js +0 -209
- package/dist/mcp/tools/collection/update.js.map +0 -1
- package/dist/mcp/tools/config/find.d.ts +0 -10
- package/dist/mcp/tools/config/find.d.ts.map +0 -1
- package/dist/mcp/tools/config/find.js +0 -97
- package/dist/mcp/tools/config/find.js.map +0 -1
- package/dist/mcp/tools/config/update.d.ts +0 -10
- package/dist/mcp/tools/config/update.d.ts.map +0 -1
- package/dist/mcp/tools/config/update.js +0 -215
- package/dist/mcp/tools/config/update.js.map +0 -1
- package/dist/mcp/tools/global/find.d.ts +0 -5
- package/dist/mcp/tools/global/find.d.ts.map +0 -1
- package/dist/mcp/tools/global/find.js +0 -82
- package/dist/mcp/tools/global/find.js.map +0 -1
- package/dist/mcp/tools/global/update.d.ts +0 -6
- package/dist/mcp/tools/global/update.d.ts.map +0 -1
- package/dist/mcp/tools/global/update.js +0 -124
- package/dist/mcp/tools/global/update.js.map +0 -1
- package/dist/mcp/tools/job/create.d.ts +0 -10
- package/dist/mcp/tools/job/create.d.ts.map +0 -1
- package/dist/mcp/tools/job/create.js +0 -293
- package/dist/mcp/tools/job/create.js.map +0 -1
- package/dist/mcp/tools/job/run.d.ts +0 -10
- package/dist/mcp/tools/job/run.d.ts.map +0 -1
- package/dist/mcp/tools/job/run.js +0 -129
- package/dist/mcp/tools/job/run.js.map +0 -1
- package/dist/mcp/tools/job/update.d.ts +0 -11
- package/dist/mcp/tools/job/update.d.ts.map +0 -1
- package/dist/mcp/tools/job/update.js +0 -186
- package/dist/mcp/tools/job/update.js.map +0 -1
- package/dist/mcp/tools/resource/create.d.ts +0 -6
- package/dist/mcp/tools/resource/create.d.ts.map +0 -1
- package/dist/mcp/tools/resource/create.js +0 -124
- package/dist/mcp/tools/resource/create.js.map +0 -1
- package/dist/mcp/tools/resource/delete.d.ts +0 -5
- package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
- package/dist/mcp/tools/resource/delete.js +0 -151
- package/dist/mcp/tools/resource/delete.js.map +0 -1
- package/dist/mcp/tools/resource/find.d.ts +0 -5
- package/dist/mcp/tools/resource/find.d.ts.map +0 -1
- package/dist/mcp/tools/resource/find.js +0 -170
- package/dist/mcp/tools/resource/find.js.map +0 -1
- package/dist/mcp/tools/resource/update.d.ts +0 -6
- package/dist/mcp/tools/resource/update.d.ts.map +0 -1
- package/dist/mcp/tools/resource/update.js +0 -256
- package/dist/mcp/tools/resource/update.js.map +0 -1
- package/dist/mcp/tools/schemas.d.ts +0 -457
- package/dist/mcp/tools/schemas.d.ts.map +0 -1
- package/dist/mcp/tools/schemas.js +0 -243
- package/dist/mcp/tools/schemas.js.map +0 -1
- package/dist/utils/adminEntitySettings.d.ts +0 -17
- package/dist/utils/adminEntitySettings.d.ts.map +0 -1
- package/dist/utils/adminEntitySettings.js +0 -41
- package/dist/utils/adminEntitySettings.js.map +0 -1
- package/dist/utils/createApiKeyFields.d.ts +0 -15
- package/dist/utils/createApiKeyFields.d.ts.map +0 -1
- package/dist/utils/createApiKeyFields.js +0 -57
- package/dist/utils/createApiKeyFields.js.map +0 -1
- package/dist/utils/getEnabledSlugs.d.ts +0 -13
- package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
- package/dist/utils/getEnabledSlugs.js +0 -32
- package/dist/utils/getEnabledSlugs.js.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.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/sanitizeJsonSchema.d.ts +0 -13
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.js +0 -51
- package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
- package/src/collections/createApiKeysCollection.ts +0 -373
- package/src/defaults.ts +0 -3
- package/src/endpoints/mcp.ts +0 -91
- package/src/mcp/createRequest.ts +0 -13
- package/src/mcp/getMcpHandler.ts +0 -545
- package/src/mcp/helpers/config.ts +0 -213
- package/src/mcp/helpers/fields.ts +0 -154
- package/src/mcp/helpers/fileValidation.ts +0 -362
- package/src/mcp/registerTool.ts +0 -22
- package/src/mcp/tools/auth/auth.ts +0 -71
- package/src/mcp/tools/auth/forgotPassword.ts +0 -70
- package/src/mcp/tools/auth/login.ts +0 -72
- package/src/mcp/tools/auth/resetPassword.ts +0 -61
- package/src/mcp/tools/auth/unlock.ts +0 -64
- package/src/mcp/tools/auth/verify.ts +0 -57
- package/src/mcp/tools/collection/create.ts +0 -210
- package/src/mcp/tools/collection/delete.ts +0 -211
- package/src/mcp/tools/collection/find.ts +0 -224
- package/src/mcp/tools/collection/update.ts +0 -290
- package/src/mcp/tools/config/find.ts +0 -128
- package/src/mcp/tools/config/update.ts +0 -280
- package/src/mcp/tools/global/find.ts +0 -128
- package/src/mcp/tools/global/update.ts +0 -207
- package/src/mcp/tools/job/create.ts +0 -416
- package/src/mcp/tools/job/run.ts +0 -167
- package/src/mcp/tools/job/update.ts +0 -274
- package/src/mcp/tools/resource/create.ts +0 -211
- package/src/mcp/tools/resource/delete.ts +0 -218
- package/src/mcp/tools/resource/find.ts +0 -246
- package/src/mcp/tools/resource/update.ts +0 -383
- package/src/mcp/tools/schemas.ts +0 -520
- package/src/utils/adminEntitySettings.ts +0 -40
- package/src/utils/createApiKeyFields.ts +0 -72
- package/src/utils/getEnabledSlugs.ts +0 -42
- package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
- package/src/utils/schemaConversion/transformPointFields.ts +0 -55
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/whereSchema.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { validOperators } from 'payload/shared'\nimport { z } from 'zod'\n\nconst whereFieldSchema = z\n .partialRecord(z.enum(validOperators), z.unknown())\n .describe('Field query operators')\n\n/**\n * - Validates the `where` input of collection tools against Payload's `Where` shape\n * - Field keys map to operator objects restricted to `validOperators`\n * - `and` / `or` nest recursively\n */\nexport const whereSchema: z.ZodType<Where> = z\n .lazy(() =>\n z\n .object({\n and: z.array(whereSchema).optional(),\n or: z.array(whereSchema).optional(),\n })\n .catchall(whereFieldSchema),\n )\n .describe('Where clause using field names with Payload query operators, plus and/or groups')\n"],"names":["validOperators","z","whereFieldSchema","partialRecord","enum","unknown","describe","whereSchema","lazy","object","and","array","optional","or","catchall"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAEvB,MAAMC,mBAAmBD,EACtBE,aAAa,CAACF,EAAEG,IAAI,CAACJ,iBAAiBC,EAAEI,OAAO,IAC/CC,QAAQ,CAAC;AAEZ;;;;CAIC,GACD,OAAO,MAAMC,cAAgCN,EAC1CO,IAAI,CAAC,IACJP,EACGQ,MAAM,CAAC;QACNC,KAAKT,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;QAClCC,IAAIZ,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;IACnC,GACCE,QAAQ,CAACZ,mBAEbI,QAAQ,CAAC,mFAAkF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-mcp",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.4804abd",
|
|
4
4
|
"description": "MCP (Model Context Protocol) capabilities with Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -21,34 +21,56 @@
|
|
|
21
21
|
"url": "https://payloadcms.com"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"sideEffects": false,
|
|
25
24
|
"type": "module",
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"import": "./dist/index.js",
|
|
29
28
|
"types": "./dist/index.d.ts",
|
|
30
29
|
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./client": {
|
|
32
|
+
"import": "./dist/exports/client.js",
|
|
33
|
+
"types": "./dist/exports/client.d.ts",
|
|
34
|
+
"default": "./dist/exports/client.js"
|
|
35
|
+
},
|
|
36
|
+
"./stdio": {
|
|
37
|
+
"import": "./dist/stdio.js",
|
|
38
|
+
"types": "./dist/stdio.d.ts",
|
|
39
|
+
"default": "./dist/stdio.js"
|
|
40
|
+
},
|
|
41
|
+
"./internal": {
|
|
42
|
+
"import": "./dist/internal.js",
|
|
43
|
+
"types": "./dist/internal.d.ts",
|
|
44
|
+
"default": "./dist/internal.js"
|
|
31
45
|
}
|
|
32
46
|
},
|
|
33
47
|
"main": "./dist/index.js",
|
|
34
48
|
"types": "./dist/index.d.ts",
|
|
49
|
+
"bin": {
|
|
50
|
+
"payload-mcp": "./bin.js"
|
|
51
|
+
},
|
|
35
52
|
"files": [
|
|
36
53
|
"src",
|
|
37
|
-
"dist"
|
|
54
|
+
"dist",
|
|
55
|
+
"bin.js"
|
|
38
56
|
],
|
|
39
57
|
"dependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"zod": "^3.25.50"
|
|
58
|
+
"@cfworker/json-schema": "^4.1.1",
|
|
59
|
+
"@modelcontextprotocol/server": "2.0.0-alpha.2",
|
|
60
|
+
"tsx": "4.22.4",
|
|
61
|
+
"zod": "^4.0.0"
|
|
45
62
|
},
|
|
46
63
|
"devDependencies": {
|
|
47
64
|
"@payloadcms/eslint-config": "3.28.0",
|
|
48
|
-
"payload": "4.0.0-internal.
|
|
65
|
+
"payload": "4.0.0-internal.4804abd"
|
|
49
66
|
},
|
|
50
67
|
"peerDependencies": {
|
|
51
|
-
"payload": "4.0.0-internal.
|
|
68
|
+
"payload": "4.0.0-internal.4804abd"
|
|
69
|
+
},
|
|
70
|
+
"//deps_notes": {
|
|
71
|
+
"zod": "zod is a hard dependency of @modelcontextprotocol/server, thus we can safely use it without it impacting bundle size. Make extra sure the zod version here matches exactly what's defined in the dependencies of @modelcontextprotocol/server to avoid duplicate versions being installed.",
|
|
72
|
+
"@cfworker/json-schema": "Should be able to remove in next @modelcontextprotocol/server alpha release. Marked as an optional peer of @modelcontextprotocol/server, but its bundle does an eager top-level `import { Validator } from '@cfworker/json-schema'`, so it must be installed even when only zod-registered tools are used. Drop once upstream lazy-loads the validator. See: https://github.com/modelcontextprotocol/typescript-sdk",
|
|
73
|
+
"tsx": "Required by the `bin.js` stdio mcp. Keep the version pinned to whatever `payload` ships to avoid duplicate installs."
|
|
52
74
|
},
|
|
53
75
|
"homepage:": "https://payloadcms.com",
|
|
54
76
|
"scripts": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CollectionTool, GlobalTool, Prompt, Tool, ToolInputSchema } from './types.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Two-stage builder: pass the schema/metadata first, then chain `.handler(fn)`. Splitting the
|
|
5
|
+
* call lets TypeScript resolve `TSchema` from `input` (call 1) before contextually typing the
|
|
6
|
+
* handler (call 2). A single-call API hit a TS limitation where property order in the literal
|
|
7
|
+
* decided whether `TSchema` was inferred or pinned to its default.
|
|
8
|
+
*
|
|
9
|
+
* defineCollectionTool({ description, input })
|
|
10
|
+
* .handler(({ input }) => …) // ← input is fully typed here regardless of order
|
|
11
|
+
*
|
|
12
|
+
* Config and handler signatures are derived from `Tool` / `CollectionTool` / `GlobalTool` /
|
|
13
|
+
* `Prompt` via `Omit` + indexed access so there's no duplication with `types.ts`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const defineTool = <
|
|
17
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
18
|
+
>(
|
|
19
|
+
args: Omit<Tool<TSchema>, 'handler'>,
|
|
20
|
+
): { handler: (fn: Tool<TSchema>['handler']) => Tool } => ({
|
|
21
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as Tool,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const defineCollectionTool = <
|
|
25
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
26
|
+
>(
|
|
27
|
+
args: Omit<CollectionTool<TSchema>, 'handler'>,
|
|
28
|
+
): { handler: (fn: CollectionTool<TSchema>['handler']) => CollectionTool } => ({
|
|
29
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as CollectionTool,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export const defineGlobalTool = <
|
|
33
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
34
|
+
>(
|
|
35
|
+
args: Omit<GlobalTool<TSchema>, 'handler'>,
|
|
36
|
+
): { handler: (fn: GlobalTool<TSchema>['handler']) => GlobalTool } => ({
|
|
37
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as GlobalTool,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const definePrompt = <TSchema extends ToolInputSchema = ToolInputSchema>(
|
|
41
|
+
args: Omit<Prompt<TSchema>, 'handler'>,
|
|
42
|
+
): { handler: (fn: Prompt<TSchema>['handler']) => Prompt } => ({
|
|
43
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as Prompt,
|
|
44
|
+
})
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { PayloadRequest, SanitizedPermissions } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { getAccessResults, UnauthorizedError } from 'payload'
|
|
4
|
+
|
|
5
|
+
import type { AuthorizedMCP, MCPItem } from '../types.js'
|
|
6
|
+
|
|
7
|
+
import { getPluginConfig } from '../utils/getPluginConfig.js'
|
|
8
|
+
|
|
9
|
+
export type GetAuthorizedMCPArgs = {
|
|
10
|
+
overrideAccess: boolean
|
|
11
|
+
req: PayloadRequest
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the MCP caller and returns the MCP surface authorized for that request.
|
|
16
|
+
*
|
|
17
|
+
* Authorization has two layers:
|
|
18
|
+
* 1. Payload collection/global permissions determine whether built-in operation tools are shown.
|
|
19
|
+
* 2. MCP `access` callbacks can further hide any configured tool, prompt, or resource.
|
|
20
|
+
*
|
|
21
|
+
* Like Payload core operations, `overrideAccess` skips both layers.
|
|
22
|
+
*/
|
|
23
|
+
export const getAuthorizedMCP: (args: GetAuthorizedMCPArgs) => Promise<AuthorizedMCP> = async ({
|
|
24
|
+
overrideAccess,
|
|
25
|
+
req,
|
|
26
|
+
}) => {
|
|
27
|
+
const pluginConfig = getPluginConfig({ config: req.payload.config })
|
|
28
|
+
|
|
29
|
+
if (pluginConfig.overrideGetAuthorizedMCP) {
|
|
30
|
+
return await pluginConfig.overrideGetAuthorizedMCP({
|
|
31
|
+
overrideAccess,
|
|
32
|
+
pluginConfig,
|
|
33
|
+
req,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (req.headers) {
|
|
38
|
+
const headers = new Headers(req.headers)
|
|
39
|
+
const hasAuthorization = headers.has('Authorization')
|
|
40
|
+
|
|
41
|
+
headers.set('DisableAutologin', 'true')
|
|
42
|
+
req.user = (await req.payload.auth({ headers, req })).user
|
|
43
|
+
|
|
44
|
+
if (hasAuthorization && !req.user) {
|
|
45
|
+
throw new UnauthorizedError(req.t)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
items: await filterMCPItems({
|
|
51
|
+
items: pluginConfig.items,
|
|
52
|
+
overrideAccess,
|
|
53
|
+
req,
|
|
54
|
+
}),
|
|
55
|
+
overrideAccess,
|
|
56
|
+
user: req.user,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const filterMCPItems = async ({
|
|
61
|
+
items,
|
|
62
|
+
overrideAccess,
|
|
63
|
+
req,
|
|
64
|
+
}: {
|
|
65
|
+
items: MCPItem[]
|
|
66
|
+
overrideAccess: boolean
|
|
67
|
+
req: PayloadRequest
|
|
68
|
+
}): Promise<MCPItem[]> => {
|
|
69
|
+
// Match Payload core: overrideAccess bypasses access evaluation instead of
|
|
70
|
+
// forcing each access function to return true.
|
|
71
|
+
if (overrideAccess) {
|
|
72
|
+
return items
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const authorizedItems: MCPItem[] = []
|
|
76
|
+
|
|
77
|
+
const permissions = await getAccessResults({ req })
|
|
78
|
+
|
|
79
|
+
for (const item of items) {
|
|
80
|
+
if (!(await checkItemAccess({ item, permissions, req }))) {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
authorizedItems.push(item)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return authorizedItems
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Runs MCP item access callbacks
|
|
91
|
+
*/
|
|
92
|
+
const checkItemAccess = async ({
|
|
93
|
+
item,
|
|
94
|
+
permissions,
|
|
95
|
+
req,
|
|
96
|
+
}: {
|
|
97
|
+
item: MCPItem
|
|
98
|
+
permissions?: SanitizedPermissions
|
|
99
|
+
req: PayloadRequest
|
|
100
|
+
}): Promise<boolean> => {
|
|
101
|
+
switch (item.type) {
|
|
102
|
+
case 'collectionTool':
|
|
103
|
+
return (
|
|
104
|
+
!item.tool.access ||
|
|
105
|
+
(await item.tool.access({ collectionSlug: item.collectionSlug, permissions, req }))
|
|
106
|
+
)
|
|
107
|
+
case 'globalTool':
|
|
108
|
+
return (
|
|
109
|
+
!item.tool.access ||
|
|
110
|
+
(await item.tool.access({ globalSlug: item.globalSlug, permissions, req }))
|
|
111
|
+
)
|
|
112
|
+
case 'prompt':
|
|
113
|
+
return !item.prompt.access || (await item.prompt.access({ permissions, req }))
|
|
114
|
+
case 'resource':
|
|
115
|
+
return !item.resource.access || (await item.resource.access({ permissions, req }))
|
|
116
|
+
case 'tool':
|
|
117
|
+
return !item.tool.access || (await item.tool.access({ permissions, req }))
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/server'
|
|
2
|
+
import { APIError, type PayloadHandler } from 'payload'
|
|
3
|
+
|
|
4
|
+
import { buildMcpServer } from '../mcp/buildMcpServer.js'
|
|
5
|
+
import { getPluginConfig } from '../utils/getPluginConfig.js'
|
|
6
|
+
import { getAuthorizedMCP } from './access.js'
|
|
7
|
+
|
|
8
|
+
export const mcpEndpoint: PayloadHandler = async (req) => {
|
|
9
|
+
if (!req.url) {
|
|
10
|
+
throw new APIError('Missing request URL', 400)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
req.payloadAPI = 'MCP' as const
|
|
14
|
+
|
|
15
|
+
const pluginConfig = getPluginConfig({ config: req.payload.config })
|
|
16
|
+
const overrideAccessParam = new URL(req.url).searchParams.get('overrideAccess')
|
|
17
|
+
|
|
18
|
+
if (overrideAccessParam !== null && process.env.NODE_ENV !== 'development') {
|
|
19
|
+
throw new APIError('MCP overrideAccess is only available in development.', 400)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let overrideAccess = false
|
|
23
|
+
if (overrideAccessParam === 'true') {
|
|
24
|
+
overrideAccess = true
|
|
25
|
+
} else if (overrideAccessParam !== null && overrideAccessParam !== 'false') {
|
|
26
|
+
throw new APIError('MCP overrideAccess must be "true" or "false".', 400)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
|
|
30
|
+
|
|
31
|
+
const server = buildMcpServer({ authorizedMCP, pluginConfig, req })
|
|
32
|
+
|
|
33
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
34
|
+
enableJsonResponse: true,
|
|
35
|
+
sessionIdGenerator: undefined, // stateless mode
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
await server.connect(transport)
|
|
39
|
+
|
|
40
|
+
const mcpRequest = new Request(req.url, {
|
|
41
|
+
body: req.body,
|
|
42
|
+
duplex: 'half',
|
|
43
|
+
headers: req.headers,
|
|
44
|
+
method: req.method,
|
|
45
|
+
} as { duplex: 'half' } & RequestInit)
|
|
46
|
+
|
|
47
|
+
return await transport.handleRequest(mcpRequest)
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { filterMCPItems, getAuthorizedMCP } from '../endpoint/access.js'
|
package/src/index.ts
CHANGED
|
@@ -1,113 +1,55 @@
|
|
|
1
1
|
import { definePlugin } from 'payload'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { AuthorizedMCP, MCPPluginConfig, SanitizedMCPPluginConfig } from './types.js'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { mcpEndpoint } from './endpoint/index.js'
|
|
6
|
+
import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'
|
|
7
7
|
|
|
8
8
|
declare module 'payload' {
|
|
9
9
|
export interface PayloadRequest {
|
|
10
10
|
payloadAPI: 'GraphQL' | 'local' | 'MCP' | 'REST'
|
|
11
11
|
}
|
|
12
12
|
interface RegisteredPlugins {
|
|
13
|
+
/** After the plugin's `plugin` callback runs, `options` holds the sanitized config. */
|
|
13
14
|
'@payloadcms/plugin-mcp': MCPPluginConfig
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
export type { AuthorizedMCP, MCPPluginConfig, SanitizedMCPPluginConfig }
|
|
18
19
|
|
|
19
|
-
export
|
|
20
|
+
export { defineCollectionTool, defineGlobalTool, definePrompt, defineTool } from './defineTool.js'
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* The MCP Plugin for Payload. This plugin allows you to add MCP capabilities to your Payload project.
|
|
23
|
-
*
|
|
24
|
-
* @param pluginOptions - The options for the MCP plugin.
|
|
25
|
-
*/
|
|
26
22
|
export const mcpPlugin = definePlugin<MCPPluginConfig>({
|
|
27
23
|
slug: '@payloadcms/plugin-mcp',
|
|
28
24
|
order: 10,
|
|
29
|
-
plugin: ({ config, plugins
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
plugin: ({ config, plugins, ...rawConfig }) => {
|
|
26
|
+
const pluginConfig = sanitizeMCPConfig({ config, pluginConfig: rawConfig })
|
|
27
|
+
|
|
28
|
+
// Stash the sanitized config on plugin options so `getPluginConfig()` reads it.
|
|
29
|
+
const registered = plugins['@payloadcms/plugin-mcp']
|
|
30
|
+
if (registered) {
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
registered.sanitizedOptions = pluginConfig as unknown as typeof registered.options
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
const collections = pluginOptions.collections || {}
|
|
36
|
-
// Globals
|
|
37
|
-
const globals = pluginOptions.globals || {}
|
|
38
|
-
// Extract custom tools for the global config
|
|
39
|
-
const customTools =
|
|
40
|
-
pluginOptions.mcp?.tools?.map((tool) => ({
|
|
41
|
-
name: tool.name,
|
|
42
|
-
description: tool.description,
|
|
43
|
-
})) || []
|
|
44
|
-
|
|
45
|
-
// User Collection
|
|
46
|
-
pluginOptions.userCollection =
|
|
47
|
-
pluginOptions.userCollection ?? config?.admin?.user ?? defaults.userCollection
|
|
48
|
-
|
|
49
|
-
const experimentalTools = pluginOptions?.experimental?.tools || {}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* API Keys
|
|
53
|
-
* --------
|
|
54
|
-
* High resolution control over MCP capabilities is crucial when using Payload with LLMs.
|
|
55
|
-
*
|
|
56
|
-
* This API Keys collection has ways for admins to create API keys and allow or disallow the MCP capabilities.
|
|
57
|
-
* This is useful when Admins want to allow or disallow the use of the MCP capabilities in real time.
|
|
58
|
-
* For example:
|
|
59
|
-
* - If a collection has all of its capabilities enabled, admins can allow or disallow the create, update, delete, and find capabilities on that collection.
|
|
60
|
-
* - If a collection only has the find capability enabled, admins can only allow or disallow the find capability on that collection.
|
|
61
|
-
* - If a global has all of its capabilities enabled, admins can allow or disallow the find and update capabilities on that global.
|
|
62
|
-
* - If a custom tool has gone haywire, admins can disallow that tool.
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
const apiKeyCollection = createAPIKeysCollection(
|
|
66
|
-
collections,
|
|
67
|
-
globals,
|
|
68
|
-
customTools,
|
|
69
|
-
experimentalTools,
|
|
70
|
-
pluginOptions,
|
|
71
|
-
)
|
|
72
|
-
if (pluginOptions.overrideApiKeyCollection) {
|
|
73
|
-
config.collections.push(pluginOptions.overrideApiKeyCollection(apiKeyCollection))
|
|
74
|
-
} else {
|
|
75
|
-
config.collections.push(apiKeyCollection)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* If the plugin is disabled, we still want to keep added collections/fields so the database schema is consistent which is important for migrations.
|
|
80
|
-
* If your plugin heavily modifies the database schema, you may want to remove this property.
|
|
81
|
-
*/
|
|
82
|
-
if (pluginOptions.disabled) {
|
|
35
|
+
if (pluginConfig.disabled) {
|
|
83
36
|
return config
|
|
84
37
|
}
|
|
85
38
|
|
|
86
|
-
|
|
87
|
-
config
|
|
39
|
+
return {
|
|
40
|
+
...config,
|
|
41
|
+
endpoints: [
|
|
42
|
+
...(config.endpoints ?? []),
|
|
43
|
+
// Payload prefixes /api, so the full path is /api/mcp.
|
|
44
|
+
{ handler: mcpEndpoint, method: 'post', path: '/mcp' },
|
|
45
|
+
// Streamable HTTP's optional server=>client GET stream. We don't offer
|
|
46
|
+
// one, so answer 405 per spec-— clients then skip it cleanly
|
|
47
|
+
{
|
|
48
|
+
handler: () => new Response(null, { headers: { Allow: 'POST' }, status: 405 }),
|
|
49
|
+
method: 'get',
|
|
50
|
+
path: '/mcp',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
88
53
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* This is the primary MCP Server Endpoint.
|
|
92
|
-
* Payload will automatically add the /api prefix to the path, so the full path is `/api/mcp`
|
|
93
|
-
* NOTE: This is only transport method until we add full support for SSE which will be another endpoint at `/api/sse`
|
|
94
|
-
*/
|
|
95
|
-
config.endpoints.push({
|
|
96
|
-
handler: initializeMCPHandler(pluginOptions),
|
|
97
|
-
method: 'post',
|
|
98
|
-
path: '/mcp',
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The GET response is always: {"jsonrpc":"2.0","error":{"code":-32000,"message":"Method not allowed."},"id":null} -- even with an API key
|
|
103
|
-
* This is expected behavior and MCP clients should always use the POST endpoint.
|
|
104
|
-
*/
|
|
105
|
-
config.endpoints.push({
|
|
106
|
-
handler: initializeMCPHandler(pluginOptions),
|
|
107
|
-
method: 'get',
|
|
108
|
-
path: '/mcp',
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
return config
|
|
112
54
|
},
|
|
113
55
|
})
|