@payloadcms/plugin-mcp 3.85.0 → 4.0.0-internal.1f9ae9a
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/README.md +2 -2
- package/bin.js +39 -0
- package/dist/collection/getAccessField.d.ts +12 -0
- package/dist/collection/getAccessField.d.ts.map +1 -0
- package/dist/collection/getAccessField.js +57 -0
- package/dist/collection/getAccessField.js.map +1 -0
- package/dist/collection/index.d.ts +6 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +59 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/components/AccessField/index.client.d.ts +10 -0
- package/dist/components/AccessField/index.client.d.ts.map +1 -0
- package/dist/components/AccessField/index.client.js +305 -0
- package/dist/components/AccessField/index.client.js.map +1 -0
- package/dist/components/AccessField/index.css +93 -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 +10 -0
- package/dist/endpoint/access.d.ts.map +1 -0
- package/dist/endpoint/access.js +106 -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 +36 -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/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -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 +163 -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 +250 -0
- package/dist/mcp/builtin/collections/authTools.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/createTool.js +87 -0
- package/dist/mcp/builtin/collections/createTool.js.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.js +117 -0
- package/dist/mcp/builtin/collections/deleteTool.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 +159 -0
- package/dist/mcp/builtin/collections/findTool.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 +187 -0
- package/dist/mcp/builtin/collections/updateTool.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 +76 -0
- package/dist/mcp/builtin/globals/findTool.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 +92 -0
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +37 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -0
- package/dist/mcp/builtinTools.js +64 -0
- package/dist/mcp/builtinTools.js.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.js +167 -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 +89 -0
- package/dist/stdio.js.map +1 -0
- package/dist/types.d.ts +262 -455
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getLogger.d.ts +10 -0
- package/dist/utils/getLogger.d.ts.map +1 -0
- package/dist/utils/getLogger.js +22 -0
- package/dist/utils/getLogger.js.map +1 -0
- package/dist/utils/getPluginConfig.d.ts +12 -0
- package/dist/utils/getPluginConfig.d.ts.map +1 -0
- package/dist/utils/getPluginConfig.js +15 -0
- package/dist/utils/getPluginConfig.js.map +1 -0
- package/dist/utils/localAPIDefaults.d.ts +20 -0
- package/dist/utils/localAPIDefaults.d.ts.map +1 -0
- package/dist/utils/localAPIDefaults.js +19 -0
- package/dist/utils/localAPIDefaults.js.map +1 -0
- package/dist/utils/resolveProjectRoot.d.ts +7 -0
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
- package/dist/utils/resolveProjectRoot.js +15 -0
- package/dist/utils/resolveProjectRoot.js.map +1 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts +7 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.js +37 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.js.map +1 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +2 -2
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +1 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +7 -4
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +1 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +2 -2
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +1 -1
- package/dist/utils/schemaConversion/transformPointFields.js +7 -1
- package/dist/utils/schemaConversion/transformPointFields.js.map +1 -1
- 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/package.json +35 -10
- package/src/collection/getAccessField.ts +64 -0
- package/src/collection/index.ts +63 -0
- package/src/components/AccessField/index.client.tsx +344 -0
- package/src/components/AccessField/index.css +93 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +132 -0
- package/src/endpoint/index.ts +35 -0
- package/src/exports/client.ts +2 -0
- package/src/index.ts +35 -85
- package/src/mcp/buildMcpServer.ts +224 -0
- package/src/mcp/builtin/collections/authTools.ts +233 -0
- package/src/mcp/builtin/collections/createTool.ts +116 -0
- package/src/mcp/builtin/collections/deleteTool.ts +123 -0
- package/src/mcp/builtin/collections/findTool.ts +187 -0
- package/src/mcp/builtin/collections/updateTool.ts +205 -0
- package/src/mcp/builtin/globals/findTool.ts +96 -0
- package/src/mcp/builtin/globals/updateTool.ts +118 -0
- package/src/mcp/builtinTools.ts +84 -0
- package/src/mcp/sanitizeMCPConfig.ts +239 -0
- package/src/stdio.ts +98 -0
- package/src/types.ts +295 -490
- package/src/utils/getLogger.ts +22 -0
- package/src/utils/getPluginConfig.ts +24 -0
- package/src/utils/localAPIDefaults.ts +22 -0
- package/src/utils/resolveProjectRoot.ts +17 -0
- package/src/utils/schemaConversion/prepareCollectionSchema.ts +39 -0
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +4 -4
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +11 -6
- package/src/utils/schemaConversion/transformPointFields.ts +6 -5
- package/src/utils/toStandardSchema.ts +9 -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/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/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,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AG,SAAS,CAAA;CACvB,CAAA"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The caller's identity + the MCP items they can use for this request. Returned
|
|
3
|
+
* by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers
|
|
4
|
+
* receive this via `args.authorizedMCP` so they can spread
|
|
5
|
+
* `localAPIDefaults(authorizedMCP)` into every local API call.
|
|
6
|
+
*/ export { };
|
|
2
7
|
|
|
3
8
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CollectionConfig,\n CollectionSlug,\n GlobalSlug,\n PayloadRequest,\n TypedUser,\n} from 'payload'\nimport type { z } from 'zod'\n\nimport { type ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'\n\nexport type MCPPluginConfig = {\n /**\n * Set the collections that should be available as resources via MCP.\n */\n collections?: Partial<\n Record<\n CollectionSlug,\n {\n /**\n * Set the description of the collection. This is used by MCP clients to determine when to use the collecton as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the collection. Admins can then allow or disallow the use of the capability by MCP clients.\n */\n enabled:\n | {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * 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.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * Disable the MCP plugin.\n */\n disabled?: boolean\n /**\n * Experimental features\n * **These features are for experimental purposes -- They are Disabled in Production by Default**\n */\n experimental?: {\n /**\n * These are MCP tools that can be used by a client to modify Payload.\n */\n tools: {\n /**\n * **Experimental** -- Auth MCP tools allow a client to change authentication priviliages for users. This is for developing ideas that help Admins with authentication tasks.\n */\n auth?: {\n /**\n * Enable the auth MCP tools. This allows Admins to enable or disable the auth capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **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.\n */\n collections?: {\n /**\n * Set the directory path to the collections directory. This can be a directory outside of your default directory, or another Payload project.\n */\n collectionsDirPath: string\n /**\n * Enable the collection MCP tools. This allows Admins to enable or disable the Collection modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Config MCP tools allow for the modification of a Payload Config. This is for developing ideas that help Developers with config tasks.\n */\n config?: {\n /**\n * Set the directory path to the config directory. This can be a directory outside of your default directory, or another Payload project.\n */\n configFilePath: string\n /**\n * Enable the config MCP tools. This allows Admins to enable or disable the Payload Config modification capabilities.\n * @default false\n */\n enabled: boolean\n }\n /**\n * **Experimental** -- Jobs MCP tools allow for the modification of Payload jobs. This is for developing ideas that help Developers with job tasks.\n */\n jobs?: {\n /**\n * Enable the jobs MCP tools. This allows Admins to enable or disable the Job modification capabilities.\n * @default false\n */\n enabled: boolean\n /**\n * Set the directory path to the jobs directory. This can be a directory outside of your default directory, or another Payload project.\n */\n jobsDirPath: string\n }\n }\n }\n /**\n * Set the globals that should be available as resources via MCP.\n * Globals are singleton configuration objects (e.g., site settings, navigation).\n * Note: Globals only support find and update operations.\n */\n globals?: Partial<\n Record<\n GlobalSlug,\n {\n /**\n * Set the description of the global. This is used by MCP clients to determine when to use the global as a resource.\n */\n description?: string\n /**\n * Set the enabled capabilities of the global. Admins can then allow or disallow the use of the capability by MCP clients.\n * Note: Globals only support find and update operations as they are singletons.\n */\n enabled:\n | {\n find?: boolean\n update?: boolean\n }\n | boolean\n\n /**\n * 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.\n */\n overrideResponse?: (\n response: {\n content: Array<{\n text: string\n type: string\n }>\n },\n doc: Record<string, unknown>,\n req: PayloadRequest,\n ) => {\n content: Array<{\n text: string\n type: string\n }>\n }\n }\n >\n >\n /**\n * MCP Server options.\n */\n mcp?: {\n handlerOptions?: MCPHandlerOptions\n /**\n * Add custom MCP Prompts.\n */\n prompts?: {\n /**\n * 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.\n */\n argsSchema: z.ZodRawShape\n /**\n * Set the description of the prompt. This is used by MCP clients to determine when to use the prompt.\n */\n description: string\n /**\n * Set the handler of the prompt. This is the function that will be called when the prompt is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }\n | Promise<{\n messages: Array<{\n content: {\n text: string\n type: 'text'\n }\n role: 'assistant' | 'user'\n }>\n }>\n /**\n * Set the function name of the prompt.\n */\n name: string\n /**\n * Set the title of the prompt. LLMs will interperate the title to determine when to use the prompt.\n */\n title: string\n }[]\n\n /**\n * Add custom MCP Resource.\n */\n resources?: {\n /**\n * Set the description of the resource. This is used by MCP clients to determine when to use the resource.\n * example: 'Data is a resource that contains special data.'\n */\n description: string\n /**\n * Set the handler of the resource. This is the function that will be called when the resource is used.\n * The handler can have either 3 arguments (when no args are passed) or 4 arguments (when args are passed).\n */\n handler: (...args: any[]) =>\n | {\n contents: Array<{\n text: string\n uri: string\n }>\n }\n | Promise<{\n contents: Array<{\n text: string\n uri: string\n }>\n }>\n /**\n * Set the mime type of the resource.\n * example: 'text/plain'\n */\n mimeType: string\n /**\n * Set the function name of the resource.\n * example: 'data'\n */\n name: string\n /**\n * Set the title of the resource. LLMs will interperate the title to determine when to use the resource.\n * example: 'Data'\n */\n title: string\n /**\n * Set the uri of the resource.\n * example: 'data://app'\n */\n uri: ResourceTemplate | string\n }[]\n serverOptions?: MCPServerOptions\n /**\n * Add custom MCP Tools.\n */\n tools?: {\n /**\n * Set the description of the tool. This is used by MCP clients to determine when to use the tool.\n */\n description: string\n /**\n * Set the handler of the tool. This is the function that will be called when the tool is used.\n */\n handler: (\n args: Record<string, unknown>,\n req: PayloadRequest,\n _extra: unknown,\n ) =>\n | {\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }\n | Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n role?: string\n }>\n /**\n * 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.\n */\n name: string\n /**\n * Set the parameters of the tool. This is the parameters that will be passed to the tool.\n */\n parameters: z.ZodRawShape\n }[]\n }\n\n /**\n * Override the API key collection.\n * This allows you to add fields to the API key collection or modify the collection in any way you want.\n * @param collection - The API key collection.\n * @returns The modified API key collection.\n */\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n\n /**\n * Override the authentication method.\n * This allows you to use a custom authentication method instead of the default API key authentication.\n * @param req - The request object.\n * @returns The MCP access settings.\n */\n overrideAuth?: (\n req: PayloadRequest,\n getDefaultMcpAccessSettings: (overrideApiKey?: null | string) => Promise<MCPAccessSettings>,\n ) => MCPAccessSettings | Promise<MCPAccessSettings>\n\n /**\n * Set the users collection that API keys should be associated with.\n */\n userCollection?: CollectionSlug\n}\n\n/**\n * MCP Handler options.\n */\nexport type MCPHandlerOptions = {\n /**\n * Set the base path of the MCP handler. This is the path that will be used to access the MCP handler.\n * @default /api\n */\n basePath?: string\n /**\n * If true, disables the SSE endpoint. Only Streamable HTTP will be available.\n * @default true\n */\n disableSse?: boolean\n /**\n * Set the maximum duration of the MCP handler. This is the maximum duration that the MCP handler will run for.\n * @default 60\n */\n maxDuration?: number\n /**\n * Callback function that receives MCP events.\n * This can be used to track analytics, debug issues, or implement custom behaviors.\n */\n onEvent?: (event: unknown) => void\n /**\n * Set the Redis URL for the MCP handler. This is the URL that will be used to access the Redis server.\n * @default process.env.REDIS_URL\n */\n redisUrl?: string\n /**\n * Set verbose logging.\n * @default false\n */\n verboseLogs?: boolean\n}\n\n/**\n * MCP Server options.\n */\nexport type MCPServerOptions = {\n /**\n * Optional instructions describing how to use the server and its features.\n */\n instructions?: string\n /**\n * Set the server info of the MCP server.\n */\n serverInfo?: {\n /**\n * Set the name of the MCP server.\n * @default 'Payload MCP Server'\n */\n name: string\n /**\n * Set the version of the MCP server.\n * @default '1.0.0'\n */\n version: string\n }\n}\n\nexport type MCPAccessSettings = {\n auth?: {\n auth?: boolean\n forgotPassword?: boolean\n login?: boolean\n resetPassword?: boolean\n unlock?: boolean\n verify?: boolean\n }\n collections?: {\n create?: boolean\n delete?: boolean\n find?: boolean\n update?: boolean\n }\n config?: {\n find?: boolean\n update?: boolean\n }\n custom?: Record<string, boolean>\n globals?: {\n find?: boolean\n update?: boolean\n }\n jobs?: {\n create?: boolean\n run?: boolean\n update?: boolean\n }\n 'payload-mcp-prompt'?: Record<string, boolean>\n 'payload-mcp-resource'?: Record<string, boolean>\n 'payload-mcp-tool'?: Record<string, boolean>\n user: TypedUser\n} & Record<string, unknown>\n\nexport type EntityConfig = MCPPluginConfig['collections'] | MCPPluginConfig['globals']\n\nexport type FieldDefinition = {\n description?: string\n name: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type: string\n}\n\nexport type FieldModification = {\n changes: {\n description?: string\n options?: { label: string; value: string }[]\n position?: 'main' | 'sidebar'\n required?: boolean\n type?: string\n }\n fieldName: string\n}\n\nexport type CollectionConfigUpdates = {\n access?: {\n create?: string\n delete?: string\n read?: string\n update?: string\n }\n description?: string\n slug?: string\n timestamps?: boolean\n versioning?: boolean\n}\n\nexport type AdminConfig = {\n avatar?: string\n css?: string\n dateFormat?: string\n inactivityRoute?: string\n livePreview?: {\n breakpoints?: Array<{\n height: number\n label: string\n name: string\n width: number\n }>\n }\n logoutRoute?: string\n meta?: {\n favicon?: string\n ogImage?: string\n titleSuffix?: string\n }\n user?: string\n}\n\nexport type DatabaseConfig = {\n connectOptions?: string\n type?: 'mongodb' | 'postgres'\n url?: string\n}\n\nexport type PluginUpdates = {\n add?: string[]\n remove?: string[]\n}\n\nexport type GeneralConfig = {\n cookiePrefix?: string\n cors?: string\n csrf?: string\n graphQL?: {\n disable?: boolean\n schemaOutputFile?: string\n }\n rateLimit?: {\n max?: number\n skip?: string\n window?: number\n }\n secret?: string\n serverURL?: string\n typescript?: {\n declare?: boolean\n outputFile?: string\n }\n}\n\nexport interface SchemaField {\n description?: string\n name: string\n options?: string[]\n required?: boolean\n type: string\n}\n\nexport interface TaskSequenceItem {\n description?: string\n retries?: number\n taskId: string\n taskSlug: string\n timeout?: number\n}\n\nexport interface JobConfigUpdate {\n description?: string\n queue?: string\n retries?: number\n timeout?: number\n}\n"],"names":[],"mappings":"AAwhBA,WAKC"}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n CallToolResult,\n ContentBlock,\n JsonSchemaType,\n McpServer,\n ResourceTemplate,\n ServerContext,\n StandardSchemaWithJSON,\n} from '@modelcontextprotocol/server'\nimport type {\n AuthCollectionSlug,\n CollectionConfig,\n CollectionSlug,\n DefaultDocumentIDType,\n GlobalSlug,\n MaybePromise,\n PayloadRequest,\n TypedUser,\n} from 'payload'\n\nimport type {\n MCPCollectionAuthToolName,\n MCPCollectionBuiltinName,\n MCPGlobalBuiltinName,\n} from './mcp/builtinTools.js'\n\nexport type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }\n\n/** Re-exported from `@modelcontextprotocol/server` — the JSON Schema shape the MCP runtime validates against. */\nexport type { JsonSchemaType, StandardSchemaWithJSON }\n\n/**\n * What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw\n * JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).\n */\nexport type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON\n\n/**\n * Serializable mirror of `SanitizedMCPPluginConfig` for client components —\n * the full sanitized config carries functions (tool handlers, etc.) that can't\n * cross the server→client boundary. Built by `sanitizeClientPluginConfig` and\n * passed to the `AccessField` component via `clientProps`.\n *\n * @internal\n */\nexport type ClientMCPPluginConfig = {\n items: Array<{\n collectionSlug?: string\n description: string\n globalSlug?: string\n key: string\n label: string\n type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'\n }>\n}\n\nexport type MCPToolResponse = {\n content: ContentBlock[]\n /**\n * If available, return the document fetched within the\n * mcp tool. This is threaded as an additional argument to\n * overrideResponse functions and stripped before going on the wire.\n */\n doc?: Record<string, unknown>\n} & Pick<CallToolResult, '_meta' | 'isError' | 'structuredContent'>\n\nexport type MCPResponseOverride = (\n response: MCPToolResponse,\n doc: Record<string, unknown>,\n req: PayloadRequest,\n) => MCPToolResponse\n\n/**\n * The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets\n * its inferred output; anything else falls back to `Record<string, unknown>`.\n */\nexport type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON\n ? StandardSchemaWithJSON extends TSchema\n ? Record<string, unknown>\n : StandardSchemaWithJSON.InferOutput<TSchema>\n : Record<string, unknown>\n\nexport type ToolHandlerArgs<TSchema = undefined> = {\n authorizedMCP: AuthorizedMCP\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type CollectionToolHandlerArgs<TSchema = undefined> = {\n collectionSlug: CollectionSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type GlobalToolHandlerArgs<TSchema = undefined> = {\n globalSlug: GlobalSlug\n} & ToolHandlerArgs<TSchema>\n\nexport type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {\n description: string\n handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: TSchema\n /**\n * Override the return value of the tool handler\n */\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * `TSchema` is the schema itself (Standard Schema, raw JSON Schema, or undefined).\n * The function-form variant of `input` carries a concrete `{ collectionSchema: JsonSchemaType }`\n * parameter type so callers can write `({ collectionSchema }) => …` without annotating it.\n */\nexport type CollectionTool<\n TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,\n> = {\n handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: ((args: { collectionSchema: JsonSchemaType }) => TSchema) | TSchema\n} & Pick<Tool, 'description' | 'overrideResponse'>\n\nexport type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =\n {\n handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>\n input?: ((args: { globalSchema: JsonSchemaType }) => TSchema) | TSchema\n } & Pick<Tool, 'description' | 'overrideResponse'>\n\n/**\n * Configures (or disables) a built-in tool without replacing it.\n * `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a\n * required handler) from being silently accepted at a built-in key slot.\n */\nexport type MCPBuiltInToolOverride = {\n description?: string\n handler?: never\n overrideResponse?: MCPResponseOverride\n}\n\n/**\n * Value at a custom (non-built-in) tool key. Either the tool itself, or `false`\n * to disable it (useful when one plugin defines a custom tool and another\n * wants to opt out per-collection).\n */\nexport type MCPTopLevelToolEntry = Tool\n\nexport type MCPCollectionToolsMap = {\n [customToolName: string]: boolean | CollectionTool | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPCollectionBuiltinName]?: false | MCPBuiltInToolOverride\n}\n\nexport type MCPAuthCollectionToolsMap = {\n [K in MCPCollectionAuthToolName]?: MCPBuiltInToolOverride | true\n} & MCPCollectionToolsMap\n\n/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */\nexport type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends AuthCollectionSlug\n ? MCPAuthCollectionToolsMap\n : MCPCollectionToolsMap\n\nexport type MCPGlobalToolsMap = {\n [customToolName: string]: boolean | GlobalTool | MCPBuiltInToolOverride | undefined\n} & {\n [K in MCPGlobalBuiltinName]?: false | MCPBuiltInToolOverride\n}\n\nexport type MCPTopLevelToolsMap = Record<string, Tool>\n\nexport type PromptHandlerArgs<TSchema = undefined> = {\n input: TypedInput<TSchema>\n req: PayloadRequest\n serverContext: ServerContext\n}\n\nexport type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {\n argsSchema: TSchema\n description: string\n handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{\n messages: Array<{ content: { text: string; type: 'text' }; role: 'assistant' | 'user' }>\n }>\n title: string\n}\n\nexport type ResourceHandlerArgs = {\n /** Variables extracted from a `ResourceTemplate` URI. Empty for static-URI resources. */\n params: Record<string, string>\n req: PayloadRequest\n serverContext: ServerContext\n uri: URL\n}\n\nexport type Resource = {\n description: string\n handler: (args: ResourceHandlerArgs) => MaybePromise<{\n contents: Array<{ text: string; uri: string }>\n }>\n mimeType: string\n title: string\n uri: ResourceTemplate | string\n}\n\nexport type MCPPluginCollectionConfig<TSlug extends CollectionSlug> = {\n description?: string\n /** Fallback for built-in tools that don't set their own `overrideResponse`. */\n overrideResponse?: MCPResponseOverride\n tools?: MCPToolsMapForCollection<TSlug>\n}\n\nexport type MCPPluginGlobalConfig = {\n description?: string\n overrideResponse?: MCPResponseOverride\n tools?: MCPGlobalToolsMap\n}\n\n/**\n * The user-facing config shape passed to `mcpPlugin({ ... })`. Tools, prompts,\n * resources, and per-collection/global tool maps live in their own nested\n * fields. `sanitizeMCPConfig` flattens those into `items` and applies defaults\n * to produce a `SanitizedMCPPluginConfig` — the form every internal consumer\n * actually works with.\n */\nexport type MCPPluginConfig = {\n collections?: {\n [Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>\n }\n /** Skip MCP registration. The API key collection is still added (so DB / types stay stable). */\n disabled?: boolean\n globals?: {\n [Slug in GlobalSlug]?: MCPPluginGlobalConfig\n }\n mcp?: {\n serverOptions?: MCPServerOptions\n verboseLogs?: boolean\n }\n overrideApiKeyCollection?: (collection: CollectionConfig) => CollectionConfig\n /** Replace the default API-key auth with a custom resolver. */\n overrideAuth?: (args: {\n getAPIKeyDoc: (overrideApiKey?: string) => Promise<MCPAPIKeysDoc>\n getAuthorizedMCP: (args: { apiKeyDoc: MCPAPIKeysDoc }) => AuthorizedMCP\n pluginConfig: SanitizedMCPPluginConfig\n req: PayloadRequest\n }) => MaybePromise<AuthorizedMCP>\n prompts?: Record<string, Prompt>\n resources?: Record<string, Resource>\n /** Cross-cutting tools (not scoped to any collection or global). */\n tools?: MCPTopLevelToolsMap\n userCollection?: CollectionSlug\n}\n\nexport type SanitizedMCPPluginConfig = {\n items: MCPItem[]\n userCollection: CollectionSlug\n} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>\n\nexport type MCPServerOptions = {\n options?: ConstructorParameters<typeof McpServer>[1]\n serverInfo?: Partial<ConstructorParameters<typeof McpServer>[0]>\n}\n\n/**\n * Nested access tree as stored in the collection.\n * A `false` leaf disables that tool; missing keys defer to\n * defaults (built-in CRUD is on, opt-in tools are off).\n */\nexport type MCPAPIKeysDocAccessTree = {\n collections?: {\n [CollectionSlug: CollectionSlug]: {\n [ToolKey: string]: boolean\n }\n }\n globals?: {\n [GlobalSlug: GlobalSlug]: {\n [ToolKey: string]: boolean\n }\n }\n prompts?: {\n [PromptKey: string]: boolean\n }\n resources?: {\n [ResourceKey: string]: boolean\n }\n tools?: {\n [ToolKey: string]: boolean\n }\n}\n\n/**\n * Stored on `payload-mcp-api-keys` docs\n */\nexport type MCPAPIKeysDoc = {\n access: MCPAPIKeysDocAccessTree\n id: DefaultDocumentIDType\n overrideAccess?: boolean\n user: null | TypedUser\n}\n\n/**\n * One MCP primitive — tool, prompt, or resource — paired with the metadata both\n * the endpoint and the API key collection need. Built by `sanitizeMCPConfig`,\n * filtered by `getAuthorizedMCP`, registered by the MCP endpoint.\n *\n * - `key`: the config identifier (`find`, `echo`). Used for the API-key deny\n * lookup and as the admin checkbox field name. For collection/global tools,\n * the MCP wire name (`findPosts`) is derived from `key + slug` at\n * registration time.\n * - `label`: human-readable admin-UI display text for the checkbox.\n * - `tool` / `prompt` / `resource`: the live primitive (its own\n * `description` is what both MCP clients and the admin UI surface).\n */\nexport type MCPItemBase = {\n key: string\n label: string\n}\n\nexport type MCPItem =\n | ({\n collectionSlug: CollectionSlug\n tool: CollectionTool\n type: 'collectionTool'\n } & MCPItemBase)\n | ({\n globalSlug: GlobalSlug\n tool: GlobalTool\n type: 'globalTool'\n } & MCPItemBase)\n | ({\n prompt: Prompt\n type: 'prompt'\n } & MCPItemBase)\n | ({\n resource: Resource\n type: 'resource'\n } & MCPItemBase)\n | ({\n tool: Tool\n type: 'tool'\n } & MCPItemBase)\n\n/**\n * The caller's identity + the MCP items they can use for this request. Returned\n * by `getAuthorizedMCP`; denied items are simply absent from `items`. Handlers\n * receive this via `args.authorizedMCP` so they can spread\n * `localAPIDefaults(authorizedMCP)` into every local API call.\n */\nexport type AuthorizedMCP = {\n items: MCPItem[]\n overrideAccess: boolean\n user: null | TypedUser\n}\n"],"names":[],"mappings":"AAgVA;;;;;CAKC,GACD,WAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/utils/camelCase.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/utils/camelCase.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAIzC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Get the logger for the MCP plugin. Child of the main Payload logger, prefixed with `[plugin-mcp]`
|
|
4
|
+
* and tagged with a structured `plugin: 'mcp'` field. When `verboseLogs` is off, info/debug calls
|
|
5
|
+
* are silenced; warn/error still surface so operators don't lose error signal.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getLogger: (args: {
|
|
8
|
+
payload: Payload;
|
|
9
|
+
}) => Payload['logger'];
|
|
10
|
+
//# sourceMappingURL=getLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../src/utils/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAYvE,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getPluginConfig } from './getPluginConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the logger for the MCP plugin. Child of the main Payload logger, prefixed with `[plugin-mcp]`
|
|
4
|
+
* and tagged with a structured `plugin: 'mcp'` field. When `verboseLogs` is off, info/debug calls
|
|
5
|
+
* are silenced; warn/error still surface so operators don't lose error signal.
|
|
6
|
+
*/ export const getLogger = ({ payload })=>{
|
|
7
|
+
const pluginConfig = getPluginConfig({
|
|
8
|
+
config: payload.config
|
|
9
|
+
});
|
|
10
|
+
const useVerboseLogs = pluginConfig?.mcp?.verboseLogs ?? false;
|
|
11
|
+
const logger = payload.logger.child({
|
|
12
|
+
plugin: 'mcp'
|
|
13
|
+
}, {
|
|
14
|
+
msgPrefix: '[plugin-mcp] '
|
|
15
|
+
});
|
|
16
|
+
if (!useVerboseLogs) {
|
|
17
|
+
logger.level = 'warn';
|
|
18
|
+
}
|
|
19
|
+
return logger;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=getLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getLogger.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport { getPluginConfig } from './getPluginConfig.js'\n\n/**\n * Get the logger for the MCP plugin. Child of the main Payload logger, prefixed with `[plugin-mcp]`\n * and tagged with a structured `plugin: 'mcp'` field. When `verboseLogs` is off, info/debug calls\n * are silenced; warn/error still surface so operators don't lose error signal.\n */\nexport const getLogger: (args: { payload: Payload }) => Payload['logger'] = ({ payload }) => {\n const pluginConfig = getPluginConfig({ config: payload.config })\n\n const useVerboseLogs = pluginConfig?.mcp?.verboseLogs ?? false\n\n const logger = payload.logger.child({ plugin: 'mcp' }, { msgPrefix: '[plugin-mcp] ' })\n\n if (!useVerboseLogs) {\n logger.level = 'warn'\n }\n\n return logger\n}\n"],"names":["getPluginConfig","getLogger","payload","pluginConfig","config","useVerboseLogs","mcp","verboseLogs","logger","child","plugin","msgPrefix","level"],"mappings":"AAEA,SAASA,eAAe,QAAQ,uBAAsB;AAEtD;;;;CAIC,GACD,OAAO,MAAMC,YAA+D,CAAC,EAAEC,OAAO,EAAE;IACtF,MAAMC,eAAeH,gBAAgB;QAAEI,QAAQF,QAAQE,MAAM;IAAC;IAE9D,MAAMC,iBAAiBF,cAAcG,KAAKC,eAAe;IAEzD,MAAMC,SAASN,QAAQM,MAAM,CAACC,KAAK,CAAC;QAAEC,QAAQ;IAAM,GAAG;QAAEC,WAAW;IAAgB;IAEpF,IAAI,CAACN,gBAAgB;QACnBG,OAAOI,KAAK,GAAG;IACjB;IAEA,OAAOJ;AACT,EAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
import type { SanitizedMCPPluginConfig } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the sanitized plugin config — the form produced by
|
|
5
|
+
* `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
|
|
6
|
+
* Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
|
|
7
|
+
* being fully resolved.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getPluginConfig: (args: {
|
|
10
|
+
config: SanitizedConfig;
|
|
11
|
+
}) => SanitizedMCPPluginConfig;
|
|
12
|
+
//# sourceMappingURL=getPluginConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPluginConfig.d.ts","sourceRoot":"","sources":["../../src/utils/getPluginConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAE1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,KAAK,wBAapE,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the sanitized plugin config — the form produced by
|
|
3
|
+
* `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
|
|
4
|
+
* Callers downstream of plugin init can rely on `items`, `userCollection`, etc.
|
|
5
|
+
* being fully resolved.
|
|
6
|
+
*/ export const getPluginConfig = ({ config })=>{
|
|
7
|
+
const plugin = config.plugins?.find((plugin)=>plugin.slug === '@payloadcms/plugin-mcp');
|
|
8
|
+
if (!plugin) {
|
|
9
|
+
throw new Error('MCP Plugin not found in config.plugins.');
|
|
10
|
+
}
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
return plugin.sanitizedOptions;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=getPluginConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getPluginConfig.ts"],"sourcesContent":["import type { PluginsMap, SanitizedConfig } from 'payload'\n\nimport type { SanitizedMCPPluginConfig } from '../types.js'\n\n/**\n * Returns the sanitized plugin config — the form produced by\n * `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.\n * Callers downstream of plugin init can rely on `items`, `userCollection`, etc.\n * being fully resolved.\n */\nexport const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({\n config,\n}) => {\n const plugin = config.plugins?.find(\n (plugin) => plugin.slug === '@payloadcms/plugin-mcp',\n ) as PluginsMap['@payloadcms/plugin-mcp']\n\n if (!plugin) {\n throw new Error('MCP Plugin not found in config.plugins.')\n }\n\n // @ts-expect-error\n return plugin.sanitizedOptions\n}\n"],"names":["getPluginConfig","config","plugin","plugins","find","slug","Error","sanitizedOptions"],"mappings":"AAIA;;;;;CAKC,GACD,OAAO,MAAMA,kBAAmF,CAAC,EAC/FC,MAAM,EACP;IACC,MAAMC,SAASD,OAAOE,OAAO,EAAEC,KAC7B,CAACF,SAAWA,OAAOG,IAAI,KAAK;IAG9B,IAAI,CAACH,QAAQ;QACX,MAAM,IAAII,MAAM;IAClB;IAEA,mBAAmB;IACnB,OAAOJ,OAAOK,gBAAgB;AAChC,EAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AuthorizedMCP } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the `user` and `overrideAccess` arguments every Payload local API call
|
|
4
|
+
* should receive when initiated from an MCP request. Spread the result into the
|
|
5
|
+
* call's arg object so the two pieces of caller state can't drift apart.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* await req.payload.create({
|
|
10
|
+
* collection: 'posts',
|
|
11
|
+
* data,
|
|
12
|
+
* ...localAPIDefaults(authorizedMCP),
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const localAPIDefaults: (authorizedMCP: AuthorizedMCP) => {
|
|
17
|
+
overrideAccess: boolean;
|
|
18
|
+
user: AuthorizedMCP["user"];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=localAPIDefaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localAPIDefaults.d.ts","sourceRoot":"","sources":["../../src/utils/localAPIDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,aAAa,KAC3B;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAGvD,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the `user` and `overrideAccess` arguments every Payload local API call
|
|
3
|
+
* should receive when initiated from an MCP request. Spread the result into the
|
|
4
|
+
* call's arg object so the two pieces of caller state can't drift apart.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* await req.payload.create({
|
|
9
|
+
* collection: 'posts',
|
|
10
|
+
* data,
|
|
11
|
+
* ...localAPIDefaults(authorizedMCP),
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/ export const localAPIDefaults = (authorizedMCP)=>({
|
|
15
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
16
|
+
user: authorizedMCP.user
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=localAPIDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/localAPIDefaults.ts"],"sourcesContent":["import type { AuthorizedMCP } from '../types.js'\n\n/**\n * Returns the `user` and `overrideAccess` arguments every Payload local API call\n * should receive when initiated from an MCP request. Spread the result into the\n * call's arg object so the two pieces of caller state can't drift apart.\n *\n * @example\n * ```ts\n * await req.payload.create({\n * collection: 'posts',\n * data,\n * ...localAPIDefaults(authorizedMCP),\n * })\n * ```\n */\nexport const localAPIDefaults = (\n authorizedMCP: AuthorizedMCP,\n): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({\n overrideAccess: authorizedMCP.overrideAccess,\n user: authorizedMCP.user,\n})\n"],"names":["localAPIDefaults","authorizedMCP","overrideAccess","user"],"mappings":"AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMA,mBAAmB,CAC9BC,gBAC8D,CAAA;QAC9DC,gBAAgBD,cAAcC,cAAc;QAC5CC,MAAMF,cAAcE,IAAI;IAC1B,CAAA,EAAE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the project root: the parent of the outermost `node_modules` segment in
|
|
3
|
+
* `fromPath`. Returns `null` when the path has no `node_modules` (e.g. running from
|
|
4
|
+
* source inside the Payload monorepo).
|
|
5
|
+
*/
|
|
6
|
+
export declare const resolveProjectRoot: (fromPath: string) => null | string;
|
|
7
|
+
//# sourceMappingURL=resolveProjectRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProjectRoot.d.ts","sourceRoot":"","sources":["../../src/utils/resolveProjectRoot.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,KAAG,IAAI,GAAG,MAS5D,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the project root: the parent of the outermost `node_modules` segment in
|
|
4
|
+
* `fromPath`. Returns `null` when the path has no `node_modules` (e.g. running from
|
|
5
|
+
* source inside the Payload monorepo).
|
|
6
|
+
*/ export const resolveProjectRoot = (fromPath)=>{
|
|
7
|
+
const segments = fromPath.split(path.sep);
|
|
8
|
+
const nodeModulesIndex = segments.indexOf('node_modules');
|
|
9
|
+
if (nodeModulesIndex <= 0) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return segments.slice(0, nodeModulesIndex).join(path.sep) || null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=resolveProjectRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/resolveProjectRoot.ts"],"sourcesContent":["import path from 'path'\n\n/**\n * Returns the project root: the parent of the outermost `node_modules` segment in\n * `fromPath`. Returns `null` when the path has no `node_modules` (e.g. running from\n * source inside the Payload monorepo).\n */\nexport const resolveProjectRoot = (fromPath: string): null | string => {\n const segments = fromPath.split(path.sep)\n const nodeModulesIndex = segments.indexOf('node_modules')\n\n if (nodeModulesIndex <= 0) {\n return null\n }\n\n return segments.slice(0, nodeModulesIndex).join(path.sep) || null\n}\n"],"names":["path","resolveProjectRoot","fromPath","segments","split","sep","nodeModulesIndex","indexOf","slice","join"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AAEvB;;;;CAIC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,WAAWD,SAASE,KAAK,CAACJ,KAAKK,GAAG;IACxC,MAAMC,mBAAmBH,SAASI,OAAO,CAAC;IAE1C,IAAID,oBAAoB,GAAG;QACzB,OAAO;IACT;IAEA,OAAOH,SAASK,KAAK,CAAC,GAAGF,kBAAkBG,IAAI,CAACT,KAAKK,GAAG,KAAK;AAC/D,EAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { JsonSchemaType } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sanitizes Payload's auto-generated collection JSON Schema so it can be safely
|
|
4
|
+
* fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).
|
|
5
|
+
*/
|
|
6
|
+
export declare const prepareCollectionSchema: (schema: JsonSchemaType) => JsonSchemaType;
|
|
7
|
+
//# sourceMappingURL=prepareCollectionSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareCollectionSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/prepareCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAapD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,cAAc,KAAG,cAqBhE,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sanitizeJsonSchema } from './sanitizeJsonSchema.js';
|
|
2
|
+
import { simplifyRelationshipFields } from './simplifyRelationshipFields.js';
|
|
3
|
+
import { transformPointFieldsForMCP } from './transformPointFields.js';
|
|
4
|
+
/**
|
|
5
|
+
* Fields Payload manages automatically — clients should never be required to provide
|
|
6
|
+
* them. Stripped from `required` and `properties` so they don't appear in tool
|
|
7
|
+
* inputs.
|
|
8
|
+
*/ const PAYLOAD_MANAGED_FIELDS = new Set([
|
|
9
|
+
'_status',
|
|
10
|
+
'createdAt',
|
|
11
|
+
'id',
|
|
12
|
+
'updatedAt'
|
|
13
|
+
]);
|
|
14
|
+
/**
|
|
15
|
+
* Sanitizes Payload's auto-generated collection JSON Schema so it can be safely
|
|
16
|
+
* fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).
|
|
17
|
+
*/ export const prepareCollectionSchema = (schema)=>{
|
|
18
|
+
// Clone to avoid mutating the original schema (used elsewhere for tool listing)
|
|
19
|
+
const schemaClone = JSON.parse(JSON.stringify(schema));
|
|
20
|
+
const sanitized = sanitizeJsonSchema(schemaClone);
|
|
21
|
+
const pointTransformed = transformPointFieldsForMCP(sanitized);
|
|
22
|
+
const simplified = simplifyRelationshipFields(pointTransformed);
|
|
23
|
+
if (simplified.properties) {
|
|
24
|
+
for (const field of PAYLOAD_MANAGED_FIELDS){
|
|
25
|
+
delete simplified.properties[field];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(simplified.required)) {
|
|
29
|
+
simplified.required = simplified.required.filter((name)=>!PAYLOAD_MANAGED_FIELDS.has(name));
|
|
30
|
+
if (simplified.required.length === 0) {
|
|
31
|
+
delete simplified.required;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return simplified;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=prepareCollectionSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/prepareCollectionSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\n/**\n * Fields Payload manages automatically — clients should never be required to provide\n * them. Stripped from `required` and `properties` so they don't appear in tool\n * inputs.\n */\nconst PAYLOAD_MANAGED_FIELDS = new Set(['_status', 'createdAt', 'id', 'updatedAt'])\n\n/**\n * Sanitizes Payload's auto-generated collection JSON Schema so it can be safely\n * fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).\n */\nexport const prepareCollectionSchema = (schema: JsonSchemaType): JsonSchemaType => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JsonSchemaType\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const simplified = simplifyRelationshipFields(pointTransformed)\n\n if (simplified.properties) {\n for (const field of PAYLOAD_MANAGED_FIELDS) {\n delete simplified.properties[field]\n }\n }\n if (Array.isArray(simplified.required)) {\n simplified.required = simplified.required.filter((name) => !PAYLOAD_MANAGED_FIELDS.has(name))\n if (simplified.required.length === 0) {\n delete simplified.required\n }\n }\n\n return simplified\n}\n"],"names":["sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","PAYLOAD_MANAGED_FIELDS","Set","prepareCollectionSchema","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","simplified","properties","field","Array","isArray","required","filter","name","has","length"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE;;;;CAIC,GACD,MAAMC,yBAAyB,IAAIC,IAAI;IAAC;IAAW;IAAa;IAAM;CAAY;AAElF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAACC;IACtC,gFAAgF;IAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAE9C,MAAMK,YAAYX,mBAAmBO;IACrC,MAAMK,mBAAmBV,2BAA2BS;IACpD,MAAME,aAAaZ,2BAA2BW;IAE9C,IAAIC,WAAWC,UAAU,EAAE;QACzB,KAAK,MAAMC,SAASZ,uBAAwB;YAC1C,OAAOU,WAAWC,UAAU,CAACC,MAAM;QACrC;IACF;IACA,IAAIC,MAAMC,OAAO,CAACJ,WAAWK,QAAQ,GAAG;QACtCL,WAAWK,QAAQ,GAAGL,WAAWK,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAS,CAACjB,uBAAuBkB,GAAG,CAACD;QACvF,IAAIP,WAAWK,QAAQ,CAACI,MAAM,KAAK,GAAG;YACpC,OAAOT,WAAWK,QAAQ;QAC5B;IACF;IAEA,OAAOL;AACT,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonSchemaType } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Removes virtual fields from a JSON Schema by name so they don't appear
|
|
4
4
|
* in the generated MCP tool input schema.
|
|
5
5
|
*/
|
|
6
|
-
export declare function removeVirtualFieldsFromSchema(schema:
|
|
6
|
+
export declare function removeVirtualFieldsFromSchema(schema: JsonSchemaType, virtualFieldNames: string[]): JsonSchemaType;
|
|
7
7
|
//# sourceMappingURL=removeVirtualFieldsFromSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeVirtualFieldsFromSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"removeVirtualFieldsFromSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,cAAc,EACtB,iBAAiB,EAAE,MAAM,EAAE,GAC1B,cAAc,CAiBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes virtual fields from a JSON Schema by name so they don't appear\n * in the generated MCP tool input schema.\n */\nexport function removeVirtualFieldsFromSchema(\n schema: JsonSchemaType,\n virtualFieldNames: string[],\n): JsonSchemaType {\n if (virtualFieldNames.length === 0) {\n return schema\n }\n\n for (const name of virtualFieldNames) {\n delete schema?.properties?.[name]\n }\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n return schema\n}\n"],"names":["removeVirtualFieldsFromSchema","schema","virtualFieldNames","length","name","properties","Array","isArray","required","filter","field","includes"],"mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,8BACdC,MAAsB,EACtBC,iBAA2B;IAE3B,IAAIA,kBAAkBC,MAAM,KAAK,GAAG;QAClC,OAAOF;IACT;IAEA,KAAK,MAAMG,QAAQF,kBAAmB;QACpC,OAAOD,QAAQI,YAAY,CAACD,KAAK;IACnC;IAEA,IAAIE,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAU,CAACR,kBAAkBS,QAAQ,CAACD;QAChF,IAAIT,OAAOO,QAAQ,CAACL,MAAM,KAAK,GAAG;YAChC,OAAOF,OAAOO,QAAQ;QACxB;IACF;IAEA,OAAOP;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonSchemaType } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Removes internal Payload properties (id, createdAt, updatedAt) from a
|
|
4
4
|
* JSON Schema so they don't appear in the generated Zod validation schema.
|
|
@@ -9,5 +9,5 @@ import type { JSONSchema4 } from 'json-schema';
|
|
|
9
9
|
* emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
|
|
10
10
|
* the concrete `type` from the output and breaking schema introspection.
|
|
11
11
|
*/
|
|
12
|
-
export declare function sanitizeJsonSchema(schema:
|
|
12
|
+
export declare function sanitizeJsonSchema(schema: JsonSchemaType): JsonSchemaType;
|
|
13
13
|
//# sourceMappingURL=sanitizeJsonSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA6BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n *\n * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →\n * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`\n * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping\n * the concrete `type` from the output and breaking schema introspection.\n */\nexport function sanitizeJsonSchema(schema: JsonSchemaType): JsonSchemaType {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const key of Object.keys(schema.properties)) {\n const prop = schema.properties[key] as JsonSchemaType\n if (!prop || typeof prop !== 'object') {\n continue\n }\n normalizeNullableType(prop)\n if (prop.properties) {\n sanitizeJsonSchema(prop)\n }\n if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {\n sanitizeJsonSchema(prop.items)\n }\n }\n }\n\n return schema\n}\n\n/**\n * Strips `'null'` from a `type` array only when the remaining type is a\n * complex structural type (`array` or `object`).\n *\n * Simple scalar types (`string`, `number`, `boolean`) are intentionally\n * preserved as `['string', 'null']` so that the MCP SDK serialises them as a\n * compact inline `type` array. Complex types however cause `zodToJsonSchema`\n * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which\n * has no top-level `type` property and breaks schema introspection by clients.\n */\nfunction normalizeNullableType(schema: JsonSchemaType): void {\n if (!Array.isArray(schema.type)) {\n return\n }\n const nonNullTypes = schema.type.filter((t) => t !== 'null')\n if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {\n schema.type = nonNullTypes[0]\n }\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length","key","Object","keys","prop","normalizeNullableType","items","type","nonNullTypes","t"],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,SAASA,mBAAmBC,MAAsB;IACvD,OAAOA,QAAQC,YAAYC;IAC3B,OAAOF,QAAQC,YAAYE;IAC3B,OAAOH,QAAQC,YAAYG;IAE3B,IAAIC,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAUA,UAAU;QAC9D,IAAIT,OAAOO,QAAQ,CAACG,MAAM,KAAK,GAAG;YAChC,OAAOV,OAAOO,QAAQ;QACxB;IACF;IAEA,IAAIP,OAAOC,UAAU,IAAI,OAAOD,OAAOC,UAAU,KAAK,UAAU;QAC9D,KAAK,MAAMU,OAAOC,OAAOC,IAAI,CAACb,OAAOC,UAAU,EAAG;YAChD,MAAMa,OAAOd,OAAOC,UAAU,CAACU,IAAI;YACnC,IAAI,CAACG,QAAQ,OAAOA,SAAS,UAAU;gBACrC;YACF;YACAC,sBAAsBD;YACtB,IAAIA,KAAKb,UAAU,EAAE;gBACnBF,mBAAmBe;YACrB;YACA,IAAIA,KAAKE,KAAK,IAAI,OAAOF,KAAKE,KAAK,KAAK,YAAY,CAACX,MAAMC,OAAO,CAACQ,KAAKE,KAAK,GAAG;gBAC9EjB,mBAAmBe,KAAKE,KAAK;YAC/B;QACF;IACF;IAEA,OAAOhB;AACT;AAEA;;;;;;;;;CASC,GACD,SAASe,sBAAsBf,MAAsB;IACnD,IAAI,CAACK,MAAMC,OAAO,CAACN,OAAOiB,IAAI,GAAG;QAC/B;IACF;IACA,MAAMC,eAAelB,OAAOiB,IAAI,CAACT,MAAM,CAAC,CAACW,IAAMA,MAAM;IACrD,IAAID,aAAaR,MAAM,KAAK,KAAMQ,CAAAA,YAAY,CAAC,EAAE,KAAK,WAAWA,YAAY,CAAC,EAAE,KAAK,QAAO,GAAI;QAC9FlB,OAAOiB,IAAI,GAAGC,YAAY,CAAC,EAAE;IAC/B;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonSchemaType } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Recursively processes JSON schema properties to simplify relationship fields
|
|
4
4
|
* and convert `oneOf` constructs into MCP-friendly schemas.
|
|
@@ -16,5 +16,5 @@ import type { JSONSchema4 } from 'json-schema';
|
|
|
16
16
|
* NOTE: This function must operate on a cloned schema to avoid mutating
|
|
17
17
|
* the original JSON schema used for tool listing.
|
|
18
18
|
*/
|
|
19
|
-
export declare function simplifyRelationshipFields(schema:
|
|
19
|
+
export declare function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType;
|
|
20
20
|
//# sourceMappingURL=simplifyRelationshipFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplifyRelationshipFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"simplifyRelationshipFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAkDjF"}
|
|
@@ -23,25 +23,28 @@
|
|
|
23
23
|
};
|
|
24
24
|
if (Array.isArray(processed.oneOf)) {
|
|
25
25
|
const hasRef = processed.oneOf.some((option)=>option && typeof option === 'object' && '$ref' in option);
|
|
26
|
+
const recurse = (option)=>typeof option === 'object' ? simplifyRelationshipFields(option) : option;
|
|
26
27
|
if (hasRef) {
|
|
27
|
-
const nonRefOptions = processed.oneOf.filter((option)=>!(option && typeof option === 'object' && '$ref' in option)).map(
|
|
28
|
+
const nonRefOptions = processed.oneOf.filter((option)=>!(option && typeof option === 'object' && '$ref' in option)).map(recurse);
|
|
28
29
|
if (nonRefOptions.length === 1) {
|
|
29
30
|
const single = nonRefOptions[0];
|
|
30
31
|
delete processed.oneOf;
|
|
31
|
-
|
|
32
|
+
if (typeof single === 'object') {
|
|
33
|
+
Object.assign(processed, single);
|
|
34
|
+
}
|
|
32
35
|
} else if (nonRefOptions.length > 1) {
|
|
33
36
|
delete processed.oneOf;
|
|
34
37
|
processed.anyOf = nonRefOptions;
|
|
35
38
|
}
|
|
36
39
|
} else {
|
|
37
|
-
processed.anyOf = processed.oneOf.map(
|
|
40
|
+
processed.anyOf = processed.oneOf.map(recurse);
|
|
38
41
|
delete processed.oneOf;
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
if (processed.properties && typeof processed.properties === 'object') {
|
|
42
45
|
processed.properties = Object.fromEntries(Object.entries(processed.properties).map(([key, value])=>[
|
|
43
46
|
key,
|
|
44
|
-
simplifyRelationshipFields(value)
|
|
47
|
+
typeof value === 'object' ? simplifyRelationshipFields(value) : value
|
|
45
48
|
]));
|
|
46
49
|
}
|
|
47
50
|
if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Recursively processes JSON schema properties to simplify relationship fields\n * and convert `oneOf` constructs into MCP-friendly schemas.\n *\n * For create/update validation we only need to accept IDs (string/number),\n * not populated objects. `$ref` options pointing to full entity definitions\n * are removed entirely from `oneOf` unions. When a single option remains the\n * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.\n *\n * This matters because `json-schema-to-zod` converts `oneOf` into a strict\n * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing\n * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP\n * tool input schema. `anyOf` instead produces a clean `z.union([...])`.\n *\n * NOTE: This function must operate on a cloned schema to avoid mutating\n * the original JSON schema used for tool listing.\n */\nexport function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const processed = { ...schema }\n\n if (Array.isArray(processed.oneOf)) {\n const hasRef = processed.oneOf.some(\n (option) => option && typeof option === 'object' && '$ref' in option,\n )\n\n const recurse = (option: boolean | JsonSchemaType): boolean | JsonSchemaType =>\n typeof option === 'object' ? simplifyRelationshipFields(option) : option\n\n if (hasRef) {\n const nonRefOptions = processed.oneOf\n .filter((option) => !(option && typeof option === 'object' && '$ref' in option))\n .map(recurse)\n\n if (nonRefOptions.length === 1) {\n const single = nonRefOptions[0]!\n delete processed.oneOf\n if (typeof single === 'object') {\n Object.assign(processed, single)\n }\n } else if (nonRefOptions.length > 1) {\n delete processed.oneOf\n processed.anyOf = nonRefOptions\n }\n } else {\n processed.anyOf = processed.oneOf.map(recurse)\n delete processed.oneOf\n }\n }\n\n if (processed.properties && typeof processed.properties === 'object') {\n processed.properties = Object.fromEntries(\n Object.entries(processed.properties).map(([key, value]) => [\n key,\n typeof value === 'object' ? simplifyRelationshipFields(value) : value,\n ]),\n )\n }\n\n if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {\n processed.items = simplifyRelationshipFields(processed.items)\n }\n\n return processed\n}\n"],"names":["simplifyRelationshipFields","schema","processed","Array","isArray","oneOf","hasRef","some","option","recurse","nonRefOptions","filter","map","length","single","Object","assign","anyOf","properties","fromEntries","entries","key","value","items"],"mappings":"AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASA,2BAA2BC,MAAsB;IAC/D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,YAAY;QAAE,GAAGD,MAAM;IAAC;IAE9B,IAAIE,MAAMC,OAAO,CAACF,UAAUG,KAAK,GAAG;QAClC,MAAMC,SAASJ,UAAUG,KAAK,CAACE,IAAI,CACjC,CAACC,SAAWA,UAAU,OAAOA,WAAW,YAAY,UAAUA;QAGhE,MAAMC,UAAU,CAACD,SACf,OAAOA,WAAW,WAAWR,2BAA2BQ,UAAUA;QAEpE,IAAIF,QAAQ;YACV,MAAMI,gBAAgBR,UAAUG,KAAK,CAClCM,MAAM,CAAC,CAACH,SAAW,CAAEA,CAAAA,UAAU,OAAOA,WAAW,YAAY,UAAUA,MAAK,GAC5EI,GAAG,CAACH;YAEP,IAAIC,cAAcG,MAAM,KAAK,GAAG;gBAC9B,MAAMC,SAASJ,aAAa,CAAC,EAAE;gBAC/B,OAAOR,UAAUG,KAAK;gBACtB,IAAI,OAAOS,WAAW,UAAU;oBAC9BC,OAAOC,MAAM,CAACd,WAAWY;gBAC3B;YACF,OAAO,IAAIJ,cAAcG,MAAM,GAAG,GAAG;gBACnC,OAAOX,UAAUG,KAAK;gBACtBH,UAAUe,KAAK,GAAGP;YACpB;QACF,OAAO;YACLR,UAAUe,KAAK,GAAGf,UAAUG,KAAK,CAACO,GAAG,CAACH;YACtC,OAAOP,UAAUG,KAAK;QACxB;IACF;IAEA,IAAIH,UAAUgB,UAAU,IAAI,OAAOhB,UAAUgB,UAAU,KAAK,UAAU;QACpEhB,UAAUgB,UAAU,GAAGH,OAAOI,WAAW,CACvCJ,OAAOK,OAAO,CAAClB,UAAUgB,UAAU,EAAEN,GAAG,CAAC,CAAC,CAACS,KAAKC,MAAM,GAAK;gBACzDD;gBACA,OAAOC,UAAU,WAAWtB,2BAA2BsB,SAASA;aACjE;IAEL;IAEA,IAAIpB,UAAUqB,KAAK,IAAI,OAAOrB,UAAUqB,KAAK,KAAK,YAAY,CAACpB,MAAMC,OAAO,CAACF,UAAUqB,KAAK,GAAG;QAC7FrB,UAAUqB,KAAK,GAAGvB,2BAA2BE,UAAUqB,KAAK;IAC9D;IAEA,OAAOrB;AACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function transformPointFieldsForMCP(schema:
|
|
1
|
+
import type { JsonSchemaType } from '../../types.js';
|
|
2
|
+
export declare function transformPointFieldsForMCP(schema: JsonSchemaType): JsonSchemaType;
|
|
3
3
|
//# sourceMappingURL=transformPointFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformPointFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"transformPointFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAqDjF"}
|
|
@@ -7,8 +7,14 @@ export function transformPointFieldsForMCP(schema) {
|
|
|
7
7
|
};
|
|
8
8
|
if (transformed.properties && typeof transformed.properties === 'object') {
|
|
9
9
|
transformed.properties = Object.fromEntries(Object.entries(transformed.properties).map(([key, value])=>{
|
|
10
|
+
if (!value || typeof value !== 'object') {
|
|
11
|
+
return [
|
|
12
|
+
key,
|
|
13
|
+
value
|
|
14
|
+
];
|
|
15
|
+
}
|
|
10
16
|
const isArrayType = value.type === 'array' || Array.isArray(value.type) && value.type.includes('array');
|
|
11
|
-
if (
|
|
17
|
+
if (isArrayType && Array.isArray(value.items) && value.items.length === 2 && value.items.every((item)=>item && typeof item === 'object' && item.type === 'number')) {
|
|
12
18
|
// Transform to object format
|
|
13
19
|
const isNullable = Array.isArray(value.type) && value.type.includes('null');
|
|
14
20
|
return [
|