@payloadcms/plugin-mcp 4.0.0-internal.697830c → 4.0.0-internal.7b031c8

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.
Files changed (44) hide show
  1. package/bin.js +7 -0
  2. package/dist/defaultAccess.d.ts.map +1 -1
  3. package/dist/defineTool.d.ts +8 -8
  4. package/dist/defineTool.d.ts.map +1 -1
  5. package/dist/endpoint/access.d.ts.map +1 -1
  6. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  7. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  8. package/dist/mcp/builtin/collections/createTool.js +13 -3
  9. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  10. package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
  11. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  12. package/dist/mcp/builtin/collections/fileInput.js +100 -0
  13. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  14. package/dist/mcp/builtin/collections/fileInput.spec.js +72 -0
  15. package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
  16. package/dist/mcp/builtin/collections/findTool.js +1 -1
  17. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  18. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  19. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  20. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  21. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +23 -2
  22. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  23. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  24. package/dist/mcp/builtin/collections/updateTool.js +21 -8
  25. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  26. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
  27. package/dist/mcp/builtinTools.d.ts.map +1 -1
  28. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  29. package/dist/utils/camelCase.d.ts.map +1 -1
  30. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  31. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -1
  32. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
  33. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
  34. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +2 -2
  35. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
  36. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  37. package/package.json +4 -4
  38. package/src/mcp/builtin/collections/createTool.ts +13 -3
  39. package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
  40. package/src/mcp/builtin/collections/fileInput.ts +139 -0
  41. package/src/mcp/builtin/collections/findTool.ts +1 -1
  42. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +14 -1
  43. package/src/mcp/builtin/collections/updateTool.ts +23 -6
  44. 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.record(z.string(), z.unknown()).describe('The fields to update'),
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('Whether to update the document as a draft')
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
- filePath: z.string().describe('File path for file uploads').optional(),
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
- filePath,
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
- ...(filePath ? { filePath } : {}),
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
- ...(filePath ? { filePath } : {}),
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 fields (createdAt/updatedAt/_status) are excluded upstream by the `input` variant;
80
- // `id` stays because it's a valid optional input (a client may supply a custom ID).
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',