@payloadcms/plugin-mcp 4.0.0-internal.8001944 → 4.0.0-internal.8089ef7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB,4CA0ElC,CAAA"}
1
+ {"version":3,"file":"getCollectionSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,4CAoFlC,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload';
2
+ import { getLLMInstructions } from 'payload/internal';
2
3
  import { defaultAccess } from '../../../defaultAccess.js';
3
4
  import { defineCollectionTool } from '../../../defineTool.js';
4
5
  export const getCollectionSchemaTool = defineCollectionTool({
@@ -13,7 +14,7 @@ export const getCollectionSchemaTool = defineCollectionTool({
13
14
  readOnlyHint: true,
14
15
  title: 'Get Collection Schema'
15
16
  },
16
- description: 'Get the input schema for creating or updating documents in a collection.',
17
+ description: 'Get the input schema and LLM instructions before creating or updating documents in a collection.',
17
18
  input: getCollectionSchemaInputSchema
18
19
  }).handler(async ({ slug, authorizedMCP, req })=>{
19
20
  const permissions = authorizedMCP.overrideAccess ? null : (await getAccessResults({
@@ -69,17 +70,32 @@ export const getCollectionSchemaTool = defineCollectionTool({
69
70
  } : {
70
71
  enabled: false
71
72
  };
73
+ const instructions = await getLLMInstructions({
74
+ slug,
75
+ type: 'collection',
76
+ overrideAccess: authorizedMCP.overrideAccess,
77
+ req
78
+ });
72
79
  return {
73
80
  content: [
74
81
  {
75
82
  type: 'text',
76
83
  text: `Schema for collection "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\`\nUpload configuration:\n\`\`\`json\n${JSON.stringify(upload)}\n\`\`\``
77
- }
84
+ },
85
+ ...instructions ? [
86
+ {
87
+ type: 'text',
88
+ text: instructions
89
+ }
90
+ ] : []
78
91
  ],
79
92
  structuredContent: {
80
93
  slug,
81
94
  schema: inputSchema,
82
- upload
95
+ upload,
96
+ ...instructions ? {
97
+ instructions
98
+ } : {}
83
99
  }
84
100
  };
85
101
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.slug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description: 'Get the input schema for creating or updating documents in a collection.',\n input: getCollectionSchemaInputSchema,\n}).handler(async ({ slug, authorizedMCP, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[slug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${slug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug: slug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${slug}\" not found` }],\n isError: true,\n }\n }\n\n const uploadConfig = req.payload.collections[slug]?.config.upload\n const maxFileSize = req.payload.config.upload.limits?.fileSize\n const upload = uploadConfig\n ? {\n enabled: true,\n filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,\n mimeTypes: uploadConfig.mimeTypes ?? ['*/*'],\n sources: [\n ...(uploadConfig.pasteURL !== false ? ['externalURL'] : []),\n 'base64',\n 'uploadReference',\n ],\n ...(typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? { maxFileSize } : {}),\n }\n : { enabled: false }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\`\\nUpload configuration:\\n\\`\\`\\`json\\n${JSON.stringify(upload)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n slug,\n schema: inputSchema,\n upload,\n },\n }\n})\n"],"names":["getAccessResults","getCollectionInputSchema","getCollectionSchemaInputSchema","defaultAccess","defineCollectionTool","getCollectionSchemaTool","access","args","permissions","collections","slug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","collectionSlug","uploadConfig","payload","config","upload","maxFileSize","limits","fileSize","enabled","filesRequiredOnCreate","mimeTypes","sources","pasteURL","Number","isFinite","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,wBAAwB,EAAEC,8BAA8B,QAAQ,UAAS;AAEpG,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAO,MAAMC,0BAA0BD,qBAAqB;IAC1DE,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,IAAI,CAAC;QAE9D,OAAOP,cAAcI,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;IACbC,OAAOnB;AACT,GAAGoB,OAAO,CAAC,OAAO,EAAEZ,IAAI,E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EAAEoC,KAAKC,SAAS,CAACjB,aAAa,6CAA6C,EAAEgB,KAAKC,SAAS,CAACZ,QAAQ,QAAQ,CAAC;YACpK;SACD;QACDa,mBAAmB;YACjBtC;YACAuC,QAAQnB;YACRK;QACF;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/collections/getCollectionSchemaTool.ts"],"sourcesContent":["import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload'\nimport { getLLMInstructions } from 'payload/internal'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\n\nexport const getCollectionSchemaTool = defineCollectionTool({\n access: (args) => {\n const permissions = args.permissions?.collections?.[args.slug]\n\n return defaultAccess(args) && Boolean(permissions?.create || permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Collection Schema',\n },\n description:\n 'Get the input schema and LLM instructions before creating or updating documents in a collection.',\n input: getCollectionSchemaInputSchema,\n}).handler(async ({ slug, authorizedMCP, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).collections?.[slug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.create && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getCollectionSchema\" is not enabled for collection \"${slug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getCollectionInputSchema({\n collectionSlug: slug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Collection \"${slug}\" not found` }],\n isError: true,\n }\n }\n\n const uploadConfig = req.payload.collections[slug]?.config.upload\n const maxFileSize = req.payload.config.upload.limits?.fileSize\n const upload = uploadConfig\n ? {\n enabled: true,\n filesRequiredOnCreate: uploadConfig.filesRequiredOnCreate !== false,\n mimeTypes: uploadConfig.mimeTypes ?? ['*/*'],\n sources: [\n ...(uploadConfig.pasteURL !== false ? ['externalURL'] : []),\n 'base64',\n 'uploadReference',\n ],\n ...(typeof maxFileSize === 'number' && Number.isFinite(maxFileSize) ? { maxFileSize } : {}),\n }\n : { enabled: false }\n\n const instructions = await getLLMInstructions({\n slug,\n type: 'collection',\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for collection \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\`\\nUpload configuration:\\n\\`\\`\\`json\\n${JSON.stringify(upload)}\\n\\`\\`\\``,\n },\n ...(instructions ? [{ type: 'text' as const, text: instructions }] : []),\n ],\n structuredContent: {\n slug,\n schema: inputSchema,\n upload,\n ...(instructions ? { instructions } : {}),\n },\n }\n})\n"],"names":["getAccessResults","getCollectionInputSchema","getCollectionSchemaInputSchema","getLLMInstructions","defaultAccess","defineCollectionTool","getCollectionSchemaTool","access","args","permissions","collections","slug","Boolean","create","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","collectionSlug","uploadConfig","payload","config","upload","maxFileSize","limits","fileSize","enabled","filesRequiredOnCreate","mimeTypes","sources","pasteURL","Number","isFinite","instructions","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,wBAAwB,EAAEC,8BAA8B,QAAQ,UAAS;AACpG,SAASC,kBAAkB,QAAQ,mBAAkB;AAErD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yBAAwB;AAE7D,OAAO,MAAMC,0BAA0BD,qBAAqB;IAC1DE,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,aAAa,CAACF,KAAKG,IAAI,CAAC;QAE9D,OAAOP,cAAcI,SAASI,QAAQH,aAAaI,UAAUJ,aAAaK;IAC5E;IACAC,aAAa;QACXC,iBAAiB;QACjBC,g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AC5F,IACA;QAAEG,SAAS;IAAM;IAErB,MAAMO,eAAe,MAAM5C,mBAAmB;QAC5CQ;QACAiB,MAAM;QACNF,gBAAgBF,cAAcE,cAAc;QAC5CD;IACF;IAEA,OAAO;QACLE,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,uBAAuB,EAAElB,KAAK,gBAAgB,EAAEqC,KAAKC,SAAS,CAAClB,aAAa,6CAA6C,EAAEiB,KAAKC,SAAS,CAACb,QAAQ,QAAQ,CAAC;YACpK;eACIW,eAAe;gBAAC;oBAAEnB,MAAM;oBAAiBC,MAAMkB;gBAAa;aAAE,GAAG,EAAE;SACxE;QACDG,mBAAmB;YACjBvC;YACAwC,QAAQpB;YACRK;YACA,GAAIW,eAAe;gBAAEA;YAAa,IAAI,CAAC,CAAC;QAC1C;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,wCAyD9B,CAAA"}
1
+ {"version":3,"file":"getGlobalSchemaTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,wCAkE9B,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { getAccessResults, getGlobalInputSchema, getGlobalSchemaInputSchema } from 'payload';
2
+ import { getLLMInstructions } from 'payload/internal';
2
3
  import { defaultAccess } from '../../../defaultAccess.js';
3
4
  import { defineGlobalTool } from '../../../defineTool.js';
4
5
  export const getGlobalSchemaTool = defineGlobalTool({
@@ -13,7 +14,7 @@ export const getGlobalSchemaTool = defineGlobalTool({
13
14
  readOnlyHint: true,
14
15
  title: 'Get Global Schema'
15
16
  },
16
- description: 'Get the input schema for updating a global.',
17
+ description: 'Get the input schema and LLM instructions before updating a global.',
17
18
  input: getGlobalSchemaInputSchema
18
19
  }).handler(async ({ slug, authorizedMCP, req })=>{
19
20
  const permissions = authorizedMCP.overrideAccess ? null : (await getAccessResults({
@@ -48,16 +49,31 @@ export const getGlobalSchemaTool = defineGlobalTool({
48
49
  isError: true
49
50
  };
50
51
  }
52
+ const instructions = await getLLMInstructions({
53
+ slug,
54
+ type: 'global',
55
+ overrideAccess: authorizedMCP.overrideAccess,
56
+ req
57
+ });
51
58
  return {
52
59
  content: [
53
60
  {
54
61
  type: 'text',
55
62
  text: `Schema for global "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``
56
- }
63
+ },
64
+ ...instructions ? [
65
+ {
66
+ type: 'text',
67
+ text: instructions
68
+ }
69
+ ] : []
57
70
  ],
58
71
  structuredContent: {
59
72
  slug,
60
- schema: inputSchema
73
+ schema: inputSchema,
74
+ ...instructions ? {
75
+ instructions
76
+ } : {}
61
77
  }
62
78
  };
63
79
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"sourcesContent":["import { getAccessResults, getGlobalInputSchema, getGlobalSchemaInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\n\nexport const getGlobalSchemaTool = defineGlobalTool({\n access: (args) => {\n const permissions = args.permissions?.globals?.[args.slug]\n\n return defaultAccess(args) && Boolean(permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Global Schema',\n },\n description: 'Get the input schema for updating a global.',\n input: getGlobalSchemaInputSchema,\n}).handler(async ({ slug, authorizedMCP, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).globals?.[slug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getGlobalSchema\" is not enabled for global \"${slug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getGlobalInputSchema({\n globalSlug: slug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Global \"${slug}\" not found` }],\n isError: true,\n }\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ],\n structuredContent: {\n slug,\n schema: inputSchema,\n },\n }\n})\n"],"names":["getAccessResults","getGlobalInputSchema","getGlobalSchemaInputSchema","defaultAccess","defineGlobalTool","getGlobalSchemaTool","access","args","permissions","globals","slug","Boolean","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","globalSlug","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,oBAAoB,EAAEC,0BAA0B,QAAQ,UAAS;AAE5F,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,OAAO,MAAMC,sBAAsBD,iBAAiB;IAClDE,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,SAAS,CAACF,KAAKG,IAAI,CAAC;QAE1D,OAAOP,cAAcI,SAASI,QAAQH,aAAaI;IACrD;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;IACbC,OAAOlB;AACT,GAAGmB,OAAO,CAAC,OAAO,EAAEX,IAAI,EAAEY,aAAa,EAAEC,GAAG,EAAE;IAC5C,MAAMf,cAAcc,cAAcE,cAAc,GAC5C,OACA,AAAC,CAAA,MAAMxB,iBAAiB;QAAEuB;IAAI,EAAC,EAAGd,OAAO,EAAE,CAACC,KAAK;IAErD,IAAI,CAACY,cAAcE,cAAc,IAAI,CAAChB,aAAaI,QAAQ;QACzD,OAAO;YACLa,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,kEAAkE,EAAEjB,KAAK,CAAC,CAAC;gBACpF;aACD;YACDkB,SAAS;QACX;IACF;IAEA,MAAMC,cAAc5B,qBAAqB;QACvC6B,YAAYpB;QACZa;QACA,GAAIf,cAAc;YAAEA;QAAY,IAAI,CAAC,CAAC;IACxC;IAEA,IAAI,CAACqB,aAAa;QAChB,OAAO;YACLJ,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,eAAe,EAAEjB,KAAK,WAAW,CAAC;gBAAC;aAAE;YACtEkB,SAAS;QACX;IACF;IAEA,OAAO;QACLH,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,mBAAmB,EAAEjB,KAAK,gBAAgB,EAAEqB,KAAKC,SAAS,CAACH,aAAa,QAAQ,CAAC;YAC1F;SACD;QACDI,mBAAmB;YACjBvB;YACAwB,QAAQL;QACV;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/getGlobalSchemaTool.ts"],"sourcesContent":["import { getAccessResults, getGlobalInputSchema, getGlobalSchemaInputSchema } from 'payload'\nimport { getLLMInstructions } from 'payload/internal'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\n\nexport const getGlobalSchemaTool = defineGlobalTool({\n access: (args) => {\n const permissions = args.permissions?.globals?.[args.slug]\n\n return defaultAccess(args) && Boolean(permissions?.update)\n },\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Get Global Schema',\n },\n description: 'Get the input schema and LLM instructions before updating a global.',\n input: getGlobalSchemaInputSchema,\n}).handler(async ({ slug, authorizedMCP, req }) => {\n const permissions = authorizedMCP.overrideAccess\n ? null\n : (await getAccessResults({ req })).globals?.[slug]\n\n if (!authorizedMCP.overrideAccess && !permissions?.update) {\n return {\n content: [\n {\n type: 'text',\n text: `Error: MCP access to \"getGlobalSchema\" is not enabled for global \"${slug}\"`,\n },\n ],\n isError: true,\n }\n }\n\n const inputSchema = getGlobalInputSchema({\n globalSlug: slug,\n req,\n ...(permissions ? { permissions } : {}),\n })\n\n if (!inputSchema) {\n return {\n content: [{ type: 'text', text: `Error: Global \"${slug}\" not found` }],\n isError: true,\n }\n }\n\n const instructions = await getLLMInstructions({\n slug,\n type: 'global',\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Schema for global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(inputSchema)}\\n\\`\\`\\``,\n },\n ...(instructions ? [{ type: 'text' as const, text: instructions }] : []),\n ],\n structuredContent: {\n slug,\n schema: inputSchema,\n ...(instructions ? { instructions } : {}),\n },\n }\n})\n"],"names":["getAccessResults","getGlobalInputSchema","getGlobalSchemaInputSchema","getLLMInstructions","defaultAccess","defineGlobalTool","getGlobalSchemaTool","access","args","permissions","globals","slug","Boolean","update","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","overrideAccess","content","type","text","isError","inputSchema","globalSlug","instructions","JSON","stringify","structuredContent","schema"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,oBAAoB,EAAEC,0BAA0B,QAAQ,UAAS;AAC5F,SAASC,kBAAkB,QAAQ,mBAAkB;AAErD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AAEzD,OAAO,MAAMC,sBAAsBD,iBAAiB;IAClDE,QAAQ,CAACC;QACP,MAAMC,cAAcD,KAAKC,WAAW,EAAEC,SAAS,CAACF,KAAKG,IAAI,CAAC;QAE1D,OAAOP,cAAcI,SAASI,QAAQH,aAAaI;IACrD;IACAC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;IACbC,OAAOnB;AACT,GAAGoB,OAAO,CAAC,OAAO,EAAEX,IAAI,EAAEY,aAAa,EAAEC,GAAG,EAAE;IAC5C,MAAMf,cAAcc,cAAcE,cAAc,GAC5C,OACA,AAAC,CAAA,MAAMzB,iBAAiB;QAAEwB;IAAI,EAAC,EAAGd,OAAO,EAAE,CAACC,KAAK;IAErD,IAAI,CAACY,cAAcE,cAAc,IAAI,CAAChB,aAAaI,QAAQ;QACzD,OAAO;YACLa,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,kEAAkE,EAAEjB,KAAK,CAAC,CAAC;gBACpF;aACD;YACDkB,SAAS;QACX;IACF;IAEA,MAAMC,cAAc7B,qBAAqB;QACvC8B,YAAYpB;QACZa;QACA,GAAIf,cAAc;YAAEA;QAAY,IAAI,CAAC,CAAC;IACxC;IAEA,IAAI,CAACqB,aAAa;QAChB,OAAO;YACLJ,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,eAAe,EAAEjB,KAAK,WAAW,CAAC;gBAAC;aAAE;YACtEkB,SAAS;QACX;IACF;IAEA,MAAMG,eAAe,MAAM7B,mBAAmB;QAC5CQ;QACAgB,MAAM;QACNF,gBAAgBF,cAAcE,cAAc;QAC5CD;IACF;IAEA,OAAO;QACLE,SAAS;YACP;gBACEC,MAAM;gBACNC,MAAM,CAAC,mBAAmB,EAAEjB,KAAK,gBAAgB,EAAEsB,KAAKC,SAAS,CAACJ,aAAa,QAAQ,CAAC;YAC1F;eACIE,eAAe;gBAAC;oBAAEL,MAAM;oBAAiBC,MAAMI;gBAAa;aAAE,GAAG,EAAE;SACxE;QACDG,mBAAmB;YACjBxB;YACAyB,QAAQN;YACR,GAAIE,eAAe;gBAAEA;YAAa,IAAI,CAAC,CAAC;QAC1C;IACF;AACF,GAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-mcp",
3
- "version": "4.0.0-internal.8001944",
3
+ "version": "4.0.0-internal.8089ef7",
4
4
  "description": "MCP (Model Context Protocol) capabilities with Payload",
5
5
  "keywords": [
6
6
  "plugin",
@@ -59,11 +59,11 @@
59
59
  "tsx": "4.23.15"
60
60
  },
61
61
  "devDependencies": {
62
- "payload": "4.0.0-internal.8001944",
63
- "@payloadcms/eslint-config": "3.28.0"
62
+ "@payloadcms/eslint-config": "3.28.0",
63
+ "payload": "4.0.0-internal.8089ef7"
64
64
  },
65
65
  "peerDependencies": {
66
- "payload": "4.0.0-internal.8001944"
66
+ "payload": "4.0.0-internal.8089ef7"
67
67
  },
68
68
  "//deps_notes": {
69
69
  "tsx": "Required by the `bin.js` stdio mcp. Keep the version pinned to whatever `payload` ships to avoid duplicate installs."
@@ -1,4 +1,5 @@
1
1
  import { getAccessResults, getCollectionInputSchema, getCollectionSchemaInputSchema } from 'payload'
2
+ import { getLLMInstructions } from 'payload/internal'
2
3
 
3
4
  import { defaultAccess } from '../../../defaultAccess.js'
4
5
  import { defineCollectionTool } from '../../../defineTool.js'
@@ -16,7 +17,8 @@ export const getCollectionSchemaTool = defineCollectionTool({
16
17
  readOnlyHint: true,
17
18
  title: 'Get Collection Schema',
18
19
  },
19
- description: 'Get the input schema for creating or updating documents in a collection.',
20
+ description:
21
+ 'Get the input schema and LLM instructions before creating or updating documents in a collection.',
20
22
  input: getCollectionSchemaInputSchema,
21
23
  }).handler(async ({ slug, authorizedMCP, req }) => {
22
24
  const permissions = authorizedMCP.overrideAccess
@@ -64,17 +66,26 @@ export const getCollectionSchemaTool = defineCollectionTool({
64
66
  }
65
67
  : { enabled: false }
66
68
 
69
+ const instructions = await getLLMInstructions({
70
+ slug,
71
+ type: 'collection',
72
+ overrideAccess: authorizedMCP.overrideAccess,
73
+ req,
74
+ })
75
+
67
76
  return {
68
77
  content: [
69
78
  {
70
79
  type: 'text',
71
80
  text: `Schema for collection "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\`\nUpload configuration:\n\`\`\`json\n${JSON.stringify(upload)}\n\`\`\``,
72
81
  },
82
+ ...(instructions ? [{ type: 'text' as const, text: instructions }] : []),
73
83
  ],
74
84
  structuredContent: {
75
85
  slug,
76
86
  schema: inputSchema,
77
87
  upload,
88
+ ...(instructions ? { instructions } : {}),
78
89
  },
79
90
  }
80
91
  })
@@ -1,4 +1,5 @@
1
1
  import { getAccessResults, getGlobalInputSchema, getGlobalSchemaInputSchema } from 'payload'
2
+ import { getLLMInstructions } from 'payload/internal'
2
3
 
3
4
  import { defaultAccess } from '../../../defaultAccess.js'
4
5
  import { defineGlobalTool } from '../../../defineTool.js'
@@ -16,7 +17,7 @@ export const getGlobalSchemaTool = defineGlobalTool({
16
17
  readOnlyHint: true,
17
18
  title: 'Get Global Schema',
18
19
  },
19
- description: 'Get the input schema for updating a global.',
20
+ description: 'Get the input schema and LLM instructions before updating a global.',
20
21
  input: getGlobalSchemaInputSchema,
21
22
  }).handler(async ({ slug, authorizedMCP, req }) => {
22
23
  const permissions = authorizedMCP.overrideAccess
@@ -48,16 +49,25 @@ export const getGlobalSchemaTool = defineGlobalTool({
48
49
  }
49
50
  }
50
51
 
52
+ const instructions = await getLLMInstructions({
53
+ slug,
54
+ type: 'global',
55
+ overrideAccess: authorizedMCP.overrideAccess,
56
+ req,
57
+ })
58
+
51
59
  return {
52
60
  content: [
53
61
  {
54
62
  type: 'text',
55
63
  text: `Schema for global "${slug}":\n\`\`\`json\n${JSON.stringify(inputSchema)}\n\`\`\``,
56
64
  },
65
+ ...(instructions ? [{ type: 'text' as const, text: instructions }] : []),
57
66
  ],
58
67
  structuredContent: {
59
68
  slug,
60
69
  schema: inputSchema,
70
+ ...(instructions ? { instructions } : {}),
61
71
  },
62
72
  }
63
73
  })