@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
|
+
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
|
+
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
+
const DEFAULT_DESCRIPTION = 'Restore a global from a previous version in any version-enabled global.';
|
|
6
|
+
export const restoreGlobalVersionTool = defineGlobalTool({
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: true,
|
|
10
|
+
idempotentHint: false,
|
|
11
|
+
openWorldHint: false,
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
title: 'Restore Global Version'
|
|
14
|
+
},
|
|
15
|
+
description: DEFAULT_DESCRIPTION,
|
|
16
|
+
input: z.object({
|
|
17
|
+
id: z.string().describe('The ID of the global version to restore'),
|
|
18
|
+
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in response').optional().default(0),
|
|
19
|
+
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
20
|
+
locale: z.string().describe('Optional: locale code to restore in (e.g., "en", "es")').optional(),
|
|
21
|
+
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
22
|
+
showHiddenFields: z.boolean().describe('Optional: include hidden fields in the restored global response').optional()
|
|
23
|
+
})
|
|
24
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
25
|
+
const payload = req.payload;
|
|
26
|
+
const logger = getLogger({
|
|
27
|
+
payload
|
|
28
|
+
});
|
|
29
|
+
const { id, depth, fallbackLocale, locale, populate, showHiddenFields } = input;
|
|
30
|
+
logger.info(`Restoring version for global: ${globalSlug} with ID: ${id}`);
|
|
31
|
+
try {
|
|
32
|
+
const result = await payload.restoreGlobalVersion({
|
|
33
|
+
id,
|
|
34
|
+
slug: globalSlug,
|
|
35
|
+
depth,
|
|
36
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
37
|
+
req,
|
|
38
|
+
...fallbackLocale ? {
|
|
39
|
+
fallbackLocale
|
|
40
|
+
} : {},
|
|
41
|
+
...locale ? {
|
|
42
|
+
locale
|
|
43
|
+
} : {},
|
|
44
|
+
...populate ? {
|
|
45
|
+
populate: populate
|
|
46
|
+
} : {},
|
|
47
|
+
...showHiddenFields !== undefined ? {
|
|
48
|
+
showHiddenFields
|
|
49
|
+
} : {}
|
|
50
|
+
});
|
|
51
|
+
const resultObject = result;
|
|
52
|
+
const restoredGlobal = resultObject.version && typeof resultObject.version === 'object' ? resultObject.version : resultObject;
|
|
53
|
+
return {
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: `Version "${id}" restored successfully for global "${globalSlug}"!\nRestored global:\n\`\`\`json\n${JSON.stringify(restoredGlobal)}\n\`\`\``
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
doc: restoredGlobal
|
|
61
|
+
};
|
|
62
|
+
} catch (error) {
|
|
63
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
64
|
+
logger.error(`Error restoring version ${id} for global ${globalSlug}: ${errorMessage}`);
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: 'text',
|
|
69
|
+
text: `❌ **Error restoring version "${id}" for global "${globalSlug}":** ${errorMessage}`
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
isError: true
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=restoreVersionTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/restoreVersionTool.ts"],"sourcesContent":["import type { PopulateType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Restore a global from a previous version in any version-enabled global.'\n\nexport const restoreGlobalVersionTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Restore Global Version',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to restore'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe('Optional: locale code to restore in (e.g., \"en\", \"es\")')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the restored global response')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, showHiddenFields } = input\n\n logger.info(`Restoring version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.restoreGlobalVersion({\n id,\n slug: globalSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n const resultObject = result as Record<string, unknown>\n const restoredGlobal =\n resultObject.version && typeof resultObject.version === 'object'\n ? (resultObject.version as Record<string, unknown>)\n : resultObject\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" restored successfully for global \"${globalSlug}\"!\\nRestored global:\\n\\`\\`\\`json\\n${JSON.stringify(restoredGlobal)}\\n\\`\\`\\``,\n },\n ],\n doc: restoredGlobal,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error restoring version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error restoring version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","restoreGlobalVersionTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","restoreGlobalVersion","slug","overrideAccess","undefined","resultObject","restoredGlobal","version","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,2BAA2BH,iBAAiB;IACvDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB,EAAEqB,MAAM,CAAC;QACdC,IAAItB,EAAEuB,MAAM,GAAGC,QAAQ,CAAC;QACxBC,OAAOzB,EACJ0B,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJL,QAAQ,CAAC,8DACTM,QAAQ,GACRC,OAAO,CAAC;QACXC,gBAAgBhC,EACbuB,MAAM,GACNC,QAAQ,CAAC,gFACTM,QAAQ;QACXG,QAAQjC,EACLuB,MAAM,GACNC,QAAQ,CAAC,0DACTM,QAAQ;QACXI,UAAUlC,EACPmC,MAAM,CAACnC,EAAEuB,MAAM,IAAIvB,EAAEoC,OAAO,IAC5BZ,QAAQ,CACP,8FAEDM,QAAQ;QACXO,kBAAkBrC,EACfsC,OAAO,GACPd,QAAQ,CAAC,mEACTM,QAAQ;IACb;AACF,GAAGS,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAE7B,UAAU,EAAES,KAAK,EAAEqB,GAAG,EAAE;IACzD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAASxC,UAAU;QAAEuC;IAAQ;IACnC,MAAM,EAAEpB,EAAE,EAAEG,KAAK,EAAEO,cAAc,EAAEC,MAAM,EAAEC,QAAQ,EAAEG,gBAAgB,EAAE,GAAGjB;IAE1EuB,OAAOC,IAAI,CAAC,CAAC,8BAA8B,EAAEjC,WAAW,UAAU,EAAEW,IAAI;IAExE,IAAI;QACF,MAAMuB,SAAS,MAAMH,QAAQI,oBAAoB,CAAC;YAChDxB;YACAyB,MAAMpC;YACNc;YACAuB,gBAAgBR,cAAcQ,cAAc;YAC5CP;YACA,GAAIT,iBAAiB;gBAAEA;YAAe,IAAI,CAAC,CAAC;YAC5C,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,WAAW;gBAAEA,UAAUA;YAAyB,IAAI,CAAC,CAAC;YAC1D,GAAIG,qBAAqBY,YAAY;gBAAEZ;YAAiB,IAAI,CAAC,CAAC;QAChE;QACA,MAAMa,eAAeL;QACrB,MAAMM,iBACJD,aAAaE,OAAO,IAAI,OAAOF,aAAaE,OAAO,KAAK,WACnDF,aAAaE,OAAO,GACrBF;QAEN,OAAO;YACLG,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAEjC,GAAG,oCAAoC,EAAEX,WAAW,kCAAkC,EAAE6C,KAAKC,SAAS,CAACN,gBAAgB,QAAQ,CAAC;gBACpJ;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DnB,OAAOgB,KAAK,CAAC,CAAC,wBAAwB,EAAErC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAEiD,cAAc;QACtF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6BAA6B,EAAEjC,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAEiD,cAAc;gBAC3F;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,gBAAgB,wCAkG3B,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
|
+
import { defineGlobalTool } from '../../../defineTool.js';
|
|
4
|
+
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
+
import { getGlobalVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
|
|
6
|
+
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
|
|
7
|
+
import { validateGlobalData } from '../validateEntityData.js';
|
|
8
|
+
const DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.';
|
|
9
|
+
export const updateGlobalTool = defineGlobalTool({
|
|
10
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: true,
|
|
13
|
+
idempotentHint: false,
|
|
14
|
+
openWorldHint: false,
|
|
15
|
+
readOnlyHint: false,
|
|
16
|
+
title: 'Update Global'
|
|
17
|
+
},
|
|
18
|
+
description: DEFAULT_DESCRIPTION,
|
|
19
|
+
input: z.object({
|
|
20
|
+
data: z.record(z.string(), z.unknown()).describe('The global fields to update'),
|
|
21
|
+
depth: z.number().describe('Optional: Depth of relationships to populate').optional().default(0),
|
|
22
|
+
draft: z.boolean().describe('Optional: Whether to save as draft (default: false)').optional().default(false),
|
|
23
|
+
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
24
|
+
locale: z.string().describe('Optional: locale code to update data in (e.g., "en", "es"). Use "all" to update all locales for localized fields').optional(),
|
|
25
|
+
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"siteName": true}').optional()
|
|
26
|
+
})
|
|
27
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
|
|
28
|
+
const payload = req.payload;
|
|
29
|
+
const logger = getLogger({
|
|
30
|
+
payload
|
|
31
|
+
});
|
|
32
|
+
const { data, depth, draft, fallbackLocale, locale, select } = input;
|
|
33
|
+
logger.info(`Updating global: ${globalSlug}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
|
|
34
|
+
try {
|
|
35
|
+
const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, globalSlug);
|
|
36
|
+
const inputData = stripVirtualFields(data, virtualFieldNames);
|
|
37
|
+
const validationError = validateGlobalData({
|
|
38
|
+
data: inputData,
|
|
39
|
+
globalSlug,
|
|
40
|
+
req
|
|
41
|
+
});
|
|
42
|
+
if (validationError) {
|
|
43
|
+
return validationError;
|
|
44
|
+
}
|
|
45
|
+
const parsedData = transformPointDataToPayload(inputData);
|
|
46
|
+
const updateOptions = {
|
|
47
|
+
slug: globalSlug,
|
|
48
|
+
data: parsedData,
|
|
49
|
+
depth,
|
|
50
|
+
draft,
|
|
51
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
52
|
+
req
|
|
53
|
+
};
|
|
54
|
+
if (locale) {
|
|
55
|
+
updateOptions.locale = locale;
|
|
56
|
+
}
|
|
57
|
+
if (fallbackLocale) {
|
|
58
|
+
updateOptions.fallbackLocale = fallbackLocale;
|
|
59
|
+
}
|
|
60
|
+
if (select) {
|
|
61
|
+
updateOptions.select = select;
|
|
62
|
+
}
|
|
63
|
+
const result = await payload.updateGlobal(updateOptions);
|
|
64
|
+
return {
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `Global "${globalSlug}" updated successfully!\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
doc: result
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
75
|
+
logger.error(`Error updating global ${globalSlug}: ${errorMessage}`);
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: `Error updating global "${globalSlug}": ${errorMessage}`
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=updateTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/globals/updateTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getGlobalVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateGlobalData } from '../validateEntityData.js'\n\nconst DEFAULT_DESCRIPTION = 'Update any Payload global by passing the global slug and data.'\n\nexport const updateGlobalTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z.record(z.string(), z.unknown()).describe('The global fields to update'),\n depth: z\n .number()\n .describe('Optional: Depth of relationships to populate')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Optional: Whether to save as draft (default: false)')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"siteName\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Updating global: ${globalSlug}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, globalSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateGlobalData({ data: inputData, globalSlug, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const updateOptions: Parameters<typeof payload.updateGlobal>[0] = {\n slug: globalSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n }\n\n if (locale) {\n updateOptions.locale = locale\n }\n if (fallbackLocale) {\n updateOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n updateOptions.select = select as SelectType\n }\n\n const result = await payload.updateGlobal(updateOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${globalSlug}\" updated successfully!\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating global ${globalSlug}: ${errorMessage}`)\n return {\n content: [{ type: 'text', text: `Error updating global \"${globalSlug}\": ${errorMessage}` }],\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","getGlobalVirtualFieldNames","stripVirtualFields","transformPointDataToPayload","validateGlobalData","DEFAULT_DESCRIPTION","updateGlobalTool","access","args","Boolean","permissions","globals","globalSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","optional","default","draft","boolean","fallbackLocale","locale","select","handler","authorizedMCP","req","payload","logger","info","virtualFieldNames","config","inputData","validationError","parsedData","updateOptions","slug","overrideAccess","result","updateGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,0BAA0B,EAC1BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,kBAAkB,QAAQ,2BAA0B;AAE7D,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,mBAAmBP,iBAAiB;IAC/CQ,QAAQ,CAACC,OACPV,cAAcU,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOxB,EAAEyB,MAAM,CAAC;QACdC,MAAM1B,EAAE2B,MAAM,CAAC3B,EAAE4B,MAAM,IAAI5B,EAAE6B,OAAO,IAAIC,QAAQ,CAAC;QACjDC,OAAO/B,EACJgC,MAAM,GACNF,QAAQ,CAAC,gDACTG,QAAQ,GACRC,OAAO,CAAC;QACXC,OAAOnC,EACJoC,OAAO,GACPN,QAAQ,CAAC,uDACTG,QAAQ,GACRC,OAAO,CAAC;QACXG,gBAAgBrC,EACb4B,MAAM,GACNE,QAAQ,CAAC,gFACTG,QAAQ;QACXK,QAAQtC,EACL4B,MAAM,GACNE,QAAQ,CACP,oHAEDG,QAAQ;QACXM,QAAQvC,EACL2B,MAAM,CAAC3B,EAAE4B,MAAM,IAAI5B,EAAE6B,OAAO,IAC5BC,QAAQ,CACP,yGAEDG,QAAQ;IACb;AACF,GAAGO,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAE1B,UAAU,EAAES,KAAK,EAAEkB,GAAG,EAAE;IACzD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAASzC,UAAU;QAAEwC;IAAQ;IAEnC,MAAM,EAAEjB,IAAI,EAAEK,KAAK,EAAEI,KAAK,EAAEE,cAAc,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGf;IAE/DoB,OAAOC,IAAI,CACT,CAAC,iBAAiB,EAAE9B,WAAW,SAAS,EAAEoB,QAAQG,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;IAGzF,IAAI;QACF,MAAMQ,oBAAoB1C,2BAA2BuC,QAAQI,MAAM,EAAEhC;QACrE,MAAMiC,YAAY3C,mBAAmBqB,MAAMoB;QAC3C,MAAMG,kBAAkB1C,mBAAmB;YAAEmB,MAAMsB;YAAWjC;YAAY2B;QAAI;QAE9E,IAAIO,iBAAiB;YACnB,OAAOA;QACT;QAEA,MAAMC,aAAa5C,4BAA4B0C;QAE/C,MAAMG,gBAA4D;YAChEC,MAAMrC;YACNW,MAAMwB;YACNnB;YACAI;YACAkB,gBAAgBZ,cAAcY,cAAc;YAC5CX;QACF;QAEA,IAAIJ,QAAQ;YACVa,cAAcb,MAAM,GAAGA;QACzB;QACA,IAAID,gBAAgB;YAClBc,cAAcd,cAAc,GAAGA;QACjC;QACA,IAAIE,QAAQ;YACVY,cAAcZ,MAAM,GAAGA;QACzB;QAEA,MAAMe,SAAS,MAAMX,QAAQY,YAAY,CAACJ;QAE1C,OAAO;YACLK,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAE3C,WAAW,qCAAqC,EAAE4C,KAAKC,SAAS,CAACN,QAAQ,QAAQ,CAAC;gBACrG;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,sBAAsB,EAAE/C,WAAW,EAAE,EAAEgD,cAAc;QACnE,OAAO;YACLP,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,uBAAuB,EAAE3C,WAAW,GAAG,EAAEgD,cAAc;gBAAC;aAAE;QAC7F;IACF;AACF,GAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CollectionSlug, GlobalSlug, PayloadRequest } from 'payload';
|
|
2
|
+
import type { MCPToolResponse } from '../../types.js';
|
|
3
|
+
export declare const validateCollectionData: ({ collectionSlug, data, partial, req, }: {
|
|
4
|
+
collectionSlug: CollectionSlug;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
partial?: boolean;
|
|
7
|
+
req: PayloadRequest;
|
|
8
|
+
}) => MCPToolResponse | null;
|
|
9
|
+
export declare const validateGlobalData: ({ data, globalSlug, req, }: {
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
globalSlug: GlobalSlug;
|
|
12
|
+
req: PayloadRequest;
|
|
13
|
+
}) => MCPToolResponse | null;
|
|
14
|
+
//# sourceMappingURL=validateEntityData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAI1F,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAuBrE,eAAO,MAAM,sBAAsB,4CAKhC;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA;AAEJ,eAAO,MAAM,kBAAkB,+BAI5B;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker';
|
|
2
|
+
import { getCollectionInputSchema, getGlobalInputSchema } from '../../utils/schemaConversion/getEntityInputSchema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.
|
|
5
|
+
*/ const validator = new CfWorkerJsonSchemaValidator({
|
|
6
|
+
shortcircuit: true
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* - Caches each entity's schema and validator, so both are only built on the first request.
|
|
10
|
+
* - Keyed by payload config, then by entity type, slug, partial and language.
|
|
11
|
+
*/ const validatorCache = new WeakMap();
|
|
12
|
+
export const validateCollectionData = ({ collectionSlug, data, partial, req })=>validateData({
|
|
13
|
+
slug: collectionSlug,
|
|
14
|
+
buildSchema: ()=>getCollectionInputSchema({
|
|
15
|
+
collectionSlug,
|
|
16
|
+
req
|
|
17
|
+
}),
|
|
18
|
+
data,
|
|
19
|
+
entity: 'collection',
|
|
20
|
+
partial,
|
|
21
|
+
req
|
|
22
|
+
});
|
|
23
|
+
export const validateGlobalData = ({ data, globalSlug, req })=>validateData({
|
|
24
|
+
slug: globalSlug,
|
|
25
|
+
buildSchema: ()=>getGlobalInputSchema({
|
|
26
|
+
globalSlug,
|
|
27
|
+
req
|
|
28
|
+
}),
|
|
29
|
+
data,
|
|
30
|
+
entity: 'global',
|
|
31
|
+
partial: true,
|
|
32
|
+
req
|
|
33
|
+
});
|
|
34
|
+
const validateData = ({ slug, buildSchema, data, entity, partial, req })=>{
|
|
35
|
+
let cache = validatorCache.get(req.payload.config);
|
|
36
|
+
if (!cache) {
|
|
37
|
+
cache = new Map();
|
|
38
|
+
validatorCache.set(req.payload.config, cache);
|
|
39
|
+
}
|
|
40
|
+
const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`;
|
|
41
|
+
let entityValidator = cache.get(cacheKey);
|
|
42
|
+
if (!entityValidator) {
|
|
43
|
+
const schema = buildSchema();
|
|
44
|
+
if (!schema) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
entityValidator = {
|
|
48
|
+
schema,
|
|
49
|
+
validate: validator.getValidator(partial ? withoutRequired(schema) : schema)
|
|
50
|
+
};
|
|
51
|
+
cache.set(cacheKey, entityValidator);
|
|
52
|
+
}
|
|
53
|
+
const result = entityValidator.validate(data);
|
|
54
|
+
if (result.valid) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const { schema } = entityValidator;
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: `Invalid data for ${entity} "${slug}": ${result.errorMessage}\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
isError: true,
|
|
66
|
+
structuredContent: {
|
|
67
|
+
[`${entity}Slug`]: slug,
|
|
68
|
+
errors: [
|
|
69
|
+
{
|
|
70
|
+
message: result.errorMessage
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
schema
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/** Updates are partial — drop the schema's top-level `required` before validating. */ const withoutRequired = (schema)=>{
|
|
78
|
+
const { required: _required, ...rest } = schema;
|
|
79
|
+
return rest;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=validateEntityData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/builtin/validateEntityData.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker'\n\nimport type { JsonSchemaType, MCPToolResponse } from '../../types.js'\n\nimport {\n getCollectionInputSchema,\n getGlobalInputSchema,\n} from '../../utils/schemaConversion/getEntityInputSchema.js'\n\n/**\n * Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.\n */\nconst validator = new CfWorkerJsonSchemaValidator({ shortcircuit: true })\n\ntype EntityValidator = {\n schema: JsonSchemaType\n validate: ReturnType<(typeof validator)['getValidator']>\n}\n\n/**\n * - Caches each entity's schema and validator, so both are only built on the first request.\n * - Keyed by payload config, then by entity type, slug, partial and language.\n */\nconst validatorCache = new WeakMap<SanitizedConfig, Map<string, EntityValidator>>()\n\nexport const validateCollectionData = ({\n collectionSlug,\n data,\n partial,\n req,\n}: {\n collectionSlug: CollectionSlug\n data: Record<string, unknown>\n partial?: boolean\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: collectionSlug,\n buildSchema: () => getCollectionInputSchema({ collectionSlug, req }),\n data,\n entity: 'collection',\n partial,\n req,\n })\n\nexport const validateGlobalData = ({\n data,\n globalSlug,\n req,\n}: {\n data: Record<string, unknown>\n globalSlug: GlobalSlug\n req: PayloadRequest\n}): MCPToolResponse | null =>\n validateData({\n slug: globalSlug,\n buildSchema: () => getGlobalInputSchema({ globalSlug, req }),\n data,\n entity: 'global',\n partial: true,\n req,\n })\n\nconst validateData = ({\n slug,\n buildSchema,\n data,\n entity,\n partial,\n req,\n}: {\n buildSchema: () => JsonSchemaType | null\n data: Record<string, unknown>\n entity: 'collection' | 'global'\n partial?: boolean\n req: PayloadRequest\n slug: string\n}): MCPToolResponse | null => {\n let cache = validatorCache.get(req.payload.config)\n if (!cache) {\n cache = new Map()\n validatorCache.set(req.payload.config, cache)\n }\n\n const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`\n let entityValidator = cache.get(cacheKey)\n\n if (!entityValidator) {\n const schema = buildSchema()\n\n if (!schema) {\n return null\n }\n\n entityValidator = {\n schema,\n validate: validator.getValidator(partial ? withoutRequired(schema) : schema),\n }\n cache.set(cacheKey, entityValidator)\n }\n\n const result = entityValidator.validate(data)\n\n if (result.valid) {\n return null\n }\n\n const { schema } = entityValidator\n\n return {\n content: [\n {\n type: 'text',\n text: `Invalid data for ${entity} \"${slug}\": ${result.errorMessage}\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(schema)}\\n\\`\\`\\``,\n },\n ],\n isError: true,\n structuredContent: {\n [`${entity}Slug`]: slug,\n errors: [{ message: result.errorMessage }],\n schema,\n },\n }\n}\n\n/** Updates are partial — drop the schema's top-level `required` before validating. */\nconst withoutRequired = (schema: JsonSchemaType): JsonSchemaType => {\n const { required: _required, ...rest } = schema\n return rest\n}\n"],"names":["CfWorkerJsonSchemaValidator","getCollectionInputSchema","getGlobalInputSchema","validator","shortcircuit","validatorCache","WeakMap","validateCollectionData","collectionSlug","data","partial","req","validateData","slug","buildSchema","entity","validateGlobalData","globalSlug","cache","get","payload","config","Map","set","cacheKey","i18n","language","entityValidator","schema","validate","getValidator","withoutRequired","result","valid","content","type","text","errorMessage","JSON","stringify","isError","structuredContent","errors","message","required","_required","rest"],"mappings":"AAEA,SAASA,2BAA2B,QAAQ,oDAAmD;AAI/F,SACEC,wBAAwB,EACxBC,oBAAoB,QACf,uDAAsD;AAE7D;;CAEC,GACD,MAAMC,YAAY,IAAIH,4BAA4B;IAAEI,cAAc;AAAK;AAOvE;;;CAGC,GACD,MAAMC,iBAAiB,IAAIC;AAE3B,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,cAAc,EACdC,IAAI,EACJC,OAAO,EACPC,GAAG,EAMJ,GACCC,aAAa;QACXC,MAAML;QACNM,aAAa,IAAMb,yBAAyB;gBAAEO;gBAAgBG;YAAI;QAClEF;QACAM,QAAQ;QACRL;QACAC;IACF,GAAE;AAEJ,OAAO,MAAMK,qBAAqB,CAAC,EACjCP,IAAI,EACJQ,UAAU,EACVN,GAAG,EAKJ,GACCC,aAAa;QACXC,MAAMI;QACNH,aAAa,IAAMZ,qBAAqB;gBAAEe;gBAAYN;YAAI;QAC1DF;QACAM,QAAQ;QACRL,SAAS;QACTC;IACF,GAAE;AAEJ,MAAMC,eAAe,CAAC,EACpBC,IAAI,EACJC,WAAW,EACXL,IAAI,EACJM,MAAM,EACNL,OAAO,EACPC,GAAG,EAQJ;IACC,IAAIO,QAAQb,eAAec,GAAG,CAACR,IAAIS,OAAO,CAACC,MAAM;IACjD,IAAI,CAACH,OAAO;QACVA,QAAQ,IAAII;QACZjB,eAAekB,GAAG,CAACZ,IAAIS,OAAO,CAACC,MAAM,EAAEH;IACzC;IAEA,MAAMM,WAAW,GAAGT,OAAO,CAAC,EAAEF,KAAK,CAAC,EAAEH,UAAU,YAAY,OAAO,CAAC,EAAEC,IAAIc,IAAI,CAACC,QAAQ,EAAE;IACzF,IAAIC,kBAAkBT,MAAMC,GAAG,CAACK;IAEhC,IAAI,CAACG,iBAAiB;QACpB,MAAMC,SAASd;QAEf,IAAI,CAACc,QAAQ;YACX,OAAO;QACT;QAEAD,kBAAkB;YAChBC;YACAC,UAAU1B,UAAU2B,YAAY,CAACpB,UAAUqB,gBAAgBH,UAAUA;QACvE;QACAV,MAAMK,GAAG,CAACC,UAAUG;IACtB;IAEA,MAAMK,SAASL,gBAAgBE,QAAQ,CAACpB;IAExC,IAAIuB,OAAOC,KAAK,EAAE;QAChB,OAAO;IACT;IAEA,MAAM,EAAEL,MAAM,EAAE,GAAGD;IAEnB,OAAO;QACLO,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,iBAAiB,EAAErB,OAAO,EAAE,EAAEF,KAAK,GAAG,EAAEmB,OAAOK,YAAY,CAAC,2CAA2C,EAAEC,KAAKC,SAAS,CAACX,QAAQ,QAAQ,CAAC;YAClJ;SACD;QACDY,SAAS;QACTC,mBAAmB;YACjB,CAAC,GAAG1B,OAAO,IAAI,CAAC,CAAC,EAAEF;YACnB6B,QAAQ;gBAAC;oBAAEC,SAASX,OAAOK,YAAY;gBAAC;aAAE;YAC1CT;QACF;IACF;AACF;AAEA,oFAAoF,GACpF,MAAMG,kBAAkB,CAACH;IACvB,MAAM,EAAEgB,UAAUC,SAAS,EAAE,GAAGC,MAAM,GAAGlB;IACzC,OAAOkB;AACT"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { CollectionTool, GlobalTool, Tool } from '../types.js';
|
|
2
|
+
type CollectionBuiltin = {
|
|
3
|
+
mcpName: string;
|
|
4
|
+
requiresDuplicateEnabled?: boolean;
|
|
5
|
+
requiresVersions?: boolean;
|
|
6
|
+
tool: CollectionTool;
|
|
7
|
+
};
|
|
8
|
+
type GlobalBuiltin = {
|
|
9
|
+
mcpName: string;
|
|
10
|
+
requiresVersions?: boolean;
|
|
11
|
+
tool: GlobalTool;
|
|
12
|
+
};
|
|
13
|
+
export declare const TOOL_BUILTINS: {
|
|
14
|
+
getConfigInfo: {
|
|
15
|
+
mcpName: string;
|
|
16
|
+
tool: Tool;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The static built-in collection CRUD tools. Keys here are the source of truth
|
|
21
|
+
* for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
|
|
22
|
+
* automatically.
|
|
23
|
+
*/
|
|
24
|
+
export declare const COLLECTION_BUILTINS: {
|
|
25
|
+
count: {
|
|
26
|
+
mcpName: string;
|
|
27
|
+
tool: CollectionTool;
|
|
28
|
+
};
|
|
29
|
+
countVersions: {
|
|
30
|
+
mcpName: string;
|
|
31
|
+
requiresVersions: true;
|
|
32
|
+
tool: CollectionTool;
|
|
33
|
+
};
|
|
34
|
+
create: {
|
|
35
|
+
mcpName: string;
|
|
36
|
+
tool: CollectionTool;
|
|
37
|
+
};
|
|
38
|
+
delete: {
|
|
39
|
+
mcpName: string;
|
|
40
|
+
tool: CollectionTool;
|
|
41
|
+
};
|
|
42
|
+
duplicate: {
|
|
43
|
+
mcpName: string;
|
|
44
|
+
requiresDuplicateEnabled: true;
|
|
45
|
+
tool: CollectionTool;
|
|
46
|
+
};
|
|
47
|
+
find: {
|
|
48
|
+
mcpName: string;
|
|
49
|
+
tool: CollectionTool;
|
|
50
|
+
};
|
|
51
|
+
findDistinct: {
|
|
52
|
+
mcpName: string;
|
|
53
|
+
tool: CollectionTool;
|
|
54
|
+
};
|
|
55
|
+
findVersionByID: {
|
|
56
|
+
mcpName: string;
|
|
57
|
+
requiresVersions: true;
|
|
58
|
+
tool: CollectionTool;
|
|
59
|
+
};
|
|
60
|
+
findVersions: {
|
|
61
|
+
mcpName: string;
|
|
62
|
+
requiresVersions: true;
|
|
63
|
+
tool: CollectionTool;
|
|
64
|
+
};
|
|
65
|
+
getCollectionSchema: {
|
|
66
|
+
mcpName: string;
|
|
67
|
+
tool: CollectionTool;
|
|
68
|
+
};
|
|
69
|
+
restoreVersion: {
|
|
70
|
+
mcpName: string;
|
|
71
|
+
requiresVersions: true;
|
|
72
|
+
tool: CollectionTool;
|
|
73
|
+
};
|
|
74
|
+
update: {
|
|
75
|
+
mcpName: string;
|
|
76
|
+
tool: CollectionTool;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The static auth tools surfaced under auth-enabled collections. Keys are the
|
|
81
|
+
* source of truth for `MCPCollectionAuthToolName`.
|
|
82
|
+
*/
|
|
83
|
+
export declare const COLLECTION_AUTH_BUILTINS: {
|
|
84
|
+
auth: {
|
|
85
|
+
mcpName: string;
|
|
86
|
+
tool: CollectionTool;
|
|
87
|
+
};
|
|
88
|
+
forgotPassword: {
|
|
89
|
+
mcpName: string;
|
|
90
|
+
tool: CollectionTool;
|
|
91
|
+
};
|
|
92
|
+
login: {
|
|
93
|
+
mcpName: string;
|
|
94
|
+
tool: CollectionTool;
|
|
95
|
+
};
|
|
96
|
+
resetPassword: {
|
|
97
|
+
mcpName: string;
|
|
98
|
+
tool: CollectionTool;
|
|
99
|
+
};
|
|
100
|
+
unlock: {
|
|
101
|
+
mcpName: string;
|
|
102
|
+
tool: CollectionTool;
|
|
103
|
+
};
|
|
104
|
+
verify: {
|
|
105
|
+
mcpName: string;
|
|
106
|
+
tool: CollectionTool;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The static built-in global tools. Keys are the source of truth for
|
|
111
|
+
* `MCPGlobalBuiltinName`.
|
|
112
|
+
*/
|
|
113
|
+
export declare const GLOBAL_BUILTINS: {
|
|
114
|
+
countGlobalVersions: {
|
|
115
|
+
mcpName: string;
|
|
116
|
+
requiresVersions: true;
|
|
117
|
+
tool: GlobalTool;
|
|
118
|
+
};
|
|
119
|
+
find: {
|
|
120
|
+
mcpName: string;
|
|
121
|
+
tool: GlobalTool;
|
|
122
|
+
};
|
|
123
|
+
findGlobalVersionByID: {
|
|
124
|
+
mcpName: string;
|
|
125
|
+
requiresVersions: true;
|
|
126
|
+
tool: GlobalTool;
|
|
127
|
+
};
|
|
128
|
+
findGlobalVersions: {
|
|
129
|
+
mcpName: string;
|
|
130
|
+
requiresVersions: true;
|
|
131
|
+
tool: GlobalTool;
|
|
132
|
+
};
|
|
133
|
+
getGlobalSchema: {
|
|
134
|
+
mcpName: string;
|
|
135
|
+
tool: GlobalTool;
|
|
136
|
+
};
|
|
137
|
+
restoreGlobalVersion: {
|
|
138
|
+
mcpName: string;
|
|
139
|
+
requiresVersions: true;
|
|
140
|
+
tool: GlobalTool;
|
|
141
|
+
};
|
|
142
|
+
update: {
|
|
143
|
+
mcpName: string;
|
|
144
|
+
tool: GlobalTool;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS;
|
|
148
|
+
export type MCPCollectionAuthToolName = keyof typeof COLLECTION_AUTH_BUILTINS;
|
|
149
|
+
export type MCPGlobalBuiltinName = keyof typeof GLOBAL_BUILTINS;
|
|
150
|
+
export type MCPTopLevelBuiltinName = keyof typeof TOOL_BUILTINS;
|
|
151
|
+
/**
|
|
152
|
+
* Pre-typed `Object.entries` for each registry. The cast from `string` to the
|
|
153
|
+
* literal key union lives here once so consumers can iterate without their own
|
|
154
|
+
* cast — TypeScript's `Object.entries` always widens keys to `string`, which
|
|
155
|
+
* defeats the narrow type lookups on `MCPCollectionToolsMap`.
|
|
156
|
+
*/
|
|
157
|
+
export declare const TOOL_BUILTIN_ENTRIES: Array<[MCPTopLevelBuiltinName, (typeof TOOL_BUILTINS)[MCPTopLevelBuiltinName]]>;
|
|
158
|
+
export declare const COLLECTION_BUILTIN_ENTRIES: Array<[MCPCollectionBuiltinName, CollectionBuiltin]>;
|
|
159
|
+
export declare const COLLECTION_AUTH_BUILTIN_ENTRIES: Array<[MCPCollectionAuthToolName, (typeof COLLECTION_AUTH_BUILTINS)[MCPCollectionAuthToolName]]>;
|
|
160
|
+
export declare const GLOBAL_BUILTIN_ENTRIES: Array<[MCPGlobalBuiltinName, GlobalBuiltin]>;
|
|
161
|
+
export {};
|
|
162
|
+
//# sourceMappingURL=builtinTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BnE,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,aAAa;;QACP,OAAO;QAAmB,IAAI;;CACU,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;QACrB,OAAO;QAAoB,IAAI;;;;;;;;QAE9B,OAAO;QAAoB,IAAI;;;QAC/B,OAAO;QAAqB,IAAI;;;;;;;;QAMlC,OAAO;QAAmB,IAAI;;;QACtB,OAAO;QAAkB,IAAI;;;;;;;;;;;;;QAOtB,OAAO;QAAyB,IAAI;;;;;;;;QAEjD,OAAO;QAAoB,IAAI;;CACE,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;QAC3B,OAAO;QAAU,IAAI;;;QAE3B,OAAO;QACP,IAAI;;;QAEG,OAAO;QAAW,IAAI;;;QAE7B,OAAO;QACP,IAAI;;;QAEI,OAAO;QAAY,IAAI;;;QACvB,OAAO;QAAY,IAAI;;CACkC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;QAMlB,OAAO;QAAgB,IAAI;;;;;;;;;;;;;QAWhB,OAAO;QAAqB,IAAI;;;;;;;;QAMzC,OAAO;QAAkB,IAAI;;CACA,CAAA;AAEzC,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AAEvE,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,eAAe,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,aAAa,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAoC,KAAK,CACxE,CAAC,sBAAsB,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAC9C,CAAA;AAED,eAAO,MAAM,+BAA+B,EAA+C,KAAK,CAC9F,CAAC,yBAAyB,EAAE,CAAC,OAAO,wBAAwB,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAC1F,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAsC,KAAK,CAC5E,CAAC,oBAAoB,EAAE,aAAa,CAAC,CACtC,CAAA"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { authCollectionTool, forgotPasswordCollectionTool, loginCollectionTool, resetPasswordCollectionTool, unlockCollectionTool, verifyCollectionTool } from './builtin/collections/authTools.js';
|
|
2
|
+
import { countDocumentsTool } from './builtin/collections/countTool.js';
|
|
3
|
+
import { countVersionsTool } from './builtin/collections/countVersionsTool.js';
|
|
4
|
+
import { createDocumentTool } from './builtin/collections/createTool.js';
|
|
5
|
+
import { deleteDocumentsTool } from './builtin/collections/deleteTool.js';
|
|
6
|
+
import { duplicateDocumentTool } from './builtin/collections/duplicateTool.js';
|
|
7
|
+
import { findDistinctTool } from './builtin/collections/findDistinctTool.js';
|
|
8
|
+
import { findDocumentsTool } from './builtin/collections/findTool.js';
|
|
9
|
+
import { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js';
|
|
10
|
+
import { findVersionsTool } from './builtin/collections/findVersionsTool.js';
|
|
11
|
+
import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js';
|
|
12
|
+
import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js';
|
|
13
|
+
import { updateDocumentTool } from './builtin/collections/updateTool.js';
|
|
14
|
+
import { getConfigInfoTool } from './builtin/getConfigInfoTool.js';
|
|
15
|
+
import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js';
|
|
16
|
+
import { findGlobalTool } from './builtin/globals/findTool.js';
|
|
17
|
+
import { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js';
|
|
18
|
+
import { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js';
|
|
19
|
+
import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js';
|
|
20
|
+
import { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js';
|
|
21
|
+
import { updateGlobalTool } from './builtin/globals/updateTool.js';
|
|
22
|
+
export const TOOL_BUILTINS = {
|
|
23
|
+
getConfigInfo: {
|
|
24
|
+
mcpName: 'getConfigInfo',
|
|
25
|
+
tool: getConfigInfoTool
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The static built-in collection CRUD tools. Keys here are the source of truth
|
|
30
|
+
* for `MCPCollectionBuiltinName` — adding/removing an entry updates the type
|
|
31
|
+
* automatically.
|
|
32
|
+
*/ export const COLLECTION_BUILTINS = {
|
|
33
|
+
count: {
|
|
34
|
+
mcpName: 'countDocuments',
|
|
35
|
+
tool: countDocumentsTool
|
|
36
|
+
},
|
|
37
|
+
countVersions: {
|
|
38
|
+
mcpName: 'countVersions',
|
|
39
|
+
requiresVersions: true,
|
|
40
|
+
tool: countVersionsTool
|
|
41
|
+
},
|
|
42
|
+
create: {
|
|
43
|
+
mcpName: 'createDocument',
|
|
44
|
+
tool: createDocumentTool
|
|
45
|
+
},
|
|
46
|
+
delete: {
|
|
47
|
+
mcpName: 'deleteDocuments',
|
|
48
|
+
tool: deleteDocumentsTool
|
|
49
|
+
},
|
|
50
|
+
duplicate: {
|
|
51
|
+
mcpName: 'duplicateDocument',
|
|
52
|
+
requiresDuplicateEnabled: true,
|
|
53
|
+
tool: duplicateDocumentTool
|
|
54
|
+
},
|
|
55
|
+
find: {
|
|
56
|
+
mcpName: 'findDocuments',
|
|
57
|
+
tool: findDocumentsTool
|
|
58
|
+
},
|
|
59
|
+
findDistinct: {
|
|
60
|
+
mcpName: 'findDistinct',
|
|
61
|
+
tool: findDistinctTool
|
|
62
|
+
},
|
|
63
|
+
findVersionByID: {
|
|
64
|
+
mcpName: 'findVersionByID',
|
|
65
|
+
requiresVersions: true,
|
|
66
|
+
tool: findVersionByIDTool
|
|
67
|
+
},
|
|
68
|
+
findVersions: {
|
|
69
|
+
mcpName: 'findVersions',
|
|
70
|
+
requiresVersions: true,
|
|
71
|
+
tool: findVersionsTool
|
|
72
|
+
},
|
|
73
|
+
getCollectionSchema: {
|
|
74
|
+
mcpName: 'getCollectionSchema',
|
|
75
|
+
tool: getCollectionSchemaTool
|
|
76
|
+
},
|
|
77
|
+
restoreVersion: {
|
|
78
|
+
mcpName: 'restoreVersion',
|
|
79
|
+
requiresVersions: true,
|
|
80
|
+
tool: restoreVersionTool
|
|
81
|
+
},
|
|
82
|
+
update: {
|
|
83
|
+
mcpName: 'updateDocument',
|
|
84
|
+
tool: updateDocumentTool
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* The static auth tools surfaced under auth-enabled collections. Keys are the
|
|
89
|
+
* source of truth for `MCPCollectionAuthToolName`.
|
|
90
|
+
*/ export const COLLECTION_AUTH_BUILTINS = {
|
|
91
|
+
auth: {
|
|
92
|
+
mcpName: 'auth',
|
|
93
|
+
tool: authCollectionTool
|
|
94
|
+
},
|
|
95
|
+
forgotPassword: {
|
|
96
|
+
mcpName: 'forgotPassword',
|
|
97
|
+
tool: forgotPasswordCollectionTool
|
|
98
|
+
},
|
|
99
|
+
login: {
|
|
100
|
+
mcpName: 'login',
|
|
101
|
+
tool: loginCollectionTool
|
|
102
|
+
},
|
|
103
|
+
resetPassword: {
|
|
104
|
+
mcpName: 'resetPassword',
|
|
105
|
+
tool: resetPasswordCollectionTool
|
|
106
|
+
},
|
|
107
|
+
unlock: {
|
|
108
|
+
mcpName: 'unlock',
|
|
109
|
+
tool: unlockCollectionTool
|
|
110
|
+
},
|
|
111
|
+
verify: {
|
|
112
|
+
mcpName: 'verify',
|
|
113
|
+
tool: verifyCollectionTool
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* The static built-in global tools. Keys are the source of truth for
|
|
118
|
+
* `MCPGlobalBuiltinName`.
|
|
119
|
+
*/ export const GLOBAL_BUILTINS = {
|
|
120
|
+
countGlobalVersions: {
|
|
121
|
+
mcpName: 'countGlobalVersions',
|
|
122
|
+
requiresVersions: true,
|
|
123
|
+
tool: countGlobalVersionsTool
|
|
124
|
+
},
|
|
125
|
+
find: {
|
|
126
|
+
mcpName: 'findGlobal',
|
|
127
|
+
tool: findGlobalTool
|
|
128
|
+
},
|
|
129
|
+
findGlobalVersionByID: {
|
|
130
|
+
mcpName: 'findGlobalVersionByID',
|
|
131
|
+
requiresVersions: true,
|
|
132
|
+
tool: findGlobalVersionByIDTool
|
|
133
|
+
},
|
|
134
|
+
findGlobalVersions: {
|
|
135
|
+
mcpName: 'findGlobalVersions',
|
|
136
|
+
requiresVersions: true,
|
|
137
|
+
tool: findGlobalVersionsTool
|
|
138
|
+
},
|
|
139
|
+
getGlobalSchema: {
|
|
140
|
+
mcpName: 'getGlobalSchema',
|
|
141
|
+
tool: getGlobalSchemaTool
|
|
142
|
+
},
|
|
143
|
+
restoreGlobalVersion: {
|
|
144
|
+
mcpName: 'restoreGlobalVersion',
|
|
145
|
+
requiresVersions: true,
|
|
146
|
+
tool: restoreGlobalVersionTool
|
|
147
|
+
},
|
|
148
|
+
update: {
|
|
149
|
+
mcpName: 'updateGlobal',
|
|
150
|
+
tool: updateGlobalTool
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Pre-typed `Object.entries` for each registry. The cast from `string` to the
|
|
155
|
+
* literal key union lives here once so consumers can iterate without their own
|
|
156
|
+
* cast — TypeScript's `Object.entries` always widens keys to `string`, which
|
|
157
|
+
* defeats the narrow type lookups on `MCPCollectionToolsMap`.
|
|
158
|
+
*/ export const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS);
|
|
159
|
+
export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS);
|
|
160
|
+
export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS);
|
|
161
|
+
export const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS);
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=builtinTools.js.map
|