@payloadcms/plugin-mcp 4.0.0-internal.63f8536 → 4.0.0-internal.656159a
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/bin.js +7 -0
- package/dist/defaultAccess.d.ts.map +1 -1
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +13 -3
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +100 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +72 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.js +1 -1
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +23 -2
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +21 -8
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +2 -2
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/mcp/builtin/collections/createTool.ts +13 -3
- package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
- package/src/mcp/builtin/collections/fileInput.ts +139 -0
- package/src/mcp/builtin/collections/findTool.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +14 -1
- package/src/mcp/builtin/collections/updateTool.ts +23 -6
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +2 -2
|
@@ -13,6 +13,7 @@ import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEnt
|
|
|
13
13
|
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
|
|
14
14
|
import { whereSchema } from '../../../utils/whereSchema.js'
|
|
15
15
|
import { validateCollectionData } from '../validateEntityData.js'
|
|
16
|
+
import { fileInputSchema, resolveFileInput } from './fileInput.js'
|
|
16
17
|
import { formatCollectionError } from './formatCollectionError.js'
|
|
17
18
|
|
|
18
19
|
const DEFAULT_DESCRIPTION =
|
|
@@ -31,7 +32,11 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
31
32
|
description: DEFAULT_DESCRIPTION,
|
|
32
33
|
input: z.object({
|
|
33
34
|
id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),
|
|
34
|
-
data: z
|
|
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
|
+
),
|
|
35
40
|
depth: z
|
|
36
41
|
.number()
|
|
37
42
|
.describe('How many levels deep to populate relationships')
|
|
@@ -39,14 +44,16 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
39
44
|
.default(0),
|
|
40
45
|
draft: z
|
|
41
46
|
.boolean()
|
|
42
|
-
.describe(
|
|
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
|
+
)
|
|
43
50
|
.optional()
|
|
44
51
|
.default(false),
|
|
45
52
|
fallbackLocale: z
|
|
46
53
|
.string()
|
|
47
54
|
.describe('Optional: fallback locale code to use when requested locale is not available')
|
|
48
55
|
.optional(),
|
|
49
|
-
|
|
56
|
+
file: fileInputSchema.optional(),
|
|
50
57
|
locale: z
|
|
51
58
|
.string()
|
|
52
59
|
.describe(
|
|
@@ -63,6 +70,12 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
63
70
|
.describe('Whether to overwrite existing files')
|
|
64
71
|
.optional()
|
|
65
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(),
|
|
66
79
|
select: z
|
|
67
80
|
.record(z.string(), z.unknown())
|
|
68
81
|
.describe(
|
|
@@ -85,10 +98,11 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
85
98
|
depth,
|
|
86
99
|
draft,
|
|
87
100
|
fallbackLocale,
|
|
88
|
-
|
|
101
|
+
file: fileInput,
|
|
89
102
|
locale,
|
|
90
103
|
overrideLock,
|
|
91
104
|
overwriteExistingFiles,
|
|
105
|
+
publishAllLocales,
|
|
92
106
|
select,
|
|
93
107
|
where,
|
|
94
108
|
} = input
|
|
@@ -118,6 +132,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
118
132
|
}
|
|
119
133
|
|
|
120
134
|
const parsedData = transformPointDataToPayload(inputData)
|
|
135
|
+
const file = await resolveFileInput({ collectionSlug, input: fileInput, req })
|
|
121
136
|
|
|
122
137
|
const whereClause: Where = where ?? {}
|
|
123
138
|
|
|
@@ -131,8 +146,9 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
131
146
|
overrideAccess: authorizedMCP.overrideAccess,
|
|
132
147
|
overrideLock,
|
|
133
148
|
req,
|
|
134
|
-
...(
|
|
149
|
+
...(file ? { file } : {}),
|
|
135
150
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
151
|
+
...(publishAllLocales !== undefined ? { publishAllLocales } : {}),
|
|
136
152
|
...(locale ? { locale } : {}),
|
|
137
153
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
138
154
|
...(select ? { select: select as SelectType } : {}),
|
|
@@ -158,8 +174,9 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
158
174
|
overrideLock,
|
|
159
175
|
req,
|
|
160
176
|
where: whereClause,
|
|
161
|
-
...(
|
|
177
|
+
...(file ? { file } : {}),
|
|
162
178
|
...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),
|
|
179
|
+
...(publishAllLocales !== undefined ? { publishAllLocales } : {}),
|
|
163
180
|
...(locale ? { locale } : {}),
|
|
164
181
|
...(fallbackLocale ? { fallbackLocale } : {}),
|
|
165
182
|
...(select ? { select: select as SelectType } : {}),
|
|
@@ -76,8 +76,8 @@ describe('sanitizeEntitySchema', () => {
|
|
|
76
76
|
},
|
|
77
77
|
},
|
|
78
78
|
properties: {
|
|
79
|
-
// Managed
|
|
80
|
-
//
|
|
79
|
+
// Managed timestamps are excluded upstream by the `input` variant. `id` stays because it's
|
|
80
|
+
// a valid optional input (a client may supply a custom ID).
|
|
81
81
|
id: { type: 'string' },
|
|
82
82
|
content: {
|
|
83
83
|
type: 'object',
|