@payloadcms/plugin-mcp 4.0.0-internal.38b7f1d → 4.0.0-internal.4c792ad
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 +34 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -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 +78 -0
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -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/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/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
- package/src/utils/schemaConversion/transformPointFields.ts +0 -55
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CollectionConfig,
|
|
3
|
+
Config,
|
|
4
|
+
GlobalConfig,
|
|
5
|
+
SanitizedCollectionConfig,
|
|
6
|
+
SanitizedConfig,
|
|
7
|
+
SanitizedGlobalConfig,
|
|
8
|
+
} from 'payload'
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
CollectionMCPItem,
|
|
12
|
+
CollectionTool,
|
|
13
|
+
GlobalMCPItem,
|
|
14
|
+
GlobalTool,
|
|
15
|
+
MCPItem,
|
|
16
|
+
MCPPluginConfig,
|
|
17
|
+
SanitizedMCPPluginConfig,
|
|
18
|
+
} from '../types.js'
|
|
19
|
+
|
|
20
|
+
import { defaultAccess } from '../defaultAccess.js'
|
|
21
|
+
import {
|
|
22
|
+
COLLECTION_AUTH_BUILTIN_ENTRIES,
|
|
23
|
+
COLLECTION_AUTH_BUILTINS,
|
|
24
|
+
COLLECTION_BUILTIN_ENTRIES,
|
|
25
|
+
COLLECTION_BUILTINS,
|
|
26
|
+
GLOBAL_BUILTIN_ENTRIES,
|
|
27
|
+
GLOBAL_BUILTINS,
|
|
28
|
+
TOOL_BUILTIN_ENTRIES,
|
|
29
|
+
TOOL_BUILTINS,
|
|
30
|
+
} from './builtinTools.js'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Converts the user-configured `MCPPluginConfig` into a `SanitizedMCPPluginConfig`:
|
|
34
|
+
* - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
|
|
35
|
+
* tool maps into a single `items` array.
|
|
36
|
+
* - Applies built-in tools for collections and globals, respecting opt-out user overrides.
|
|
37
|
+
*
|
|
38
|
+
* Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
|
|
39
|
+
* ?.options` holds the sanitized result
|
|
40
|
+
*/
|
|
41
|
+
export const sanitizeMCPConfig = ({
|
|
42
|
+
config,
|
|
43
|
+
pluginConfig,
|
|
44
|
+
}: {
|
|
45
|
+
config: Config | SanitizedConfig
|
|
46
|
+
pluginConfig: MCPPluginConfig
|
|
47
|
+
}): SanitizedMCPPluginConfig => {
|
|
48
|
+
const items: MCPItem[] = []
|
|
49
|
+
|
|
50
|
+
for (const collection of config.collections ?? []) {
|
|
51
|
+
items.push(...sanitizeCollectionConfig({ collection, pluginConfig }))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const global of config.globals ?? []) {
|
|
55
|
+
items.push(...sanitizeGlobalConfig({ global, pluginConfig }))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const [configKey, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {
|
|
59
|
+
items.push({
|
|
60
|
+
type: 'tool',
|
|
61
|
+
configKey,
|
|
62
|
+
label: tool.annotations?.title ?? configKey,
|
|
63
|
+
mcpName,
|
|
64
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const [configKey, tool] of Object.entries(pluginConfig.tools ?? {})) {
|
|
69
|
+
if (configKey in TOOL_BUILTINS) {
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
items.push({
|
|
73
|
+
type: 'tool',
|
|
74
|
+
configKey,
|
|
75
|
+
label: tool.annotations?.title ?? configKey,
|
|
76
|
+
mcpName: configKey,
|
|
77
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const [configKey, prompt] of Object.entries(pluginConfig.prompts ?? {})) {
|
|
82
|
+
items.push({
|
|
83
|
+
type: 'prompt',
|
|
84
|
+
configKey,
|
|
85
|
+
label: prompt.title ?? configKey,
|
|
86
|
+
mcpName: configKey,
|
|
87
|
+
prompt: { ...prompt, access: prompt.access ?? defaultAccess },
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const [configKey, resource] of Object.entries(pluginConfig.resources ?? {})) {
|
|
92
|
+
items.push({
|
|
93
|
+
type: 'resource',
|
|
94
|
+
configKey,
|
|
95
|
+
label: resource.title ?? configKey,
|
|
96
|
+
mcpName: configKey,
|
|
97
|
+
resource: { ...resource, access: resource.access ?? defaultAccess },
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
disabled: pluginConfig.disabled,
|
|
103
|
+
items,
|
|
104
|
+
mcp: pluginConfig.mcp,
|
|
105
|
+
overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const sanitizeCollectionConfig = ({
|
|
110
|
+
collection,
|
|
111
|
+
pluginConfig,
|
|
112
|
+
}: {
|
|
113
|
+
collection: CollectionConfig | SanitizedCollectionConfig
|
|
114
|
+
pluginConfig: MCPPluginConfig
|
|
115
|
+
}): CollectionMCPItem[] => {
|
|
116
|
+
const slug = collection.slug
|
|
117
|
+
const collectionPluginConfig = pluginConfig.collections?.[slug]
|
|
118
|
+
const items: CollectionMCPItem[] = []
|
|
119
|
+
/**
|
|
120
|
+
* Payload disables duplicate for auth collections by default unless the
|
|
121
|
+
* collection explicitly opts back in with `disableDuplicate: false`.
|
|
122
|
+
*/
|
|
123
|
+
const isDuplicateDisabled =
|
|
124
|
+
collection.disableDuplicate === true ||
|
|
125
|
+
(Boolean(collection.auth) && collection.disableDuplicate !== false)
|
|
126
|
+
|
|
127
|
+
for (const [
|
|
128
|
+
toolKey,
|
|
129
|
+
{ mcpName, requiresDuplicateEnabled, requiresVersions, tool },
|
|
130
|
+
] of COLLECTION_BUILTIN_ENTRIES) {
|
|
131
|
+
if (requiresVersions && !collection.versions) {
|
|
132
|
+
continue
|
|
133
|
+
}
|
|
134
|
+
if (requiresDuplicateEnabled && isDuplicateDisabled) {
|
|
135
|
+
continue
|
|
136
|
+
}
|
|
137
|
+
const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]
|
|
138
|
+
if (matchedConfigEntry === false) {
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
141
|
+
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
142
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
143
|
+
items.push({
|
|
144
|
+
type: 'collectionTool',
|
|
145
|
+
collectionSlug: slug,
|
|
146
|
+
configKey: toolKey,
|
|
147
|
+
label: annotations.title ?? toolKey,
|
|
148
|
+
mcpName,
|
|
149
|
+
tool: {
|
|
150
|
+
...tool,
|
|
151
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
152
|
+
annotations,
|
|
153
|
+
description: override?.description ?? tool.description,
|
|
154
|
+
overrideResponse:
|
|
155
|
+
override?.overrideResponse ??
|
|
156
|
+
collectionPluginConfig?.overrideResponse ??
|
|
157
|
+
tool.overrideResponse,
|
|
158
|
+
},
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (collection.auth) {
|
|
163
|
+
for (const [authToolKey, { mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {
|
|
164
|
+
const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]
|
|
165
|
+
if (!matchedConfigEntry) {
|
|
166
|
+
continue
|
|
167
|
+
}
|
|
168
|
+
// `true` means "enable, no override"; only the object form carries fields.
|
|
169
|
+
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
170
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
171
|
+
items.push({
|
|
172
|
+
type: 'collectionTool',
|
|
173
|
+
collectionSlug: slug,
|
|
174
|
+
configKey: authToolKey,
|
|
175
|
+
label: annotations.title ?? authToolKey,
|
|
176
|
+
mcpName,
|
|
177
|
+
tool: {
|
|
178
|
+
...tool,
|
|
179
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
180
|
+
annotations,
|
|
181
|
+
description: override?.description ?? tool.description,
|
|
182
|
+
overrideResponse:
|
|
183
|
+
override?.overrideResponse ??
|
|
184
|
+
collectionPluginConfig?.overrideResponse ??
|
|
185
|
+
tool.overrideResponse,
|
|
186
|
+
},
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Cast: builtin keys are filtered out below, so the remaining values are
|
|
192
|
+
// always custom tools (`CollectionTool`) or undefined
|
|
193
|
+
const customEntries = Object.entries(collectionPluginConfig?.tools ?? {}) as Array<
|
|
194
|
+
[string, CollectionTool | undefined]
|
|
195
|
+
>
|
|
196
|
+
for (const [configKey, customTool] of customEntries) {
|
|
197
|
+
if (configKey in COLLECTION_BUILTINS || configKey in COLLECTION_AUTH_BUILTINS) {
|
|
198
|
+
continue
|
|
199
|
+
}
|
|
200
|
+
if (!customTool) {
|
|
201
|
+
continue
|
|
202
|
+
}
|
|
203
|
+
items.push({
|
|
204
|
+
type: 'collectionTool',
|
|
205
|
+
collectionSlug: slug,
|
|
206
|
+
configKey,
|
|
207
|
+
label: customTool.annotations?.title ?? configKey,
|
|
208
|
+
mcpName: configKey,
|
|
209
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return items
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const sanitizeGlobalConfig = ({
|
|
217
|
+
global,
|
|
218
|
+
pluginConfig,
|
|
219
|
+
}: {
|
|
220
|
+
global: GlobalConfig | SanitizedGlobalConfig
|
|
221
|
+
pluginConfig: MCPPluginConfig
|
|
222
|
+
}): GlobalMCPItem[] => {
|
|
223
|
+
const slug = global.slug
|
|
224
|
+
const globalPluginConfig = pluginConfig.globals?.[slug]
|
|
225
|
+
const items: GlobalMCPItem[] = []
|
|
226
|
+
|
|
227
|
+
for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
228
|
+
if (requiresVersions && !global.versions) {
|
|
229
|
+
continue
|
|
230
|
+
}
|
|
231
|
+
const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]
|
|
232
|
+
if (matchedConfigEntry === false) {
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
235
|
+
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
236
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
237
|
+
items.push({
|
|
238
|
+
type: 'globalTool',
|
|
239
|
+
configKey: toolKey,
|
|
240
|
+
globalSlug: slug,
|
|
241
|
+
label: annotations.title ?? toolKey,
|
|
242
|
+
mcpName,
|
|
243
|
+
tool: {
|
|
244
|
+
...tool,
|
|
245
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
246
|
+
annotations,
|
|
247
|
+
description: override?.description ?? tool.description,
|
|
248
|
+
overrideResponse:
|
|
249
|
+
override?.overrideResponse ??
|
|
250
|
+
globalPluginConfig?.overrideResponse ??
|
|
251
|
+
tool.overrideResponse,
|
|
252
|
+
},
|
|
253
|
+
})
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const customEntries = Object.entries(globalPluginConfig?.tools ?? {}) as Array<
|
|
257
|
+
[string, GlobalTool | undefined]
|
|
258
|
+
>
|
|
259
|
+
for (const [configKey, customTool] of customEntries) {
|
|
260
|
+
if (configKey in GLOBAL_BUILTINS) {
|
|
261
|
+
continue
|
|
262
|
+
}
|
|
263
|
+
if (!customTool) {
|
|
264
|
+
continue
|
|
265
|
+
}
|
|
266
|
+
items.push({
|
|
267
|
+
type: 'globalTool',
|
|
268
|
+
configKey,
|
|
269
|
+
globalSlug: slug,
|
|
270
|
+
label: customTool.annotations?.title ?? configKey,
|
|
271
|
+
mcpName: configKey,
|
|
272
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return items
|
|
277
|
+
}
|
package/src/stdio.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { MaybePromise, Plugin, SanitizedConfig } from 'payload'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/server'
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
6
|
+
import { createLocalReq, getPayload } from 'payload'
|
|
7
|
+
import { findConfig } from 'payload/node'
|
|
8
|
+
|
|
9
|
+
import type { SanitizedMCPPluginConfig } from './types.js'
|
|
10
|
+
|
|
11
|
+
import { getAuthorizedMCP } from './endpoint/access.js'
|
|
12
|
+
import { buildMcpServer } from './mcp/buildMcpServer.js'
|
|
13
|
+
import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'
|
|
14
|
+
import { getPluginConfig } from './utils/getPluginConfig.js'
|
|
15
|
+
import { resolveProjectRoot } from './utils/resolveProjectRoot.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Stdio adapter for the Payload MCP server.
|
|
19
|
+
*
|
|
20
|
+
* Pass PAYLOAD_MCP_AUTHORIZATION when stdio should authenticate with the same
|
|
21
|
+
* Payload auth header as HTTP. In development, PAYLOAD_MCP_OVERRIDE_ACCESS=true
|
|
22
|
+
* skips access control for local setup.
|
|
23
|
+
*/
|
|
24
|
+
export const runMcpStdio = async (): Promise<void> => {
|
|
25
|
+
/**
|
|
26
|
+
* If MCP clients spawn stdio servers from an arbitrary working directory,
|
|
27
|
+
* Payload's cwd-anchored `findConfig()` can't locate the project on
|
|
28
|
+
* its own. This module always lives inside the project's `node_modules`, so
|
|
29
|
+
* we derive the project root from its own path and `chdir` into it.
|
|
30
|
+
*
|
|
31
|
+
* An absolute `PAYLOAD_CONFIG_PATH` still overrides everything; unusual
|
|
32
|
+
* layouts (e.g. a monorepo where the package is hoisted above the app) can
|
|
33
|
+
* fall back to it. See the implementation of findConfig for details.
|
|
34
|
+
*/
|
|
35
|
+
const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))
|
|
36
|
+
if (projectRoot) {
|
|
37
|
+
process.chdir(projectRoot)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const configPath = findConfig()
|
|
41
|
+
const configModule = await import(pathToFileURL(configPath).toString())
|
|
42
|
+
const config = (await (configModule.default ?? configModule)) as MaybePromise<SanitizedConfig>
|
|
43
|
+
|
|
44
|
+
const payload = await getPayload({ config })
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If the user added `mcpPlugin({...})` to their `plugins` array, read the
|
|
48
|
+
* sanitized config they registered. Otherwise fall back to the defaults. That way,
|
|
49
|
+
* the mcp works on any project that has `@payloadcms/plugin-mcp` installed,
|
|
50
|
+
* even if the plugin is not added to the plugins array.
|
|
51
|
+
*/
|
|
52
|
+
let pluginConfig: SanitizedMCPPluginConfig
|
|
53
|
+
try {
|
|
54
|
+
pluginConfig = getPluginConfig({ config: payload.config })
|
|
55
|
+
} catch {
|
|
56
|
+
pluginConfig = sanitizeMCPConfig({ config: payload.config, pluginConfig: {} })
|
|
57
|
+
|
|
58
|
+
const fakePluginFn: Plugin = (config) => config
|
|
59
|
+
fakePluginFn.slug = '@payloadcms/plugin-mcp'
|
|
60
|
+
// @ts-expect-error
|
|
61
|
+
fakePluginFn.sanitizedOptions = pluginConfig
|
|
62
|
+
|
|
63
|
+
// Push to payload config, to ensure consecutive calls to `getPluginConfig()` work
|
|
64
|
+
;(payload.config.plugins ??= []).push(fakePluginFn)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const overrideAccessEnv = process.env.PAYLOAD_MCP_OVERRIDE_ACCESS
|
|
68
|
+
let overrideAccess = false
|
|
69
|
+
|
|
70
|
+
if (overrideAccessEnv === 'true') {
|
|
71
|
+
overrideAccess = true
|
|
72
|
+
} else if (overrideAccessEnv && overrideAccessEnv !== 'false') {
|
|
73
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS must be "true" or "false".')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (overrideAccess && process.env.NODE_ENV !== 'development') {
|
|
77
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS is only available in development.')
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const headers = new Headers()
|
|
81
|
+
if (process.env.PAYLOAD_MCP_AUTHORIZATION) {
|
|
82
|
+
headers.set('Authorization', process.env.PAYLOAD_MCP_AUTHORIZATION)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const req = await createLocalReq({ req: { headers } }, payload)
|
|
86
|
+
req.payloadAPI = 'MCP' as const
|
|
87
|
+
const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
|
|
88
|
+
|
|
89
|
+
const server = buildMcpServer({ authorizedMCP, pluginConfig, req })
|
|
90
|
+
|
|
91
|
+
const transport = new StdioServerTransport()
|
|
92
|
+
await server.connect(transport)
|
|
93
|
+
|
|
94
|
+
// Process now lives until stdin closes. Wire graceful shutdown so DB
|
|
95
|
+
// connections (and any other Payload-managed resources) get released.
|
|
96
|
+
const shutdown = async (code = 0) => {
|
|
97
|
+
try {
|
|
98
|
+
await server.close()
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error('[payload-mcp] error closing server:', err)
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
await payload.destroy()
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.error('[payload-mcp] error destroying payload:', err)
|
|
106
|
+
}
|
|
107
|
+
process.exit(code)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
process.on('SIGINT', () => void shutdown(0))
|
|
111
|
+
process.on('SIGTERM', () => void shutdown(0))
|
|
112
|
+
process.stdin.on('close', () => void shutdown(0))
|
|
113
|
+
}
|