@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.
- package/LICENSE.md +1 -1
- 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 +2 -7
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +4 -11
- 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 +57 -17
- package/dist/endpoint/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- 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 +32 -10
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countTool.js +1 -2
- package/dist/mcp/builtin/collections/countTool.js.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.js +1 -2
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +14 -5
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +1 -2
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.js +1 -2
- package/dist/mcp/builtin/collections/duplicateTool.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/findDistinctTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findDistinctTool.js +1 -2
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +3 -4
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +1 -2
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.js +1 -2
- package/dist/mcp/builtin/collections/findVersionsTool.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 +44 -5
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.js +1 -2
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +23 -11
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +2 -5
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.js +1 -2
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +2 -2
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +1 -2
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.js +1 -2
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +21 -3
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.js +1 -2
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +2 -2
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
- package/dist/mcp/builtin/validateEntityData.js +1 -1
- package/dist/mcp/builtin/validateEntityData.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +1 -0
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -4
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +59 -41
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +57 -9
- 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/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 +5 -3
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +9 -11
- package/src/endpoint/access.ts +3 -10
- package/src/endpoint/index.ts +45 -16
- package/src/index.ts +4 -4
- package/src/mcp/buildMcpServer.ts +40 -20
- package/src/mcp/builtin/collections/countTool.ts +1 -2
- package/src/mcp/builtin/collections/countVersionsTool.ts +1 -2
- package/src/mcp/builtin/collections/createTool.ts +14 -5
- package/src/mcp/builtin/collections/deleteTool.ts +1 -2
- package/src/mcp/builtin/collections/duplicateTool.ts +1 -2
- package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
- package/src/mcp/builtin/collections/fileInput.ts +139 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +1 -2
- package/src/mcp/builtin/collections/findTool.ts +3 -4
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +1 -2
- package/src/mcp/builtin/collections/findVersionsTool.ts +1 -2
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +39 -9
- package/src/mcp/builtin/collections/restoreVersionTool.ts +1 -2
- package/src/mcp/builtin/collections/updateTool.ts +25 -9
- package/src/mcp/builtin/getConfigInfoTool.ts +2 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +1 -2
- package/src/mcp/builtin/globals/findTool.ts +2 -2
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +1 -2
- package/src/mcp/builtin/globals/findVersionsTool.ts +1 -2
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +25 -3
- package/src/mcp/builtin/globals/restoreVersionTool.ts +1 -2
- package/src/mcp/builtin/globals/updateTool.ts +2 -2
- package/src/mcp/builtin/validateEntityData.ts +1 -1
- package/src/mcp/sanitizeMCPConfig.ts +1 -0
- package/src/stdio.ts +59 -42
- package/src/types.ts +57 -9
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- 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/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/src/@types/assets.d.ts +0 -3
- package/src/utils/localAPIDefaults.ts +0 -22
- 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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
|
-
//
|
|
20
|
-
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
|
|
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
|
-
* **
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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: {
|
|
74
|
-
* → { properties: { tags: { type: 'array', items: {} } }, required: [
|
|
62
|
+
* { properties: { tags: { type: ['array', 'null'], items: {} } }, required: [] }
|
|
63
|
+
* → { properties: { tags: { type: 'array', items: {} } }, required: [] }
|
|
75
64
|
*/
|
|
76
|
-
const
|
|
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
|
-
|
|
75
|
+
collapseOptionalContainerTypes(prop)
|
|
90
76
|
}
|
|
91
77
|
if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
|
|
92
|
-
|
|
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
|
|
354
|
+
sharedEntries[name] = node
|
|
452
355
|
}
|
|
453
356
|
return { $ref: `#/$defs/${name}` }
|
|
454
357
|
}
|
package/dist/@types/assets.d.js
DELETED
|
@@ -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"}
|
package/src/@types/assets.d.ts
DELETED
|
@@ -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
|
-
}
|