@payloadcms/plugin-mcp 4.0.0-internal.bc5cf8c → 4.0.0-internal.c7d5de4

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 (169) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +7 -0
  3. package/dist/defaultAccess.d.ts.map +1 -1
  4. package/dist/defineTool.d.ts +8 -8
  5. package/dist/defineTool.d.ts.map +1 -1
  6. package/dist/endpoint/access.d.ts +2 -7
  7. package/dist/endpoint/access.d.ts.map +1 -1
  8. package/dist/endpoint/access.js +4 -11
  9. package/dist/endpoint/access.js.map +1 -1
  10. package/dist/endpoint/index.d.ts +1 -1
  11. package/dist/endpoint/index.d.ts.map +1 -1
  12. package/dist/endpoint/index.js +57 -17
  13. package/dist/endpoint/index.js.map +1 -1
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/buildMcpServer.d.ts +4 -4
  19. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  20. package/dist/mcp/buildMcpServer.js +32 -10
  21. package/dist/mcp/buildMcpServer.js.map +1 -1
  22. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
  23. package/dist/mcp/builtin/collections/countTool.js +1 -2
  24. package/dist/mcp/builtin/collections/countTool.js.map +1 -1
  25. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
  26. package/dist/mcp/builtin/collections/countVersionsTool.js +1 -2
  27. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
  28. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  29. package/dist/mcp/builtin/collections/createTool.js +14 -5
  30. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  31. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  32. package/dist/mcp/builtin/collections/deleteTool.js +1 -2
  33. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  34. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
  35. package/dist/mcp/builtin/collections/duplicateTool.js +1 -2
  36. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
  37. package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
  38. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  39. package/dist/mcp/builtin/collections/fileInput.js +100 -0
  40. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  41. package/dist/mcp/builtin/collections/fileInput.spec.js +72 -0
  42. package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
  43. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
  44. package/dist/mcp/builtin/collections/findDistinctTool.js +1 -2
  45. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
  46. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  47. package/dist/mcp/builtin/collections/findTool.js +3 -4
  48. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  49. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
  50. package/dist/mcp/builtin/collections/findVersionByIDTool.js +1 -2
  51. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
  52. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
  53. package/dist/mcp/builtin/collections/findVersionsTool.js +1 -2
  54. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
  55. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  56. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  57. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  58. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +44 -5
  59. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  60. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
  61. package/dist/mcp/builtin/collections/restoreVersionTool.js +1 -2
  62. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
  63. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  64. package/dist/mcp/builtin/collections/updateTool.js +23 -11
  65. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  66. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  67. package/dist/mcp/builtin/getConfigInfoTool.js +2 -5
  68. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  69. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
  70. package/dist/mcp/builtin/globals/countVersionsTool.js +1 -2
  71. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
  72. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  73. package/dist/mcp/builtin/globals/findTool.js +2 -2
  74. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  75. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
  76. package/dist/mcp/builtin/globals/findVersionByIDTool.js +1 -2
  77. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
  78. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
  79. package/dist/mcp/builtin/globals/findVersionsTool.js +1 -2
  80. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
  81. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  82. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +21 -3
  83. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  84. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
  85. package/dist/mcp/builtin/globals/restoreVersionTool.js +1 -2
  86. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
  87. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  88. package/dist/mcp/builtin/globals/updateTool.js +2 -2
  89. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  90. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
  91. package/dist/mcp/builtin/validateEntityData.js +1 -1
  92. package/dist/mcp/builtin/validateEntityData.js.map +1 -1
  93. package/dist/mcp/builtinTools.d.ts.map +1 -1
  94. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  95. package/dist/mcp/sanitizeMCPConfig.js +1 -0
  96. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  97. package/dist/stdio.d.ts +3 -4
  98. package/dist/stdio.d.ts.map +1 -1
  99. package/dist/stdio.js +59 -41
  100. package/dist/stdio.js.map +1 -1
  101. package/dist/types.d.ts +57 -9
  102. package/dist/types.d.ts.map +1 -1
  103. package/dist/types.js +2 -4
  104. package/dist/types.js.map +1 -1
  105. package/dist/utils/camelCase.d.ts.map +1 -1
  106. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  107. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +28 -0
  108. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
  109. package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
  110. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
  111. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
  112. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
  113. package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
  114. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
  115. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
  116. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
  117. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
  118. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
  119. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
  120. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
  121. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  122. package/package.json +9 -11
  123. package/src/endpoint/access.ts +3 -10
  124. package/src/endpoint/index.ts +45 -16
  125. package/src/index.ts +4 -4
  126. package/src/mcp/buildMcpServer.ts +40 -20
  127. package/src/mcp/builtin/collections/countTool.ts +1 -2
  128. package/src/mcp/builtin/collections/countVersionsTool.ts +1 -2
  129. package/src/mcp/builtin/collections/createTool.ts +14 -5
  130. package/src/mcp/builtin/collections/deleteTool.ts +1 -2
  131. package/src/mcp/builtin/collections/duplicateTool.ts +1 -2
  132. package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
  133. package/src/mcp/builtin/collections/fileInput.ts +139 -0
  134. package/src/mcp/builtin/collections/findDistinctTool.ts +1 -2
  135. package/src/mcp/builtin/collections/findTool.ts +3 -4
  136. package/src/mcp/builtin/collections/findVersionByIDTool.ts +1 -2
  137. package/src/mcp/builtin/collections/findVersionsTool.ts +1 -2
  138. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +39 -9
  139. package/src/mcp/builtin/collections/restoreVersionTool.ts +1 -2
  140. package/src/mcp/builtin/collections/updateTool.ts +25 -9
  141. package/src/mcp/builtin/getConfigInfoTool.ts +2 -4
  142. package/src/mcp/builtin/globals/countVersionsTool.ts +1 -2
  143. package/src/mcp/builtin/globals/findTool.ts +2 -2
  144. package/src/mcp/builtin/globals/findVersionByIDTool.ts +1 -2
  145. package/src/mcp/builtin/globals/findVersionsTool.ts +1 -2
  146. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +25 -3
  147. package/src/mcp/builtin/globals/restoreVersionTool.ts +1 -2
  148. package/src/mcp/builtin/globals/updateTool.ts +2 -2
  149. package/src/mcp/builtin/validateEntityData.ts +1 -1
  150. package/src/mcp/sanitizeMCPConfig.ts +1 -0
  151. package/src/stdio.ts +59 -42
  152. package/src/types.ts +57 -9
  153. package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
  154. package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
  155. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
  156. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
  157. package/dist/@types/assets.d.js +0 -2
  158. package/dist/@types/assets.d.js.map +0 -1
  159. package/dist/utils/localAPIDefaults.d.ts +0 -20
  160. package/dist/utils/localAPIDefaults.d.ts.map +0 -1
  161. package/dist/utils/localAPIDefaults.js +0 -19
  162. package/dist/utils/localAPIDefaults.js.map +0 -1
  163. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  164. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  165. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  166. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  167. package/src/@types/assets.d.ts +0 -3
  168. package/src/utils/localAPIDefaults.ts +0 -22
  169. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
@@ -1,30 +1,22 @@
1
1
  import type { JsonSchemaType } from '../../types.js'
2
2
 
3
3
  /**
4
- * Turns the JSON Schema that Payload generates for a collection or global into the input schema for
5
- * an MCP create/update tool. In short, it:
6
- *
7
- * - drops fields a client can't set (`id`, `createdAt`, the draft `_status`, …),
8
- * - rewrites Payload-specific field shapes (points, relationships) into plain JSON the model can fill,
9
- * - and shrinks the result so it's cheaper for the model to read,
10
- *
11
- * while keeping every node valid JSON Schema draft 2020-12. Each step below is tagged with why it runs -
12
- * **Correctness** (valid input the API accepts), **Size** (equivalence-preserving shrink), or **LLM
13
- * ergonomics** (easier for the model to read/fill) - and carries a before/after example on its definition.
4
+ * Refines Payload's `input`-variant JSON Schema into an MCP create/update tool's input schema. The
5
+ * variant already covers correctness (ID-only relationships, no managed/virtual/join fields); the
6
+ * passes here are MCP-specific - reshaping fields for the model and shrinking the result - and keep
7
+ * every node valid JSON Schema draft 2020-12. Each is tagged **Correctness**, **Size**, or **LLM
8
+ * ergonomics**, with a before/after example on its definition.
14
9
  */
15
10
  export const sanitizeEntitySchema = (schema: JsonSchemaType): JsonSchemaType => {
16
11
  // Work on a copy — the caller reuses the original schema elsewhere (e.g. when listing tools).
17
12
  let result = structuredClone(schema)
18
13
 
19
- // Correctness — drop the fields a client can't set (id, createdAt, updatedAt, draft _status) + collapse nullable types.
20
- result = removeManagedFields(result)
14
+ // LLM ergonomics — drop the redundant `'null'` from optional arrays/objects (`['array','null']` `'array'`).
15
+ result = collapseOptionalContainerTypes(result)
21
16
 
22
17
  // LLM ergonomics — rewrite point fields from a `[number, number]` tuple into a `{ longitude, latitude }` object.
23
18
  result = pointFieldsToObjects(result)
24
19
 
25
- // Correctness — a relationship value can be an ID or a populated doc; on input only the ID is valid, so keep that.
26
- result = relationshipsToIds(result)
27
-
28
20
  // Size — strip inert type-gen leftovers that only bloat the schema (`tsType`, block-collision notes).
29
21
  result = removeTypeGenArtifacts(result)
30
22
 
@@ -58,26 +50,20 @@ const mapNodes = (node: unknown, visit: (node: JsonSchemaType) => JsonSchemaType
58
50
  for (const [key, value] of Object.entries(node)) {
59
51
  out[key] = mapNodes(value, visit)
60
52
  }
61
- return visit(out as JsonSchemaType)
53
+ return visit(out)
62
54
  }
63
55
 
64
- // Payload sets these on every document, so an MCP client never provides them when creating/updating.
65
- const PAYLOAD_MANAGED_FIELDS = new Set(['_status', 'createdAt', 'id', 'updatedAt'])
66
-
67
56
  /**
68
- * **Correctness.** Removes the fields a client can't set on create/update - `id`, `createdAt`, `updatedAt`, and the draft
69
- * `_status` - from every field object's `properties` and `required` (recursing into nested objects and
70
- * array items). Along the way it also collapses optional array/object types via {@link collapseNullableType}.
57
+ * **LLM ergonomics.** Collapses optional array/object types (`['array', 'null']` `'array'`) via
58
+ * {@link collapseNullableType}, recursing through `properties` and array items. The `required` list
59
+ * already conveys optionality, so the `'null'` is redundant noise for the model.
71
60
  *
72
61
  * @example
73
- * { properties: { id: { type: 'string' }, tags: { type: ['array', 'null'], items: {} } }, required: ['id', 'tags'] }
74
- * → { properties: { tags: { type: 'array', items: {} } }, required: ['tags'] }
62
+ * { properties: { tags: { type: ['array', 'null'], items: {} } }, required: [] }
63
+ * → { properties: { tags: { type: 'array', items: {} } }, required: [] }
75
64
  */
76
- const removeManagedFields = (schema: JsonSchemaType): JsonSchemaType => {
65
+ const collapseOptionalContainerTypes = (schema: JsonSchemaType): JsonSchemaType => {
77
66
  if (schema.properties && typeof schema.properties === 'object') {
78
- for (const field of PAYLOAD_MANAGED_FIELDS) {
79
- delete schema.properties[field]
80
- }
81
67
  for (const key of Object.keys(schema.properties)) {
82
68
  const prop = schema.properties[key] as JsonSchemaType
83
69
  if (!prop || typeof prop !== 'object') {
@@ -86,21 +72,14 @@ const removeManagedFields = (schema: JsonSchemaType): JsonSchemaType => {
86
72
  const isRequired = Array.isArray(schema.required) && schema.required.includes(key)
87
73
  collapseNullableType(prop, isRequired)
88
74
  if (prop.properties) {
89
- removeManagedFields(prop)
75
+ collapseOptionalContainerTypes(prop)
90
76
  }
91
77
  if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
92
- removeManagedFields(prop.items)
78
+ collapseOptionalContainerTypes(prop.items)
93
79
  }
94
80
  }
95
81
  }
96
82
 
97
- if (Array.isArray(schema.required)) {
98
- schema.required = schema.required.filter((name) => !PAYLOAD_MANAGED_FIELDS.has(name))
99
- if (schema.required.length === 0) {
100
- delete schema.required
101
- }
102
- }
103
-
104
83
  return schema
105
84
  }
106
85
 
@@ -193,82 +172,6 @@ const pointFieldsToObjects = (schema: JsonSchemaType): JsonSchemaType => {
193
172
  return transformed
194
173
  }
195
174
 
196
- /**
197
- * **Correctness.** Reduces relationship/upload fields to the IDs a client actually sends. Payload types the value as
198
- * "an ID or the full related document" - but the populated-document form only appears in read responses;
199
- * on create/update you always reference a relationship by its ID. So we drop that `$ref` option, leaving
200
- * the bare ID. A single remaining target collapses inline (with a description naming the target
201
- * collection); several targets become an `anyOf` of IDs.
202
- *
203
- * @example
204
- * { oneOf: [{ type: 'string' }, { $ref: '#/$defs/posts' }] }
205
- * → { type: 'string', description: 'The ID of the related "posts" document.' }
206
- */
207
- const relationshipsToIds = (schema: JsonSchemaType): JsonSchemaType => {
208
- if (!schema || typeof schema !== 'object') {
209
- return schema
210
- }
211
-
212
- const processed = { ...schema }
213
-
214
- if (Array.isArray(processed.oneOf)) {
215
- const isRelatedDocRef = (option: unknown): option is { $ref: string } =>
216
- !!option && typeof option === 'object' && '$ref' in option
217
-
218
- if (processed.oneOf.some(isRelatedDocRef)) {
219
- // A relationship value is "an ID, or the populated related document". Keep the ID option(s) and
220
- // drop the `$ref`s to the related collections, since a client only ever sends the ID.
221
- const idOptions = processed.oneOf
222
- .filter((option) => !isRelatedDocRef(option))
223
- .map((option) => (typeof option === 'object' ? relationshipsToIds(option) : option))
224
- const targetCollections = processed.oneOf
225
- .filter(isRelatedDocRef)
226
- .map((option) => option.$ref.replace('#/$defs/', ''))
227
-
228
- if (idOptions.length === 1) {
229
- delete processed.oneOf
230
- Object.assign(processed, idOptions[0])
231
- if (targetCollections.length > 0 && !processed.description) {
232
- processed.description = `The ID of the related "${targetCollections.join('" or "')}" document.`
233
- }
234
- } else if (idOptions.length > 1) {
235
- delete processed.oneOf
236
- processed.anyOf = idOptions
237
- }
238
- } else {
239
- processed.oneOf = processed.oneOf.map((option) =>
240
- typeof option === 'object' ? relationshipsToIds(option) : option,
241
- )
242
- }
243
- }
244
-
245
- if (processed.properties && typeof processed.properties === 'object') {
246
- processed.properties = Object.fromEntries(
247
- Object.entries(processed.properties).map(([key, value]) => [
248
- key,
249
- typeof value === 'object' ? relationshipsToIds(value) : value,
250
- ]),
251
- )
252
- }
253
-
254
- if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
255
- processed.items = relationshipsToIds(processed.items)
256
- }
257
-
258
- // Lexical node unions and blocks live under `$defs` and have their own relationship fields, so walk
259
- // those too — otherwise their `$ref`s would dangle once we don't bundle the related collections.
260
- if (processed.$defs && typeof processed.$defs === 'object') {
261
- processed.$defs = Object.fromEntries(
262
- Object.entries(processed.$defs).map(([key, value]) => [
263
- key,
264
- typeof value === 'object' ? relationshipsToIds(value) : value,
265
- ]),
266
- )
267
- }
268
-
269
- return processed
270
- }
271
-
272
175
  /**
273
176
  * **Size.** Strips type-generation leftovers that bloat the schema without helping the model: the `tsType`
274
177
  * hint (a `json-schema-to-typescript` extension; JSON Schema validators just ignore it, they don't reject it)
@@ -448,7 +351,7 @@ const deduplicateIntoDefinitions = (schema: JsonSchemaType): JsonSchemaType => {
448
351
  if (!name) {
449
352
  name = `shared_${nameByKey.size}`
450
353
  nameByKey.set(key, name)
451
- sharedEntries[name] = node as JsonSchemaType
354
+ sharedEntries[name] = node
452
355
  }
453
356
  return { $ref: `#/$defs/${name}` }
454
357
  }
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=assets.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/@types/assets.d.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- import type { AuthorizedMCP } from '../types.js';
2
- /**
3
- * Returns the `user` and `overrideAccess` arguments every Payload local API call
4
- * should receive when initiated from an MCP request. Spread the result into the
5
- * call's arg object so the two pieces of caller state can't drift apart.
6
- *
7
- * @example
8
- * ```ts
9
- * await req.payload.create({
10
- * collection: 'posts',
11
- * data,
12
- * ...localAPIDefaults(authorizedMCP),
13
- * })
14
- * ```
15
- */
16
- export declare const localAPIDefaults: (authorizedMCP: AuthorizedMCP) => {
17
- overrideAccess: boolean;
18
- user: AuthorizedMCP["user"];
19
- };
20
- //# sourceMappingURL=localAPIDefaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localAPIDefaults.d.ts","sourceRoot":"","sources":["../../src/utils/localAPIDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,aAAa,KAC3B;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAGvD,CAAA"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Returns the `user` and `overrideAccess` arguments every Payload local API call
3
- * should receive when initiated from an MCP request. Spread the result into the
4
- * call's arg object so the two pieces of caller state can't drift apart.
5
- *
6
- * @example
7
- * ```ts
8
- * await req.payload.create({
9
- * collection: 'posts',
10
- * data,
11
- * ...localAPIDefaults(authorizedMCP),
12
- * })
13
- * ```
14
- */ export const localAPIDefaults = (authorizedMCP)=>({
15
- overrideAccess: authorizedMCP.overrideAccess,
16
- user: authorizedMCP.user
17
- });
18
-
19
- //# sourceMappingURL=localAPIDefaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/localAPIDefaults.ts"],"sourcesContent":["import type { AuthorizedMCP } from '../types.js'\n\n/**\n * Returns the `user` and `overrideAccess` arguments every Payload local API call\n * should receive when initiated from an MCP request. Spread the result into the\n * call's arg object so the two pieces of caller state can't drift apart.\n *\n * @example\n * ```ts\n * await req.payload.create({\n * collection: 'posts',\n * data,\n * ...localAPIDefaults(authorizedMCP),\n * })\n * ```\n */\nexport const localAPIDefaults = (\n authorizedMCP: AuthorizedMCP,\n): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({\n overrideAccess: authorizedMCP.overrideAccess,\n user: authorizedMCP.user,\n})\n"],"names":["localAPIDefaults","authorizedMCP","overrideAccess","user"],"mappings":"AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMA,mBAAmB,CAC9BC,gBAC8D,CAAA;QAC9DC,gBAAgBD,cAAcC,cAAc;QAC5CC,MAAMF,cAAcE,IAAI;IAC1B,CAAA,EAAE"}
@@ -1,7 +0,0 @@
1
- import type { JsonSchemaType } from '../../types.js';
2
- /**
3
- * Removes virtual fields from a JSON Schema by name so they don't appear
4
- * in the generated MCP tool input schema.
5
- */
6
- export declare function removeVirtualFieldsFromSchema(schema: JsonSchemaType, virtualFieldNames: string[]): JsonSchemaType;
7
- //# sourceMappingURL=removeVirtualFieldsFromSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeVirtualFieldsFromSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,cAAc,EACtB,iBAAiB,EAAE,MAAM,EAAE,GAC1B,cAAc,CAiBhB"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Removes virtual fields from a JSON Schema by name so they don't appear
3
- * in the generated MCP tool input schema.
4
- */ export function removeVirtualFieldsFromSchema(schema, virtualFieldNames) {
5
- if (virtualFieldNames.length === 0) {
6
- return schema;
7
- }
8
- for (const name of virtualFieldNames){
9
- delete schema?.properties?.[name];
10
- }
11
- if (Array.isArray(schema.required)) {
12
- schema.required = schema.required.filter((field)=>!virtualFieldNames.includes(field));
13
- if (schema.required.length === 0) {
14
- delete schema.required;
15
- }
16
- }
17
- return schema;
18
- }
19
-
20
- //# sourceMappingURL=removeVirtualFieldsFromSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes virtual fields from a JSON Schema by name so they don't appear\n * in the generated MCP tool input schema.\n */\nexport function removeVirtualFieldsFromSchema(\n schema: JsonSchemaType,\n virtualFieldNames: string[],\n): JsonSchemaType {\n if (virtualFieldNames.length === 0) {\n return schema\n }\n\n for (const name of virtualFieldNames) {\n delete schema?.properties?.[name]\n }\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n return schema\n}\n"],"names":["removeVirtualFieldsFromSchema","schema","virtualFieldNames","length","name","properties","Array","isArray","required","filter","field","includes"],"mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,8BACdC,MAAsB,EACtBC,iBAA2B;IAE3B,IAAIA,kBAAkBC,MAAM,KAAK,GAAG;QAClC,OAAOF;IACT;IAEA,KAAK,MAAMG,QAAQF,kBAAmB;QACpC,OAAOD,QAAQI,YAAY,CAACD,KAAK;IACnC;IAEA,IAAIE,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAU,CAACR,kBAAkBS,QAAQ,CAACD;QAChF,IAAIT,OAAOO,QAAQ,CAACL,MAAM,KAAK,GAAG;YAChC,OAAOF,OAAOO,QAAQ;QACxB;IACF;IAEA,OAAOP;AACT"}
@@ -1,3 +0,0 @@
1
- declare module '*.css'
2
-
3
- declare module '*.scss'
@@ -1,22 +0,0 @@
1
- import type { AuthorizedMCP } from '../types.js'
2
-
3
- /**
4
- * Returns the `user` and `overrideAccess` arguments every Payload local API call
5
- * should receive when initiated from an MCP request. Spread the result into the
6
- * call's arg object so the two pieces of caller state can't drift apart.
7
- *
8
- * @example
9
- * ```ts
10
- * await req.payload.create({
11
- * collection: 'posts',
12
- * data,
13
- * ...localAPIDefaults(authorizedMCP),
14
- * })
15
- * ```
16
- */
17
- export const localAPIDefaults = (
18
- authorizedMCP: AuthorizedMCP,
19
- ): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({
20
- overrideAccess: authorizedMCP.overrideAccess,
21
- user: authorizedMCP.user,
22
- })
@@ -1,27 +0,0 @@
1
- import type { JsonSchemaType } from '../../types.js'
2
-
3
- /**
4
- * Removes virtual fields from a JSON Schema by name so they don't appear
5
- * in the generated MCP tool input schema.
6
- */
7
- export function removeVirtualFieldsFromSchema(
8
- schema: JsonSchemaType,
9
- virtualFieldNames: string[],
10
- ): JsonSchemaType {
11
- if (virtualFieldNames.length === 0) {
12
- return schema
13
- }
14
-
15
- for (const name of virtualFieldNames) {
16
- delete schema?.properties?.[name]
17
- }
18
-
19
- if (Array.isArray(schema.required)) {
20
- schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))
21
- if (schema.required.length === 0) {
22
- delete schema.required
23
- }
24
- }
25
-
26
- return schema
27
- }