@payloadcms/plugin-mcp 3.73.0-internal.f0458fb → 3.73.0
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/getMcpHandler.js +1 -1
- package/dist/mcp/getMcpHandler.js.map +1 -1
- package/dist/mcp/tools/global/find.d.ts.map +1 -1
- package/dist/mcp/tools/global/find.js +23 -3
- 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 +25 -4
- 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 +25 -4
- 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 +27 -3
- 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 +27 -3
- package/dist/mcp/tools/resource/update.js.map +1 -1
- package/dist/mcp/tools/schemas.d.ts +15 -0
- package/dist/mcp/tools/schemas.d.ts.map +1 -1
- package/dist/mcp/tools/schemas.js +8 -3
- package/dist/mcp/tools/schemas.js.map +1 -1
- package/package.json +3 -3
- package/src/mcp/getMcpHandler.ts +1 -1
- package/src/mcp/tools/global/find.ts +25 -3
- package/src/mcp/tools/global/update.ts +31 -2
- package/src/mcp/tools/resource/create.ts +30 -2
- package/src/mcp/tools/resource/find.ts +37 -3
- package/src/mcp/tools/resource/update.ts +31 -1
- package/src/mcp/tools/schemas.ts +30 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/tools/resource/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const findResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: number | string,\n limit: number = 10,\n page: number = 1,\n sort?: string,\n where?: string,\n depth: number = 0,\n locale?: string,\n fallbackLocale?: string,\n draft?: boolean,\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] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\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.warn(`[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 // If ID is provided, use findByID\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth,\n overrideAccess: false,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n })\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource from collection \"${collectionSlug}\":\n${JSON.stringify(doc, null, 2)}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, doc, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (_findError) {\n payload.logger.warn(\n `[payload-mcp] Document not found with ID: ${id} in collection: ${collectionSlug}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\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\n // Otherwise, use find to get multiple documents\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n depth,\n limit,\n overrideAccess: false,\n page,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n\n if (Object.keys(whereClause).length > 0) {\n findOptions.where = whereClause\n }\n\n const result = await payload.find(findOptions)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Found ${result.docs.length} documents in collection: ${collectionSlug}`,\n )\n }\n\n let responseText = `Collection: \"${collectionSlug}\"\nTotal: ${result.totalDocs} documents\nPage: ${result.page} of ${result.totalPages}\n`\n\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc, null, 2)}\\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?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error reading resources from collection ${collectionSlug}: ${errorMessage}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading resources from collection \"${collectionSlug}\":** ${errorMessage}`,\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 server.tool(\n `find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`,\n toolSchemas.findResources.parameters.shape,\n async ({ id, depth, draft, fallbackLocale, limit, locale, page, sort, where }) => {\n return await tool(id, limit, page, sort, where, depth, locale, fallbackLocale, draft)\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","findResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","limit","page","sort","where","depth","locale","fallbackLocale","draft","payload","logger","info","whereClause","JSON","parse","_parseError","warn","response","content","type","text","overrideResponse","doc","findByID","collection","overrideAccess","undefined","stringify","_findError","findOptions","Object","keys","length","result","find","docs","responseText","totalDocs","totalPages","error","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","findResources","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,CAC9BC,QACAC,KACAC,MACAC,aACAC,gBACAC;IAEA,MAAMC,OAAO,OACXC,IACAC,QAAgB,EAAE,EAClBC,OAAe,CAAC,EAChBC,MACAC,OACAC,QAAgB,CAAC,EACjBC,QACAC,gBACAC;QAOA,MAAMC,UAAUf,IAAIe,OAAO;QAE3B,IAAIb,aAAa;YACfa,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,gDAAgD,EAAEd,iBAAiBG,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,GAAG,SAAS,EAAEC,MAAM,QAAQ,EAAEC,OAAOI,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;QAE3K;QAEA,IAAI;YACF,iCAAiC;YACjC,IAAIM,cAAc,CAAC;YACnB,IAAIR,OAAO;gBACT,IAAI;oBACFQ,cAAcC,KAAKC,KAAK,CAACV;oBACzB,IAAIR,aAAa;wBACfa,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,kCAAkC,EAAEP,OAAO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C,MAAM,CAAC6B,KAAK,CAClB,CAAC,sDAAsD,EAAE1C,eAAe,EAAE,EAAE2C,cAAc;YAE5F,MAAMvB,WAAW;gBACfC,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,6CAA6C,EAAEvB,eAAe,KAAK,EAAE2C,cAAc;oBAC5F;iBACD;YACH;YACA,OAAQ1C,aAAa,CAACD,eAAe,EAAEwB,mBAAmBJ,UAAU,CAAC,GAAGvB,QAAQuB;QAMlF;IACF;IAEA,IAAInB,aAAa,CAACD,eAAe,EAAE8C,SAAS;QAC1ClD,OAAOM,IAAI,CACT,CAAC,IAAI,EAAEF,eAAe+C,MAAM,CAAC,GAAGC,WAAW,KAAKvD,YAAYO,gBAAgBiD,KAAK,CAAC,IAAI,EACtF,GAAGhD,aAAa,CAACD,eAAe,EAAEkD,eAAexD,YAAYyD,aAAa,CAACD,WAAW,CAACE,IAAI,IAAI,EAC/F1D,YAAYyD,aAAa,CAACE,UAAU,CAACC,KAAK,EAC1C,OAAO,EAAEnD,EAAE,EAAEK,KAAK,EAAEG,KAAK,EAAED,cAAc,EAAEN,KAAK,EAAEK,MAAM,EAAEJ,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE;YAC3E,OAAO,MAAML,KAAKC,IAAIC,OAAOC,MAAMC,MAAMC,OAAOC,OAAOC,QAAQC,gBAAgBC;QACjF;IAEJ;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/tools/resource/find.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest, SelectType, TypedUser } from 'payload'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { toolSchemas } from '../schemas.js'\n\nexport const findResourceTool = (\n server: McpServer,\n req: PayloadRequest,\n user: TypedUser,\n verboseLogs: boolean,\n collectionSlug: string,\n collections: PluginMCPServerConfig['collections'],\n) => {\n const tool = async (\n id?: number | string,\n limit: number = 10,\n page: number = 1,\n sort?: string,\n where?: string,\n select?: string,\n depth: number = 0,\n locale?: string,\n fallbackLocale?: string,\n draft?: boolean,\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] Reading resource from collection: ${collectionSlug}${id ? ` with ID: ${id}` : ''}, limit: ${limit}, page: ${page}${locale ? `, locale: ${locale}` : ''}`,\n )\n }\n\n try {\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.warn(`[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 // Parse select clause if provided\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 // If ID is provided, use findByID\n if (id) {\n try {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth,\n ...(selectClause && { select: selectClause }),\n overrideAccess: false,\n req,\n user,\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n })\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found document with ID: ${id}`)\n }\n\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Resource from collection \"${collectionSlug}\":\n${JSON.stringify(doc, null, 2)}`,\n },\n ],\n }\n\n return (collections?.[collectionSlug]?.overrideResponse?.(response, doc, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (_findError) {\n payload.logger.warn(\n `[payload-mcp] Document not found with ID: ${id} in collection: ${collectionSlug}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `Error: Document with ID \"${id}\" not found in collection \"${collectionSlug}\"`,\n },\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\n // Otherwise, use find to get multiple documents\n const findOptions: Parameters<typeof payload.find>[0] = {\n collection: collectionSlug,\n depth,\n limit,\n overrideAccess: false,\n page,\n req,\n user,\n ...(selectClause && { select: selectClause }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\n ...(draft !== undefined && { draft }),\n }\n\n if (sort) {\n findOptions.sort = sort\n }\n\n if (Object.keys(whereClause).length > 0) {\n findOptions.where = whereClause\n }\n\n const result = await payload.find(findOptions)\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Found ${result.docs.length} documents in collection: ${collectionSlug}`,\n )\n }\n\n let responseText = `Collection: \"${collectionSlug}\"\nTotal: ${result.totalDocs} documents\nPage: ${result.page} of ${result.totalPages}\n`\n\n for (const doc of result.docs) {\n responseText += `\\n\\`\\`\\`json\\n${JSON.stringify(doc, null, 2)}\\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?.(response, result, req) ||\n response) as {\n content: Array<{\n text: string\n type: 'text'\n }>\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n payload.logger.error(\n `[payload-mcp] Error reading resources from collection ${collectionSlug}: ${errorMessage}`,\n )\n const response = {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error reading resources from collection \"${collectionSlug}\":** ${errorMessage}`,\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 server.tool(\n `find${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.findResources.description.trim()}`,\n toolSchemas.findResources.parameters.shape,\n async ({ id, depth, draft, fallbackLocale, limit, locale, page, select, sort, where }) => {\n return await tool(\n id,\n limit,\n page,\n sort,\n where,\n select,\n depth,\n locale,\n fallbackLocale,\n draft,\n )\n },\n )\n }\n}\n"],"names":["toCamelCase","toolSchemas","findResourceTool","server","req","user","verboseLogs","collectionSlug","collections","tool","id","limit","page","sort","where","select","depth","locale","fallbackLocale","draft","payload","logger","info","whereClause","JSON","parse","_parseError","warn","response","content","type","text","overrideResponse","selectClause","doc","findByID","collection","overrideAccess","undefined","stringify","_findError","findOptions","Object","keys","length","result","find","docs","responseText","totalDocs","totalPages","error","errorMessage","Error","message","enabled","charAt","toUpperCase","slice","description","findResources","trim","parameters","shape"],"mappings":"AAKA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,WAAW,QAAQ,gBAAe;AAE3C,OAAO,MAAMC,mBAAmB,CAC9BC,QACAC,KACAC,MACAC,aACAC,gBACAC;IAEA,MAAMC,OAAO,OACXC,IACAC,QAAgB,EAAE,EAClBC,OAAe,CAAC,EAChBC,MACAC,OACAC,QACAC,QAAgB,CAAC,EACjBC,QACAC,gBACAC;QAOA,MAAMC,UAAUhB,IAAIgB,OAAO;QAE3B,IAAId,aAAa;YACfc,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,gDAAgD,EAAEf,iBAAiBG,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,GAAG,SAAS,EAAEC,MAAM,QAAQ,EAAEC,OAAOK,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,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D,aAAa,CAACD,WAAW,CAACE,IAAI,IAAI,EAC/F5D,YAAY2D,aAAa,CAACE,UAAU,CAACC,KAAK,EAC1C,OAAO,EAAErD,EAAE,EAAEM,KAAK,EAAEG,KAAK,EAAED,cAAc,EAAEP,KAAK,EAAEM,MAAM,EAAEL,IAAI,EAAEG,MAAM,EAAEF,IAAI,EAAEC,KAAK,EAAE;YACnF,OAAO,MAAML,KACXC,IACAC,OACAC,MACAC,MACAC,OACAC,QACAC,OACAC,QACAC,gBACAC;QAEJ;IAEJ;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/resource/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAc,SAAS,EAAE,MAAM,SAAS,CAAA;AAIpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAK9D,eAAO,MAAM,kBAAkB,WACrB,SAAS,OACZ,cAAc,QACb,SAAS,eACF,OAAO,kBACJ,MAAM,eACT,qBAAqB,CAAC,aAAa,CAAC,UACzC,WAAW,SA8VpB,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { toCamelCase } from '../../../utils/camelCase.js';
|
|
|
3
3
|
import { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.js';
|
|
4
4
|
import { toolSchemas } from '../schemas.js';
|
|
5
5
|
export const updateResourceTool = (server, req, user, verboseLogs, collectionSlug, collections, schema)=>{
|
|
6
|
-
const tool = async (data, id, where, draft = false, depth = 0, overrideLock = true, filePath, overwriteExistingFiles = false, locale, fallbackLocale)=>{
|
|
6
|
+
const tool = async (data, id, where, draft = false, depth = 0, overrideLock = true, filePath, overwriteExistingFiles = false, locale, fallbackLocale, select)=>{
|
|
7
7
|
const payload = req.payload;
|
|
8
8
|
if (verboseLogs) {
|
|
9
9
|
payload.logger.info(`[payload-mcp] Updating resource in collection: ${collectionSlug}${id ? ` with ID: ${id}` : ' with where clause'}, draft: ${draft}${locale ? `, locale: ${locale}` : ''}`);
|
|
@@ -62,6 +62,23 @@ export const updateResourceTool = (server, req, user, verboseLogs, collectionSlu
|
|
|
62
62
|
return collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
let selectClause;
|
|
66
|
+
if (select) {
|
|
67
|
+
try {
|
|
68
|
+
selectClause = JSON.parse(select);
|
|
69
|
+
} catch (_parseError) {
|
|
70
|
+
payload.logger.warn(`[payload-mcp] Invalid select clause JSON: ${select}`);
|
|
71
|
+
const response = {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: 'text',
|
|
75
|
+
text: 'Error: Invalid JSON in select clause'
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
return collections?.[collectionSlug]?.overrideResponse?.(response, {}, req) || response;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
// Update by ID or where clause
|
|
66
83
|
if (id) {
|
|
67
84
|
// Single document update
|
|
@@ -86,6 +103,9 @@ export const updateResourceTool = (server, req, user, verboseLogs, collectionSlu
|
|
|
86
103
|
},
|
|
87
104
|
...fallbackLocale && {
|
|
88
105
|
fallbackLocale
|
|
106
|
+
},
|
|
107
|
+
...selectClause && {
|
|
108
|
+
select: selectClause
|
|
89
109
|
}
|
|
90
110
|
};
|
|
91
111
|
if (verboseLogs) {
|
|
@@ -134,6 +154,9 @@ ${JSON.stringify(result, null, 2)}
|
|
|
134
154
|
},
|
|
135
155
|
...fallbackLocale && {
|
|
136
156
|
fallbackLocale
|
|
157
|
+
},
|
|
158
|
+
...selectClause && {
|
|
159
|
+
select: selectClause
|
|
137
160
|
}
|
|
138
161
|
};
|
|
139
162
|
if (verboseLogs) {
|
|
@@ -209,13 +232,14 @@ ${JSON.stringify(errors, null, 2)}
|
|
|
209
232
|
locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
|
|
210
233
|
overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
|
|
211
234
|
overwriteExistingFiles: z.boolean().optional().default(false).describe('Whether to overwrite existing files'),
|
|
235
|
+
select: z.string().optional().describe('Optional: define exactly which fields you\'d like to return in the response (JSON), e.g., \'{"title": "My Post"}\''),
|
|
212
236
|
where: z.string().optional().describe('JSON string for where clause to update multiple documents')
|
|
213
237
|
});
|
|
214
238
|
server.tool(`update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`, `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`, updateResourceSchema.shape, async (params)=>{
|
|
215
|
-
const { id, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, where, ...fieldData } = params;
|
|
239
|
+
const { id, depth, draft, fallbackLocale, filePath, locale, overrideLock, overwriteExistingFiles, select, where, ...fieldData } = params;
|
|
216
240
|
// Convert field data back to JSON string format expected by the tool
|
|
217
241
|
const data = JSON.stringify(fieldData);
|
|
218
|
-
return await tool(data, id, where, draft, depth, overrideLock, filePath, overwriteExistingFiles, locale, fallbackLocale);
|
|
242
|
+
return await tool(data, id, where, draft, depth, overrideLock, filePath, overwriteExistingFiles, locale, fallbackLocale, select);
|
|
219
243
|
});
|
|
220
244
|
}
|
|
221
245
|
};
|
|
@@ -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, TypedUser } from 'payload'\n\nimport { z } from 'zod'\n\nimport type { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.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: PluginMCPServerConfig['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 filePath?: string,\n overwriteExistingFiles: boolean = false,\n locale?: string,\n fallbackLocale?: 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 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 ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\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, null, 2)}\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 ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\n ...(locale && { locale }),\n ...(fallbackLocale && { fallbackLocale }),\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, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\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 filePath: z.string().optional().describe('File path for file uploads'),\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 overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n where: z\n .string()\n .optional()\n .describe('JSON string for where clause to update multiple documents'),\n })\n\n server.tool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n updateResourceSchema.shape,\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\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 filePath as string | undefined,\n overwriteExistingFiles as boolean,\n locale as string | undefined,\n fallbackLocale as string | undefined,\n )\n },\n )\n }\n}\n"],"names":["z","toCamelCase","convertCollectionSchemaToZod","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","locale","fallbackLocale","payload","logger","info","parsedData","JSON","parse","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","charAt","toUpperCase","slice","description","updateResource","trim","params","fieldData"],"mappings":"AAIA,SAASA,CA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B,EACJ+D,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,OACRD,QAAQ,CAAC;YACZvC,gBAAgBtB,EACb0D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;YACZ1C,UAAUnB,EAAE0D,MAAM,GAAGE,QAAQ,GAAGC,QAAQ,CAAC;YACzCxC,QAAQrB,EACL0D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJ3C,cAAclB,EACX+D,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,MACRD,QAAQ,CAAC;YACZzC,wBAAwBpB,EACrB+D,OAAO,GACPH,QAAQ,GACRE,OAAO,CAAC,OACRD,QAAQ,CAAC;YACZ9C,OAAOf,EACJ0D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEAxD,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAeuD,MAAM,CAAC,GAAGC,WAAW,KAAKhE,YAAYQ,gBAAgByD,KAAK,CAAC,IAAI,EACxF,GAAGxD,aAAa,CAACD,eAAe,EAAE0D,eAAehE,YAAYiE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGhB,qBAAqBG,KAAK,EAC1B,OAAOc;YACL,MAAM,EACJxD,EAAE,EACFG,KAAK,EACLD,KAAK,EACLM,cAAc,EACdH,QAAQ,EACRE,MAAM,EACNH,YAAY,EACZE,sBAAsB,EACtBL,KAAK,EACL,GAAGwD,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAMzD,OAAOc,KAAKE,SAAS,CAAC0C;YAC5B,OAAO,MAAM3D,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC,wBACAC,QACAC;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 { PluginMCPServerConfig } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { convertCollectionSchemaToZod } from '../../../utils/convertCollectionSchemaToZod.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: PluginMCPServerConfig['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 filePath?: string,\n overwriteExistingFiles: boolean = false,\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 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 ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\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, null, 2)}\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 ...(filePath && { filePath }),\n ...(overwriteExistingFiles && { overwriteExistingFiles }),\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, null, 2)}\n\\`\\`\\``\n }\n\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\n\\`\\`\\`json\n${JSON.stringify(errors, null, 2)}\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 filePath: z.string().optional().describe('File path for file uploads'),\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 overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\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.tool(\n `update${collectionSlug.charAt(0).toUpperCase() + toCamelCase(collectionSlug).slice(1)}`,\n `${collections?.[collectionSlug]?.description || toolSchemas.updateResource.description.trim()}`,\n updateResourceSchema.shape,\n async (params: Record<string, unknown>) => {\n const {\n id,\n depth,\n draft,\n fallbackLocale,\n filePath,\n locale,\n overrideLock,\n overwriteExistingFiles,\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 filePath as string | undefined,\n overwriteExistingFiles 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","convertCollectionSchemaToZod","toolSchemas","updateResourceTool","server","req","user","verboseLogs","collectionSlug","collections","schema","tool","data","id","where","draft","depth","overrideLock","filePath","overwriteExistingFiles","locale","fallbackLocale","select","payload","logger","info","parsedData","JSON","parse","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","charAt","toUpperCase","slice","description","updateResource","trim","params","fieldData"],"mappings":"AAIA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,4BAA4B,QAAQ,iDAAgD;AAC7F,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,UACAC,yBAAkC,KAAK,EACvCC,QACAC,gBACAC;QAOA,MAAMC,UAAUlB,IAAIkB,OAAO;QAE3B,IAAIhB,aAAa;YACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,+CAA+C,EAAEjB,iBAAiBK,KAAK,CAAC,UAAU,EAAEA,IAAI,GAAG,qBAAqB,SAAS,EAAEE,QAAQK,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;QAE7K;QAEA,IAAI;YACF,sBAAsB;YACtB,IAAIM;YACJ,IAAI;gBACFA,aAAaC,KAAKC,KAAK,CAAChB;gBACxB,IAAIL,aAAa;oBACfgB,QAAQC,MAAM,CAACC,IAAI,CACjB,CAAC,8BAA8B,EAAEjB,eAAe,EAAE,EAAEmB,KAAKE,SAAS,CAACH,aAAa;gBAEpF;YACF,EAAE,OAAOI,aAAa;gBACpBP,QAAQC,MAAM,CAACO,KAAK,CAAC,CAAC,0CAA0C,EAAEnB,MAAM;gBACx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CAAC,OACRD,QAAQ,CAAC;YACZzC,QAAQvB,EACL6D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CACP;YAEJjD,OAAOf,EACJ6D,MAAM,GACNE,QAAQ,GACRC,QAAQ,CAAC;QACd;QAEA3D,OAAOO,IAAI,CACT,CAAC,MAAM,EAAEH,eAAe0D,MAAM,CAAC,GAAGC,WAAW,KAAKnE,YAAYQ,gBAAgB4D,KAAK,CAAC,IAAI,EACxF,GAAG3D,aAAa,CAACD,eAAe,EAAE6D,eAAenE,YAAYoE,cAAc,CAACD,WAAW,CAACE,IAAI,IAAI,EAChGhB,qBAAqBG,KAAK,EAC1B,OAAOc;YACL,MAAM,EACJ3D,EAAE,EACFG,KAAK,EACLD,KAAK,EACLM,cAAc,EACdH,QAAQ,EACRE,MAAM,EACNH,YAAY,EACZE,sBAAsB,EACtBG,MAAM,EACNR,KAAK,EACL,GAAG2D,WACJ,GAAGD;YACJ,qEAAqE;YACrE,MAAM5D,OAAOe,KAAKE,SAAS,CAAC4C;YAC5B,OAAO,MAAM9D,KACXC,MACAC,IACAC,OACAC,OACAC,OACAC,cACAC,UACAC,wBACAC,QACAC,gBACAC;QAEJ;IAEJ;AACF,EAAC"}
|
|
@@ -6,13 +6,16 @@ export declare const toolSchemas: {
|
|
|
6
6
|
depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
7
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
8
8
|
locale: z.ZodOptional<z.ZodString>;
|
|
9
|
+
select: z.ZodOptional<z.ZodString>;
|
|
9
10
|
}, "strip", z.ZodTypeAny, {
|
|
10
11
|
depth: number;
|
|
11
12
|
locale?: string | undefined;
|
|
13
|
+
select?: string | undefined;
|
|
12
14
|
fallbackLocale?: string | undefined;
|
|
13
15
|
}, {
|
|
14
16
|
depth?: number | undefined;
|
|
15
17
|
locale?: string | undefined;
|
|
18
|
+
select?: string | undefined;
|
|
16
19
|
fallbackLocale?: string | undefined;
|
|
17
20
|
}>;
|
|
18
21
|
};
|
|
@@ -26,6 +29,7 @@ export declare const toolSchemas: {
|
|
|
26
29
|
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
27
30
|
locale: z.ZodOptional<z.ZodString>;
|
|
28
31
|
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
32
|
+
select: z.ZodOptional<z.ZodString>;
|
|
29
33
|
sort: z.ZodOptional<z.ZodString>;
|
|
30
34
|
where: z.ZodOptional<z.ZodString>;
|
|
31
35
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -33,6 +37,7 @@ export declare const toolSchemas: {
|
|
|
33
37
|
limit: number;
|
|
34
38
|
page: number;
|
|
35
39
|
locale?: string | undefined;
|
|
40
|
+
select?: string | undefined;
|
|
36
41
|
sort?: string | undefined;
|
|
37
42
|
draft?: boolean | undefined;
|
|
38
43
|
where?: string | undefined;
|
|
@@ -41,6 +46,7 @@ export declare const toolSchemas: {
|
|
|
41
46
|
}, {
|
|
42
47
|
depth?: number | undefined;
|
|
43
48
|
locale?: string | undefined;
|
|
49
|
+
select?: string | undefined;
|
|
44
50
|
sort?: string | undefined;
|
|
45
51
|
draft?: boolean | undefined;
|
|
46
52
|
where?: string | undefined;
|
|
@@ -58,16 +64,19 @@ export declare const toolSchemas: {
|
|
|
58
64
|
draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
59
65
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
60
66
|
locale: z.ZodOptional<z.ZodString>;
|
|
67
|
+
select: z.ZodOptional<z.ZodString>;
|
|
61
68
|
}, "strip", z.ZodTypeAny, {
|
|
62
69
|
depth: number;
|
|
63
70
|
draft: boolean;
|
|
64
71
|
data: string;
|
|
65
72
|
locale?: string | undefined;
|
|
73
|
+
select?: string | undefined;
|
|
66
74
|
fallbackLocale?: string | undefined;
|
|
67
75
|
}, {
|
|
68
76
|
data: string;
|
|
69
77
|
depth?: number | undefined;
|
|
70
78
|
locale?: string | undefined;
|
|
79
|
+
select?: string | undefined;
|
|
71
80
|
draft?: boolean | undefined;
|
|
72
81
|
fallbackLocale?: string | undefined;
|
|
73
82
|
}>;
|
|
@@ -84,6 +93,7 @@ export declare const toolSchemas: {
|
|
|
84
93
|
locale: z.ZodOptional<z.ZodString>;
|
|
85
94
|
overrideLock: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
86
95
|
overwriteExistingFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
96
|
+
select: z.ZodOptional<z.ZodString>;
|
|
87
97
|
where: z.ZodOptional<z.ZodString>;
|
|
88
98
|
}, "strip", z.ZodTypeAny, {
|
|
89
99
|
depth: number;
|
|
@@ -92,6 +102,7 @@ export declare const toolSchemas: {
|
|
|
92
102
|
overrideLock: boolean;
|
|
93
103
|
overwriteExistingFiles: boolean;
|
|
94
104
|
locale?: string | undefined;
|
|
105
|
+
select?: string | undefined;
|
|
95
106
|
where?: string | undefined;
|
|
96
107
|
id?: string | number | undefined;
|
|
97
108
|
fallbackLocale?: string | undefined;
|
|
@@ -100,6 +111,7 @@ export declare const toolSchemas: {
|
|
|
100
111
|
data: string;
|
|
101
112
|
depth?: number | undefined;
|
|
102
113
|
locale?: string | undefined;
|
|
114
|
+
select?: string | undefined;
|
|
103
115
|
draft?: boolean | undefined;
|
|
104
116
|
where?: string | undefined;
|
|
105
117
|
id?: string | number | undefined;
|
|
@@ -139,16 +151,19 @@ export declare const toolSchemas: {
|
|
|
139
151
|
draft: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
140
152
|
fallbackLocale: z.ZodOptional<z.ZodString>;
|
|
141
153
|
locale: z.ZodOptional<z.ZodString>;
|
|
154
|
+
select: z.ZodOptional<z.ZodString>;
|
|
142
155
|
}, "strip", z.ZodTypeAny, {
|
|
143
156
|
depth: number;
|
|
144
157
|
draft: boolean;
|
|
145
158
|
data: string;
|
|
146
159
|
locale?: string | undefined;
|
|
160
|
+
select?: string | undefined;
|
|
147
161
|
fallbackLocale?: string | undefined;
|
|
148
162
|
}, {
|
|
149
163
|
data: string;
|
|
150
164
|
depth?: number | undefined;
|
|
151
165
|
locale?: string | undefined;
|
|
166
|
+
select?: string | undefined;
|
|
152
167
|
draft?: boolean | undefined;
|
|
153
168
|
fallbackLocale?: string | undefined;
|
|
154
169
|
}>;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsgBvB,CAAA"}
|
|
@@ -5,7 +5,8 @@ export const toolSchemas = {
|
|
|
5
5
|
parameters: z.object({
|
|
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
|
-
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')
|
|
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
|
+
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'")
|
|
9
10
|
})
|
|
10
11
|
},
|
|
11
12
|
findResources: {
|
|
@@ -21,6 +22,7 @@ export const toolSchemas = {
|
|
|
21
22
|
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)'),
|
|
22
23
|
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'),
|
|
23
24
|
page: z.number().int().min(1, 'Page must be at least 1').optional().default(1).describe('Page number for pagination (default: 1)'),
|
|
25
|
+
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'"),
|
|
24
26
|
sort: z.string().optional().describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)'),
|
|
25
27
|
where: z.string().optional().describe('Optional JSON string for where clause filtering (e.g., \'{"title": {"contains": "test"}}\')')
|
|
26
28
|
})
|
|
@@ -32,7 +34,8 @@ export const toolSchemas = {
|
|
|
32
34
|
depth: z.number().int().min(0).max(10).optional().default(0).describe('How many levels deep to populate relationships in response (default: 0)'),
|
|
33
35
|
draft: z.boolean().optional().default(false).describe('Whether to create the document as a draft'),
|
|
34
36
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
35
|
-
locale: z.string().optional().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale')
|
|
37
|
+
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 (JSON), e.g., '{\"title\": true}'")
|
|
36
39
|
})
|
|
37
40
|
},
|
|
38
41
|
updateResource: {
|
|
@@ -50,6 +53,7 @@ export const toolSchemas = {
|
|
|
50
53
|
locale: z.string().optional().describe('Optional: locale code to update the document in (e.g., "en", "es"). Defaults to the default locale'),
|
|
51
54
|
overrideLock: z.boolean().optional().default(true).describe('Whether to override document locks'),
|
|
52
55
|
overwriteExistingFiles: z.boolean().optional().default(false).describe('Whether to overwrite existing files'),
|
|
56
|
+
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"title\": true}'"),
|
|
53
57
|
where: z.string().optional().describe('Optional: JSON string for where clause to update multiple documents')
|
|
54
58
|
})
|
|
55
59
|
},
|
|
@@ -73,7 +77,8 @@ export const toolSchemas = {
|
|
|
73
77
|
depth: z.number().int().min(0).max(10).optional().default(0).describe('Depth of population for relationships'),
|
|
74
78
|
draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),
|
|
75
79
|
fallbackLocale: z.string().optional().describe('Optional: fallback locale code to use when requested locale is not available'),
|
|
76
|
-
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')
|
|
80
|
+
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'),
|
|
81
|
+
select: z.string().optional().describe("Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\"siteName\": true}'")
|
|
77
82
|
})
|
|
78
83
|
},
|
|
79
84
|
// Experimental Below This Line
|
|
@@ -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 }),\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 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 }),\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 filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\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 overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\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 }),\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 generalConfig: z.any().optional().describe('General configuration updates'),\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 overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\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 disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\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","findResources","id","union","draft","boolean","limit","page","sort","where","createResource","data","updateResource","filePath","overrideLock","overwriteExistingFiles","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","generalConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","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,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AAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7B8E,UAAU3F,EACPO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRE,QAAQ,CAAC;YACZ+E,OAAO5F,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 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 filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\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 overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\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 generalConfig: z.any().optional().describe('General configuration updates'),\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 overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\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 disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\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","filePath","overrideLock","overwriteExistingFiles","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","generalConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","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,MA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M,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.73.0
|
|
3
|
+
"version": "3.73.0",
|
|
4
4
|
"description": "MCP (Model Context Protocol) capabilities with Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@payloadcms/eslint-config": "3.28.0",
|
|
48
|
-
"payload": "3.73.0
|
|
48
|
+
"payload": "3.73.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"payload": "3.73.0
|
|
51
|
+
"payload": "3.73.0"
|
|
52
52
|
},
|
|
53
53
|
"homepage:": "https://payloadcms.com",
|
|
54
54
|
"scripts": {
|
package/src/mcp/getMcpHandler.ts
CHANGED
|
@@ -506,7 +506,7 @@ export const getMCPHandler = (
|
|
|
506
506
|
serverInfo: serverOptions.serverInfo,
|
|
507
507
|
},
|
|
508
508
|
{
|
|
509
|
-
basePath: MCPHandlerOptions.basePath || '/api',
|
|
509
|
+
basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',
|
|
510
510
|
maxDuration: MCPHandlerOptions.maxDuration || 60,
|
|
511
511
|
// INFO: Disabled until developer clarity is reached for server side streaming and we have an auth pattern for all SSE patterns
|
|
512
512
|
// redisUrl: MCPHandlerOptions.redisUrl || process.env.REDIS_URL,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
-
import type { PayloadRequest, TypedUser } from 'payload'
|
|
2
|
+
import type { PayloadRequest, SelectType, TypedUser } from 'payload'
|
|
3
3
|
|
|
4
4
|
import type { PluginMCPServerConfig } from '../../../types.js'
|
|
5
5
|
|
|
@@ -18,6 +18,7 @@ export const findGlobalTool = (
|
|
|
18
18
|
depth: number = 0,
|
|
19
19
|
locale?: string,
|
|
20
20
|
fallbackLocale?: string,
|
|
21
|
+
select?: string,
|
|
21
22
|
): Promise<{
|
|
22
23
|
content: Array<{
|
|
23
24
|
text: string
|
|
@@ -39,6 +40,24 @@ export const findGlobalTool = (
|
|
|
39
40
|
user,
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
let selectClause: SelectType | undefined
|
|
44
|
+
if (select) {
|
|
45
|
+
try {
|
|
46
|
+
selectClause = JSON.parse(select) as SelectType
|
|
47
|
+
} catch (_parseError) {
|
|
48
|
+
payload.logger.warn(`[payload-mcp] Invalid select clause JSON for global: ${select}`)
|
|
49
|
+
const response = {
|
|
50
|
+
content: [{ type: 'text' as const, text: 'Error: Invalid JSON in select clause' }],
|
|
51
|
+
}
|
|
52
|
+
return (globals?.[globalSlug]?.overrideResponse?.(response, {}, req) || response) as {
|
|
53
|
+
content: Array<{
|
|
54
|
+
text: string
|
|
55
|
+
type: 'text'
|
|
56
|
+
}>
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
42
61
|
// Add locale parameters if provided
|
|
43
62
|
if (locale) {
|
|
44
63
|
findOptions.locale = locale
|
|
@@ -46,6 +65,9 @@ export const findGlobalTool = (
|
|
|
46
65
|
if (fallbackLocale) {
|
|
47
66
|
findOptions.fallbackLocale = fallbackLocale
|
|
48
67
|
}
|
|
68
|
+
if (selectClause) {
|
|
69
|
+
findOptions.select = selectClause
|
|
70
|
+
}
|
|
49
71
|
|
|
50
72
|
const result = await payload.findGlobal(findOptions)
|
|
51
73
|
|
|
@@ -96,8 +118,8 @@ ${JSON.stringify(result, null, 2)}
|
|
|
96
118
|
`find${globalSlug.charAt(0).toUpperCase() + toCamelCase(globalSlug).slice(1)}`,
|
|
97
119
|
`${toolSchemas.findGlobal.description.trim()}\n\n${globals?.[globalSlug]?.description || ''}`,
|
|
98
120
|
toolSchemas.findGlobal.parameters.shape,
|
|
99
|
-
async ({ depth, fallbackLocale, locale }) => {
|
|
100
|
-
return await tool(depth, locale, fallbackLocale)
|
|
121
|
+
async ({ depth, fallbackLocale, locale, select }) => {
|
|
122
|
+
return await tool(depth, locale, fallbackLocale, select)
|
|
101
123
|
},
|
|
102
124
|
)
|
|
103
125
|
}
|