@payloadcms/plugin-mcp 4.0.0-internal.8867dba → 4.0.0-internal.8ba6b5b
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 +0 -7
- 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 +4 -14
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- 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 +2 -24
- 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 +9 -22
- 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 +0 -6
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +0 -6
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +1 -4
- package/dist/mcp/sanitizeMCPConfig.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.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 +4 -14
- package/src/mcp/builtin/collections/findTool.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +1 -18
- package/src/mcp/builtin/collections/updateTool.ts +7 -24
- package/src/mcp/builtinTools.ts +0 -7
- package/src/mcp/sanitizeMCPConfig.ts +1 -4
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +2 -2
- package/dist/mcp/builtin/collections/fileInput.d.ts +0 -28
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/fileInput.js +0 -117
- package/dist/mcp/builtin/collections/fileInput.js.map +0 -1
- package/dist/mcp/builtin/collections/fileInput.spec.js +0 -86
- package/dist/mcp/builtin/collections/fileInput.spec.js.map +0 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +0 -2
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +0 -55
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +0 -1
- package/src/mcp/builtin/collections/fileInput.spec.ts +0 -93
- package/src/mcp/builtin/collections/fileInput.ts +0 -154
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +0 -64
package/bin.js
CHANGED
|
@@ -27,13 +27,6 @@ const start = async () => {
|
|
|
27
27
|
return
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// tsx 4.22.4's synchronous loader leaks its namespace query onto Node built-ins on Node 23.5+.
|
|
31
|
-
// Force the stable asynchronous loader path, matching payload/bin.js.
|
|
32
|
-
const nodeModule = await import('node:module')
|
|
33
|
-
if (typeof nodeModule.default.registerHooks === 'function') {
|
|
34
|
-
nodeModule.default.registerHooks = undefined
|
|
35
|
-
}
|
|
36
|
-
|
|
37
30
|
const { tsImport } = await import('tsx/esm/api')
|
|
38
31
|
const { runMcpStdio } = await tsImport('./dist/stdio.js', baseURL)
|
|
39
32
|
await runMcpStdio()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultAccess.d.ts","sourceRoot":"","sources":["../src/defaultAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"defaultAccess.d.ts","sourceRoot":"","sources":["../src/defaultAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,aAAa,GAAI,SAAS,aAAa,KAAG,OAA4B,CAAA"}
|
package/dist/defineTool.d.ts
CHANGED
|
@@ -11,16 +11,16 @@ import type { CollectionTool, GlobalTool, Prompt, Tool, ToolInputSchema } from '
|
|
|
11
11
|
* Config and handler signatures are derived from `Tool` / `CollectionTool` / `GlobalTool` /
|
|
12
12
|
* `Prompt` via `Omit` + indexed access so there's no duplication with `types.ts`.
|
|
13
13
|
*/
|
|
14
|
-
export declare const defineTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<Tool<TSchema>,
|
|
15
|
-
handler: (fn: Tool<TSchema>[
|
|
14
|
+
export declare const defineTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<Tool<TSchema>, "handler">) => {
|
|
15
|
+
handler: (fn: Tool<TSchema>["handler"]) => Tool;
|
|
16
16
|
};
|
|
17
|
-
export declare const defineCollectionTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<CollectionTool<TSchema>,
|
|
18
|
-
handler: (fn: CollectionTool<TSchema>[
|
|
17
|
+
export declare const defineCollectionTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<CollectionTool<TSchema>, "handler">) => {
|
|
18
|
+
handler: (fn: CollectionTool<TSchema>["handler"]) => CollectionTool;
|
|
19
19
|
};
|
|
20
|
-
export declare const defineGlobalTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<GlobalTool<TSchema>,
|
|
21
|
-
handler: (fn: GlobalTool<TSchema>[
|
|
20
|
+
export declare const defineGlobalTool: <TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined>(args: Omit<GlobalTool<TSchema>, "handler">) => {
|
|
21
|
+
handler: (fn: GlobalTool<TSchema>["handler"]) => GlobalTool;
|
|
22
22
|
};
|
|
23
|
-
export declare const definePrompt: <TSchema extends ToolInputSchema = ToolInputSchema>(args: Omit<Prompt<TSchema>,
|
|
24
|
-
handler: (fn: Prompt<TSchema>[
|
|
23
|
+
export declare const definePrompt: <TSchema extends ToolInputSchema = ToolInputSchema>(args: Omit<Prompt<TSchema>, "handler">) => {
|
|
24
|
+
handler: (fn: Prompt<TSchema>["handler"]) => Prompt;
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=defineTool.d.ts.map
|
package/dist/defineTool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineTool.d.ts","sourceRoot":"","sources":["../src/defineTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE3F;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,UAAU,GACrB,OAAO,SAAS,eAAe,GAAG,SAAS,GAAG,eAAe,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"defineTool.d.ts","sourceRoot":"","sources":["../src/defineTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM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AA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIzD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,aAAa,CAkCnF,CAAA;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/endpoint/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAIzD,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,aAAa,CAkCnF,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,iCAIlC;IACD,KAAK,EAAE,OAAO,EAAE,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,OAAO,CAAC,OAAO,EAAE,CAkBpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildMcpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/buildMcpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAGvD,OAAO,KAAK,EACV,aAAa,EAMb,wBAAwB,EAEzB,MAAM,aAAa,CAAA;AAKpB;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"buildMcpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/buildMcpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAGvD,OAAO,KAAK,EACV,aAAa,EAMb,wBAAwB,EAEzB,MAAM,aAAa,CAAA;AAKpB;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,uCAI5B;IACD,aAAa,EAAE,aAAa,CAAA;IAC5B,YAAY,EAAE,wBAAwB,CAAA;IACtC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,SAkNH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,kBAAkB,4CA4F7B,CAAA"}
|
|
@@ -5,9 +5,8 @@ import { getLogger } from '../../../utils/getLogger.js';
|
|
|
5
5
|
import { getCollectionVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
|
|
6
6
|
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
|
|
7
7
|
import { validateCollectionData } from '../validateEntityData.js';
|
|
8
|
-
import { fileInputSchema, resolveFile } from './fileInput.js';
|
|
9
8
|
import { formatCollectionError } from './formatCollectionError.js';
|
|
10
|
-
const DEFAULT_DESCRIPTION = 'Create a document in any collection
|
|
9
|
+
const DEFAULT_DESCRIPTION = 'Create a document in any collection by passing the collection slug and data.';
|
|
11
10
|
export const createDocumentTool = defineCollectionTool({
|
|
12
11
|
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.create),
|
|
13
12
|
annotations: {
|
|
@@ -19,11 +18,10 @@ export const createDocumentTool = defineCollectionTool({
|
|
|
19
18
|
},
|
|
20
19
|
description: DEFAULT_DESCRIPTION,
|
|
21
20
|
input: z.object({
|
|
22
|
-
data: z.record(z.string(), z.unknown()).describe('The document fields to create
|
|
21
|
+
data: z.record(z.string(), z.unknown()).describe('The document fields to create'),
|
|
23
22
|
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in response').optional().default(0),
|
|
24
|
-
draft: z.boolean().describe('
|
|
23
|
+
draft: z.boolean().describe('Whether to create the document as a draft').optional().default(false),
|
|
25
24
|
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
26
|
-
file: fileInputSchema.optional(),
|
|
27
25
|
locale: z.string().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
|
|
28
26
|
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return, e.g., {"title": true}').optional()
|
|
29
27
|
})
|
|
@@ -32,7 +30,7 @@ export const createDocumentTool = defineCollectionTool({
|
|
|
32
30
|
const logger = getLogger({
|
|
33
31
|
payload
|
|
34
32
|
});
|
|
35
|
-
const { data, depth, draft, fallbackLocale,
|
|
33
|
+
const { data, depth, draft, fallbackLocale, locale, select } = input;
|
|
36
34
|
logger.info(`Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`);
|
|
37
35
|
try {
|
|
38
36
|
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug);
|
|
@@ -46,11 +44,6 @@ export const createDocumentTool = defineCollectionTool({
|
|
|
46
44
|
return validationError;
|
|
47
45
|
}
|
|
48
46
|
const parsedData = transformPointDataToPayload(inputData);
|
|
49
|
-
const file = await resolveFile({
|
|
50
|
-
collectionSlug,
|
|
51
|
-
input: fileInput,
|
|
52
|
-
req
|
|
53
|
-
});
|
|
54
47
|
const result = await payload.create({
|
|
55
48
|
collection: collectionSlug,
|
|
56
49
|
data: parsedData,
|
|
@@ -58,9 +51,6 @@ export const createDocumentTool = defineCollectionTool({
|
|
|
58
51
|
draft,
|
|
59
52
|
overrideAccess: authorizedMCP.overrideAccess,
|
|
60
53
|
req,
|
|
61
|
-
...file ? {
|
|
62
|
-
file
|
|
63
|
-
} : {},
|
|
64
54
|
...locale ? {
|
|
65
55
|
locale
|
|
66
56
|
} : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Create a document in any collection by passing the collection slug and data.'\n\nexport const createDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.create),\n annotations: {\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Create Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n data: z.record(z.string(), z.unknown()).describe('The document fields to create'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Whether to create the document as a draft')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return, e.g., {\"title\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,\n )\n\n try {\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({ collectionSlug, data: inputData, req })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`)\n\n return {\n content: [\n {\n type: 'text',\n text: `Document created successfully in collection \"${collectionSlug}\"!\\nCreated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'creating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","transformPointDataToPayload","validateCollectionData","formatCollectionError","DEFAULT_DESCRIPTION","createDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","create","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","data","record","string","unknown","describe","depth","number","int","min","max","optional","default","draft","boolean","fallbackLocale","locale","select","handler","authorizedMCP","req","payload","logger","info","virtualFieldNames","config","inputData","validationError","parsedData","result","collection","overrideAccess","id","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,qBAAqBR,qBAAqB;IACrDS,QAAQ,CAACC,OACPX,cAAcW,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,cAAc,CAAC,EAAEC;IACvFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOzB,EAAE0B,MAAM,CAAC;QACdC,MAAM3B,EAAE4B,MAAM,CAAC5B,EAAE6B,MAAM,IAAI7B,EAAE8B,OAAO,IAAIC,QAAQ,CAAC;QACjDC,OAAOhC,EACJiC,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IAC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AI,CAAC,CAAC;YAC5C,GAAIE,SAAS;gBAAEA,QAAQA;YAAqB,IAAI,CAAC,CAAC;QACpD;QAEAK,OAAOC,IAAI,CAAC,CAAC,iCAAiC,EAAEjC,eAAe,UAAU,EAAEuC,OAAOG,EAAE,EAAE;QAEtF,OAAO;YACLC,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6CAA6C,EAAE7C,eAAe,mCAAmC,EAAE8C,KAAKC,SAAS,CAACR,QAAQ,QAAQ,CAAC;gBAC5I;aACD;YACDS,KAAKT;QACP;IACF,EAAE,OAAOU,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DpB,OAAOiB,KAAK,CAAC,CAAC,2BAA2B,EAAEjD,eAAe,EAAE,EAAEkD,cAAc;QAC5E,OAAO1D,sBAAsB;YAAE6D,QAAQ;YAAYrD;YAAgBiD;YAAOnB;QAAI;IAChF;AACF,GAAE"}
|
|
@@ -20,7 +20,7 @@ export const findDocumentsTool = defineCollectionTool({
|
|
|
20
20
|
z.number()
|
|
21
21
|
]).describe('Optional: specific document ID to retrieve. If not provided, returns all documents').optional(),
|
|
22
22
|
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships (default: 0)').optional().default(0),
|
|
23
|
-
draft: z.boolean().describe('
|
|
23
|
+
draft: z.boolean().describe('Optional: whether the document should be queried from the versions table/collection or not.').optional(),
|
|
24
24
|
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
25
25
|
joins: z.union([
|
|
26
26
|
z.record(z.string(), z.unknown()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/findTool.ts"],"sourcesContent":["import type { JoinQuery, PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find documents in any collection by passing the collection slug and optional ID or where clause.'\n\nexport const findDocumentsTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.read),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Documents',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z\n .union([z.string(), z.number()])\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n )\n .optional(),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships (default: 0)')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'For versioned collections, true returns the latest draft version when available. False reads the main document.',\n )\n .optional(),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n joins: z\n .union([z.record(z.string(), z.unknown()), z.literal(false)])\n .describe('Optional: configure join field queries, or pass false to disable all join fields.')\n .optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .describe('Maximum number of documents to return (default: 10, max: 100)')\n .optional()\n .default(10),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n )\n .optional(),\n page: z\n .number()\n .int()\n .min(1)\n .describe('Page number for pagination (default: 1)')\n .optional()\n .default(1),\n pagination: z\n .boolean()\n .describe('Optional: set to false to skip the count query overhead')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n sort: z\n .string()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)')\n .optional(),\n trash: z\n .boolean()\n .describe('Optional: include soft-deleted documents when trash is enabled on the collection')\n .optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n joins,\n limit,\n locale,\n page,\n pagination,\n populate,\n select,\n sort,\n trash,\n where,\n } = input\n\n logger.info(\n `Reading document from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(select && { select: select as SelectType }),\n ...(populate && { populate: populate as PopulateType }),\n ...(joins !== undefined && { joins: joins as JoinQuery }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n ...(trash !== undefined && { trash }),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document from collection \"${collectionSlug}\":\\n${JSON.stringify(doc)}`,\n },\n ],\n doc: doc as Record<string, unknown>,\n }\n } catch {\n logger.warn(`Document not found with ID: ${id} in collection: ${collectionSlug}`)\n return {\n content: [\n {\n type: 'text',\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\n ],\n }\n }\n }\n\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(select && { select: select as SelectType }),\n ...(populate && { populate: populate as PopulateType }),\n ...(joins !== undefined && { joins: joins as JoinQuery }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n ...(pagination !== undefined && { pagination }),\n ...(trash !== undefined && { trash }),\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n if (where) {\n findOptions.where = where\n }\n\n const result = await payload.find(findOptions)\n\n let responseText = `Collection: \"${collectionSlug}\"\\nTotal: ${result.totalDocs} documents\\nPage: ${result.page} of ${result.totalPages}\\n`\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error reading documents from collection ${collectionSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error reading documents from collection \"${collectionSlug}\":** ${errorMessage}`,\n },\n ],\n }\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","whereSchema","DEFAULT_DESCRIPTION","findDocumentsTool","access","args","Boolean","permissions","collections","collectionSlug","read","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","depth","int","min","max","default","draft","boolean","fallbackLocale","joins","record","unknown","literal","limit","locale","page","pagination","populate","select","sort","trash","where","handler","authorizedMCP","req","payload","logger","info","doc","findByID","collection","overrideAccess","undefined","content","type","text","JSON","stringify","warn","findOptions","result","find","responseText","totalDocs","totalPages","docs","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,oBAAoBJ,qBAAqB;IACpDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,cAAc,CAAC,EAAEC;IACvFC,aAAa;QACXC,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,CAAC,EAAE,CAAC;QAC1I,KAAK,MAAMhB,OAAOY,OAAOK,IAAI,CAAE;YAC7BH,gBAAgB,CAAC,cAAc,EAAEN,KAAKC,SAAS,CAACT,KAAK,QAAQ,CAAC;QAChE;QAEA,OAAO;YACLK,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAMO;gBAAa;aAAE;YAC/Cd,KAAKY;QACP;IACF,EAAE,OAAOM,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DvB,OAAOoB,KAAK,CAAC,CAAC,wCAAwC,EAAE9D,eAAe,EAAE,EAAE+D,cAAc;QACzF,OAAO;YACLd,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,6CAA6C,EAAEnD,eAAe,KAAK,EAAE+D,cAAc;gBAC5F;aACD;QACH;IACF;AACF,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/findTool.ts"],"sourcesContent":["import type { JoinQuery, PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find documents in any collection by passing the collection slug and optional ID or where clause.'\n\nexport const findDocumentsTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.read),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Documents',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z\n .union([z.string(), z.number()])\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n )\n .optional(),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships (default: 0)')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n 'Optional: whether the document should be queried from the versions table/collection or not.',\n )\n .optional(),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n joins: z\n .union([z.record(z.string(), z.unknown()), z.literal(false)])\n .describe('Optional: configure join field queries, or pass false to disable all join fields.')\n .optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .describe('Maximum number of documents to return (default: 10, max: 100)')\n .optional()\n .default(10),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n )\n .optional(),\n page: z\n .number()\n .int()\n .min(1)\n .describe('Page number for pagination (default: 1)')\n .optional()\n .default(1),\n pagination: z\n .boolean()\n .describe('Optional: set to false to skip the count query overhead')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n sort: z\n .string()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)')\n .optional(),\n trash: z\n .boolean()\n .describe('Optional: include soft-deleted documents when trash is enabled on the collection')\n .optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n joins,\n limit,\n locale,\n page,\n pagination,\n populate,\n select,\n sort,\n trash,\n where,\n } = input\n\n logger.info(\n `Reading document from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(select && { select: select as SelectType }),\n ...(populate && { populate: populate as PopulateType }),\n ...(joins !== undefined && { joins: joins as JoinQuery }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n ...(trash !== undefined && { trash }),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document from collection \"${collectionSlug}\":\\n${JSON.stringify(doc)}`,\n },\n ],\n doc: doc as Record<string, unknown>,\n }\n } catch {\n logger.warn(`Document not found with ID: ${id} in collection: ${collectionSlug}`)\n return {\n content: [\n {\n type: 'text',\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\n ],\n }\n }\n }\n\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(select && { select: select as SelectType }),\n ...(populate && { populate: populate as PopulateType }),\n ...(joins !== undefined && { joins: joins as JoinQuery }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n ...(pagination !== undefined && { pagination }),\n ...(trash !== undefined && { trash }),\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n if (where) {\n findOptions.where = where\n }\n\n const result = await payload.find(findOptions)\n\n let responseText = `Collection: \"${collectionSlug}\"\\nTotal: ${result.totalDocs} documents\\nPage: ${result.page} of ${result.totalPages}\\n`\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error reading documents from collection ${collectionSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error reading documents from collection \"${collectionSlug}\":** ${errorMessage}`,\n },\n ],\n }\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","whereSchema","DEFAULT_DESCRIPTION","findDocumentsTool","access","args","Boolean","permissions","collections","collectionSlug","read","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","depth","int","min","max","default","draft","boolean","fallbackLocale","joins","record","unknown","literal","limit","locale","page","pagination","populate","select","sort","trash","where","handler","authorizedMCP","req","payload","logger","info","doc","findByID","collection","overrideAccess","undefined","content","type","text","JSON","stringify","warn","findOptions","result","find","responseText","totalDocs","totalPages","docs","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,oBAAoBJ,qBAAqB;IACpDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,cAAc,CAAC,EAAEC;IACvFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOrB,EAAEsB,MAAM,CAAC;QACdC,IAAIvB,EACDwB,KAAK,CAAC;YAACxB,EAAEyB,MAAM;YAAIzB,EAAE0B,MAAM;SAAG,EAC9BC,QAAQ,CACP,sFAEDC,QAAQ;QACXC,OAAO7B,EACJ0B,MAAM,GACNI,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJL,QAAQ,CAAC,+DACTC,QAAQ,GACRK,OAAO,CAAC;QACXC,OAAOlC,EACJmC,OAAO,GACPR,QAAQ,CACP,+FAEDC,QAAQ;QACXQ,gBAAgBpC,EACbyB,MAAM,GACNE,QAAQ,CAAC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AAEnD,eAAe,KAAK,EAAE+D,cAAc;gBAC5F;aACD;QACH;IACF;AACF,GAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CollectionSlug, PayloadRequest } from 'payload';
|
|
2
2
|
import type { MCPToolResponse } from '../../../types.js';
|
|
3
3
|
export declare const formatCollectionError: ({ action, collectionSlug, error, req, }: {
|
|
4
|
-
action:
|
|
4
|
+
action: "creating" | "duplicating" | "updating";
|
|
5
5
|
collectionSlug: CollectionSlug;
|
|
6
6
|
error: unknown;
|
|
7
7
|
req: PayloadRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatCollectionError.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/formatCollectionError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAgCxD,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"formatCollectionError.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/formatCollectionError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAgCxD,eAAO,MAAM,qBAAqB,GAAI,yCAKnC;IACD,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;IAC/C,cAAc,EAAE,cAAc,CAAA;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAuCH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,4CAwDlC,CAAA"}
|
|
@@ -48,38 +48,16 @@ export const getCollectionSchemaTool = defineCollectionTool({
|
|
|
48
48
|
isError: true
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
const uploadConfig = req.payload.collections[collectionSlug]?.config.upload;
|
|
52
|
-
const maxFileSize = req.payload.config.upload.limits?.fileSize;
|
|
53
|
-
const upload = uploadConfig ? {
|
|
54
|
-
enabled: true,
|
|
55
|
-
filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,
|
|
56
|
-
mimeTypes: uploadConfig.mimeTypes ?? [
|
|
57
|
-
'*/*'
|
|
58
|
-
],
|
|
59
|
-
sources: [
|
|
60
|
-
...uploadConfig.pasteURL !== false ? [
|
|
61
|
-
'externalURL'
|
|
62
|
-
] : [],
|
|
63
|
-
'base64',
|
|
64
|
-
'uploadReference'
|
|
65
|
-
],
|
|
66
|
-
...typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? {
|
|
67
|
-
maxFileSize
|
|
68
|
-
} : {}
|
|
69
|
-
} : {
|
|
70
|
-
enabled: false
|
|
71
|
-
};
|
|
72
51
|
return {
|
|
73
52
|
content: [
|
|
74
53
|
{
|
|
75
54
|
type: 'text',
|
|
76
|
-
text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n
|
|
55
|
+
text: `Schema for collection "${collectionSlug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``
|
|
77
56
|
}
|
|
78
57
|
],
|
|
79
58
|
structuredContent: {
|
|
80
59
|
collectionSlug,
|
|
81
|
-
schema: inputSchema
|
|
82
|
-
upload
|
|
60
|
+
schema: inputSchema
|
|
83
61
|
}
|
|
84
62
|
};
|
|
85
63
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.collectionSlug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n}).handler(async ({ authorizedMCP, collectionSlug, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[collectionSlug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${collectionSlug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${collectionSlug}\" not found` }],\n isError: true,\n }\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.collectionSlug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n}).handler(async ({ authorizedMCP, collectionSlug, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[collectionSlug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${collectionSlug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${collectionSlug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${collectionSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n collectionSlug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["getAccessResults","defaultAccess","defineCollectionTool","getCollectionInputSchema","getCollectionSchemaTool","access","args","permissions","collections","collectionSlug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,UAAS;AAE1C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,wBAAwB,QAAQ,0DAAyD;AAElG,OAAO,MAAMC,0BAA0BF,qBAAqB;IAC1DG,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,cAAc,CAAC;QAExE,OAAOR,cAAcK,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEZ,cAAc,EAAEa,GAAG,EAAE;IACtD,MAAMf,cAAcc,cAAcE,cAAc,GAC5C,OACA,AAAC,CAAA,MAAMvB,iBAAiB;QAAEsB;IAAI,EAAC,EAAGd,WAAW,EAAE,CAACC,eAAe;IAEnE,IAAI,CAACY,cAAcE,cAAc,IAAI,CAAChB,aAAaI,UAAU,CAACJ,aAAaK,QAAQ;QACjF,OAAO;YACLY,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,0EAA0E,EAAEjB,eAAe,CAAC,CAAC;gBACtG;aACD;YACDkB,SAAS;QACX;IACF;IAEA,MAAMC,cAAczB,yBAAyB;QAC3CM;QACAa;QACA,GAAIf,cAAc;YAAEA;QAAY,IAAI,CAAC,CAAC;IACxC;IAEA,IAAI,CAACqB,aAAa;QAChB,OAAO;YACLJ,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,mBAAmB,EAAEjB,eAAe,WAAW,CAAC;gBAAC;aAAE;YACpFkB,SAAS;QACX;IACF;IAEA,OAAO;QACLH,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAEjB,eAAe,gBAAgB,EAAEoB,KAAKC,SAAS,CAACF,aAAa,QAAQ,CAAC;YACxG;SACD;QACDG,mBAAmB;YACjBtB;YACAuB,QAAQJ;QACV;IACF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB,4CA6L7B,CAAA"}
|
|
@@ -7,9 +7,8 @@ import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEnt
|
|
|
7
7
|
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
|
|
8
8
|
import { whereSchema } from '../../../utils/whereSchema.js';
|
|
9
9
|
import { validateCollectionData } from '../validateEntityData.js';
|
|
10
|
-
import { fileInputSchema, resolveFile } from './fileInput.js';
|
|
11
10
|
import { formatCollectionError } from './formatCollectionError.js';
|
|
12
|
-
const DEFAULT_DESCRIPTION = 'Update documents in any collection
|
|
11
|
+
const DEFAULT_DESCRIPTION = 'Update documents in any collection by passing the collection slug and data.';
|
|
13
12
|
export const updateDocumentTool = defineCollectionTool({
|
|
14
13
|
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),
|
|
15
14
|
annotations: {
|
|
@@ -25,15 +24,14 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
25
24
|
z.string(),
|
|
26
25
|
z.number()
|
|
27
26
|
]).describe('The ID of the document to update').optional(),
|
|
28
|
-
data: z.record(z.string(), z.unknown()).describe('The fields to update
|
|
27
|
+
data: z.record(z.string(), z.unknown()).describe('The fields to update'),
|
|
29
28
|
depth: z.number().describe('How many levels deep to populate relationships').optional().default(0),
|
|
30
|
-
draft: z.boolean().describe('
|
|
29
|
+
draft: z.boolean().describe('Whether to update the document as a draft').optional().default(false),
|
|
31
30
|
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
32
|
-
|
|
31
|
+
filePath: z.string().describe('File path for file uploads').optional(),
|
|
33
32
|
locale: z.string().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
|
|
34
33
|
overrideLock: z.boolean().describe('Whether to override document locks').optional().default(true),
|
|
35
34
|
overwriteExistingFiles: z.boolean().describe('Whether to overwrite existing files').optional().default(false),
|
|
36
|
-
publishAllLocales: z.boolean().describe('For collections with localized publishing status, whether publishing should affect every locale. Set false with locale to publish only that locale.').optional(),
|
|
37
35
|
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}').optional(),
|
|
38
36
|
where: whereSchema.describe('Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}').optional()
|
|
39
37
|
})
|
|
@@ -42,7 +40,7 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
42
40
|
const logger = getLogger({
|
|
43
41
|
payload
|
|
44
42
|
});
|
|
45
|
-
const { id, data, depth, draft, fallbackLocale,
|
|
43
|
+
const { id, data, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, select, where } = input;
|
|
46
44
|
logger.info(`Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
|
|
47
45
|
try {
|
|
48
46
|
if (!id && !where) {
|
|
@@ -67,11 +65,6 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
67
65
|
return validationError;
|
|
68
66
|
}
|
|
69
67
|
const parsedData = transformPointDataToPayload(inputData);
|
|
70
|
-
const file = await resolveFile({
|
|
71
|
-
collectionSlug,
|
|
72
|
-
input: fileInput,
|
|
73
|
-
req
|
|
74
|
-
});
|
|
75
68
|
const whereClause = where ?? {};
|
|
76
69
|
if (id) {
|
|
77
70
|
const result = await payload.update({
|
|
@@ -83,15 +76,12 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
83
76
|
overrideAccess: authorizedMCP.overrideAccess,
|
|
84
77
|
overrideLock,
|
|
85
78
|
req,
|
|
86
|
-
...
|
|
87
|
-
|
|
79
|
+
...filePath ? {
|
|
80
|
+
filePath
|
|
88
81
|
} : {},
|
|
89
82
|
...overwriteExistingFiles ? {
|
|
90
83
|
overwriteExistingFiles
|
|
91
84
|
} : {},
|
|
92
|
-
...publishAllLocales !== undefined ? {
|
|
93
|
-
publishAllLocales
|
|
94
|
-
} : {},
|
|
95
85
|
...locale ? {
|
|
96
86
|
locale
|
|
97
87
|
} : {},
|
|
@@ -121,15 +111,12 @@ export const updateDocumentTool = defineCollectionTool({
|
|
|
121
111
|
overrideLock,
|
|
122
112
|
req,
|
|
123
113
|
where: whereClause,
|
|
124
|
-
...
|
|
125
|
-
|
|
114
|
+
...filePath ? {
|
|
115
|
+
filePath
|
|
126
116
|
} : {},
|
|
127
117
|
...overwriteExistingFiles ? {
|
|
128
118
|
overwriteExistingFiles
|
|
129
119
|
} : {},
|
|
130
|
-
...publishAllLocales !== undefined ? {
|
|
131
|
-
publishAllLocales
|
|
132
|
-
} : {},
|
|
133
120
|
...locale ? {
|
|
134
121
|
locale
|
|
135
122
|
} : {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { SelectType, Where } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { fileInputSchema, resolveFile } from './fileInput.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents in any collection. Files can use a URL, base64, or an upload prepared by getUploadInstructions.'\n\nexport const updateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),\n data: z\n .record(z.string(), z.unknown())\n .describe(\n 'The fields to update. Only include fields permitted by the schema returned by getCollectionSchema.',\n ),\n depth: z\n .number()\n .describe('How many levels deep to populate relationships')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe(\n '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.',\n )\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n file: fileInputSchema.optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n overrideLock: z\n .boolean()\n .describe('Whether to override document locks')\n .optional()\n .default(true),\n overwriteExistingFiles: z\n .boolean()\n .describe('Whether to overwrite existing files')\n .optional()\n .default(false),\n publishAllLocales: z\n .boolean()\n .describe(\n 'For collections with localized publishing status, whether publishing should affect every locale. Set false with locale to publish only that locale.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n where: whereSchema\n .describe(\n 'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n file: fileInput,\n locale,\n overrideLock,\n overwriteExistingFiles,\n publishAllLocales,\n select,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (!id && !where) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({\n collectionSlug,\n data: inputData,\n partial: true,\n req,\n })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n const file = await resolveFile({ collectionSlug, input: fileInput, req })\n\n const whereClause: Where = where ?? {}\n\n if (id) {\n const result = await payload.update({\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n ...(file ? { file } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${collectionSlug}\"!\\nUpdated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n const result = await payload.update({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n where: whereClause,\n ...(file ? { file } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(publishAllLocales !== undefined ? { publishAllLocales } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n collectionSlug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'updating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","getCollectionInputSchema","transformPointDataToPayload","whereSchema","validateCollectionData","fileInputSchema","resolveFile","formatCollectionError","DEFAULT_DESCRIPTION","updateDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","data","record","unknown","depth","default","draft","boolean","fallbackLocale","file","locale","overrideLock","overwriteExistingFiles","publishAllLocales","select","where","handler","authorizedMCP","req","payload","logger","fileInput","info","content","type","text","virtualFieldNames","config","inputData","validationError","partial","parsedData","whereClause","result","collection","overrideAccess","undefined","JSON","stringify","doc","docs","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,wBAAwB,QAA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
{"version":3,"sources":["../../../../src/mcp/builtin/collections/updateTool.ts"],"sourcesContent":["import type { SelectType, Where } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\nimport { validateCollectionData } from '../validateEntityData.js'\nimport { formatCollectionError } from './formatCollectionError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Update documents in any collection by passing the collection slug and data.'\n\nexport const updateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.collectionSlug]?.update),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Update Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.union([z.string(), z.number()]).describe('The ID of the document to update').optional(),\n data: z.record(z.string(), z.unknown()).describe('The fields to update'),\n depth: z\n .number()\n .describe('How many levels deep to populate relationships')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Whether to update the document as a draft')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n filePath: z.string().describe('File path for file uploads').optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n overrideLock: z\n .boolean()\n .describe('Whether to override document locks')\n .optional()\n .default(true),\n overwriteExistingFiles: z\n .boolean()\n .describe('Whether to overwrite existing files')\n .optional()\n .default(false),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n where: whereSchema\n .describe(\n 'Where clause to update multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {\"title\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const {\n id,\n data,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\n select,\n where,\n } = input\n\n logger.info(\n `Updating document in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (!id && !where) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n const inputData = stripVirtualFields(data, virtualFieldNames)\n const validationError = validateCollectionData({\n collectionSlug,\n data: inputData,\n partial: true,\n req,\n })\n\n if (validationError) {\n return validationError\n }\n\n const parsedData = transformPointDataToPayload(inputData)\n\n const whereClause: Where = where ?? {}\n\n if (id) {\n const result = await payload.update({\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document updated successfully in collection \"${collectionSlug}\"!\\nUpdated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n const result = await payload.update({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n overrideLock,\n req,\n where: whereClause,\n ...(filePath ? { filePath } : {}),\n ...(overwriteExistingFiles ? { overwriteExistingFiles } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(select ? { select: select as SelectType } : {}),\n })\n\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\\nUpdated: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n\n const errorSchema = getCollectionInputSchema({ collectionSlug, req })\n\n if (errorSchema) {\n responseText += `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(errorSchema)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n isError: true,\n ...(errorSchema\n ? {\n structuredContent: {\n collectionSlug,\n docs,\n errors,\n schema: errorSchema,\n },\n }\n : {}),\n }\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error updating document in ${collectionSlug}: ${errorMessage}`)\n return formatCollectionError({ action: 'updating', collectionSlug, error, req })\n }\n})\n"],"names":["z","defaultAccess","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","getCollectionInputSchema","transformPointDataToPayload","whereSchema","validateCollectionData","formatCollectionError","DEFAULT_DESCRIPTION","updateDocumentTool","access","args","Boolean","permissions","collections","collectionSlug","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","union","string","number","describe","optional","data","record","unknown","depth","default","draft","boolean","fallbackLocale","filePath","locale","overrideLock","overwriteExistingFiles","select","where","handler","authorizedMCP","req","payload","logger","info","content","type","text","virtualFieldNames","config","inputData","validationError","partial","parsedData","whereClause","result","collection","overrideAccess","JSON","stringify","doc","docs","errors","responseText","length","errorSchema","isError","structuredContent","schema","error","errorMessage","Error","message","action"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,wBAAwB,QAAQ,0DAAyD;AAClG,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,WAAW,QAAQ,gCAA+B;AAC3D,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE,MAAMC,sBACJ;AAEF,OAAO,MAAMC,qBAAqBV,qBAAqB;IACrDW,QAAQ,CAACC,OACPb,cAAca,SAASC,QAAQD,KAAKE,WAAW,EAAEC,aAAa,CAACH,KAAKI,cAAc,CAAC,EAAEC;IACvFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAO3B,EAAE4B,MAAM,CAAC;QACdC,IAAI7B,EAAE8B,KAAK,CAAC;YAAC9B,EAAE+B,MAAM;YAAI/B,EAAEgC,MAAM;SAAG,EAAEC,QAAQ,CAAC,oCAAoCC,QAAQ;QAC3FC,MAAMnC,EAAEoC,MAAM,CAACpC,EAAE+B,MAAM,IAAI/B,EAAEqC,OAAO,IAAIJ,QAAQ,CAAC;QACjDK,OAAOtC,EACJgC,MAAM,GACNC,QAAQ,CAAC,kDACTC,QAAQ,GACRK,OAAO,CAAC;QACXC,OAAOxC,EACJyC,OAAO,GACPR,QAAQ,CAAC,6CACTC,QAAQ,GACRK,OAAO,CAAC;QACXG,gBAAgB1C,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Q;YAAYjE;YAAgB6D;YAAO5B;QAAI;IAChF;AACF,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAI1F,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAuBrE,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"validateEntityData.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/validateEntityData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAI1F,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAuBrE,eAAO,MAAM,sBAAsB,GAAI,yCAKpC;IACD,cAAc,EAAE,cAAc,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA;AAEJ,eAAO,MAAM,kBAAkB,GAAI,4BAIhC;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAG,eAAe,GAAG,IAQlB,CAAA"}
|
|
@@ -2,7 +2,6 @@ import type { CollectionTool, GlobalTool, Tool } from '../types.js';
|
|
|
2
2
|
type CollectionBuiltin = {
|
|
3
3
|
mcpName: string;
|
|
4
4
|
requiresDuplicateEnabled?: boolean;
|
|
5
|
-
requiresUpload?: boolean;
|
|
6
5
|
requiresVersions?: boolean;
|
|
7
6
|
tool: CollectionTool;
|
|
8
7
|
};
|
|
@@ -67,11 +66,6 @@ export declare const COLLECTION_BUILTINS: {
|
|
|
67
66
|
mcpName: string;
|
|
68
67
|
tool: CollectionTool;
|
|
69
68
|
};
|
|
70
|
-
getUploadInstructions: {
|
|
71
|
-
mcpName: string;
|
|
72
|
-
requiresUpload: true;
|
|
73
|
-
tool: CollectionTool;
|
|
74
|
-
};
|
|
75
69
|
restoreVersion: {
|
|
76
70
|
mcpName: string;
|
|
77
71
|
requiresVersions: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"builtinTools.d.ts","sourceRoot":"","sources":["../../src/mcp/builtinTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AA+BnE,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,UAAU,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;CAEiC,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBa,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;CAagC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwBa,CAAA;AAEzC,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AAEvE,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,wBAAwB,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,eAAe,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,aAAa,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAoC,KAAK,CACxE,CAAC,sBAAsB,EAAE,CAAC,OAAO,aAAa,EAAE,sBAAsB,CAAC,CAAC,CACzE,CAAA;AAED,eAAO,MAAM,0BAA0B,EAA0C,KAAK,CACpF,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAC9C,CAAA;AAED,eAAO,MAAM,+BAA+B,EAA+C,KAAK,CAC9F,CAAC,yBAAyB,EAAE,CAAC,OAAO,wBAAwB,EAAE,yBAAyB,CAAC,CAAC,CAC1F,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAsC,KAAK,CAC5E,CAAC,oBAAoB,EAAE,aAAa,CAAC,CACtC,CAAA"}
|
package/dist/mcp/builtinTools.js
CHANGED
|
@@ -11,7 +11,6 @@ import { findVersionsTool } from './builtin/collections/findVersionsTool.js';
|
|
|
11
11
|
import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js';
|
|
12
12
|
import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js';
|
|
13
13
|
import { updateDocumentTool } from './builtin/collections/updateTool.js';
|
|
14
|
-
import { getUploadInstructionsTool } from './builtin/collections/uploadInstructionsTool.js';
|
|
15
14
|
import { getConfigInfoTool } from './builtin/getConfigInfoTool.js';
|
|
16
15
|
import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js';
|
|
17
16
|
import { findGlobalTool } from './builtin/globals/findTool.js';
|
|
@@ -75,11 +74,6 @@ export const TOOL_BUILTINS = {
|
|
|
75
74
|
mcpName: 'getCollectionSchema',
|
|
76
75
|
tool: getCollectionSchemaTool
|
|
77
76
|
},
|
|
78
|
-
getUploadInstructions: {
|
|
79
|
-
mcpName: 'getUploadInstructions',
|
|
80
|
-
requiresUpload: true,
|
|
81
|
-
tool: getUploadInstructionsTool
|
|
82
|
-
},
|
|
83
77
|
restoreVersion: {
|
|
84
78
|
mcpName: 'restoreVersion',
|
|
85
79
|
requiresVersions: true,
|