@payloadcms/plugin-mcp 3.90.2 → 3.91.0-internal.07e4582
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/dist/mcp/tools/auth/auth.d.ts.map +1 -1
- package/dist/mcp/tools/auth/auth.js +3 -9
- package/dist/mcp/tools/auth/auth.js.map +1 -1
- package/dist/mcp/tools/auth/auth.spec.js +2 -2
- package/dist/mcp/tools/auth/auth.spec.js.map +1 -1
- package/dist/mcp/tools/global/find.d.ts.map +1 -1
- package/dist/mcp/tools/global/find.js +8 -22
- package/dist/mcp/tools/global/find.js.map +1 -1
- package/dist/mcp/tools/global/update.d.ts.map +1 -1
- package/dist/mcp/tools/global/update.js +3 -20
- package/dist/mcp/tools/global/update.js.map +1 -1
- package/dist/mcp/tools/resource/create.d.ts.map +1 -1
- package/dist/mcp/tools/resource/create.js +3 -20
- package/dist/mcp/tools/resource/create.js.map +1 -1
- package/dist/mcp/tools/resource/find.d.ts.map +1 -1
- package/dist/mcp/tools/resource/find.js +28 -25
- package/dist/mcp/tools/resource/find.js.map +1 -1
- package/dist/mcp/tools/resource/update.d.ts.map +1 -1
- package/dist/mcp/tools/resource/update.js +5 -22
- package/dist/mcp/tools/resource/update.js.map +1 -1
- package/dist/mcp/tools/schemas.d.ts +33 -18
- package/dist/mcp/tools/schemas.d.ts.map +1 -1
- package/dist/mcp/tools/schemas.js +14 -6
- package/dist/mcp/tools/schemas.js.map +1 -1
- package/package.json +4 -4
- package/src/mcp/tools/auth/auth.spec.ts +2 -2
- package/src/mcp/tools/auth/auth.ts +4 -10
- package/src/mcp/tools/global/find.ts +10 -24
- package/src/mcp/tools/global/update.ts +6 -24
- package/src/mcp/tools/resource/create.ts +5 -24
- package/src/mcp/tools/resource/find.ts +35 -25
- package/src/mcp/tools/resource/update.ts +6 -25
- package/src/mcp/tools/schemas.ts +38 -14
|
@@ -68,23 +68,6 @@ export const updateResourceTool = (server, req, user, verboseLogs, collectionSlu
|
|
|
68
68
|
return collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
let selectClause;
|
|
72
|
-
if (select) {
|
|
73
|
-
try {
|
|
74
|
-
selectClause = JSON.parse(select);
|
|
75
|
-
} catch (_parseError) {
|
|
76
|
-
payload.logger.warn(`[payload-mcp] Invalid select clause JSON: ${select}`);
|
|
77
|
-
const response = {
|
|
78
|
-
content: [
|
|
79
|
-
{
|
|
80
|
-
type: 'text',
|
|
81
|
-
text: 'Error: Invalid JSON in select clause'
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
};
|
|
85
|
-
return collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
71
|
// Update by ID or where clause
|
|
89
72
|
if (id) {
|
|
90
73
|
// Single document update
|
|
@@ -104,8 +87,8 @@ export const updateResourceTool = (server, req, user, verboseLogs, collectionSlu
|
|
|
104
87
|
...fallbackLocale && {
|
|
105
88
|
fallbackLocale
|
|
106
89
|
},
|
|
107
|
-
...
|
|
108
|
-
select:
|
|
90
|
+
...select && {
|
|
91
|
+
select: select
|
|
109
92
|
}
|
|
110
93
|
};
|
|
111
94
|
if (verboseLogs) {
|
|
@@ -149,8 +132,8 @@ ${JSON.stringify(result)}
|
|
|
149
132
|
...fallbackLocale && {
|
|
150
133
|
fallbackLocale
|
|
151
134
|
},
|
|
152
|
-
...
|
|
153
|
-
select:
|
|
135
|
+
...select && {
|
|
136
|
+
select: select
|
|
154
137
|
}
|
|
155
138
|
};
|
|
156
139
|
if (verboseLogs) {
|
|
@@ -224,7 +207,7 @@ ${JSON.stringify(errors)}
|
|
|
224
207
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
225
208
|
locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
|
|
226
209
|
overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
|
|
227
|
-
select: z.string().optional().describe(
|
|
210
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"title\": true}"),
|
|
228
211
|
where: z.string().optional().describe('JSON string for where clause to update multiple documents')
|
|
229
212
|
});
|
|
230
213
|
server.registerTool(`update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/tools/resource/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, SelectType, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { MCPPluginConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/schemaConversion/convertCollectionSchemaToZod.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { toolSchemas } from '../schemas.js'\nexport const updateResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: MCPPluginConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n id?: number | string,\n where?: string,\n draft: boolean = false,\n depth: number = 0,\n overrideLock: boolean = true,\n locale?: string,\n fallbackLocale?: string,\n select?: string,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n\n // Transform point fields from object format to tuple array\n parsedData = transformPointDataToPayload(parsedData)\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n parsedData = stripVirtualFields(parsedData, virtualFieldNames)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n let selectClause: SelectType | undefined\n if (select) {\n try {\n selectClause = JSON.parse(select) as SelectType\n } catch (_parseError) {\n payload.logger.warn(`[payload-mcp] Invalid select clause JSON: ${select}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in select clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Update by ID or where clause\n if (id) {\n // Single document update\n const updateOptions = {\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(selectClause && { select: selectClause }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating single document with ID: ${id}`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document updated successfully in collection \"${collectionSlug}\"!\nUpdated document:\n\\`\\`\\`json\n${JSON.stringify(result)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents update\n const updateOptions = {\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n where: whereClause,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(selectClause && { select: selectClause }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating multiple documents with where clause`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully updated ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\n\\`\\`\\`json\n${JSON.stringify(docs)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error updating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n // Create a new schema that combines the converted fields with update-specific parameters\n // Use .partial() to make all fields optional for partial updates\n const updateResourceSchema = z.object({\n ...convertedFields.partial().shape,\n id: z.union([z.string(), z.number()]).optional().describe('The ID of the document to update'),\n depth: z\n .number()\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n select: z\n .string()\n .optional()\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response (JSON), e.g., \\'{\"title\": \"My Post\"}\\'',\n ),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.registerTool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n {\n description: `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n inputSchema: updateResourceSchema.shape,\n },\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n locale,\n overrideLock,\n select,\n where,\n ...fieldData\n } = params\n // Convert field data back to JSON string format expected by the tool\n const data = JSON.stringify(fieldData)\n return await tool(\n data,\n id as number | string | undefined,\n where as string | undefined,\n draft as boolean,\n depth as number,\n overrideLock as boolean,\n locale as string | undefined,\n fallbackLocale as string | undefined,\n select as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","getCollectionVirtualFieldNames","stripVirtualFields","convertCollectionSchemaToZod","transformPointDataToPayload","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","locale","fallbackLocale","select","payload","logger","info","parsedData","JSON","parse","virtualFieldNames","config","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","selectClause","warn","updateOptions","collection","overrideAccess","result","update","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","convertedFields","updateResourceSchema","object","partial","shape","union","string","number","optional","describe","default","boolean","registerTool","charAt","toUpperCase","slice","description","updateResource","trim","inputSchema","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,4BAA4B,QAAQ,kEAAiE;AAC9G,SAASC,2BAA2B,QAAQ,gDAA+C;AAC3F,SAASC,WAAW,QAAQ,gBAAe;AAC3C,OAAO,MAAMC,qBAAqB,CAChCC,QACAC,KACAC,MACAC,aACAC,gBACAC,aACAC;IAEA,MAAMC,OAAO,OACXC,MACAC,IACAC,OACAC,QAAiB,KAAK,EACtBC,QAAgB,CAAC,EACjBC,eAAwB,IAAI,EAC5BC,QACAC,gBACAC;QAOA,MAAMC,UAAUhB,IAAIgB,OAAO;Q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ACRD,QAAQ,CAAC;YACZhD,OAAOnB,EACJqE,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,OACRD,QAAQ,CAAC;YACZ5C,gBAAgBvB,EACbgE,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;YACZ7C,QAAQtB,EACLgE,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJ9C,cAAcrB,EACXqE,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,MACRD,QAAQ,CAAC;YACZ3C,QAAQxB,EACLgE,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJjD,OAAOlB,EACJgE,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEA3D,OAAO8D,YAAY,CACjB,CAAC,MAAM,EAAE1D,eAAe2D,MAAM,CAAC,GAAGC,WAAW,KAAKvE,YAAYW,gBAAgB6D,KAAK,CAAC,IAAI,EACxF;YACEC,aAAa,GAAG7D,aAAa,CAACD,eAAe,EAAE8D,eAAepE,YAAYqE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI;YAC7GC,aAAalB,qBAAqBG,KAAK;QACzC,GACA,OAAOgB;YACL,MAAM,EACJ7D,EAAE,EACFG,KAAK,EACLD,KAAK,EACLI,cAAc,EACdD,MAAM,EACND,YAAY,EACZG,MAAM,EACNN,KAAK,EACL,GAAG6D,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAM9D,OAAOa,KAAKI,SAAS,CAAC8C;YAC5B,OAAO,MAAMhE,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,QACAC,gBACAC;QAEJ;IAEJ;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/tools/resource/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { PayloadRequest, SelectType, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { MCPPluginConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/schemaConversion/convertCollectionSchemaToZod.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\nimport { toolSchemas } from '../schemas.js'\nexport const updateResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: MCPPluginConfig['collections'],\n schema: JSONSchema4,\n) => {\n const tool = async (\n data: string,\n id?: number | string,\n where?: string,\n draft: boolean = false,\n depth: number = 0,\n overrideLock: boolean = true,\n locale?: string,\n fallbackLocale?: string,\n select?: Record<string, unknown>,\n ): Promise<{\n content: Array<{\n text: string\n type: 'text'\n }>\n }> => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\n // Parse the data JSON\n let parsedData: Record<string, unknown>\n try {\n parsedData = JSON.parse(data)\n\n // Transform point fields from object format to tuple array\n parsedData = transformPointDataToPayload(parsedData)\n\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n parsedData = stripVirtualFields(parsedData, virtualFieldNames)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,\n )\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid JSON data provided: ${data}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON data provided' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Validate that either id or where is provided\n if (!id && !where) {\n payload.logger.error('[payload-mcp] Either id or where clause must be provided')\n const response = {\n content: [\n { type: 'text' as const, text: 'Error: Either id or where clause must be provided' },\n ],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n\n // Parse where clause if provided\n let whereClause = {}\n if (where) {\n try {\n whereClause = JSON.parse(where)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using where clause: ${where}`)\n }\n } catch (_parseError) {\n payload.logger.error(`[payload-mcp] Invalid where clause JSON: ${where}`)\n const response = {\n content: [{ type: 'text' as const, text: 'Error: Invalid JSON in where clause' }],\n }\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n // Update by ID or where clause\n if (id) {\n // Single document update\n const updateOptions = {\n id,\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(select && { select: select as SelectType }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating single document with ID: ${id}`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Document updated successfully in collection \"${collectionSlug}\"!\nUpdated document:\n\\`\\`\\`json\n${JSON.stringify(result)}\n\\`\\`\\``,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } else {\n // Multiple documents update\n const updateOptions = {\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n overrideAccess: false,\n overrideLock,\n req,\n user,\n where: whereClause,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(select && { select: select as SelectType }),\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating multiple documents with where clause`)\n }\n const result = await payload.update({\n ...updateOptions,\n data: parsedData,\n } as any)\n\n const bulkResult = result as { docs?: unknown[]; errors?: unknown[] }\n const docs = bulkResult.docs || []\n const errors = bulkResult.errors || []\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Successfully updated ${docs.length} documents, ${errors.length} errors`,\n )\n }\n\n let responseText = `Multiple documents updated in collection \"${collectionSlug}\"!\nUpdated: ${docs.length} documents\nErrors: ${errors.length}\n---`\n\n if (docs.length > 0) {\n responseText += `\\n\\nUpdated documents:\n\\`\\`\\`json\n${JSON.stringify(docs)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors)}\n\\`\\`\\``\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: responseText,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(\n response,\n { docs, errors },\n req,\n ) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error updating resource in ${collectionSlug}: ${errorMessage}`,\n )\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error updating resource in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n }\n }\n\n if (collections?.[collectionSlug]?.enabled) {\n const convertedFields = convertCollectionSchemaToZod(schema)\n\n // Create a new schema that combines the converted fields with update-specific parameters\n // Use .partial() to make all fields optional for partial updates\n const updateResourceSchema = z.object({\n ...convertedFields.partial().shape,\n id: z.union([z.string(), z.number()]).optional().describe('The ID of the document to update'),\n depth: z\n .number()\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"title\\\": true}\",\n ),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.registerTool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n {\n description: `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n inputSchema: updateResourceSchema.shape,\n },\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n locale,\n overrideLock,\n select,\n where,\n ...fieldData\n } = params\n // Convert field data back to JSON string format expected by the tool\n const data = JSON.stringify(fieldData)\n return await tool(\n data,\n id as number | string | undefined,\n where as string | undefined,\n draft as boolean,\n depth as number,\n overrideLock as boolean,\n locale as string | undefined,\n fallbackLocale as string | undefined,\n select as Record<string, unknown> | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","getCollectionVirtualFieldNames","stripVirtualFields","convertCollectionSchemaToZod","transformPointDataToPayload","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","locale","fallbackLocale","select","payload","logger","info","parsedData","JSON","parse","virtualFieldNames","config","stringify","_parseError","error","response","content","type","text","overrideResponse","whereClause","updateOptions","collection","overrideAccess","result","update","bulkResult","docs","errors","length","responseText","errorMessage","Error","message","enabled","convertedFields","updateResourceSchema","object","partial","shape","union","string","number","optional","describe","default","boolean","record","unknown","registerTool","charAt","toUpperCase","slice","description","updateResource","trim","inputS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ZodOptional<z.ZodNumber>>;
|
|
7
7
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
8
8
|
locale: z.ZodOptional<z.ZodString>;
|
|
9
|
-
|
|
9
|
+
populate: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
11
|
}, "strip", z.ZodTypeAny, {
|
|
11
12
|
depth: number;
|
|
12
13
|
locale?: string | undefined;
|
|
13
|
-
select?: string | undefined;
|
|
14
|
+
select?: Record<string, unknown> | undefined;
|
|
14
15
|
fallbackLocale?: string | undefined;
|
|
16
|
+
populate?: Record<string, unknown> | undefined;
|
|
15
17
|
}, {
|
|
16
18
|
depth?: number | undefined;
|
|
17
19
|
locale?: string | undefined;
|
|
18
|
-
select?: string | undefined;
|
|
20
|
+
select?: Record<string, unknown> | undefined;
|
|
19
21
|
fallbackLocale?: string | undefined;
|
|
22
|
+
populate?: Record<string, unknown> | undefined;
|
|
20
23
|
}>;
|
|
21
24
|
};
|
|
22
25
|
findResources: {
|
|
@@ -26,34 +29,46 @@ export declare const toolSchemas: {
|
|
|
26
29
|
depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
27
30
|
draft: z.ZodOptional<z.ZodBoolean>;
|
|
28
31
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
32
|
+
joins: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodLiteral<false>]>>;
|
|
29
33
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
30
34
|
locale: z.ZodOptional<z.ZodString>;
|
|
31
35
|
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
32
|
-
|
|
36
|
+
pagination: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
populate: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
38
|
+
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
33
39
|
sort: z.ZodOptional<z.ZodString>;
|
|
40
|
+
trash: z.ZodOptional<z.ZodBoolean>;
|
|
34
41
|
where: z.ZodOptional<z.ZodString>;
|
|
35
42
|
}, "strip", z.ZodTypeAny, {
|
|
36
43
|
depth: number;
|
|
37
44
|
page: number;
|
|
38
45
|
limit: number;
|
|
39
46
|
locale?: string | undefined;
|
|
40
|
-
select?: string | undefined;
|
|
47
|
+
select?: Record<string, unknown> | undefined;
|
|
41
48
|
sort?: string | undefined;
|
|
49
|
+
trash?: boolean | undefined;
|
|
42
50
|
draft?: boolean | undefined;
|
|
43
51
|
where?: string | undefined;
|
|
44
52
|
id?: string | number | undefined;
|
|
45
53
|
fallbackLocale?: string | undefined;
|
|
54
|
+
populate?: Record<string, unknown> | undefined;
|
|
55
|
+
joins?: false | Record<string, unknown> | undefined;
|
|
56
|
+
pagination?: boolean | undefined;
|
|
46
57
|
}, {
|
|
47
58
|
depth?: number | undefined;
|
|
48
59
|
locale?: string | undefined;
|
|
49
|
-
select?: string | undefined;
|
|
60
|
+
select?: Record<string, unknown> | undefined;
|
|
50
61
|
sort?: string | undefined;
|
|
62
|
+
trash?: boolean | undefined;
|
|
51
63
|
draft?: boolean | undefined;
|
|
52
64
|
where?: string | undefined;
|
|
53
65
|
id?: string | number | undefined;
|
|
54
66
|
page?: number | undefined;
|
|
55
67
|
fallbackLocale?: string | undefined;
|
|
68
|
+
populate?: Record<string, unknown> | undefined;
|
|
69
|
+
joins?: false | Record<string, unknown> | undefined;
|
|
56
70
|
limit?: number | undefined;
|
|
71
|
+
pagination?: boolean | undefined;
|
|
57
72
|
}>;
|
|
58
73
|
};
|
|
59
74
|
createResource: {
|
|
@@ -64,19 +79,19 @@ export declare const toolSchemas: {
|
|
|
64
79
|
draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
65
80
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
66
81
|
locale: z.ZodOptional<z.ZodString>;
|
|
67
|
-
select: z.ZodOptional<z.ZodString
|
|
82
|
+
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
68
83
|
}, "strip", z.ZodTypeAny, {
|
|
69
84
|
depth: number;
|
|
70
85
|
draft: boolean;
|
|
71
86
|
data: string;
|
|
72
87
|
locale?: string | undefined;
|
|
73
|
-
select?: string | undefined;
|
|
88
|
+
select?: Record<string, unknown> | undefined;
|
|
74
89
|
fallbackLocale?: string | undefined;
|
|
75
90
|
}, {
|
|
76
91
|
data: string;
|
|
77
92
|
depth?: number | undefined;
|
|
78
93
|
locale?: string | undefined;
|
|
79
|
-
select?: string | undefined;
|
|
94
|
+
select?: Record<string, unknown> | undefined;
|
|
80
95
|
draft?: boolean | undefined;
|
|
81
96
|
fallbackLocale?: string | undefined;
|
|
82
97
|
}>;
|
|
@@ -91,7 +106,7 @@ export declare const toolSchemas: {
|
|
|
91
106
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
92
107
|
locale: z.ZodOptional<z.ZodString>;
|
|
93
108
|
overrideLock: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
94
|
-
select: z.ZodOptional<z.ZodString
|
|
109
|
+
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
95
110
|
where: z.ZodOptional<z.ZodString>;
|
|
96
111
|
}, "strip", z.ZodTypeAny, {
|
|
97
112
|
depth: number;
|
|
@@ -99,7 +114,7 @@ export declare const toolSchemas: {
|
|
|
99
114
|
data: string;
|
|
100
115
|
overrideLock: boolean;
|
|
101
116
|
locale?: string | undefined;
|
|
102
|
-
select?: string | undefined;
|
|
117
|
+
select?: Record<string, unknown> | undefined;
|
|
103
118
|
where?: string | undefined;
|
|
104
119
|
id?: string | number | undefined;
|
|
105
120
|
fallbackLocale?: string | undefined;
|
|
@@ -107,7 +122,7 @@ export declare const toolSchemas: {
|
|
|
107
122
|
data: string;
|
|
108
123
|
depth?: number | undefined;
|
|
109
124
|
locale?: string | undefined;
|
|
110
|
-
select?: string | undefined;
|
|
125
|
+
select?: Record<string, unknown> | undefined;
|
|
111
126
|
draft?: boolean | undefined;
|
|
112
127
|
where?: string | undefined;
|
|
113
128
|
id?: string | number | undefined;
|
|
@@ -145,19 +160,19 @@ export declare const toolSchemas: {
|
|
|
145
160
|
draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
146
161
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
147
162
|
locale: z.ZodOptional<z.ZodString>;
|
|
148
|
-
select: z.ZodOptional<z.ZodString
|
|
163
|
+
select: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
149
164
|
}, "strip", z.ZodTypeAny, {
|
|
150
165
|
depth: number;
|
|
151
166
|
draft: boolean;
|
|
152
167
|
data: string;
|
|
153
168
|
locale?: string | undefined;
|
|
154
|
-
select?: string | undefined;
|
|
169
|
+
select?: Record<string, unknown> | undefined;
|
|
155
170
|
fallbackLocale?: string | undefined;
|
|
156
171
|
}, {
|
|
157
172
|
data: string;
|
|
158
173
|
depth?: number | undefined;
|
|
159
174
|
locale?: string | undefined;
|
|
160
|
-
select?: string | undefined;
|
|
175
|
+
select?: Record<string, unknown> | undefined;
|
|
161
176
|
draft?: boolean | undefined;
|
|
162
177
|
fallbackLocale?: string | undefined;
|
|
163
178
|
}>;
|
|
@@ -279,11 +294,11 @@ export declare const toolSchemas: {
|
|
|
279
294
|
auth: {
|
|
280
295
|
description: string;
|
|
281
296
|
parameters: z.ZodObject<{
|
|
282
|
-
headers: z.ZodOptional<z.ZodString
|
|
297
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
283
298
|
}, "strip", z.ZodTypeAny, {
|
|
284
|
-
headers?: string | undefined;
|
|
299
|
+
headers?: Record<string, string> | undefined;
|
|
285
300
|
}, {
|
|
286
|
-
headers?: string | undefined;
|
|
301
|
+
headers?: Record<string, string> | undefined;
|
|
287
302
|
}>;
|
|
288
303
|
};
|
|
289
304
|
login: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwgBvB,CAAA"}
|
|
@@ -6,7 +6,8 @@ export const toolSchemas = {
|
|
|
6
6
|
depth: z.number().int().min(0).max(10).optional().default(0).describe('Depth of population for relationships'),
|
|
7
7
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
8
8
|
locale: z.string().optional().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields'),
|
|
9
|
-
|
|
9
|
+
populate: z.record(z.string(), z.unknown()).optional().describe('Optional: control which fields to include from populated relationship or upload documents.'),
|
|
10
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"title\": true}")
|
|
10
11
|
})
|
|
11
12
|
},
|
|
12
13
|
findResources: {
|
|
@@ -19,11 +20,18 @@ export const toolSchemas = {
|
|
|
19
20
|
depth: z.number().int().min(0).max(10).optional().default(0).describe('How many levels deep to populate relationships (default: 0)'),
|
|
20
21
|
draft: z.boolean().optional().describe('Optional: Whether the document should be queried from the versions table/collection or not.'),
|
|
21
22
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
23
|
+
joins: z.union([
|
|
24
|
+
z.record(z.string(), z.unknown()),
|
|
25
|
+
z.literal(false)
|
|
26
|
+
]).optional().describe('Optional: configure join field queries, or pass false to disable all join fields.'),
|
|
22
27
|
limit: z.number().int().min(1, 'Limit must be at least 1').max(100, 'Limit cannot exceed 100').optional().default(10).describe('Maximum number of documents to return (default: 10, max: 100)'),
|
|
23
28
|
locale: z.string().optional().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields'),
|
|
24
29
|
page: z.number().int().min(1, 'Page must be at least 1').optional().default(1).describe('Page number for pagination (default: 1)'),
|
|
25
|
-
|
|
30
|
+
pagination: z.boolean().optional().describe('Optional: set to false to skip the count query overhead'),
|
|
31
|
+
populate: z.record(z.string(), z.unknown()).optional().describe('Optional: control which fields to include from populated relationship or upload documents.'),
|
|
32
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"title\": true}"),
|
|
26
33
|
sort: z.string().optional().describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)'),
|
|
34
|
+
trash: z.boolean().optional().describe('Optional: include soft-deleted documents when trash is enabled on the collection'),
|
|
27
35
|
where: z.string().optional().describe('Optional JSON string for where clause filtering (e.g., \'{"title": {"contains": "test"}}\')')
|
|
28
36
|
})
|
|
29
37
|
},
|
|
@@ -35,7 +43,7 @@ export const toolSchemas = {
|
|
|
35
43
|
draft: z.boolean().optional().default(false).describe('Whether to create the document as a draft'),
|
|
36
44
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
37
45
|
locale: z.string().optional().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale'),
|
|
38
|
-
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response
|
|
46
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"title\": true}")
|
|
39
47
|
})
|
|
40
48
|
},
|
|
41
49
|
updateResource: {
|
|
@@ -51,7 +59,7 @@ export const toolSchemas = {
|
|
|
51
59
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
52
60
|
locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
|
|
53
61
|
overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
|
|
54
|
-
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response
|
|
62
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"title\": true}"),
|
|
55
63
|
where: z.string().optional().describe('Optional: JSON string for where clause to update multiple documents')
|
|
56
64
|
})
|
|
57
65
|
},
|
|
@@ -76,7 +84,7 @@ export const toolSchemas = {
|
|
|
76
84
|
draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),
|
|
77
85
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
78
86
|
locale: z.string().optional().describe('Optional: locale code to update data in (e.g., "en", "es"). Use "all" to update all locales for localized fields'),
|
|
79
|
-
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response
|
|
87
|
+
select: z.record(z.string(), z.unknown()).optional().describe("Optional: define exactly which fields you'd like to return in the response, e.g., {\"siteName\": true}")
|
|
80
88
|
})
|
|
81
89
|
},
|
|
82
90
|
// Experimental Below This Line
|
|
@@ -150,7 +158,7 @@ export const toolSchemas = {
|
|
|
150
158
|
auth: {
|
|
151
159
|
description: 'Checks authentication status for the current user.',
|
|
152
160
|
parameters: z.object({
|
|
153
|
-
headers: z.string().optional().describe('Optional
|
|
161
|
+
headers: z.record(z.string(), z.string()).optional().describe('Optional custom headers to send with the authentication request')
|
|
154
162
|
})
|
|
155
163
|
},
|
|
156
164
|
login: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findGlobal: {\n description: 'Find a Payload global singleton configuration.',\n parameters: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\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 select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Whether the document should be queried from the versions table/collection or not.',\n ),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n locale: z\n .string()\n .optional()\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 page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships in response (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code for the operation (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n updateGlobal: {\n description: 'Update a Payload global singleton configuration.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"siteName\\\": true}'\",\n ),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n ),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n password: z.string().describe('The user password'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n password: z.string().describe('The new password for the user'),\n token: z.string().describe('The password reset token sent to the user email'),\n }),\n },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findGlobal","description","parameters","object","depth","number","int","min","max","optional","default","describe","fallbackLocale","string","locale","select","findResources","id","union","draft","boolean","limit","page","sort","where","createResource","data","updateResource","overrideLock","deleteResource","updateGlobal","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","pluginUpdates","auth","headers","login","collection","email","password","verify","token","resetPassword","forgotPassword","unlock","createJob","inputSchema","record","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,YAAY;QACVC,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,OAAON,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRC,OAAO,CAAC,GACRC,QAAQ,CAAC;YACZC,gBAAgBd,EACbe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;YACZG,QAAQhB,EACLe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CACP;YAEJI,QAAQjB,EACLe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CACP;QAEN;IACF;IAEAK,eAAe;QACbf,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBc,IAAInB,EACDoB,KAAK,CAAC;gBAACpB,EAAEe,MAAM;gBAAIf,EAAEO,MAAM;aAAG,EAC9BI,QAAQ,GACRE,QAAQ,CACP;YAEJP,OAAON,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRC,OAAO,CAAC,GACRC,QAAQ,CAAC;YACZQ,OAAOrB,EACJsB,OAAO,GACPX,QAAQ,GACRE,QAAQ,CACP;YAEJC,gBAAgBd,EACbe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;YACZU,OAAOvB,EACJO,MAAM,GACNC,G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;YACpDqE,cAAclF,EAAEqC,KAAK,CAACrC,EAAEsC,GAAG,IAAI3B,QAAQ,GAAGE,QAAQ,CAAC;YACnDoC,YAAYjD,EACTkD,IAAI,CAAC;gBAAC;gBAAiB;gBAAgB;gBAAiB;aAAkB,EAC1ErC,QAAQ,CAAC;QACd;IACF;IAEAsE,QAAQ;QACNhF,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnB+E,OAAOpF,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJE,QAAQ,GACRE,QAAQ,CAAC;YACZwE,OAAOrF,EAAEwE,MAAM,CAACxE,EAAEsC,GAAG,IAAIzB,QAAQ,CAAC;YAClC+D,SAAS5E,EAAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7ByE,UAAUtF,EACPO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRE,QAAQ,CAAC;YACZ0E,OAAOvF,EACJe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findGlobal: {\n description: 'Find a Payload global singleton configuration.',\n parameters: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\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 populate: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n ),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"title\\\": true}\",\n ),\n }),\n },\n\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Whether the document should be queried from the versions table/collection or not.',\n ),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n joins: z\n .union([z.record(z.string(), z.unknown()), z.literal(false)])\n .optional()\n .describe(\n 'Optional: configure join field queries, or pass false to disable all join fields.',\n ),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n locale: z\n .string()\n .optional()\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 page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n pagination: z\n .boolean()\n .optional()\n .describe('Optional: set to false to skip the count query overhead'),\n populate: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n ),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"title\\\": true}\",\n ),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n trash: z\n .boolean()\n .optional()\n .describe('Optional: include soft-deleted documents when trash is enabled on the collection'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships in response (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"title\\\": true}\",\n ),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"title\\\": true}\",\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code for the operation (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n updateGlobal: {\n description: 'Update a Payload global singleton configuration.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n ),\n select: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response, e.g., {\\\"siteName\\\": true}\",\n ),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .record(z.string(), z.string())\n .optional()\n .describe('Optional custom headers to send with the authentication request'),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n password: z.string().describe('The user password'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n password: z.string().describe('The new password for the user'),\n token: z.string().describe('The password reset token sent to the user email'),\n }),\n },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findGlobal","description","parameters","object","depth","number","int","min","max","optional","default","describe","fallbackLocale","string","locale","populate","record","unknown","select","findResources","id","union","draft","boolean","joins","literal","limit","page","pagination","sort","trash","where","createResource","data","updateResource","overrideLock","deleteResource","updateGlobal","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","pluginUpdates","auth","headers","login","collection","email","password","verify","token","resetPassword","forgotPassword","unlock","createJob","inputSchema","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,YAAY;QACVC,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,OAAON,EACJO,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,QAAQ,CAAC;YACpD0E,aAAavF,EACVe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;YACZiE,aAAa9E,EAAEkB,MAAM,CAAClB,EAAE6C,GAAG,IAAIlC,QAAQ,GAAGE,QAAQ,CAAC;YACnDqE,SAASlF,EAAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7BuE,cAAcpF,EAAEkB,MAAM,CAAClB,EAAE6C,GAAG,IAAIlC,QAAQ,GAAGE,QAAQ,CAAC;YACpD2E,cAAcxF,EAAE4C,KAAK,CAAC5C,EAAE6C,GAAG,IAAIlC,QAAQ,GAAGE,QAAQ,CAAC;YACnD2C,YAAYxD,EACTyD,IAAI,CAAC;gBAAC;gBAAiB;gBAAgB;gBAAiB;aAAkB,EAC1E5C,QAAQ,CAAC;QACd;IACF;IAEA4E,QAAQ;QACNtF,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBqF,OAAO1F,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJE,QAAQ,GACRE,QAAQ,CAAC;YACZ8E,OAAO3F,EAAEkB,MAAM,CAAClB,EAAE6C,GAAG,IAAIhC,QAAQ,CAAC;YAClCqE,SAASlF,EAAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7B+E,UAAU5F,EACPO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRE,QAAQ,CAAC;YACZgF,OAAO7F,EACJe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.91.0-internal.07e4582",
|
|
4
4
|
"description": "MCP (Model Context Protocol) capabilities with Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"zod": "^3.25.50"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
48
|
+
"payload": "3.91.0-internal.07e4582"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"payload": "3.
|
|
51
|
+
"payload": "3.91.0-internal.07e4582"
|
|
52
52
|
},
|
|
53
53
|
"homepage:": "https://payloadcms.com",
|
|
54
54
|
"scripts": {
|
|
@@ -20,7 +20,7 @@ type AuthToolResult = {
|
|
|
20
20
|
}>
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type AuthToolHandler = (args: { headers?: string }) => Promise<AuthToolResult>
|
|
23
|
+
type AuthToolHandler = (args: { headers?: Record<string, string> }) => Promise<AuthToolResult>
|
|
24
24
|
|
|
25
25
|
describe('authTool', () => {
|
|
26
26
|
beforeEach(() => {
|
|
@@ -70,7 +70,7 @@ describe('authTool', () => {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const result = await handler({
|
|
73
|
-
headers:
|
|
73
|
+
headers: { Authorization: 'JWT token' },
|
|
74
74
|
})
|
|
75
75
|
const json = result.content[0]!.text.match(/```json\n([\s\S]*?)\n```/)?.[1]
|
|
76
76
|
|
|
@@ -6,7 +6,7 @@ import { createLocalReq } from 'payload'
|
|
|
6
6
|
import { toolSchemas } from '../schemas.js'
|
|
7
7
|
|
|
8
8
|
export const authTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {
|
|
9
|
-
const tool = async (headers?: string) => {
|
|
9
|
+
const tool = async (headers?: Record<string, string>) => {
|
|
10
10
|
const payload = req.payload
|
|
11
11
|
|
|
12
12
|
if (verboseLogs) {
|
|
@@ -14,18 +14,12 @@ export const authTool = (server: McpServer, req: PayloadRequest, verboseLogs: bo
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
try {
|
|
17
|
-
// Parse custom headers if provided, otherwise use empty headers
|
|
18
17
|
let authHeaders = new Headers()
|
|
19
18
|
|
|
20
19
|
if (headers) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (verboseLogs) {
|
|
25
|
-
payload.logger.info(`[payload-mcp] Using custom headers: ${headers}`)
|
|
26
|
-
}
|
|
27
|
-
} catch (_ignore) {
|
|
28
|
-
payload.logger.warn(`[payload-mcp] Invalid headers JSON: ${headers}, using empty headers`)
|
|
20
|
+
authHeaders = new Headers(headers)
|
|
21
|
+
if (verboseLogs) {
|
|
22
|
+
payload.logger.info(`[payload-mcp] Using custom headers: ${JSON.stringify(headers)}`)
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
25
|
|