@payloadcms/plugin-mcp 3.86.0-internal.ac46214 → 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
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload'
|
|
2
|
-
|
|
3
|
-
import { existsSync } from 'fs'
|
|
4
|
-
import { join } from 'path'
|
|
5
|
-
|
|
6
|
-
export type ValidationType = 'collection' | 'task' | 'workflow'
|
|
7
|
-
|
|
8
|
-
export interface ValidationResult<T = unknown> {
|
|
9
|
-
config?: T
|
|
10
|
-
error?: string
|
|
11
|
-
success: boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Custom task config interface that matches what we're creating
|
|
15
|
-
export interface TaskConfig {
|
|
16
|
-
handler: (args: {
|
|
17
|
-
input: Record<string, unknown>
|
|
18
|
-
job: Record<string, unknown>
|
|
19
|
-
tasks: Record<string, unknown>
|
|
20
|
-
}) => Record<string, unknown>
|
|
21
|
-
inputSchema?: Array<{
|
|
22
|
-
label?: string
|
|
23
|
-
name: string
|
|
24
|
-
options?: Array<{ label: string; value: string }>
|
|
25
|
-
required?: boolean
|
|
26
|
-
type: string
|
|
27
|
-
}>
|
|
28
|
-
label?: string
|
|
29
|
-
outputSchema?: Array<{
|
|
30
|
-
label?: string
|
|
31
|
-
name: string
|
|
32
|
-
options?: Array<{ label: string; value: string }>
|
|
33
|
-
required?: boolean
|
|
34
|
-
type: string
|
|
35
|
-
}>
|
|
36
|
-
retries?: number
|
|
37
|
-
slug: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Custom workflow config interface that matches what we're creating
|
|
41
|
-
export interface WorkflowConfig {
|
|
42
|
-
handler: (args: {
|
|
43
|
-
input: Record<string, unknown>
|
|
44
|
-
job: Record<string, unknown>
|
|
45
|
-
tasks: Record<string, unknown>
|
|
46
|
-
}) => void
|
|
47
|
-
inputSchema?: Array<{
|
|
48
|
-
label?: string
|
|
49
|
-
name: string
|
|
50
|
-
options?: Array<{ label: string; value: string }>
|
|
51
|
-
required?: boolean
|
|
52
|
-
type: string
|
|
53
|
-
}>
|
|
54
|
-
label?: string
|
|
55
|
-
queue?: string
|
|
56
|
-
retries?: number
|
|
57
|
-
slug: string
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Generic validation function for Payload configuration files
|
|
62
|
-
* @param fileName - The name of the file (e.g., 'Users.ts', 'my-task.ts')
|
|
63
|
-
* @param type - The type of validation to perform ('collection', 'task', or 'workflow')
|
|
64
|
-
* @returns Object containing success status and any error messages
|
|
65
|
-
*/
|
|
66
|
-
export const validatePayloadFile = async <T = CollectionConfig | TaskConfig | WorkflowConfig>(
|
|
67
|
-
fileName: string,
|
|
68
|
-
type: ValidationType,
|
|
69
|
-
): Promise<ValidationResult<T>> => {
|
|
70
|
-
try {
|
|
71
|
-
const basePath = type === 'collection' ? 'collections' : type === 'task' ? 'tasks' : 'workflows'
|
|
72
|
-
const fullPath = join(process.cwd(), 'src', basePath)
|
|
73
|
-
const filePath = join(fullPath, fileName)
|
|
74
|
-
|
|
75
|
-
// Check if file exists
|
|
76
|
-
if (!existsSync(filePath)) {
|
|
77
|
-
return {
|
|
78
|
-
error: `${type} file does not exist: ${fileName}`,
|
|
79
|
-
success: false,
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Clear require cache to ensure fresh import
|
|
84
|
-
delete require.cache[filePath]
|
|
85
|
-
|
|
86
|
-
// Use relative path for webpack compatibility
|
|
87
|
-
const moduleName = fileName.replace('.ts', '')
|
|
88
|
-
const relativePath = `../${basePath}/${moduleName}`
|
|
89
|
-
|
|
90
|
-
// Dynamic import with relative path
|
|
91
|
-
const importedModule = await import(/* webpackIgnore: true */ relativePath)
|
|
92
|
-
|
|
93
|
-
// Get the configuration based on type
|
|
94
|
-
let config: T | undefined
|
|
95
|
-
|
|
96
|
-
if (type === 'collection') {
|
|
97
|
-
config = getCollectionConfig(importedModule, moduleName) as T
|
|
98
|
-
} else if (type === 'task') {
|
|
99
|
-
config = getTaskConfig(importedModule) as T
|
|
100
|
-
} else if (type === 'workflow') {
|
|
101
|
-
config = getWorkflowConfig(importedModule) as T
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!config) {
|
|
105
|
-
return {
|
|
106
|
-
error: `${type} file does not export a valid ${type} config`,
|
|
107
|
-
success: false,
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Validate the configuration
|
|
112
|
-
let validationResult: ValidationResult<unknown>
|
|
113
|
-
if (type === 'collection') {
|
|
114
|
-
validationResult = validateCollectionConfig(config as unknown as CollectionConfig)
|
|
115
|
-
} else if (type === 'task') {
|
|
116
|
-
validationResult = validateTaskConfig(config as unknown as TaskConfig)
|
|
117
|
-
} else if (type === 'workflow') {
|
|
118
|
-
validationResult = validateWorkflowConfig(config as unknown as WorkflowConfig)
|
|
119
|
-
} else {
|
|
120
|
-
return {
|
|
121
|
-
error: `Unknown validation type: ${type}`,
|
|
122
|
-
success: false,
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!validationResult.success) {
|
|
127
|
-
return validationResult as ValidationResult<T>
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
config,
|
|
132
|
-
success: true,
|
|
133
|
-
}
|
|
134
|
-
} catch (error) {
|
|
135
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error during validation'
|
|
136
|
-
return {
|
|
137
|
-
error: `Failed to validate ${type} file: ${errorMessage}`,
|
|
138
|
-
success: false,
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Extract collection configuration from module exports
|
|
145
|
-
*/
|
|
146
|
-
function getCollectionConfig(
|
|
147
|
-
importedModule: Record<string, unknown>,
|
|
148
|
-
moduleName: string,
|
|
149
|
-
): CollectionConfig | undefined {
|
|
150
|
-
if (importedModule.default) {
|
|
151
|
-
return importedModule.default as CollectionConfig
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (importedModule[moduleName]) {
|
|
155
|
-
return importedModule[moduleName] as CollectionConfig
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return undefined
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Extract task configuration from module exports
|
|
163
|
-
*/
|
|
164
|
-
function getTaskConfig(importedModule: Record<string, unknown>): TaskConfig | undefined {
|
|
165
|
-
// First check for default export
|
|
166
|
-
if (importedModule.default) {
|
|
167
|
-
return importedModule.default as TaskConfig
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Look for named exports ending with "Task"
|
|
171
|
-
const exportNames = Object.keys(importedModule)
|
|
172
|
-
const taskExport = exportNames.find((name) => name.endsWith('Task'))
|
|
173
|
-
|
|
174
|
-
if (taskExport) {
|
|
175
|
-
return importedModule[taskExport] as TaskConfig
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return undefined
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Extract workflow configuration from module exports
|
|
183
|
-
*/
|
|
184
|
-
function getWorkflowConfig(importedModule: Record<string, unknown>): undefined | WorkflowConfig {
|
|
185
|
-
// First check for default export
|
|
186
|
-
if (importedModule.default) {
|
|
187
|
-
return importedModule.default as WorkflowConfig
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Look for named exports ending with "Workflow"
|
|
191
|
-
const exportNames = Object.keys(importedModule)
|
|
192
|
-
const workflowExport = exportNames.find((name) => name.endsWith('Workflow'))
|
|
193
|
-
|
|
194
|
-
if (workflowExport) {
|
|
195
|
-
return importedModule[workflowExport] as WorkflowConfig
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return undefined
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Validate collection configuration structure
|
|
203
|
-
*/
|
|
204
|
-
function validateCollectionConfig(config: CollectionConfig): ValidationResult<CollectionConfig> {
|
|
205
|
-
if (!config) {
|
|
206
|
-
return {
|
|
207
|
-
error: 'Collection config is not a valid object',
|
|
208
|
-
success: false,
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (!config.slug) {
|
|
213
|
-
return {
|
|
214
|
-
error: 'Collection config must have a valid slug property',
|
|
215
|
-
success: false,
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Validate each field has required properties
|
|
220
|
-
if (config.fields) {
|
|
221
|
-
for (let i = 0; i < config.fields.length; i++) {
|
|
222
|
-
const field = config.fields[i]
|
|
223
|
-
if (!field || typeof field !== 'object') {
|
|
224
|
-
return {
|
|
225
|
-
error: `Field at index ${i} is not a valid object`,
|
|
226
|
-
success: false,
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Check if field has type property
|
|
231
|
-
if (!('type' in field) || !field.type) {
|
|
232
|
-
return {
|
|
233
|
-
error: `Field at index ${i} is missing a valid type property`,
|
|
234
|
-
success: false,
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return { config, success: true }
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Validates an array of schema fields (inputSchema / outputSchema).
|
|
245
|
-
* Returns an error string on the first invalid field, or null if all fields are valid.
|
|
246
|
-
*/
|
|
247
|
-
function validateSchemaFields(fields: TaskConfig['inputSchema'], label: string): null | string {
|
|
248
|
-
if (!fields || !Array.isArray(fields)) {
|
|
249
|
-
return null
|
|
250
|
-
}
|
|
251
|
-
for (let i = 0; i < fields.length; i++) {
|
|
252
|
-
const field = fields[i]
|
|
253
|
-
if (!field) {
|
|
254
|
-
return `${label} field at index ${i} is not a valid object`
|
|
255
|
-
}
|
|
256
|
-
if (!field.name) {
|
|
257
|
-
return `${label} field at index ${i} must have a valid name property`
|
|
258
|
-
}
|
|
259
|
-
if (!field.type) {
|
|
260
|
-
return `${label} field at index ${i} must have a valid type property`
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return null
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Validate task configuration structure
|
|
268
|
-
*/
|
|
269
|
-
function validateTaskConfig(config: TaskConfig): ValidationResult<TaskConfig> {
|
|
270
|
-
if (!config) {
|
|
271
|
-
return {
|
|
272
|
-
error: 'Task config is not a valid object',
|
|
273
|
-
success: false,
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (!config.slug) {
|
|
278
|
-
return {
|
|
279
|
-
error: 'Task config must have a valid slug property',
|
|
280
|
-
success: false,
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (!config.handler) {
|
|
285
|
-
return {
|
|
286
|
-
error: 'Task config must have a valid handler function',
|
|
287
|
-
success: false,
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (config.retries !== undefined && config.retries < 0) {
|
|
292
|
-
return {
|
|
293
|
-
error: 'Task config retries must be a non-negative number',
|
|
294
|
-
success: false,
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const inputError = validateSchemaFields(config.inputSchema, 'Input schema')
|
|
299
|
-
if (inputError) {
|
|
300
|
-
return { error: inputError, success: false }
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const outputError = validateSchemaFields(config.outputSchema, 'Output schema')
|
|
304
|
-
if (outputError) {
|
|
305
|
-
return { error: outputError, success: false }
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return { config, success: true }
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Validate workflow configuration structure
|
|
313
|
-
*/
|
|
314
|
-
function validateWorkflowConfig(config: WorkflowConfig): ValidationResult<WorkflowConfig> {
|
|
315
|
-
if (!config) {
|
|
316
|
-
return {
|
|
317
|
-
error: 'Workflow config is not a valid object',
|
|
318
|
-
success: false,
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (!config.slug) {
|
|
323
|
-
return {
|
|
324
|
-
error: 'Workflow config must have a valid slug property',
|
|
325
|
-
success: false,
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (!config.handler) {
|
|
330
|
-
return {
|
|
331
|
-
error: 'Workflow config must have a valid handler function',
|
|
332
|
-
success: false,
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (config.queue !== undefined && typeof config.queue !== 'string') {
|
|
337
|
-
return {
|
|
338
|
-
error: 'Workflow config queue must be a string if provided',
|
|
339
|
-
success: false,
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (config.retries !== undefined && config.retries < 0) {
|
|
344
|
-
return {
|
|
345
|
-
error: 'Workflow config retries must be a non-negative number',
|
|
346
|
-
success: false,
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const inputError = validateSchemaFields(config.inputSchema, 'Input schema')
|
|
351
|
-
if (inputError) {
|
|
352
|
-
return { error: inputError, success: false }
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return { config, success: true }
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
export const validateCollectionFile = async (
|
|
359
|
-
fileName: string,
|
|
360
|
-
): Promise<ValidationResult<CollectionConfig>> => {
|
|
361
|
-
return validatePayloadFile<CollectionConfig>(fileName, 'collection')
|
|
362
|
-
}
|
package/src/mcp/registerTool.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const registerTool = (
|
|
2
|
-
isEnabled: boolean | undefined,
|
|
3
|
-
toolType: string,
|
|
4
|
-
registrationFn: () => void,
|
|
5
|
-
payload: { logger: { info: (message: string) => void } },
|
|
6
|
-
useVerboseLogs: boolean,
|
|
7
|
-
) => {
|
|
8
|
-
if (isEnabled) {
|
|
9
|
-
try {
|
|
10
|
-
registrationFn()
|
|
11
|
-
if (useVerboseLogs) {
|
|
12
|
-
payload.logger.info(`[payload-mcp] ✅ Tool: ${toolType} Registered.`)
|
|
13
|
-
}
|
|
14
|
-
} catch (error) {
|
|
15
|
-
// Log the error and re-throw
|
|
16
|
-
payload.logger.info(`[payload-mcp] ❌ Tool: ${toolType} Failed to register.`)
|
|
17
|
-
throw error
|
|
18
|
-
}
|
|
19
|
-
} else if (useVerboseLogs) {
|
|
20
|
-
payload.logger.info(`[payload-mcp] ⏭️ Tool: ${toolType} Skipped.`)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import type { PayloadRequest } from 'payload'
|
|
3
|
-
|
|
4
|
-
import { toolSchemas } from '../schemas.js'
|
|
5
|
-
|
|
6
|
-
export const authTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
|
|
7
|
-
const tool = async (headers?: string) => {
|
|
8
|
-
const payload = req.payload
|
|
9
|
-
|
|
10
|
-
if (verboseLogs) {
|
|
11
|
-
payload.logger.info('[payload-mcp] Checking authentication status')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
// Parse custom headers if provided, otherwise use empty headers
|
|
16
|
-
let authHeaders = new Headers()
|
|
17
|
-
|
|
18
|
-
if (headers) {
|
|
19
|
-
try {
|
|
20
|
-
const parsedHeaders = JSON.parse(headers)
|
|
21
|
-
authHeaders = new Headers(parsedHeaders)
|
|
22
|
-
if (verboseLogs) {
|
|
23
|
-
payload.logger.info(`[payload-mcp] Using custom headers: ${headers}`)
|
|
24
|
-
}
|
|
25
|
-
} catch (_ignore) {
|
|
26
|
-
payload.logger.warn(`[payload-mcp] Invalid headers JSON: ${headers}, using empty headers`)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const result = await payload.auth({
|
|
31
|
-
headers: authHeaders,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
if (verboseLogs) {
|
|
35
|
-
payload.logger.info('[payload-mcp] Authentication check completed successfully')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
content: [
|
|
40
|
-
{
|
|
41
|
-
type: 'text' as const,
|
|
42
|
-
text: `# Authentication Status\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}
|
|
46
|
-
} catch (error) {
|
|
47
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
48
|
-
payload.logger.error(`[payload-mcp] Error checking authentication: ${errorMessage}`)
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
content: [
|
|
52
|
-
{
|
|
53
|
-
type: 'text' as const,
|
|
54
|
-
text: `❌ **Error checking authentication**: ${errorMessage}`,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
server.registerTool(
|
|
62
|
-
'auth',
|
|
63
|
-
{
|
|
64
|
-
description: toolSchemas.auth.description,
|
|
65
|
-
inputSchema: toolSchemas.auth.parameters.shape,
|
|
66
|
-
},
|
|
67
|
-
async ({ headers }) => {
|
|
68
|
-
return await tool(headers)
|
|
69
|
-
},
|
|
70
|
-
)
|
|
71
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import type { PayloadRequest } from 'payload'
|
|
3
|
-
|
|
4
|
-
import { toolSchemas } from '../schemas.js'
|
|
5
|
-
|
|
6
|
-
export const forgotPasswordTool = (
|
|
7
|
-
server: McpServer,
|
|
8
|
-
req: PayloadRequest,
|
|
9
|
-
verboseLogs: boolean,
|
|
10
|
-
) => {
|
|
11
|
-
const tool = async (collection: string, email: string, disableEmail: boolean = false) => {
|
|
12
|
-
const payload = req.payload
|
|
13
|
-
|
|
14
|
-
if (verboseLogs) {
|
|
15
|
-
payload.logger.info(
|
|
16
|
-
`[payload-mcp] Sending password reset email for user: ${email} in collection: ${collection}`,
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
const result = await payload.forgotPassword({
|
|
22
|
-
collection,
|
|
23
|
-
data: {
|
|
24
|
-
email,
|
|
25
|
-
},
|
|
26
|
-
disableEmail,
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
if (verboseLogs) {
|
|
30
|
-
payload.logger.info(
|
|
31
|
-
`[payload-mcp] Password reset email sent successfully for user: ${email}`,
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
content: [
|
|
37
|
-
{
|
|
38
|
-
type: 'text' as const,
|
|
39
|
-
text: `# Password Reset Email Sent\n\n**User:** ${email}\n**Collection:** ${collection}\n**Email Disabled:** ${disableEmail}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
}
|
|
43
|
-
} catch (error) {
|
|
44
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
45
|
-
payload.logger.error(
|
|
46
|
-
`[payload-mcp] Error sending password reset email for user ${email}: ${errorMessage}`,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
content: [
|
|
51
|
-
{
|
|
52
|
-
type: 'text' as const,
|
|
53
|
-
text: `❌ **Error sending password reset email for user "${email}"**: ${errorMessage}`,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
server.registerTool(
|
|
61
|
-
'forgotPassword',
|
|
62
|
-
{
|
|
63
|
-
description: toolSchemas.forgotPassword.description,
|
|
64
|
-
inputSchema: toolSchemas.forgotPassword.parameters.shape,
|
|
65
|
-
},
|
|
66
|
-
async ({ collection, disableEmail, email }) => {
|
|
67
|
-
return await tool(collection, email, disableEmail)
|
|
68
|
-
},
|
|
69
|
-
)
|
|
70
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import type { PayloadRequest } from 'payload'
|
|
3
|
-
|
|
4
|
-
import { toolSchemas } from '../schemas.js'
|
|
5
|
-
|
|
6
|
-
export const loginTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
|
|
7
|
-
const tool = async (
|
|
8
|
-
collection: string,
|
|
9
|
-
email: string,
|
|
10
|
-
password: string,
|
|
11
|
-
depth: number = 0,
|
|
12
|
-
overrideAccess: boolean = false,
|
|
13
|
-
showHiddenFields: boolean = false,
|
|
14
|
-
) => {
|
|
15
|
-
const payload = req.payload
|
|
16
|
-
|
|
17
|
-
if (verboseLogs) {
|
|
18
|
-
payload.logger.info(
|
|
19
|
-
`[payload-mcp] Attempting login for user: ${email} in collection: ${collection}`,
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const result = await payload.login({
|
|
25
|
-
collection,
|
|
26
|
-
data: {
|
|
27
|
-
email,
|
|
28
|
-
password,
|
|
29
|
-
},
|
|
30
|
-
depth,
|
|
31
|
-
overrideAccess,
|
|
32
|
-
showHiddenFields,
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
if (verboseLogs) {
|
|
36
|
-
payload.logger.info(`[payload-mcp] Login successful for user: ${email}`)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
content: [
|
|
41
|
-
{
|
|
42
|
-
type: 'text' as const,
|
|
43
|
-
text: `# Login Successful\n\n**User:** ${email}\n**Collection:** ${collection}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
}
|
|
47
|
-
} catch (error) {
|
|
48
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
49
|
-
payload.logger.error(`[payload-mcp] Login failed for user ${email}: ${errorMessage}`)
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
content: [
|
|
53
|
-
{
|
|
54
|
-
type: 'text' as const,
|
|
55
|
-
text: `❌ **Login failed for user "${email}"**: ${errorMessage}`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
server.registerTool(
|
|
63
|
-
'login',
|
|
64
|
-
{
|
|
65
|
-
description: toolSchemas.login.description,
|
|
66
|
-
inputSchema: toolSchemas.login.parameters.shape,
|
|
67
|
-
},
|
|
68
|
-
async ({ collection, depth, email, overrideAccess, password, showHiddenFields }) => {
|
|
69
|
-
return await tool(collection, email, password, depth, overrideAccess, showHiddenFields)
|
|
70
|
-
},
|
|
71
|
-
)
|
|
72
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import type { PayloadRequest } from 'payload'
|
|
3
|
-
|
|
4
|
-
import { toolSchemas } from '../schemas.js'
|
|
5
|
-
|
|
6
|
-
export const resetPasswordTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
|
|
7
|
-
const tool = async (collection: string, token: string, password: string) => {
|
|
8
|
-
const payload = req.payload
|
|
9
|
-
|
|
10
|
-
if (verboseLogs) {
|
|
11
|
-
payload.logger.info(`[payload-mcp] Resetting password for user in collection: ${collection}`)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
const result = await payload.resetPassword({
|
|
16
|
-
collection,
|
|
17
|
-
data: {
|
|
18
|
-
password,
|
|
19
|
-
token,
|
|
20
|
-
},
|
|
21
|
-
overrideAccess: true,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
if (verboseLogs) {
|
|
25
|
-
payload.logger.info('[payload-mcp] Password reset completed successfully')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
type: 'text' as const,
|
|
32
|
-
text: `# Password Reset Successful\n\n**Collection:** ${collection}\n**Token:** ${token}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
38
|
-
payload.logger.error(`[payload-mcp] Error resetting password: ${errorMessage}`)
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
content: [
|
|
42
|
-
{
|
|
43
|
-
type: 'text' as const,
|
|
44
|
-
text: `❌ **Error resetting password**: ${errorMessage}`,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
server.registerTool(
|
|
52
|
-
'resetPassword',
|
|
53
|
-
{
|
|
54
|
-
description: toolSchemas.resetPassword.description,
|
|
55
|
-
inputSchema: toolSchemas.resetPassword.parameters.shape,
|
|
56
|
-
},
|
|
57
|
-
async ({ collection, password, token }) => {
|
|
58
|
-
return await tool(collection, token, password)
|
|
59
|
-
},
|
|
60
|
-
)
|
|
61
|
-
}
|