@payloadcms/plugin-mcp 4.0.0-internal.c2b57ce → 4.0.0-internal.c3ac604
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/bin.js +7 -0
- package/dist/defaultAccess.d.ts +3 -0
- package/dist/defaultAccess.d.ts.map +1 -0
- package/dist/defaultAccess.js +3 -0
- package/dist/defaultAccess.js.map +1 -0
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +12 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +75 -88
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +70 -19
- package/dist/endpoint/index.js.map +1 -1
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -0
- package/dist/exports/internal.js +3 -0
- package/dist/exports/internal.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +4 -4
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +133 -73
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/authTools.js +44 -6
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countTool.js +68 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +110 -59
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +15 -22
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +96 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +124 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +86 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +92 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +52 -47
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +83 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +98 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +87 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +81 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +106 -89
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.js +68 -0
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +20 -23
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +79 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +94 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +65 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +77 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +33 -38
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
- package/dist/mcp/builtin/validateEntityData.js +82 -0
- package/dist/mcp/builtin/validateEntityData.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +150 -19
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +125 -20
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +124 -58
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +84 -46
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +112 -110
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getPluginConfig.d.ts +1 -1
- package/dist/utils/getPluginConfig.js +1 -1
- package/dist/utils/getPluginConfig.js.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +13 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js +66 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +10 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +384 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +133 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/dist/utils/whereSchema.d.ts +9 -0
- package/dist/utils/whereSchema.d.ts.map +1 -0
- package/dist/utils/whereSchema.js +13 -0
- package/dist/utils/whereSchema.js.map +1 -0
- package/package.json +15 -20
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +81 -101
- package/src/endpoint/index.ts +59 -17
- package/src/exports/client.ts +2 -1
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +12 -20
- package/src/mcp/buildMcpServer.ts +169 -109
- package/src/mcp/builtin/collections/authTools.ts +45 -9
- package/src/mcp/builtin/collections/countTool.ts +73 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/collections/createTool.ts +130 -78
- package/src/mcp/builtin/collections/deleteTool.ts +20 -18
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +164 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +66 -37
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +80 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +132 -110
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +67 -0
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +28 -19
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +63 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +52 -55
- package/src/mcp/builtin/validateEntityData.ts +132 -0
- package/src/mcp/builtinTools.ts +118 -41
- package/src/mcp/sanitizeMCPConfig.ts +120 -78
- package/src/stdio.ts +79 -46
- package/src/types.ts +128 -115
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +96 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +96 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +432 -0
- package/src/utils/whereSchema.ts +24 -0
- package/dist/collection/getAccessField.d.ts +0 -12
- package/dist/collection/getAccessField.d.ts.map +0 -1
- package/dist/collection/getAccessField.js +0 -57
- package/dist/collection/getAccessField.js.map +0 -1
- package/dist/collection/index.d.ts +0 -6
- package/dist/collection/index.d.ts.map +0 -1
- package/dist/collection/index.js +0 -59
- package/dist/collection/index.js.map +0 -1
- package/dist/components/AccessField/index.client.d.ts +0 -10
- package/dist/components/AccessField/index.client.d.ts.map +0 -1
- package/dist/components/AccessField/index.client.js +0 -305
- package/dist/components/AccessField/index.client.js.map +0 -1
- package/dist/components/AccessField/index.css +0 -93
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/prepareCollectionSchema.js +0 -37
- package/dist/utils/schemaConversion/prepareCollectionSchema.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -56
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.js +0 -57
- package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
- package/src/collection/getAccessField.ts +0 -64
- package/src/collection/index.ts +0 -63
- package/src/components/AccessField/index.client.tsx +0 -344
- package/src/components/AccessField/index.css +0 -93
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/prepareCollectionSchema.ts +0 -39
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -70
- package/src/utils/schemaConversion/transformPointFields.ts +0 -56
|
@@ -1,78 +1,93 @@
|
|
|
1
|
-
import type { SelectType } from 'payload'
|
|
1
|
+
import type { SelectType, Where } from 'payload'
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
6
|
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
7
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
8
|
import {
|
|
8
9
|
getCollectionVirtualFieldNames,
|
|
9
10
|
stripVirtualFields,
|
|
10
11
|
} from '../../../utils/getVirtualFieldNames.js'
|
|
11
|
-
import {
|
|
12
|
-
import { prepareCollectionSchema } from '../../../utils/schemaConversion/prepareCollectionSchema.js'
|
|
12
|
+
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
13
13
|
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.fromJSONSchema(partialSchema as unknown as z.core.JSONSchema.JSONSchema)
|
|
32
|
-
.describe('The fields to update'),
|
|
33
|
-
depth: z
|
|
34
|
-
.number()
|
|
35
|
-
.describe('How many levels deep to populate relationships')
|
|
36
|
-
.optional()
|
|
37
|
-
.default(0),
|
|
38
|
-
draft: z
|
|
39
|
-
.boolean()
|
|
40
|
-
.describe('Whether to update the document as a draft')
|
|
41
|
-
.optional()
|
|
42
|
-
.default(false),
|
|
43
|
-
fallbackLocale: z
|
|
44
|
-
.string()
|
|
45
|
-
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
46
|
-
.optional(),
|
|
47
|
-
filePath: z.string().describe('File path for file uploads').optional(),
|
|
48
|
-
locale: z
|
|
49
|
-
.string()
|
|
50
|
-
.describe(
|
|
51
|
-
'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
|
|
52
|
-
)
|
|
53
|
-
.optional(),
|
|
54
|
-
overrideLock: z
|
|
55
|
-
.boolean()
|
|
56
|
-
.describe('Whether to override document locks')
|
|
57
|
-
.optional()
|
|
58
|
-
.default(true),
|
|
59
|
-
overwriteExistingFiles: z
|
|
60
|
-
.boolean()
|
|
61
|
-
.describe('Whether to overwrite existing files')
|
|
62
|
-
.optional()
|
|
63
|
-
.default(false),
|
|
64
|
-
select: z
|
|
65
|
-
.string()
|
|
66
|
-
.describe(
|
|
67
|
-
'Optional: define exactly which fields you\'d like to return in the response (JSON), e.g., \'{"title": "My Post"}\'',
|
|
68
|
-
)
|
|
69
|
-
.optional(),
|
|
70
|
-
where: z
|
|
71
|
-
.string()
|
|
72
|
-
.describe('JSON string for where clause to update multiple documents')
|
|
73
|
-
.optional(),
|
|
74
|
-
})
|
|
14
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
15
|
+
import { validateCollectionData } from '../validateEntityData.js'
|
|
16
|
+
import { fileInputSchema, resolveFile } from './fileInput.js'
|
|
17
|
+
import { formatCollectionError } from './formatCollectionError.js'
|
|
18
|
+
|
|
19
|
+
const DEFAULT_DESCRIPTION =
|
|
20
|
+
'Update documents. Prefer uploadReference after upload, externalURL for URLs, or base64 for small local files.'
|
|
21
|
+
|
|
22
|
+
export const updateDocumentTool = defineCollectionTool({
|
|
23
|
+
access: (args) =>
|
|
24
|
+
defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
25
|
+
annotations: {
|
|
26
|
+
destructiveHint: true,
|
|
27
|
+
idempotentHint: false,
|
|
28
|
+
openWorldHint: false,
|
|
29
|
+
readOnlyHint: false,
|
|
30
|
+
title: 'Update Document',
|
|
75
31
|
},
|
|
32
|
+
description: DEFAULT_DESCRIPTION,
|
|
33
|
+
input: z.object({
|
|
34
|
+
id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),
|
|
35
|
+
data: z
|
|
36
|
+
.record(z.string(), z.unknown())
|
|
37
|
+
.describe(
|
|
38
|
+
'The fields to update. Only include fields permitted by the schema returned by getCollectionSchema.',
|
|
39
|
+
),
|
|
40
|
+
depth: z
|
|
41
|
+
.number()
|
|
42
|
+
.describe('How many levels deep to populate relationships')
|
|
43
|
+
.optional()
|
|
44
|
+
.default(0),
|
|
45
|
+
draft: z
|
|
46
|
+
.boolean()
|
|
47
|
+
.describe(
|
|
48
|
+
'Only if getCollectionSchema includes _status; otherwise _status does not exist. true saves only a draft version; false updates main and versions. data._status: "published" overrides true.',
|
|
49
|
+
)
|
|
50
|
+
.optional()
|
|
51
|
+
.default(false),
|
|
52
|
+
fallbackLocale: z
|
|
53
|
+
.string()
|
|
54
|
+
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
55
|
+
.optional(),
|
|
56
|
+
file: fileInputSchema.optional(),
|
|
57
|
+
locale: z
|
|
58
|
+
.string()
|
|
59
|
+
.describe(
|
|
60
|
+
'Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale',
|
|
61
|
+
)
|
|
62
|
+
.optional(),
|
|
63
|
+
overrideLock: z
|
|
64
|
+
.boolean()
|
|
65
|
+
.describe('Whether to override document locks')
|
|
66
|
+
.optional()
|
|
67
|
+
.default(true),
|
|
68
|
+
overwriteExistingFiles: z
|
|
69
|
+
.boolean()
|
|
70
|
+
.describe('Whether to overwrite existing files')
|
|
71
|
+
.optional()
|
|
72
|
+
.default(false),
|
|
73
|
+
publishAllLocales: z
|
|
74
|
+
.boolean()
|
|
75
|
+
.describe(
|
|
76
|
+
'For collections with localized publishing status, whether publishing should affect every locale. Set false with locale to publish only that locale.',
|
|
77
|
+
)
|
|
78
|
+
.optional(),
|
|
79
|
+
select: z
|
|
80
|
+
.record(z.string(), z.unknown())
|
|
81
|
+
.describe(
|
|
82
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
83
|
+
)
|
|
84
|
+
.optional(),
|
|
85
|
+
where: whereSchema
|
|
86
|
+
.describe(
|
|
87
|
+
'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}',
|
|
88
|
+
)
|
|
89
|
+
.optional(),
|
|
90
|
+
}),
|
|
76
91
|
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
77
92
|
const payload = req.payload
|
|
78
93
|
const logger = getLogger({ payload })
|
|
@@ -83,10 +98,11 @@ export const updateCollectionTool = defineCollectionTool({
|
|
|
83
98
|
depth,
|
|
84
99
|
draft,
|
|
85
100
|
fallbackLocale,
|
|
86
|
-
|
|
101
|
+
file: fileInput,
|
|
87
102
|
locale,
|
|
88
103
|
overrideLock,
|
|
89
104
|
overwriteExistingFiles,
|
|
105
|
+
publishAllLocales,
|
|
90
106
|
select,
|
|
91
107
|
where,
|
|
92
108
|
} = input
|
|
@@ -102,48 +118,41 @@ export const updateCollectionTool = defineCollectionTool({
|
|
|
102
118
|
}
|
|
103
119
|
}
|
|
104
120
|
|
|
105
|
-
let parsedData = transformPointDataToPayload(data as Record<string, unknown>)
|
|
106
121
|
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
logger.error(`Invalid where clause JSON: ${where}`)
|
|
115
|
-
return { content: [{ type: 'text', text: 'Error: Invalid JSON in where clause' }] }
|
|
116
|
-
}
|
|
117
|
-
}
|
|
122
|
+
const inputData = stripVirtualFields(data, virtualFieldNames)
|
|
123
|
+
const validationError = validateCollectionData({
|
|
124
|
+
collectionSlug,
|
|
125
|
+
data: inputData,
|
|
126
|
+
partial: true,
|
|
127
|
+
req,
|
|
128
|
+
})
|
|
118
129
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
selectClause = JSON.parse(select) as SelectType
|
|
123
|
-
} catch {
|
|
124
|
-
logger.warn(`Invalid select clause JSON: ${select}`)
|
|
125
|
-
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
126
|
-
}
|
|
130
|
+
if (validationError) {
|
|
131
|
+
return validationError
|
|
127
132
|
}
|
|
128
133
|
|
|
134
|
+
const parsedData = transformPointDataToPayload(inputData)
|
|
135
|
+
const file = await resolveFile({ collectionSlug, input: fileInput, req })
|
|
136
|
+
|
|
137
|
+
const whereClause: Where = where ?? {}
|
|
138
|
+
|
|
129
139
|
if (id) {
|
|
130
|
-
const
|
|
140
|
+
const result = await payload.update({
|
|
131
141
|
id,
|
|
132
142
|
collection: collectionSlug,
|
|
133
143
|
data: parsedData,
|
|
134
144
|
depth,
|
|
135
145
|
draft,
|
|
146
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
136
147
|
overrideLock,
|
|
137
148
|
req,
|
|
138
|
-
...
|
|
139
|
-
...(filePath ? { filePath } : {}),
|
|
149
|
+
...(file ? { file } : {}),
|
|
140
150
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
151
|
+
...(publishAllLocales !== undefined ? { publishAllLocales } : {}),
|
|
141
152
|
...(locale ? { locale } : {}),
|
|
142
153
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
143
|
-
...(
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const result = await payload.update(updateOptions as any)
|
|
154
|
+
...(select ? { select: select as SelectType } : {}),
|
|
155
|
+
})
|
|
147
156
|
|
|
148
157
|
return {
|
|
149
158
|
content: [
|
|
@@ -156,27 +165,25 @@ export const updateCollectionTool = defineCollectionTool({
|
|
|
156
165
|
}
|
|
157
166
|
}
|
|
158
167
|
|
|
159
|
-
const
|
|
168
|
+
const result = await payload.update({
|
|
160
169
|
collection: collectionSlug,
|
|
161
170
|
data: parsedData,
|
|
162
171
|
depth,
|
|
163
172
|
draft,
|
|
173
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
164
174
|
overrideLock,
|
|
165
175
|
req,
|
|
166
|
-
...localAPIDefaults(authorizedMCP),
|
|
167
176
|
where: whereClause,
|
|
168
|
-
...(
|
|
177
|
+
...(file ? { file } : {}),
|
|
169
178
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
179
|
+
...(publishAllLocales !== undefined ? { publishAllLocales } : {}),
|
|
170
180
|
...(locale ? { locale } : {}),
|
|
171
181
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
172
|
-
...(
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const result = await payload.update(updateOptions as any)
|
|
182
|
+
...(select ? { select: select as SelectType } : {}),
|
|
183
|
+
})
|
|
176
184
|
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const errors = bulkResult.errors || []
|
|
185
|
+
const docs = result.docs || []
|
|
186
|
+
const errors = result.errors || []
|
|
180
187
|
|
|
181
188
|
let responseText = `Multiple documents updated in collection "${collectionSlug}"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`
|
|
182
189
|
if (docs.length > 0) {
|
|
@@ -184,6 +191,28 @@ export const updateCollectionTool = defineCollectionTool({
|
|
|
184
191
|
}
|
|
185
192
|
if (errors.length > 0) {
|
|
186
193
|
responseText += `\n\nErrors:\n\`\`\`json\n${JSON.stringify(errors)}\n\`\`\``
|
|
194
|
+
|
|
195
|
+
const errorSchema = getCollectionInputSchema({ collectionSlug, req })
|
|
196
|
+
|
|
197
|
+
if (errorSchema) {
|
|
198
|
+
responseText += `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(errorSchema)}\n\`\`\``
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
content: [{ type: 'text', text: responseText }],
|
|
203
|
+
doc: { docs, errors } as unknown as Record<string, unknown>,
|
|
204
|
+
isError: true,
|
|
205
|
+
...(errorSchema
|
|
206
|
+
? {
|
|
207
|
+
structuredContent: {
|
|
208
|
+
collectionSlug,
|
|
209
|
+
docs,
|
|
210
|
+
errors,
|
|
211
|
+
schema: errorSchema,
|
|
212
|
+
},
|
|
213
|
+
}
|
|
214
|
+
: {}),
|
|
215
|
+
}
|
|
187
216
|
}
|
|
188
217
|
|
|
189
218
|
return {
|
|
@@ -193,13 +222,6 @@ export const updateCollectionTool = defineCollectionTool({
|
|
|
193
222
|
} catch (error) {
|
|
194
223
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
195
224
|
logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)
|
|
196
|
-
return {
|
|
197
|
-
content: [
|
|
198
|
-
{
|
|
199
|
-
type: 'text',
|
|
200
|
-
text: `Error updating document in collection "${collectionSlug}": ${errorMessage}`,
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
}
|
|
225
|
+
return formatCollectionError({ action: 'updating', collectionSlug, error, req })
|
|
204
226
|
}
|
|
205
227
|
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getUploadInstructions as getPayloadUploadInstructions } from 'payload/internal'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
|
+
import { defineCollectionTool } from '../../../defineTool.js'
|
|
6
|
+
|
|
7
|
+
export const getUploadInstructionsTool = defineCollectionTool({
|
|
8
|
+
access: (args) =>
|
|
9
|
+
defaultAccess(args) &&
|
|
10
|
+
Boolean(
|
|
11
|
+
args.permissions?.collections?.[args.collectionSlug]?.create ||
|
|
12
|
+
args.permissions?.collections?.[args.collectionSlug]?.update,
|
|
13
|
+
),
|
|
14
|
+
annotations: {
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
readOnlyHint: false,
|
|
19
|
+
title: 'Get Upload Instructions',
|
|
20
|
+
},
|
|
21
|
+
description:
|
|
22
|
+
'Prepare uploads for createDocuments or updateDocument. This does not upload bytes; finish the returned action before use.',
|
|
23
|
+
input: z.object({
|
|
24
|
+
docPrefix: z.string().describe('Optional document folder or prefix').optional(),
|
|
25
|
+
filename: z.string().describe('The original file name'),
|
|
26
|
+
filesize: z.number().int().nonnegative().describe('The file size in bytes'),
|
|
27
|
+
mimeType: z.string().describe('The file MIME type'),
|
|
28
|
+
}),
|
|
29
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {
|
|
30
|
+
try {
|
|
31
|
+
const instructions = await getPayloadUploadInstructions({
|
|
32
|
+
...input,
|
|
33
|
+
collectionSlug,
|
|
34
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
35
|
+
req,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const nextStep =
|
|
39
|
+
instructions.type === 'http'
|
|
40
|
+
? 'Upload bytes with instructions.request. After success, pass { source: "uploadReference", file: instructions.file }.'
|
|
41
|
+
: `Call "${instructions.name}" with file and data. After success, pass { source: "uploadReference", file: instructions.file }.`
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Upload instructions for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(instructions)}\n\`\`\`\n${nextStep}`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
structuredContent: { instructions },
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : 'Unknown error'
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: `Error getting upload instructions for collection "${collectionSlug}": ${message}`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
isError: true,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getAccessResults, isEntityHidden } from 'payload'
|
|
2
|
+
|
|
3
|
+
import { defineTool } from '../../defineTool.js'
|
|
4
|
+
|
|
5
|
+
export const getConfigInfoTool = defineTool({
|
|
6
|
+
annotations: {
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: true,
|
|
9
|
+
openWorldHint: false,
|
|
10
|
+
readOnlyHint: true,
|
|
11
|
+
title: 'Config Info',
|
|
12
|
+
},
|
|
13
|
+
description: 'List the Payload collection and global slugs visible to this MCP client.',
|
|
14
|
+
}).handler(async ({ authorizedMCP, req }) => {
|
|
15
|
+
const user = req.user
|
|
16
|
+
const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({ req })
|
|
17
|
+
const authorizedCollectionSlugs = new Set<string>()
|
|
18
|
+
const authorizedGlobalSlugs = new Set<string>()
|
|
19
|
+
|
|
20
|
+
for (const item of authorizedMCP.items) {
|
|
21
|
+
if (item.type === 'collectionTool') {
|
|
22
|
+
authorizedCollectionSlugs.add(item.collectionSlug)
|
|
23
|
+
} else if (item.type === 'globalTool') {
|
|
24
|
+
authorizedGlobalSlugs.add(item.globalSlug)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const collections: string[] = []
|
|
29
|
+
const globals: string[] = []
|
|
30
|
+
|
|
31
|
+
for (const collection of req.payload.config.collections) {
|
|
32
|
+
if (!authorizedCollectionSlugs.has(collection.slug)) {
|
|
33
|
+
continue
|
|
34
|
+
}
|
|
35
|
+
if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {
|
|
36
|
+
continue
|
|
37
|
+
}
|
|
38
|
+
if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
collections.push(collection.slug)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for (const global of req.payload.config.globals) {
|
|
46
|
+
if (!authorizedGlobalSlugs.has(global.slug)) {
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
52
|
+
if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
globals.push(global.slug)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Collections: ${collections.join(', ') || 'none'}\nGlobals: ${globals.join(', ') || 'none'}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}
|
|
67
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
4
|
+
import { defineGlobalTool } from '../../../defineTool.js'
|
|
5
|
+
import { getLogger } from '../../../utils/getLogger.js'
|
|
6
|
+
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
7
|
+
|
|
8
|
+
const DEFAULT_DESCRIPTION =
|
|
9
|
+
'Count global versions in any version-enabled global by passing the global slug and optional where clause.'
|
|
10
|
+
|
|
11
|
+
export const countGlobalVersionsTool = defineGlobalTool({
|
|
12
|
+
access: (args) =>
|
|
13
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
|
|
14
|
+
annotations: {
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: true,
|
|
17
|
+
openWorldHint: false,
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
title: 'Count Global Versions',
|
|
20
|
+
},
|
|
21
|
+
description: DEFAULT_DESCRIPTION,
|
|
22
|
+
input: z.object({
|
|
23
|
+
locale: z.string().describe('Optional: locale code to count versions in').optional(),
|
|
24
|
+
where: whereSchema
|
|
25
|
+
.describe(
|
|
26
|
+
'Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}',
|
|
27
|
+
)
|
|
28
|
+
.optional(),
|
|
29
|
+
}),
|
|
30
|
+
}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {
|
|
31
|
+
const payload = req.payload
|
|
32
|
+
const logger = getLogger({ payload })
|
|
33
|
+
const { locale, where } = input
|
|
34
|
+
|
|
35
|
+
logger.info(`Counting versions for global: ${globalSlug}`)
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const result = await payload.countGlobalVersions({
|
|
39
|
+
global: globalSlug,
|
|
40
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
41
|
+
req,
|
|
42
|
+
...(locale ? { locale } : {}),
|
|
43
|
+
...(where ? { where } : {}),
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: `Global "${globalSlug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
doc: result,
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
57
|
+
logger.error(`Error counting versions for global ${globalSlug}: ${errorMessage}`)
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: `❌ **Error counting versions for global "${globalSlug}":** ${errorMessage}`,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
isError: true,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type { SelectType } from 'payload'
|
|
1
|
+
import type { PopulateType, SelectType } from 'payload'
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
+
import { defaultAccess } from '../../../defaultAccess.js'
|
|
5
6
|
import { defineGlobalTool } from '../../../defineTool.js'
|
|
6
7
|
import { getLogger } from '../../../utils/getLogger.js'
|
|
7
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js'
|
|
8
8
|
|
|
9
|
-
const DEFAULT_DESCRIPTION = 'Find
|
|
9
|
+
const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'
|
|
10
10
|
|
|
11
11
|
export const findGlobalTool = defineGlobalTool({
|
|
12
|
+
access: (args) =>
|
|
13
|
+
defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.read),
|
|
14
|
+
annotations: {
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
idempotentHint: true,
|
|
17
|
+
openWorldHint: false,
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
title: 'Find Global',
|
|
20
|
+
},
|
|
12
21
|
description: DEFAULT_DESCRIPTION,
|
|
13
22
|
input: z.object({
|
|
14
23
|
depth: z
|
|
@@ -29,10 +38,16 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
29
38
|
'Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields',
|
|
30
39
|
)
|
|
31
40
|
.optional(),
|
|
41
|
+
populate: z
|
|
42
|
+
.record(z.string(), z.unknown())
|
|
43
|
+
.describe(
|
|
44
|
+
'Optional: control which fields to include from populated relationship or upload documents.',
|
|
45
|
+
)
|
|
46
|
+
.optional(),
|
|
32
47
|
select: z
|
|
33
|
-
.string()
|
|
48
|
+
.record(z.string(), z.unknown())
|
|
34
49
|
.describe(
|
|
35
|
-
|
|
50
|
+
'Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}',
|
|
36
51
|
)
|
|
37
52
|
.optional(),
|
|
38
53
|
}),
|
|
@@ -40,7 +55,7 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
40
55
|
const payload = req.payload
|
|
41
56
|
const logger = getLogger({ payload })
|
|
42
57
|
|
|
43
|
-
const { depth, fallbackLocale, locale, select } = input
|
|
58
|
+
const { depth, fallbackLocale, locale, populate, select } = input
|
|
44
59
|
|
|
45
60
|
logger.info(
|
|
46
61
|
`Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`,
|
|
@@ -50,17 +65,8 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
50
65
|
const findOptions: Parameters<typeof payload.findGlobal>[0] = {
|
|
51
66
|
slug: globalSlug,
|
|
52
67
|
depth,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let selectClause: SelectType | undefined
|
|
57
|
-
if (select) {
|
|
58
|
-
try {
|
|
59
|
-
selectClause = JSON.parse(select) as SelectType
|
|
60
|
-
} catch {
|
|
61
|
-
logger.warn(`Invalid select clause JSON for global: ${select}`)
|
|
62
|
-
return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }
|
|
63
|
-
}
|
|
68
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
69
|
+
req,
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
if (locale) {
|
|
@@ -69,8 +75,11 @@ export const findGlobalTool = defineGlobalTool({
|
|
|
69
75
|
if (fallbackLocale) {
|
|
70
76
|
findOptions.fallbackLocale = fallbackLocale
|
|
71
77
|
}
|
|
72
|
-
if (
|
|
73
|
-
findOptions.select =
|
|
78
|
+
if (select) {
|
|
79
|
+
findOptions.select = select as SelectType
|
|
80
|
+
}
|
|
81
|
+
if (populate) {
|
|
82
|
+
findOptions.populate = populate as PopulateType
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
const result = await payload.findGlobal(findOptions)
|