@payloadcms/plugin-mcp 4.0.0-internal.e16cf59 → 4.0.0-internal.e55ccef
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 +46 -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 +17 -0
- package/dist/endpoint/access.d.ts.map +1 -0
- package/dist/endpoint/access.js +93 -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 +87 -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 +6 -9
- 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 +223 -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 +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 +2 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/createTool.js +96 -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 +110 -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 +96 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +100 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +72 -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 +2 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findTool.js +164 -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 +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 +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 +86 -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 +81 -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 +204 -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 +68 -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 +64 -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 +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 +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +65 -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 +77 -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 +230 -0
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
- package/dist/stdio.d.ts +8 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +126 -0
- package/dist/stdio.js.map +1 -0
- package/dist/types.d.ts +256 -447
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.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/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/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 +13 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js +66 -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 +30 -10
- package/src/defaultAccess.ts +3 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +112 -0
- package/src/endpoint/index.ts +77 -0
- package/src/exports/client.ts +3 -0
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +31 -89
- package/src/mcp/buildMcpServer.ts +284 -0
- package/src/mcp/builtin/collections/authTools.ts +269 -0
- 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 +121 -0
- package/src/mcp/builtin/collections/deleteTool.ts +125 -0
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
- package/src/mcp/builtin/collections/fileInput.ts +139 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +216 -0
- 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 +84 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +76 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +227 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +67 -0
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +105 -0
- 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 +63 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -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 +278 -0
- package/src/stdio.ts +130 -0
- package/src/types.ts +304 -486
- package/src/utils/getLogger.ts +22 -0
- package/src/utils/getPluginConfig.ts +24 -0
- package/src/utils/resolveProjectRoot.ts +17 -0
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +96 -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
package/src/types.ts
CHANGED
|
@@ -1,542 +1,360 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
CallToolResult,
|
|
3
|
+
ContentBlock,
|
|
4
|
+
JsonSchemaType,
|
|
5
|
+
McpServer,
|
|
6
|
+
ResourceTemplate,
|
|
7
|
+
ServerContext,
|
|
8
|
+
StandardSchemaWithJSON,
|
|
9
|
+
ToolAnnotations,
|
|
10
|
+
} from '@modelcontextprotocol/server'
|
|
11
|
+
import type {
|
|
12
|
+
AuthCollectionSlug,
|
|
3
13
|
CollectionSlug,
|
|
4
14
|
GlobalSlug,
|
|
15
|
+
MaybePromise,
|
|
5
16
|
PayloadRequest,
|
|
6
|
-
|
|
17
|
+
SanitizedPermissions,
|
|
7
18
|
} from 'payload'
|
|
8
|
-
import type { z } from 'zod'
|
|
9
19
|
|
|
10
|
-
import {
|
|
20
|
+
import type { GetAuthorizedMCPArgs } from './endpoint/access.js'
|
|
21
|
+
import type {
|
|
22
|
+
MCPCollectionAuthToolName,
|
|
23
|
+
MCPCollectionBuiltinName,
|
|
24
|
+
MCPGlobalBuiltinName,
|
|
25
|
+
} from './mcp/builtinTools.js'
|
|
11
26
|
|
|
12
|
-
export type
|
|
13
|
-
/**
|
|
14
|
-
* Set the collections that should be available as resources via MCP.
|
|
15
|
-
*/
|
|
16
|
-
collections?: Partial<
|
|
17
|
-
Record<
|
|
18
|
-
CollectionSlug,
|
|
19
|
-
{
|
|
20
|
-
/**
|
|
21
|
-
* Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.
|
|
22
|
-
*/
|
|
23
|
-
description?: string
|
|
24
|
-
/**
|
|
25
|
-
* Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.
|
|
26
|
-
*/
|
|
27
|
-
enabled:
|
|
28
|
-
| {
|
|
29
|
-
create?: boolean
|
|
30
|
-
delete?: boolean
|
|
31
|
-
find?: boolean
|
|
32
|
-
update?: boolean
|
|
33
|
-
}
|
|
34
|
-
| boolean
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.
|
|
38
|
-
*/
|
|
39
|
-
overrideResponse?: (
|
|
40
|
-
response: {
|
|
41
|
-
content: Array<{
|
|
42
|
-
text: string
|
|
43
|
-
type: string
|
|
44
|
-
}>
|
|
45
|
-
},
|
|
46
|
-
doc: Record<string, unknown>,
|
|
47
|
-
req: PayloadRequest,
|
|
48
|
-
) => {
|
|
49
|
-
content: Array<{
|
|
50
|
-
text: string
|
|
51
|
-
type: string
|
|
52
|
-
}>
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
>
|
|
56
|
-
>
|
|
57
|
-
/**
|
|
58
|
-
* Disable the MCP plugin.
|
|
59
|
-
*/
|
|
60
|
-
disabled?: boolean
|
|
61
|
-
/**
|
|
62
|
-
* Experimental features
|
|
63
|
-
* **These features are for experimental purposes -- They are Disabled in Production by Default**
|
|
64
|
-
*/
|
|
65
|
-
experimental?: {
|
|
66
|
-
/**
|
|
67
|
-
* These are MCP tools that can be used by a client to modify Payload.
|
|
68
|
-
*/
|
|
69
|
-
tools: {
|
|
70
|
-
/**
|
|
71
|
-
* **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.
|
|
72
|
-
*/
|
|
73
|
-
auth?: {
|
|
74
|
-
/**
|
|
75
|
-
* Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
enabled: boolean
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* **Experimental** -- Collection MCP tools allow for the creation, modification, and deletion of Payload collections. This is for developing ideas that help Developers with collection tasks.
|
|
82
|
-
*/
|
|
83
|
-
collections?: {
|
|
84
|
-
/**
|
|
85
|
-
* Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.
|
|
86
|
-
*/
|
|
87
|
-
collectionsDirPath: string
|
|
88
|
-
/**
|
|
89
|
-
* Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.
|
|
90
|
-
* @default false
|
|
91
|
-
*/
|
|
92
|
-
enabled: boolean
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.
|
|
96
|
-
*/
|
|
97
|
-
config?: {
|
|
98
|
-
/**
|
|
99
|
-
* Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.
|
|
100
|
-
*/
|
|
101
|
-
configFilePath: string
|
|
102
|
-
/**
|
|
103
|
-
* Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.
|
|
104
|
-
* @default false
|
|
105
|
-
*/
|
|
106
|
-
enabled: boolean
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.
|
|
110
|
-
*/
|
|
111
|
-
jobs?: {
|
|
112
|
-
/**
|
|
113
|
-
* Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.
|
|
114
|
-
* @default false
|
|
115
|
-
*/
|
|
116
|
-
enabled: boolean
|
|
117
|
-
/**
|
|
118
|
-
* Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.
|
|
119
|
-
*/
|
|
120
|
-
jobsDirPath: string
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Set the globals that should be available as resources via MCP.
|
|
126
|
-
* Globals are singleton configuration objects (e.g., site settings, navigation).
|
|
127
|
-
* Note: Globals only support find and update operations.
|
|
128
|
-
*/
|
|
129
|
-
globals?: Partial<
|
|
130
|
-
Record<
|
|
131
|
-
GlobalSlug,
|
|
132
|
-
{
|
|
133
|
-
/**
|
|
134
|
-
* Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.
|
|
135
|
-
*/
|
|
136
|
-
description?: string
|
|
137
|
-
/**
|
|
138
|
-
* Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.
|
|
139
|
-
* Note: Globals only support find and update operations as they are singletons.
|
|
140
|
-
*/
|
|
141
|
-
enabled:
|
|
142
|
-
| {
|
|
143
|
-
find?: boolean
|
|
144
|
-
update?: boolean
|
|
145
|
-
}
|
|
146
|
-
| boolean
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Override the response generated by the MCP client. This allows you to modify the response that is sent to the MCP client. This is useful for adding additional data to the response, data normalization, or verifying data.
|
|
150
|
-
*/
|
|
151
|
-
overrideResponse?: (
|
|
152
|
-
response: {
|
|
153
|
-
content: Array<{
|
|
154
|
-
text: string
|
|
155
|
-
type: string
|
|
156
|
-
}>
|
|
157
|
-
},
|
|
158
|
-
doc: Record<string, unknown>,
|
|
159
|
-
req: PayloadRequest,
|
|
160
|
-
) => {
|
|
161
|
-
content: Array<{
|
|
162
|
-
text: string
|
|
163
|
-
type: string
|
|
164
|
-
}>
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
>
|
|
168
|
-
>
|
|
169
|
-
/**
|
|
170
|
-
* MCP Server options.
|
|
171
|
-
*/
|
|
172
|
-
mcp?: {
|
|
173
|
-
handlerOptions?: MCPHandlerOptions
|
|
174
|
-
/**
|
|
175
|
-
* Add custom MCP Prompts.
|
|
176
|
-
*/
|
|
177
|
-
prompts?: {
|
|
178
|
-
/**
|
|
179
|
-
* Set the args schema of the prompt. This is the args schema that will be passed to the prompt. This is used by MCP clients to determine the arguments that will be passed to the prompt.
|
|
180
|
-
*/
|
|
181
|
-
argsSchema: z.ZodRawShape
|
|
182
|
-
/**
|
|
183
|
-
* Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.
|
|
184
|
-
*/
|
|
185
|
-
description: string
|
|
186
|
-
/**
|
|
187
|
-
* Set the handler of the prompt. This is the function that will be called when the prompt is used.
|
|
188
|
-
*/
|
|
189
|
-
handler: (
|
|
190
|
-
args: Record<string, unknown>,
|
|
191
|
-
req: PayloadRequest,
|
|
192
|
-
_extra: unknown,
|
|
193
|
-
) =>
|
|
194
|
-
| {
|
|
195
|
-
messages: Array<{
|
|
196
|
-
content: {
|
|
197
|
-
text: string
|
|
198
|
-
type: 'text'
|
|
199
|
-
}
|
|
200
|
-
role: 'assistant' | 'user'
|
|
201
|
-
}>
|
|
202
|
-
}
|
|
203
|
-
| Promise<{
|
|
204
|
-
messages: Array<{
|
|
205
|
-
content: {
|
|
206
|
-
text: string
|
|
207
|
-
type: 'text'
|
|
208
|
-
}
|
|
209
|
-
role: 'assistant' | 'user'
|
|
210
|
-
}>
|
|
211
|
-
}>
|
|
212
|
-
/**
|
|
213
|
-
* Set the function name of the prompt.
|
|
214
|
-
*/
|
|
215
|
-
name: string
|
|
216
|
-
/**
|
|
217
|
-
* Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.
|
|
218
|
-
*/
|
|
219
|
-
title: string
|
|
220
|
-
}[]
|
|
27
|
+
export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }
|
|
221
28
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
*/
|
|
225
|
-
resources?: {
|
|
226
|
-
/**
|
|
227
|
-
* Set the description of the resource. This is used by MCP clients to determine when to use the resource.
|
|
228
|
-
* example: 'Data is a resource that contains special data.'
|
|
229
|
-
*/
|
|
230
|
-
description: string
|
|
231
|
-
/**
|
|
232
|
-
* Set the handler of the resource. This is the function that will be called when the resource is used.
|
|
233
|
-
* The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).
|
|
234
|
-
*/
|
|
235
|
-
handler: (...args: any[]) =>
|
|
236
|
-
| {
|
|
237
|
-
contents: Array<{
|
|
238
|
-
text: string
|
|
239
|
-
uri: string
|
|
240
|
-
}>
|
|
241
|
-
}
|
|
242
|
-
| Promise<{
|
|
243
|
-
contents: Array<{
|
|
244
|
-
text: string
|
|
245
|
-
uri: string
|
|
246
|
-
}>
|
|
247
|
-
}>
|
|
248
|
-
/**
|
|
249
|
-
* Set the mime type of the resource.
|
|
250
|
-
* example: 'text/plain'
|
|
251
|
-
*/
|
|
252
|
-
mimeType: string
|
|
253
|
-
/**
|
|
254
|
-
* Set the function name of the resource.
|
|
255
|
-
* example: 'data'
|
|
256
|
-
*/
|
|
257
|
-
name: string
|
|
258
|
-
/**
|
|
259
|
-
* Set the title of the resource. LLMs will interperate the title to determine when to use the resource.
|
|
260
|
-
* example: 'Data'
|
|
261
|
-
*/
|
|
262
|
-
title: string
|
|
263
|
-
/**
|
|
264
|
-
* Set the uri of the resource.
|
|
265
|
-
* example: 'data://app'
|
|
266
|
-
*/
|
|
267
|
-
uri: ResourceTemplate | string
|
|
268
|
-
}[]
|
|
269
|
-
serverOptions?: MCPServerOptions
|
|
270
|
-
/**
|
|
271
|
-
* Add custom MCP Tools.
|
|
272
|
-
*/
|
|
273
|
-
tools?: {
|
|
274
|
-
/**
|
|
275
|
-
* Set the description of the tool. This is used by MCP clients to determine when to use the tool.
|
|
276
|
-
*/
|
|
277
|
-
description: string
|
|
278
|
-
/**
|
|
279
|
-
* Set the handler of the tool. This is the function that will be called when the tool is used.
|
|
280
|
-
*/
|
|
281
|
-
handler: (
|
|
282
|
-
args: Record<string, unknown>,
|
|
283
|
-
req: PayloadRequest,
|
|
284
|
-
_extra: unknown,
|
|
285
|
-
) =>
|
|
286
|
-
| {
|
|
287
|
-
content: Array<{
|
|
288
|
-
text: string
|
|
289
|
-
type: 'text'
|
|
290
|
-
}>
|
|
291
|
-
role?: string
|
|
292
|
-
}
|
|
293
|
-
| Promise<{
|
|
294
|
-
content: Array<{
|
|
295
|
-
text: string
|
|
296
|
-
type: 'text'
|
|
297
|
-
}>
|
|
298
|
-
role?: string
|
|
299
|
-
}>
|
|
300
|
-
/**
|
|
301
|
-
* Set the name of the tool. This is the name that will be used to identify the tool. LLMs will interperate the name to determine when to use the tool.
|
|
302
|
-
*/
|
|
303
|
-
name: string
|
|
304
|
-
/**
|
|
305
|
-
* Set the parameters of the tool. This is the parameters that will be passed to the tool.
|
|
306
|
-
*/
|
|
307
|
-
parameters: z.ZodRawShape
|
|
308
|
-
}[]
|
|
309
|
-
}
|
|
29
|
+
/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */
|
|
30
|
+
export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }
|
|
310
31
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig
|
|
32
|
+
/**
|
|
33
|
+
* What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
|
|
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
|
+
*/
|
|
37
|
+
export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON
|
|
318
38
|
|
|
39
|
+
export type MCPToolResponse = {
|
|
40
|
+
content: ContentBlock[]
|
|
319
41
|
/**
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* @returns The MCP access settings.
|
|
42
|
+
* If available, return the document fetched within the
|
|
43
|
+
* mcp tool. This is threaded as an additional argument to
|
|
44
|
+
* overrideResponse functions and stripped before going on the wire.
|
|
324
45
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,
|
|
328
|
-
) => MCPAccessSettings | Promise<MCPAccessSettings>
|
|
46
|
+
doc?: Record<string, unknown>
|
|
47
|
+
} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>
|
|
329
48
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
49
|
+
export type MCPResponseOverride = (
|
|
50
|
+
response: MCPToolResponse,
|
|
51
|
+
doc: Record<string, unknown>,
|
|
52
|
+
req: PayloadRequest,
|
|
53
|
+
) => MCPToolResponse
|
|
54
|
+
|
|
55
|
+
export type MCPAfterToolCallHook = (args: {
|
|
56
|
+
input: unknown
|
|
57
|
+
req: PayloadRequest
|
|
58
|
+
response: MCPToolResponse
|
|
59
|
+
toolName: string
|
|
60
|
+
}) => MaybePromise<MCPToolResponse>
|
|
335
61
|
|
|
336
62
|
/**
|
|
337
|
-
*
|
|
63
|
+
* The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets
|
|
64
|
+
* its inferred output; anything else falls back to `Record<string, unknown>`.
|
|
338
65
|
*/
|
|
339
|
-
export type
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
66
|
+
export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON
|
|
67
|
+
? StandardSchemaWithJSON extends TSchema
|
|
68
|
+
? Record<string, unknown>
|
|
69
|
+
: StandardSchemaWithJSON.InferOutput<TSchema>
|
|
70
|
+
: Record<string, unknown>
|
|
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
|
+
|
|
85
|
+
export type ToolHandlerArgs<TSchema = undefined> = {
|
|
86
|
+
authorizedMCP: AuthorizedMCP
|
|
87
|
+
input: TypedInput<TSchema>
|
|
88
|
+
req: PayloadRequest
|
|
89
|
+
serverContext: ServerContext
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type CollectionToolHandlerArgs<TSchema = undefined> = {
|
|
93
|
+
collectionSlug: CollectionSlug
|
|
94
|
+
} & ToolHandlerArgs<TSchema>
|
|
95
|
+
|
|
96
|
+
export type GlobalToolHandlerArgs<TSchema = undefined> = {
|
|
97
|
+
globalSlug: GlobalSlug
|
|
98
|
+
} & ToolHandlerArgs<TSchema>
|
|
99
|
+
|
|
100
|
+
export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
|
|
345
101
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
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.
|
|
348
105
|
*/
|
|
349
|
-
|
|
106
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
107
|
+
annotations?: ToolAnnotations
|
|
108
|
+
description: string
|
|
109
|
+
handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
110
|
+
input?: TSchema
|
|
350
111
|
/**
|
|
351
|
-
*
|
|
352
|
-
* @default 60
|
|
112
|
+
* Override the return value of the tool handler
|
|
353
113
|
*/
|
|
354
|
-
|
|
114
|
+
overrideResponse?: MCPResponseOverride
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type CollectionTool<
|
|
118
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
119
|
+
> = {
|
|
355
120
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
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.
|
|
358
125
|
*/
|
|
359
|
-
|
|
126
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
127
|
+
handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
128
|
+
input?: TSchema
|
|
129
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
130
|
+
|
|
131
|
+
export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =
|
|
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>
|
|
140
|
+
handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
141
|
+
input?: TSchema
|
|
142
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Configures (or disables) a built-in tool without replacing it.
|
|
146
|
+
* `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
|
|
147
|
+
* required handler) from being silently accepted at a built-in key slot.
|
|
148
|
+
*/
|
|
149
|
+
export type MCPBuiltInCollectionToolOverride = {
|
|
360
150
|
/**
|
|
361
|
-
*
|
|
362
|
-
*
|
|
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.
|
|
363
153
|
*/
|
|
364
|
-
|
|
154
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
155
|
+
annotations?: ToolAnnotations
|
|
156
|
+
description?: string
|
|
157
|
+
handler?: never
|
|
158
|
+
overrideResponse?: MCPResponseOverride
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export type MCPBuiltInGlobalToolOverride = {
|
|
365
162
|
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
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.
|
|
368
165
|
*/
|
|
369
|
-
|
|
166
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
167
|
+
annotations?: ToolAnnotations
|
|
168
|
+
description?: string
|
|
169
|
+
handler?: never
|
|
170
|
+
overrideResponse?: MCPResponseOverride
|
|
370
171
|
}
|
|
371
172
|
|
|
372
173
|
/**
|
|
373
|
-
*
|
|
174
|
+
* Value at a custom (non-built-in) tool key. Either the tool itself, or `false`
|
|
175
|
+
* to disable it (useful when one plugin defines a custom tool and another
|
|
176
|
+
* wants to opt out per-collection).
|
|
374
177
|
*/
|
|
375
|
-
export type
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
* Set the server info of the MCP server.
|
|
382
|
-
*/
|
|
383
|
-
serverInfo?: {
|
|
384
|
-
/**
|
|
385
|
-
* Set the name of the MCP server.
|
|
386
|
-
* @default 'Payload MCP Server'
|
|
387
|
-
*/
|
|
388
|
-
name: string
|
|
389
|
-
/**
|
|
390
|
-
* Set the version of the MCP server.
|
|
391
|
-
* @default '1.0.0'
|
|
392
|
-
*/
|
|
393
|
-
version: string
|
|
394
|
-
}
|
|
178
|
+
export type MCPTopLevelToolEntry = Tool
|
|
179
|
+
|
|
180
|
+
export type MCPCollectionToolsMap = {
|
|
181
|
+
[customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined
|
|
182
|
+
} & {
|
|
183
|
+
[K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride
|
|
395
184
|
}
|
|
396
185
|
|
|
397
|
-
export type
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
forgotPassword?: boolean
|
|
401
|
-
login?: boolean
|
|
402
|
-
resetPassword?: boolean
|
|
403
|
-
unlock?: boolean
|
|
404
|
-
verify?: boolean
|
|
405
|
-
}
|
|
406
|
-
collections?: {
|
|
407
|
-
create?: boolean
|
|
408
|
-
delete?: boolean
|
|
409
|
-
find?: boolean
|
|
410
|
-
update?: boolean
|
|
411
|
-
}
|
|
412
|
-
config?: {
|
|
413
|
-
find?: boolean
|
|
414
|
-
update?: boolean
|
|
415
|
-
}
|
|
416
|
-
custom?: Record<string, boolean>
|
|
417
|
-
globals?: {
|
|
418
|
-
find?: boolean
|
|
419
|
-
update?: boolean
|
|
420
|
-
}
|
|
421
|
-
jobs?: {
|
|
422
|
-
create?: boolean
|
|
423
|
-
run?: boolean
|
|
424
|
-
update?: boolean
|
|
425
|
-
}
|
|
426
|
-
'payload-mcp-prompt'?: Record<string, boolean>
|
|
427
|
-
'payload-mcp-resource'?: Record<string, boolean>
|
|
428
|
-
'payload-mcp-tool'?: Record<string, boolean>
|
|
429
|
-
user: TypedUser
|
|
430
|
-
} & Record<string, unknown>
|
|
186
|
+
export type MCPAuthCollectionToolsMap = {
|
|
187
|
+
[K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true
|
|
188
|
+
} & MCPCollectionToolsMap
|
|
431
189
|
|
|
432
|
-
|
|
190
|
+
/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
|
|
191
|
+
export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug
|
|
192
|
+
? MCPAuthCollectionToolsMap
|
|
193
|
+
: MCPCollectionToolsMap
|
|
433
194
|
|
|
434
|
-
export type
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
position?: 'main' | 'sidebar'
|
|
439
|
-
required?: boolean
|
|
440
|
-
type: string
|
|
195
|
+
export type MCPGlobalToolsMap = {
|
|
196
|
+
[customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined
|
|
197
|
+
} & {
|
|
198
|
+
[K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride
|
|
441
199
|
}
|
|
442
200
|
|
|
443
|
-
export type
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
type?: string
|
|
450
|
-
}
|
|
451
|
-
fieldName: string
|
|
201
|
+
export type MCPTopLevelToolsMap = Record<string, Tool>
|
|
202
|
+
|
|
203
|
+
export type PromptHandlerArgs<TSchema = undefined> = {
|
|
204
|
+
input: TypedInput<TSchema>
|
|
205
|
+
req: PayloadRequest
|
|
206
|
+
serverContext: ServerContext
|
|
452
207
|
}
|
|
453
208
|
|
|
454
|
-
export type
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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>
|
|
216
|
+
argsSchema: TSchema
|
|
217
|
+
description: string
|
|
218
|
+
handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
|
|
219
|
+
messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>
|
|
220
|
+
}>
|
|
221
|
+
title: string
|
|
465
222
|
}
|
|
466
223
|
|
|
467
|
-
export type
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
224
|
+
export type ResourceHandlerArgs = {
|
|
225
|
+
/** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */
|
|
226
|
+
params: Record<string, string>
|
|
227
|
+
req: PayloadRequest
|
|
228
|
+
serverContext: ServerContext
|
|
229
|
+
uri: URL
|
|
230
|
+
}
|
|
231
|
+
|
|
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>
|
|
239
|
+
description: string
|
|
240
|
+
handler: (args: ResourceHandlerArgs) => MaybePromise<{
|
|
241
|
+
contents: Array<{ text: string; uri: string }>
|
|
242
|
+
}>
|
|
243
|
+
mimeType: string
|
|
244
|
+
title: string
|
|
245
|
+
uri: ResourceTemplate | string
|
|
487
246
|
}
|
|
488
247
|
|
|
489
|
-
export type
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
248
|
+
export type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {
|
|
249
|
+
description?: string
|
|
250
|
+
/** Fallback for built-in tools that don't set their own `overrideResponse`. */
|
|
251
|
+
overrideResponse?: MCPResponseOverride
|
|
252
|
+
tools?: MCPToolsMapForCollection<TSlug>
|
|
493
253
|
}
|
|
494
254
|
|
|
495
|
-
export type
|
|
496
|
-
|
|
497
|
-
|
|
255
|
+
export type MCPPluginGlobalConfig = {
|
|
256
|
+
description?: string
|
|
257
|
+
overrideResponse?: MCPResponseOverride
|
|
258
|
+
tools?: MCPGlobalToolsMap
|
|
498
259
|
}
|
|
499
260
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
261
|
+
/**
|
|
262
|
+
* The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,
|
|
263
|
+
* resources, and per-collection/global tool maps live in their own nested
|
|
264
|
+
* fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults
|
|
265
|
+
* to produce a `SanitizedMCPPluginConfig` — the form every internal consumer
|
|
266
|
+
* actually works with.
|
|
267
|
+
*/
|
|
268
|
+
export type MCPPluginConfig = {
|
|
269
|
+
collections?: {
|
|
270
|
+
[Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>
|
|
507
271
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
272
|
+
/** Skip MCP endpoint registration. */
|
|
273
|
+
disabled?: boolean
|
|
274
|
+
globals?: {
|
|
275
|
+
[Slug in GlobalSlug]?: MCPPluginGlobalConfig
|
|
512
276
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
277
|
+
hooks?: {
|
|
278
|
+
/** Transform a tool response after its handler returns */
|
|
279
|
+
afterToolCall?: MCPAfterToolCallHook[]
|
|
280
|
+
}
|
|
281
|
+
mcp?: {
|
|
282
|
+
serverOptions?: MCPServerOptions
|
|
283
|
+
verboseLogs?: boolean
|
|
518
284
|
}
|
|
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>
|
|
296
|
+
prompts?: Record<string, Prompt>
|
|
297
|
+
resources?: Record<string, Resource>
|
|
298
|
+
/** Cross-cutting tools (not scoped to any collection or global). */
|
|
299
|
+
tools?: MCPTopLevelToolsMap
|
|
519
300
|
}
|
|
520
301
|
|
|
521
|
-
export
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
302
|
+
export type SanitizedMCPPluginConfig = {
|
|
303
|
+
items: MCPItem[]
|
|
304
|
+
} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>
|
|
305
|
+
|
|
306
|
+
export type MCPServerOptions = {
|
|
307
|
+
options?: ConstructorParameters<typeof McpServer>[1]
|
|
308
|
+
serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>
|
|
527
309
|
}
|
|
528
310
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
311
|
+
/**
|
|
312
|
+
* One MCP primitive plus the metadata needed for config-driven filtering and
|
|
313
|
+
* registration.
|
|
314
|
+
*
|
|
315
|
+
* - `configKey`: the config identifier, e.g. `find` or `echo`.
|
|
316
|
+
* - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
|
|
317
|
+
* - `label`: human-readable display text.
|
|
318
|
+
*/
|
|
319
|
+
export type MCPItemBase = {
|
|
320
|
+
configKey: string
|
|
321
|
+
label: string
|
|
322
|
+
mcpName: string
|
|
535
323
|
}
|
|
536
324
|
|
|
537
|
-
export
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
325
|
+
export type CollectionMCPItem = {
|
|
326
|
+
collectionSlug: CollectionSlug
|
|
327
|
+
tool: CollectionTool
|
|
328
|
+
type: 'collectionTool'
|
|
329
|
+
} & MCPItemBase
|
|
330
|
+
|
|
331
|
+
export type GlobalMCPItem = {
|
|
332
|
+
globalSlug: GlobalSlug
|
|
333
|
+
tool: GlobalTool
|
|
334
|
+
type: 'globalTool'
|
|
335
|
+
} & MCPItemBase
|
|
336
|
+
|
|
337
|
+
export type MCPItem =
|
|
338
|
+
| ({
|
|
339
|
+
prompt: Prompt
|
|
340
|
+
type: 'prompt'
|
|
341
|
+
} & MCPItemBase)
|
|
342
|
+
| ({
|
|
343
|
+
resource: Resource
|
|
344
|
+
type: 'resource'
|
|
345
|
+
} & MCPItemBase)
|
|
346
|
+
| ({
|
|
347
|
+
tool: Tool
|
|
348
|
+
type: 'tool'
|
|
349
|
+
} & MCPItemBase)
|
|
350
|
+
| CollectionMCPItem
|
|
351
|
+
| GlobalMCPItem
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The MCP items and access mode authorized for this request. The authenticated user is available
|
|
355
|
+
* as `req.user`.
|
|
356
|
+
*/
|
|
357
|
+
export type AuthorizedMCP = {
|
|
358
|
+
items: MCPItem[]
|
|
359
|
+
overrideAccess: boolean
|
|
542
360
|
}
|