@payloadcms/plugin-mcp 4.0.0-internal.9726517 → 4.0.0-internal.a1317b2

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.
Files changed (165) hide show
  1. package/dist/endpoint/access.js +2 -2
  2. package/dist/endpoint/access.js.map +1 -1
  3. package/dist/mcp/buildMcpServer.d.ts +1 -1
  4. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  5. package/dist/mcp/buildMcpServer.js +35 -23
  6. package/dist/mcp/buildMcpServer.js.map +1 -1
  7. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  8. package/dist/mcp/builtin/collections/authTools.js +79 -56
  9. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  10. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
  11. package/dist/mcp/builtin/collections/countTool.js +9 -14
  12. package/dist/mcp/builtin/collections/countTool.js.map +1 -1
  13. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
  14. package/dist/mcp/builtin/collections/countVersionsTool.js +9 -13
  15. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
  16. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  17. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  18. package/dist/mcp/builtin/collections/createTool.js +100 -62
  19. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  20. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  21. package/dist/mcp/builtin/collections/deleteTool.js +40 -43
  22. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  23. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
  24. package/dist/mcp/builtin/collections/duplicateTool.js +26 -36
  25. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
  26. package/dist/mcp/builtin/collections/fileInput.d.ts +21 -21
  27. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -1
  28. package/dist/mcp/builtin/collections/fileInput.js +30 -24
  29. package/dist/mcp/builtin/collections/fileInput.js.map +1 -1
  30. package/dist/mcp/builtin/collections/fileInput.spec.js +2 -2
  31. package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -1
  32. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
  33. package/dist/mcp/builtin/collections/findDistinctTool.js +11 -26
  34. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
  35. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  36. package/dist/mcp/builtin/collections/findTool.js +21 -43
  37. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  38. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
  39. package/dist/mcp/builtin/collections/findVersionByIDTool.js +17 -26
  40. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
  41. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
  42. package/dist/mcp/builtin/collections/findVersionsTool.js +16 -30
  43. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
  44. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  45. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +12 -12
  46. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  47. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
  48. package/dist/mcp/builtin/collections/restoreVersionTool.js +14 -26
  49. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
  50. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  51. package/dist/mcp/builtin/collections/updateTool.js +40 -85
  52. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  53. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +13 -13
  54. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -1
  55. package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
  56. package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
  57. package/dist/mcp/builtin/formatEntityError.js +55 -0
  58. package/dist/mcp/builtin/formatEntityError.js.map +1 -0
  59. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  60. package/dist/mcp/builtin/getConfigInfoTool.js +3 -2
  61. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  62. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
  63. package/dist/mcp/builtin/globals/countVersionsTool.js +9 -13
  64. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
  65. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  66. package/dist/mcp/builtin/globals/findTool.js +10 -16
  67. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  68. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
  69. package/dist/mcp/builtin/globals/findVersionByIDTool.js +13 -24
  70. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
  71. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
  72. package/dist/mcp/builtin/globals/findVersionsTool.js +13 -29
  73. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
  74. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  75. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +11 -11
  76. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  77. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
  78. package/dist/mcp/builtin/globals/restoreVersionTool.js +15 -22
  79. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
  80. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  81. package/dist/mcp/builtin/globals/updateTool.js +27 -36
  82. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  83. package/dist/mcp/builtinTools.d.ts.map +1 -1
  84. package/dist/mcp/builtinTools.js +3 -3
  85. package/dist/mcp/builtinTools.js.map +1 -1
  86. package/dist/stdio.d.ts.map +1 -1
  87. package/dist/stdio.js +2 -1
  88. package/dist/stdio.js.map +1 -1
  89. package/dist/types.d.ts +4 -4
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/package.json +5 -7
  93. package/src/endpoint/access.ts +2 -3
  94. package/src/mcp/buildMcpServer.ts +39 -29
  95. package/src/mcp/builtin/collections/authTools.ts +77 -69
  96. package/src/mcp/builtin/collections/countTool.ts +9 -21
  97. package/src/mcp/builtin/collections/countVersionsTool.ts +9 -18
  98. package/src/mcp/builtin/collections/createTool.ts +96 -85
  99. package/src/mcp/builtin/collections/deleteTool.ts +36 -64
  100. package/src/mcp/builtin/collections/duplicateTool.ts +33 -84
  101. package/src/mcp/builtin/collections/fileInput.spec.ts +2 -2
  102. package/src/mcp/builtin/collections/fileInput.ts +40 -25
  103. package/src/mcp/builtin/collections/findDistinctTool.ts +11 -63
  104. package/src/mcp/builtin/collections/findTool.ts +21 -103
  105. package/src/mcp/builtin/collections/findVersionByIDTool.ts +15 -58
  106. package/src/mcp/builtin/collections/findVersionsTool.ts +14 -85
  107. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +11 -11
  108. package/src/mcp/builtin/collections/restoreVersionTool.ts +14 -56
  109. package/src/mcp/builtin/collections/updateTool.ts +49 -107
  110. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +15 -15
  111. package/src/mcp/builtin/formatEntityError.ts +77 -0
  112. package/src/mcp/builtin/getConfigInfoTool.ts +2 -1
  113. package/src/mcp/builtin/globals/countVersionsTool.ts +9 -17
  114. package/src/mcp/builtin/globals/findTool.ts +12 -51
  115. package/src/mcp/builtin/globals/findVersionByIDTool.ts +13 -52
  116. package/src/mcp/builtin/globals/findVersionsTool.ts +14 -92
  117. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +10 -10
  118. package/src/mcp/builtin/globals/restoreVersionTool.ts +14 -45
  119. package/src/mcp/builtin/globals/updateTool.ts +37 -60
  120. package/src/mcp/builtinTools.ts +2 -2
  121. package/src/stdio.ts +2 -1
  122. package/src/types.ts +4 -4
  123. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
  124. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
  125. package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
  126. package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
  127. package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
  128. package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
  129. package/dist/mcp/builtin/validateEntityData.js +0 -82
  130. package/dist/mcp/builtin/validateEntityData.js.map +0 -1
  131. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  132. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  133. package/dist/utils/getVirtualFieldNames.js +0 -35
  134. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  135. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts +0 -28
  136. package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +0 -1
  137. package/dist/utils/schemaConversion/filterFieldsByAccess.js +0 -71
  138. package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +0 -1
  139. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -13
  140. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
  141. package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -66
  142. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
  143. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -10
  144. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
  145. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -384
  146. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
  147. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -133
  148. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
  149. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  150. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  151. package/dist/utils/transformPointDataToPayload.js +0 -28
  152. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  153. package/dist/utils/whereSchema.d.ts +0 -9
  154. package/dist/utils/whereSchema.d.ts.map +0 -1
  155. package/dist/utils/whereSchema.js +0 -13
  156. package/dist/utils/whereSchema.js.map +0 -1
  157. package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
  158. package/src/mcp/builtin/validateEntityData.ts +0 -132
  159. package/src/utils/getVirtualFieldNames.ts +0 -53
  160. package/src/utils/schemaConversion/filterFieldsByAccess.ts +0 -123
  161. package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -96
  162. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -96
  163. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -432
  164. package/src/utils/transformPointDataToPayload.ts +0 -40
  165. package/src/utils/whereSchema.ts +0 -24
@@ -0,0 +1,16 @@
1
+ import type { CollectionSlug, GlobalSlug, PayloadRequest } from 'payload';
2
+ import type { MCPToolResponse } from '../../types.js';
3
+ export declare const formatEntityError: ({ slug, action, entity, error, req, }: {
4
+ action: 'creating' | 'duplicating' | 'updating';
5
+ entity: 'collection';
6
+ error: unknown;
7
+ req: PayloadRequest;
8
+ slug: CollectionSlug;
9
+ } | {
10
+ action: 'updating';
11
+ entity: 'global';
12
+ error: unknown;
13
+ req: PayloadRequest;
14
+ slug: GlobalSlug;
15
+ }) => MCPToolResponse;
16
+ //# sourceMappingURL=formatEntityError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatEntityError.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/formatEntityError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,eAAO,MAAM,iBAAiB,0CAO1B;IACE,MAAM,EAAE,UAAU,GAAG,aAAa,GAAG,UAAU,CAAA;IAC/C,MAAM,EAAE,YAAY,CAAA;IACpB,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAA;CACrB,GACD;IACE,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,QAAQ,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB,KAAG,eAsCP,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { getCollectionInputSchema, getGlobalInputSchema, ValidationError } from 'payload';
2
+ export const formatEntityError = ({ slug, action, entity, error, req })=>{
3
+ const message = error instanceof Error ? error.message : 'Unknown error';
4
+ const target = entity === 'collection' ? `document in collection "${slug}"` : `global "${slug}"`;
5
+ if (!isValidationError(error, message)) {
6
+ return {
7
+ content: [
8
+ {
9
+ type: 'text',
10
+ text: `Error ${action} ${target}: ${message}`
11
+ }
12
+ ],
13
+ isError: true
14
+ };
15
+ }
16
+ const schema = entity === 'collection' ? getCollectionInputSchema({
17
+ collectionSlug: slug,
18
+ req
19
+ }) : getGlobalInputSchema({
20
+ globalSlug: slug,
21
+ req
22
+ });
23
+ const errors = error instanceof ValidationError ? error.data.errors : [
24
+ {
25
+ message
26
+ }
27
+ ];
28
+ const validationMessage = errors.map((issue)=>`${'path' in issue ? `${issue.path}: ` : ''}${issue.message}`).join('\n');
29
+ const schemaText = schema ? `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\`` : '';
30
+ return {
31
+ content: [
32
+ {
33
+ type: 'text',
34
+ text: `Error ${action} ${target}: ${validationMessage}${schemaText}`
35
+ }
36
+ ],
37
+ isError: true,
38
+ ...schema ? {
39
+ structuredContent: {
40
+ slug,
41
+ errors,
42
+ schema
43
+ }
44
+ } : {}
45
+ };
46
+ };
47
+ const isValidationError = (error, message)=>{
48
+ if (error instanceof ValidationError) {
49
+ return true;
50
+ }
51
+ const name = error && typeof error === 'object' && 'name' in error ? error.name : undefined;
52
+ return name === 'CastError' || message.includes('Cast to ') || message.includes('validation failed');
53
+ };
54
+
55
+ //# sourceMappingURL=formatEntityError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/mcp/builtin/formatEntityError.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, PayloadRequest } from 'payload'\n\nimport { getCollectionInputSchema, getGlobalInputSchema, ValidationError } from 'payload'\n\nimport type { MCPToolResponse } from '../../types.js'\n\nexport const formatEntityError = ({\n slug,\n action,\n entity,\n error,\n req,\n}:\n | {\n action: 'creating' | 'duplicating' | 'updating'\n entity: 'collection'\n error: unknown\n req: PayloadRequest\n slug: CollectionSlug\n }\n | {\n action: 'updating'\n entity: 'global'\n error: unknown\n req: PayloadRequest\n slug: GlobalSlug\n }): MCPToolResponse => {\n const message = error instanceof Error ? error.message : 'Unknown error'\n const target = entity === 'collection' ? `document in collection \"${slug}\"` : `global \"${slug}\"`\n\n if (!isValidationError(error, message)) {\n return {\n content: [{ type: 'text', text: `Error ${action} ${target}: ${message}` }],\n isError: true,\n }\n }\n\n const schema =\n entity === 'collection'\n ? getCollectionInputSchema({ collectionSlug: slug, req })\n : getGlobalInputSchema({ globalSlug: slug, req })\n const errors = error instanceof ValidationError ? error.data.errors : [{ message }]\n const validationMessage = errors\n .map((issue) => `${'path' in issue ? `${issue.path}: ` : ''}${issue.message}`)\n .join('\\n')\n const schemaText = schema\n ? `\\n\\nUse this schema for data:\\n\\`\\`\\`json\\n${JSON.stringify(schema)}\\n\\`\\`\\``\n : ''\n\n return {\n content: [\n { type: 'text', text: `Error ${action} ${target}: ${validationMessage}${schemaText}` },\n ],\n isError: true,\n ...(schema\n ? {\n structuredContent: {\n slug,\n errors,\n schema,\n },\n }\n : {}),\n }\n}\n\nconst isValidationError = (error: unknown, message: string): boolean => {\n if (error instanceof ValidationError) {\n return true\n }\n\n const name = error && typeof error === 'object' && 'name' in error ? error.name : undefined\n\n return (\n name === 'CastError' || message.includes('Cast to ') || message.includes('validation failed')\n )\n}\n"],"names":["getCollectionInputSchema","getGlobalInputSchema","ValidationError","formatEntityError","slug","action","entity","error","req","message","Error","target","isValidationError","content","type","text","isError","schema","collectionSlug","globalSlug","errors","data","validationMessage","map","issue","path","join","schemaText","JSON","stringify","structuredContent","name","undefined","includes"],"mappings":"AAEA,SAASA,wBAAwB,EAAEC,oBAAoB,EAAEC,eAAe,QAAQ,UAAS;AAIzF,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,IAAI,EACJC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,GAAG,EAeA;IACH,MAAMC,UAAUF,iBAAiBG,QAAQH,MAAME,OAAO,GAAG;IACzD,MAAME,SAASL,WAAW,eAAe,CAAC,wBAAwB,EAAEF,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAEA,KAAK,CAAC,CAAC;IAEhG,IAAI,CAACQ,kBAAkBL,OAAOE,UAAU;QACtC,OAAO;YACLI,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,MAAM,EAAEV,OAAO,CAAC,EAAEM,OAAO,EAAE,EAAEF,SAAS;gBAAC;aAAE;YAC1EO,SAAS;QACX;IACF;IAEA,MAAMC,SACJX,WAAW,eACPN,yBAAyB;QAAEkB,gBAAgBd;QAAMI;IAAI,KACrDP,qBAAqB;QAAEkB,YAAYf;QAAMI;IAAI;IACnD,MAAMY,SAASb,iBAAiBL,kBAAkBK,MAAMc,IAAI,CAACD,MAAM,GAAG;QAAC;YAAEX;QAAQ;KAAE;IACnF,MAAMa,oBAAoBF,OACvBG,GAAG,CAAC,CAACC,QAAU,GAAG,UAAUA,QAAQ,GAAGA,MAAMC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAKD,MAAMf,OAAO,EAAE,EAC5EiB,IAAI,CAAC;IACR,MAAMC,aAAaV,SACf,CAAC,2CAA2C,EAAEW,KAAKC,SAAS,CAACZ,QAAQ,QAAQ,CAAC,GAC9E;IAEJ,OAAO;QACLJ,SAAS;YACP;gBAAEC,MAAM;gBAAQC,MAAM,CAAC,MAAM,EAAEV,OAAO,CAAC,EAAEM,OAAO,EAAE,EAAEW,oBAAoBK,YAAY;YAAC;SACtF;QACDX,SAAS;QACT,GAAIC,SACA;YACEa,mBAAmB;gBACjB1B;gBACAgB;gBACAH;YACF;QACF,IACA,CAAC,CAAC;IACR;AACF,EAAC;AAED,MAAML,oBAAoB,CAACL,OAAgBE;IACzC,IAAIF,iBAAiBL,iBAAiB;QACpC,OAAO;IACT;IAEA,MAAM6B,OAAOxB,SAAS,OAAOA,UAAU,YAAY,UAAUA,QAAQA,MAAMwB,IAAI,GAAGC;IAElF,OACED,SAAS,eAAetB,QAAQwB,QAAQ,CAAC,eAAexB,QAAQwB,QAAQ,CAAC;AAE7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"getConfigInfoTool.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,+BA8D5B,CAAA"}
1
+ {"version":3,"file":"getConfigInfoTool.d.ts","sourceRoot":"","sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,+BA+D5B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { getAccessResults, isEntityHidden } from 'payload';
1
+ import { getAccessResults, getConfigInfoInputSchema, isEntityHidden } from 'payload';
2
2
  import { defineTool } from '../../defineTool.js';
3
3
  export const getConfigInfoTool = defineTool({
4
4
  annotations: {
@@ -8,7 +8,8 @@ export const getConfigInfoTool = defineTool({
8
8
  readOnlyHint: true,
9
9
  title: 'Config Info'
10
10
  },
11
- description: 'List the Payload collection and global slugs visible to this MCP client.'
11
+ description: 'List the Payload collection and global slugs visible to this MCP client.',
12
+ input: getConfigInfoInputSchema
12
13
  }).handler(async ({ authorizedMCP, req })=>{
13
14
  const user = req.user;
14
15
  const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"sourcesContent":["import { getAccessResults, isEntityHidden } from 'payload'\n\nimport { defineTool } from '../../defineTool.js'\n\nexport const getConfigInfoTool = defineTool({\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Config Info',\n },\n description: 'List the Payload collection and global slugs visible to this MCP client.',\n}).handler(async ({ authorizedMCP, req }) => {\n const user = req.user\n const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({ req })\n const authorizedCollectionSlugs = new Set<string>()\n const authorizedGlobalSlugs = new Set<string>()\n\n for (const item of authorizedMCP.items) {\n if (item.type === 'collectionTool') {\n authorizedCollectionSlugs.add(item.collectionSlug)\n } else if (item.type === 'globalTool') {\n authorizedGlobalSlugs.add(item.globalSlug)\n }\n }\n\n const collections: string[] = []\n const globals: string[] = []\n\n for (const collection of req.payload.config.collections) {\n if (!authorizedCollectionSlugs.has(collection.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {\n continue\n }\n\n collections.push(collection.slug)\n }\n\n for (const global of req.payload.config.globals) {\n if (!authorizedGlobalSlugs.has(global.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {\n continue\n }\n\n globals.push(global.slug)\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Collections: ${collections.join(', ') || 'none'}\\nGlobals: ${globals.join(', ') || 'none'}`,\n },\n ],\n }\n})\n"],"names":["getAccessResults","isEntityHidden","defineTool","getConfigInfoTool","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","handler","authorizedMCP","req","user","permissions","overrideAccess","authorizedCollectionSlugs","Set","authorizedGlobalSlugs","item","items","type","add","collectionSlug","globalSlug","collections","globals","collection","payload","config","has","slug","hidden","admin","read","push","global","content","text","join"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,UAAS;AAE1D,SAASC,UAAU,QAAQ,sBAAqB;AAEhD,OAAO,MAAMC,oBAAoBD,WAAW;IAC1CE,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;AACf,GAAGC,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEC,GAAG,EAAE;IACtC,MAAMC,OAAOD,IAAIC,IAAI;IACrB,MAAMC,cAAcH,cAAcI,cAAc,GAAG,OAAO,MAAMhB,iBAAiB;QAAEa;IAAI;IACvF,MAAMI,4BAA4B,IAAIC;IACtC,MAAMC,wBAAwB,IAAID;IAElC,KAAK,MAAME,QAAQR,cAAcS,KAAK,CAAE;QACtC,IAAID,KAAKE,IAAI,KAAK,kBAAkB;YAClCL,0BAA0BM,GAAG,CAACH,KAAKI,cAAc;QACnD,OAAO,IAAIJ,KAAKE,IAAI,KAAK,cAAc;YACrCH,sBAAsBI,GAAG,CAACH,KAAKK,UAAU;QAC3C;IACF;IAEA,MAAMC,cAAwB,EAAE;IAChC,MAAMC,UAAoB,EAAE;IAE5B,KAAK,MAAMC,cAAcf,IAAIgB,OAAO,CAACC,MAAM,CAACJ,WAAW,CAAE;QACvD,IAAI,CAACT,0BAA0Bc,GAAG,CAACH,WAAWI,IAAI,GAAG;YACnD;QACF;QACA,IAAIlB,QAAQb,eAAe;YAAEgC,QAAQL,WAAWM,KAAK,CAACD,MAAM;YAAEnB;QAAK,IAAI;YACrE;QACF;QACA,IAAI,CAACF,cAAcI,cAAc,IAAI,CAACD,aAAaW,aAAa,CAACE,WAAWI,IAAI,CAAC,EAAEG,MAAM;YACvF;QACF;QAEAT,YAAYU,IAAI,CAACR,WAAWI,IAAI;IAClC;IAEA,KAAK,MAAMK,UAAUxB,IAAIgB,OAAO,CAACC,MAAM,CAACH,OAAO,CAAE;QAC/C,IAAI,CAACR,sBAAsBY,GAAG,CAACM,OAAOL,IAAI,GAAG;YAC3C;QACF;QACA,IAAIlB,QAAQb,eAAe;YAAEgC,QAAQI,OAAOH,KAAK,CAACD,MAAM;YAAEnB;QAAK,IAAI;YACjE;QACF;QACA,IAAI,CAACF,cAAcI,cAAc,IAAI,CAACD,aAAaY,SAAS,CAACU,OAAOL,IAAI,CAAC,EAAEG,MAAM;YAC/E;QACF;QAEAR,QAAQS,IAAI,CAACC,OAAOL,IAAI;IAC1B;IAEA,OAAO;QACLM,SAAS;YACP;gBACEhB,MAAM;gBACNiB,MAAM,CAAC,aAAa,EAAEb,YAAYc,IAAI,CAAC,SAAS,OAAO,WAAW,EAAEb,QAAQa,IAAI,CAAC,SAAS,QAAQ;YACpG;SACD;IACH;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../src/mcp/builtin/getConfigInfoTool.ts"],"sourcesContent":["import { getAccessResults, getConfigInfoInputSchema, isEntityHidden } from 'payload'\n\nimport { defineTool } from '../../defineTool.js'\n\nexport const getConfigInfoTool = defineTool({\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Config Info',\n },\n description: 'List the Payload collection and global slugs visible to this MCP client.',\n input: getConfigInfoInputSchema,\n}).handler(async ({ authorizedMCP, req }) => {\n const user = req.user\n const permissions = authorizedMCP.overrideAccess ? null : await getAccessResults({ req })\n const authorizedCollectionSlugs = new Set<string>()\n const authorizedGlobalSlugs = new Set<string>()\n\n for (const item of authorizedMCP.items) {\n if (item.type === 'collectionTool') {\n authorizedCollectionSlugs.add(item.collectionSlug)\n } else if (item.type === 'globalTool') {\n authorizedGlobalSlugs.add(item.globalSlug)\n }\n }\n\n const collections: string[] = []\n const globals: string[] = []\n\n for (const collection of req.payload.config.collections) {\n if (!authorizedCollectionSlugs.has(collection.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: collection.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.collections?.[collection.slug]?.read) {\n continue\n }\n\n collections.push(collection.slug)\n }\n\n for (const global of req.payload.config.globals) {\n if (!authorizedGlobalSlugs.has(global.slug)) {\n continue\n }\n if (user && isEntityHidden({ hidden: global.admin.hidden, user })) {\n continue\n }\n if (!authorizedMCP.overrideAccess && !permissions?.globals?.[global.slug]?.read) {\n continue\n }\n\n globals.push(global.slug)\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `Collections: ${collections.join(', ') || 'none'}\\nGlobals: ${globals.join(', ') || 'none'}`,\n },\n ],\n }\n})\n"],"names":["getAccessResults","getConfigInfoInputSchema","isEntityHidden","defineTool","getConfigInfoTool","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","user","permissions","overrideAccess","authorizedCollectionSlugs","Set","authorizedGlobalSlugs","item","items","type","add","collectionSlug","globalSlug","collections","globals","collection","payload","config","has","slug","hidden","admin","read","push","global","content","text","join"],"mappings":"AAAA,SAASA,gBAAgB,EAAEC,wBAAwB,EAAEC,cAAc,QAAQ,UAAS;AAEpF,SAASC,UAAU,QAAQ,sBAAqB;AAEhD,OAAO,MAAMC,oBAAoBD,WAAW;IAC1CE,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAa;IACbC,OAAOX;AACT,GAAGY,OAAO,CAAC,OAAO,EAAEC,aAAa,EAAEC,GAAG,EAAE;IACtC,MAAMC,OAAOD,IAAIC,IAAI;IACrB,MAAMC,cAAcH,cAAcI,cAAc,GAAG,OAAO,MAAMlB,iBAAiB;QAAEe;IAAI;IACvF,MAAMI,4BAA4B,IAAIC;IACtC,MAAMC,wBAAwB,IAAID;IAElC,KAAK,MAAME,QAAQR,cAAcS,KAAK,CAAE;QACtC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countVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,uBAAuB,wCAyDlC,CAAA"}
1
+ {"version":3,"file":"countVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,uBAAuB,wCAkDlC,CAAA"}
@@ -1,11 +1,10 @@
1
- import { z } from 'zod';
1
+ import { countGlobalVersionsInputSchema } from 'payload';
2
2
  import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
- import { whereSchema } from '../../../utils/whereSchema.js';
6
5
  const DEFAULT_DESCRIPTION = 'Count global versions in any version-enabled global by passing the global slug and optional where clause.';
7
6
  export const countGlobalVersionsTool = defineGlobalTool({
8
- access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
7
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
9
8
  annotations: {
10
9
  destructiveHint: false,
11
10
  idempotentHint: true,
@@ -14,20 +13,17 @@ export const countGlobalVersionsTool = defineGlobalTool({
14
13
  title: 'Count Global Versions'
15
14
  },
16
15
  description: DEFAULT_DESCRIPTION,
17
- input: z.object({
18
- locale: z.string().describe('Optional: locale code to count versions in').optional(),
19
- where: whereSchema.describe('Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}').optional()
20
- })
21
- }).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
16
+ input: countGlobalVersionsInputSchema
17
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
22
18
  const payload = req.payload;
23
19
  const logger = getLogger({
24
20
  payload
25
21
  });
26
22
  const { locale, where } = input;
27
- logger.info(`Counting versions for global: ${globalSlug}`);
23
+ logger.info(`Counting versions for global: ${slug}`);
28
24
  try {
29
25
  const result = await payload.countGlobalVersions({
30
- global: globalSlug,
26
+ global: slug,
31
27
  overrideAccess: authorizedMCP.overrideAccess,
32
28
  req,
33
29
  ...locale ? {
@@ -41,19 +37,19 @@ export const countGlobalVersionsTool = defineGlobalTool({
41
37
  content: [
42
38
  {
43
39
  type: 'text',
44
- text: `Global "${globalSlug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
40
+ text: `Global "${slug}" contains ${result.totalDocs} matching versions.\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
45
41
  }
46
42
  ],
47
43
  doc: result
48
44
  };
49
45
  } catch (error) {
50
46
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
51
- logger.error(`Error counting versions for global ${globalSlug}: ${errorMessage}`);
47
+ logger.error(`Error counting versions for global ${slug}: ${errorMessage}`);
52
48
  return {
53
49
  content: [
54
50
  {
55
51
  type: 'text',
56
- text: `❌ **Error counting versions for global "${globalSlug}":** ${errorMessage}`
52
+ text: `❌ **Error counting versions for global "${slug}":** ${errorMessage}`
57
53
  }
58
54
  ],
59
55
  isError: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Count global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const countGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Count Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n locale: z.string().describe('Optional: locale code to count versions in').optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering versions. Version document fields are usually under \"version\". Example: {\"version.siteName\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { locale, where } = input\n\n logger.info(`Counting versions for global: ${globalSlug}`)\n\n try {\n const result = await payload.countGlobalVersions({\n global: globalSlug,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale ? { locale } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${globalSlug}\" contains ${result.totalDocs} matching versions.\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error counting versions for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error counting versions for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","whereSchema","DEFAULT_DESCRIPTION","countGlobalVersionsTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","locale","string","describe","optional","where","handler","authorizedMCP","req","payload","logger","info","result","countGlobalVersions","global","overrideAccess","content","type","text","totalDocs","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,0BAA0BJ,iBAAiB;IACtDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAA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CAAwC,EAAE5B,WAAW,KAAK,EAAEkC,cAAc;gBACnF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/countVersionsTool.ts"],"sourcesContent":["import { countGlobalVersionsInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Count global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const countGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Count Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: countGlobalVersionsInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { locale, where } = input\n\n logger.info(`Counting versions for global: ${slug}`)\n\n try {\n const result = await payload.countGlobalVersions({\n global: slug,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale ? { locale } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${slug}\" contains ${result.totalDocs} matching versions.\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error counting versions for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error counting versions for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["countGlobalVersionsInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","countGlobalVersionsTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","locale","where","info","result","countGlobalVersions","global","overrideAccess","content","type","text","totalDocs","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,UAAS;AAExD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,0BAA0BH,iBAAiB;IACtDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IACnC,MAAM,EAAEE,MAAM,EAAEC,KAAK,EAAE,GAAGP;IAE1BK,OAAOG,IAAI,CAAC,CAAC,8BAA8B,EAAEjB,MAAM;IAEnD,IAAI;QACF,MAAMkB,SAAS,MAAML,QAAQM,mBAAmB,CAAC;YAC/CC,QAAQpB;YACRqB,gBAAgBV,cAAcU,cAAc;YAC5CT;YACA,GAAIG,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;QAEA,OAAO;YACLM,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAExB,KAAK,WAAW,EAAEkB,OAAOO,SAAS,CAAC,iCAAiC,EAAEC,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBACzH;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DlB,OAAOe,KAAK,CAAC,CAAC,mCAAmC,EAAE7B,KAAK,EAAE,EAAE8B,cAAc;QAC1E,OAAO;YACLR,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,wCAAwC,EAAExB,KAAK,KAAK,EAAE8B,cAAc;gBAC7E;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"findTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,wCA8FzB,CAAA"}
1
+ {"version":3,"file":"findTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,wCAyDzB,CAAA"}
@@ -1,10 +1,10 @@
1
- import { z } from 'zod';
1
+ import { findGlobalInputSchema } from 'payload';
2
2
  import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
5
  const DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.';
6
6
  export const findGlobalTool = defineGlobalTool({
7
- access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.read),
7
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.read),
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  idempotentHint: true,
@@ -13,23 +13,17 @@ export const findGlobalTool = defineGlobalTool({
13
13
  title: 'Find Global'
14
14
  },
15
15
  description: DEFAULT_DESCRIPTION,
16
- input: z.object({
17
- depth: z.number().int().min(0).max(10).describe('Depth of population for relationships').optional().default(0),
18
- fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
19
- locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
20
- populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
21
- select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}').optional()
22
- })
23
- }).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
16
+ input: findGlobalInputSchema
17
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
24
18
  const payload = req.payload;
25
19
  const logger = getLogger({
26
20
  payload
27
21
  });
28
22
  const { depth, fallbackLocale, locale, populate, select } = input;
29
- logger.info(`Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`);
23
+ logger.info(`Reading global: ${slug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`);
30
24
  try {
31
25
  const findOptions = {
32
- slug: globalSlug,
26
+ slug,
33
27
  depth,
34
28
  overrideAccess: authorizedMCP.overrideAccess,
35
29
  req
@@ -37,7 +31,7 @@ export const findGlobalTool = defineGlobalTool({
37
31
  if (locale) {
38
32
  findOptions.locale = locale;
39
33
  }
40
- if (fallbackLocale) {
34
+ if (fallbackLocale !== undefined) {
41
35
  findOptions.fallbackLocale = fallbackLocale;
42
36
  }
43
37
  if (select) {
@@ -51,19 +45,19 @@ export const findGlobalTool = defineGlobalTool({
51
45
  content: [
52
46
  {
53
47
  type: 'text',
54
- text: `Global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
48
+ text: `Global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
55
49
  }
56
50
  ],
57
51
  doc: result
58
52
  };
59
53
  } catch (error) {
60
54
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
61
- logger.error(`Error reading global ${globalSlug}: ${errorMessage}`);
55
+ logger.error(`Error reading global ${slug}: ${errorMessage}`);
62
56
  return {
63
57
  content: [
64
58
  {
65
59
  type: 'text',
66
- text: `❌ **Error reading global "${globalSlug}":** ${errorMessage}`
60
+ text: `❌ **Error reading global "${slug}":** ${errorMessage}`
67
61
  }
68
62
  ]
69
63
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'\n\nexport const findGlobalTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.read),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('Depth of population for relationships')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n )\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"title\": true}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { depth, fallbackLocale, locale, populate, select } = input\n\n logger.info(\n `Reading global: ${globalSlug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n const findOptions: Parameters<typeof payload.findGlobal>[0] = {\n slug: globalSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n }\n\n if (locale) {\n findOptions.locale = locale\n }\n if (fallbackLocale) {\n findOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n findOptions.select = select as SelectType\n }\n if (populate) {\n findOptions.populate = populate as PopulateType\n }\n\n const result = await payload.findGlobal(findOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error reading global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n { type: 'text', text: `❌ **Error reading global \"${globalSlug}\":** ${errorMessage}` },\n ],\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalTool","access","args","Boolean","permissions","globals","globalSlug","read","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","depth","number","int","min","max","describe","optional","default","fallbackLocale","string","locale","populate","record","unknown","select","handler","authorizedMCP","req","payload","logger","info","findOptions","slug","overrideAccess","result","findGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,iBAAiBH,iBAAiB;IAC7CI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB,EAAEqB,MAAM,CAAC;QACdC,OAAOt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gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAEvC,WAAW,gBAAgB,EAAEwC,KAAKC,SAAS,CAACN,QAAQ,QAAQ,CAAC;gBAChF;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DhB,OAAOa,KAAK,CAAC,CAAC,qBAAqB,EAAE3C,WAAW,EAAE,EAAE4C,cAAc;QAClE,OAAO;YACLP,SAAS;gBACP;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,0BAA0B,EAAEvC,WAAW,KAAK,EAAE4C,cAAc;gBAAC;aACrF;QACH;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/findTool.ts"],"sourcesContent":["import { findGlobalInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION = 'Find any Payload global by passing the global slug.'\n\nexport const findGlobalTool = defineGlobalTool({\n access: (args) => defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.read),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { depth, fallbackLocale, locale, populate, select } = input\n\n logger.info(`Reading global: ${slug}, depth: ${depth}${locale ? `, locale: ${locale}` : ''}`)\n\n try {\n const findOptions: Parameters<typeof payload.findGlobal>[0] = {\n slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n }\n\n if (locale) {\n findOptions.locale = locale\n }\n if (fallbackLocale !== undefined) {\n findOptions.fallbackLocale = fallbackLocale\n }\n if (select) {\n findOptions.select = select\n }\n if (populate) {\n findOptions.populate = populate\n }\n const result = await payload.findGlobal(findOptions)\n\n return {\n content: [\n {\n type: 'text',\n text: `Global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error reading global ${slug}: ${errorMessage}`)\n return {\n content: [{ type: 'text', text: `❌ **Error reading global \"${slug}\":** ${errorMessage}` }],\n }\n }\n})\n"],"names":["findGlobalInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalTool","access","args","Boolean","permissions","globals","slug","read","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","depth","fallbackLocale","locale","populate","select","info","findOptions","overrideAccess","undefined","result","findGlobal","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,UAAS;AAE/C,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,iBAAiBH,iBAAiB;IAC7CI,QAAQ,CAACC,OAASN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzFC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IAEnC,MAAM,EAAEE,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGV;IAE5DK,OAAOM,IAAI,CAAC,CAAC,gBAAgB,EAAEpB,KAAK,SAAS,EAAEe,QAAQE,SAAS,CAAC,UAAU,EAAEA,QAAQ,GAAG,IAAI;IAE5F,IAAI;QACF,MAAMI,cAAwD;YAC5DrB;YACAe;YACAO,gBAAgBX,cAAcW,cAAc;YAC5CV;QACF;QAEA,IAAIK,QAAQ;YACVI,YAAYJ,MAAM,GAAGA;QACvB;QACA,IAAID,mBAAmBO,WAAW;YAChCF,YAAYL,cAAc,GAAGA;QAC/B;QACA,IAAIG,QAAQ;YACVE,YAAYF,MAAM,GAAGA;QACvB;QACA,IAAID,UAAU;YACZG,YAAYH,QAAQ,GAAGA;QACzB;QACA,MAAMM,SAAS,MAAMX,QAAQY,UAAU,CAACJ;QAExC,OAAO;YACLK,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,QAAQ,EAAE5B,KAAK,gBAAgB,EAAE6B,KAAKC,SAAS,CAACN,QAAQ,QAAQ,CAAC;gBAC1E;aACD;YACDO,KAAKP;QACP;IACF,EAAE,OAAOQ,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DrB,OAAOkB,KAAK,CAAC,CAAC,qBAAqB,EAAEhC,KAAK,EAAE,EAAEiC,cAAc;QAC5D,OAAO;YACLP,SAAS;gBAAC;oBAAEC,MAAM;oBAAQC,MAAM,CAAC,0BAA0B,EAAE5B,KAAK,KAAK,EAAEiC,cAAc;gBAAC;aAAE;QAC5F;IACF;AACF,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionByIDTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,yBAAyB,wCA2FpC,CAAA"}
1
+ {"version":3,"file":"findVersionByIDTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,yBAAyB,wCAsDpC,CAAA"}
@@ -1,10 +1,10 @@
1
- import { z } from 'zod';
1
+ import { findGlobalVersionByIDInputSchema } from 'payload';
2
2
  import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
5
  const DEFAULT_DESCRIPTION = 'Find a specific global version in any version-enabled global by passing the global slug and version ID.';
6
6
  export const findGlobalVersionByIDTool = defineGlobalTool({
7
- access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
7
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  idempotentHint: true,
@@ -13,62 +13,51 @@ export const findGlobalVersionByIDTool = defineGlobalTool({
13
13
  title: 'Find Global Version By ID'
14
14
  },
15
15
  description: DEFAULT_DESCRIPTION,
16
- input: z.object({
17
- id: z.string().describe('The ID of the global version to retrieve'),
18
- depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in the global version document').optional().default(0),
19
- fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
20
- locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
21
- populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
22
- select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.siteName": true}').optional(),
23
- showHiddenFields: z.boolean().describe('Optional: include hidden fields in the returned global version document').optional()
24
- })
25
- }).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
16
+ input: findGlobalVersionByIDInputSchema
17
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
26
18
  const payload = req.payload;
27
19
  const logger = getLogger({
28
20
  payload
29
21
  });
30
- const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields } = input;
31
- logger.info(`Finding version for global: ${globalSlug} with ID: ${id}`);
22
+ const { id, depth, fallbackLocale, locale, populate, select } = input;
23
+ logger.info(`Finding version for global: ${slug} with ID: ${id}`);
32
24
  try {
33
25
  const result = await payload.findGlobalVersionByID({
34
26
  id,
35
- slug: globalSlug,
27
+ slug,
36
28
  depth,
37
29
  overrideAccess: authorizedMCP.overrideAccess,
38
30
  req,
39
- ...fallbackLocale ? {
31
+ ...fallbackLocale !== undefined ? {
40
32
  fallbackLocale
41
33
  } : {},
42
34
  ...locale ? {
43
35
  locale
44
36
  } : {},
45
37
  ...populate ? {
46
- populate: populate
38
+ populate
47
39
  } : {},
48
40
  ...select ? {
49
- select: select
50
- } : {},
51
- ...showHiddenFields !== undefined ? {
52
- showHiddenFields
41
+ select
53
42
  } : {}
54
43
  });
55
44
  return {
56
45
  content: [
57
46
  {
58
47
  type: 'text',
59
- text: `Version "${id}" from global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
48
+ text: `Version "${id}" from global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
60
49
  }
61
50
  ],
62
51
  doc: result
63
52
  };
64
53
  } catch (error) {
65
54
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
66
- logger.error(`Error finding version ${id} for global ${globalSlug}: ${errorMessage}`);
55
+ logger.error(`Error finding version ${id} for global ${slug}: ${errorMessage}`);
67
56
  return {
68
57
  content: [
69
58
  {
70
59
  type: 'text',
71
- text: `❌ **Error finding version "${id}" for global "${globalSlug}":** ${errorMessage}`
60
+ text: `❌ **Error finding version "${id}" for global "${slug}":** ${errorMessage}`
72
61
  }
73
62
  ],
74
63
  isError: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find a specific global version in any version-enabled global by passing the global slug and version ID.'\n\nexport const findGlobalVersionByIDTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Version By ID',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n id: z.string().describe('The ID of the global version to retrieve'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in the global version document')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n )\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in the returned global version document')\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, select, showHiddenFields } = input\n\n logger.info(`Finding version for global: ${globalSlug} with ID: ${id}`)\n\n try {\n const result = await payload.findGlobalVersionByID({\n id,\n slug: globalSlug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" from global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding version ${id} for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding version \"${id}\" for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionByIDTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","id","string","describe","depth","number","int","min","max","optional","default","fallbackLocale","locale","populate","record","unknown","select","showHiddenFields","boolean","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersionByID","slug","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,4BAA4BH,iBAAiB;IACxDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB,EAAEqB,MAAM,CAAC;QACdC,IAAItB,EAAEuB,MAAM,GAAGC,QAAQ,CAAC;QACxBC,OAAOzB,EACJ0B,MAAM,GACNC,GAAG,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GAAIC,qBAAqBY,YAAY;gBAAEZ;YAAiB,IAAI,CAAC,CAAC;QAChE;QAEA,OAAO;YACLa,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,SAAS,EAAE/B,GAAG,eAAe,EAAEX,WAAW,gBAAgB,EAAE2C,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBACrG;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DhB,OAAOa,KAAK,CAAC,CAAC,sBAAsB,EAAEnC,GAAG,YAAY,EAAEX,WAAW,EAAE,EAAE+C,cAAc;QACpF,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,2BAA2B,EAAE/B,GAAG,cAAc,EAAEX,WAAW,KAAK,EAAE+C,cAAc;gBACzF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionByIDTool.ts"],"sourcesContent":["import { findGlobalVersionByIDInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find a specific global version in any version-enabled global by passing the global slug and version ID.'\n\nexport const findGlobalVersionByIDTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Version By ID',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalVersionByIDInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, depth, fallbackLocale, locale, populate, select } = input\n\n logger.info(`Finding version for global: ${slug} with ID: ${id}`)\n\n try {\n const result = await payload.findGlobalVersionByID({\n id,\n slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Version \"${id}\" from global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding version ${id} for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding version \"${id}\" for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["findGlobalVersionByIDInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionByIDTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","id","depth","fallbackLocale","locale","populate","select","info","result","findGlobalVersionByID","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,gCAAgC,QAAQ,UAAS;AAE1D,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,4BAA4BH,iBAAiB;IACxDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGq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@
1
- {"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB,wCAsIjC,CAAA"}
1
+ {"version":3,"file":"findVersionsTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,sBAAsB,wCA2DjC,CAAA"}
@@ -1,11 +1,10 @@
1
- import { z } from 'zod';
1
+ import { findGlobalVersionsInputSchema } from 'payload';
2
2
  import { defaultAccess } from '../../../defaultAccess.js';
3
3
  import { defineGlobalTool } from '../../../defineTool.js';
4
4
  import { getLogger } from '../../../utils/getLogger.js';
5
- import { whereSchema } from '../../../utils/whereSchema.js';
6
5
  const DEFAULT_DESCRIPTION = 'Find global versions in any version-enabled global by passing the global slug and optional where clause.';
7
6
  export const findGlobalVersionsTool = defineGlobalTool({
8
- access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),
7
+ access: (args)=>defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),
9
8
  annotations: {
10
9
  destructiveHint: false,
11
10
  idempotentHint: true,
@@ -14,35 +13,23 @@ export const findGlobalVersionsTool = defineGlobalTool({
14
13
  title: 'Find Global Versions'
15
14
  },
16
15
  description: DEFAULT_DESCRIPTION,
17
- input: z.object({
18
- depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in global version documents').optional().default(0),
19
- fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
20
- limit: z.number().int().min(1).max(100).describe('Maximum number of versions to return (default: 10, max: 100)').optional().default(10),
21
- locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
22
- page: z.number().int().min(1).describe('Page number for pagination (default: 1)').optional().default(1),
23
- pagination: z.boolean().describe('Optional: set to false to skip the count query overhead').optional(),
24
- populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
25
- select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"version.siteName": true}').optional(),
26
- showHiddenFields: z.boolean().describe('Optional: include hidden fields in returned global version documents').optional(),
27
- sort: z.string().describe('Field to sort by (e.g., "-updatedAt", "-version.updatedAt" for descending)').optional(),
28
- where: whereSchema.describe('Optional: where clause for filtering versions. Version document fields are usually under "version". Example: {"version.siteName":{"contains":"test"}}').optional()
29
- })
30
- }).handler(async ({ authorizedMCP, globalSlug, input, req })=>{
16
+ input: findGlobalVersionsInputSchema
17
+ }).handler(async ({ slug, authorizedMCP, input, req })=>{
31
18
  const payload = req.payload;
32
19
  const logger = getLogger({
33
20
  payload
34
21
  });
35
- const { depth, fallbackLocale, limit, locale, page, pagination, populate, select, showHiddenFields, sort, where } = input;
36
- logger.info(`Finding versions for global: ${globalSlug}, limit: ${limit}, page: ${page}`);
22
+ const { depth, fallbackLocale, limit, locale, page, pagination, populate, select, sort, where } = input;
23
+ logger.info(`Finding versions for global: ${slug}, limit: ${limit}, page: ${page}`);
37
24
  try {
38
25
  const result = await payload.findGlobalVersions({
39
- slug: globalSlug,
26
+ slug,
40
27
  depth,
41
28
  limit,
42
29
  overrideAccess: authorizedMCP.overrideAccess,
43
30
  page,
44
31
  req,
45
- ...fallbackLocale ? {
32
+ ...fallbackLocale !== undefined ? {
46
33
  fallbackLocale
47
34
  } : {},
48
35
  ...locale ? {
@@ -52,13 +39,10 @@ export const findGlobalVersionsTool = defineGlobalTool({
52
39
  pagination
53
40
  } : {},
54
41
  ...populate ? {
55
- populate: populate
42
+ populate
56
43
  } : {},
57
44
  ...select ? {
58
- select: select
59
- } : {},
60
- ...showHiddenFields !== undefined ? {
61
- showHiddenFields
45
+ select
62
46
  } : {},
63
47
  ...sort ? {
64
48
  sort
@@ -71,19 +55,19 @@ export const findGlobalVersionsTool = defineGlobalTool({
71
55
  content: [
72
56
  {
73
57
  type: 'text',
74
- text: `Versions for global "${globalSlug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
58
+ text: `Versions for global "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
75
59
  }
76
60
  ],
77
61
  doc: result
78
62
  };
79
63
  } catch (error) {
80
64
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
81
- logger.error(`Error finding versions for global ${globalSlug}: ${errorMessage}`);
65
+ logger.error(`Error finding versions for global ${slug}: ${errorMessage}`);
82
66
  return {
83
67
  content: [
84
68
  {
85
69
  type: 'text',
86
- text: `❌ **Error finding versions for global "${globalSlug}":** ${errorMessage}`
70
+ text: `❌ **Error finding versions for global "${slug}":** ${errorMessage}`
87
71
  }
88
72
  ],
89
73
  isError: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import type { PopulateType, SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { whereSchema } from '../../../utils/whereSchema.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const findGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.globalSlug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in global version documents')\n .optional()\n .default(0),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n limit: z\n .number()\n .int()\n .min(1)\n .max(100)\n .describe('Maximum number of versions to return (default: 10, max: 100)')\n .optional()\n .default(10),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n )\n .optional(),\n page: z\n .number()\n .int()\n .min(1)\n .describe('Page number for pagination (default: 1)')\n .optional()\n .default(1),\n pagination: z\n .boolean()\n .describe('Optional: set to false to skip the count query overhead')\n .optional(),\n populate: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: control which fields to include from populated relationship or upload documents.',\n )\n .optional(),\n select: z\n .record(z.string(), z.unknown())\n .describe(\n 'Optional: define exactly which fields you\\'d like to return in the response, e.g., {\"version.siteName\": true}',\n )\n .optional(),\n showHiddenFields: z\n .boolean()\n .describe('Optional: include hidden fields in returned global version documents')\n .optional(),\n sort: z\n .string()\n .describe('Field to sort by (e.g., \"-updatedAt\", \"-version.updatedAt\" for descending)')\n .optional(),\n where: whereSchema\n .describe(\n 'Optional: where clause for filtering versions. Version document fields are usually under \"version\". Example: {\"version.siteName\":{\"contains\":\"test\"}}',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, globalSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const {\n depth,\n fallbackLocale,\n limit,\n locale,\n page,\n pagination,\n populate,\n select,\n showHiddenFields,\n sort,\n where,\n } = input\n\n logger.info(`Finding versions for global: ${globalSlug}, limit: ${limit}, page: ${page}`)\n\n try {\n const result = await payload.findGlobalVersions({\n slug: globalSlug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(pagination !== undefined ? { pagination } : {}),\n ...(populate ? { populate: populate as PopulateType } : {}),\n ...(select ? { select: select as SelectType } : {}),\n ...(showHiddenFields !== undefined ? { showHiddenFields } : {}),\n ...(sort ? { sort } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Versions for global \"${globalSlug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding versions for global ${globalSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding versions for global \"${globalSlug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["z","defaultAccess","defineGlobalTool","getLogger","whereSchema","DEFAULT_DESCRIPTION","findGlobalVersionsTool","access","args","Boolean","permissions","globals","globalSlug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","object","depth","number","int","min","max","describe","optional","default","fallbackLocale","string","limit","locale","page","pagination","boolean","populate","record","unknown","select","showHiddenFields","sort","where","handler","authorizedMCP","req","payload","logger","info","result","findGlobalVersions","slug","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SAASC,WAAW,QAAQ,gCAA+B;AAE3D,MAAMC,sBACJ;AAEF,OAAO,MAAMC,yBAAyBJ,iBAAiB;IACrDK,QAAQ,CAACC,OACPP,cAAcO,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,UAAU,CAAC,EAAEC;IAC/EC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOrB,EAAEsB,MAAM,CAAC;QACdC,OAAOvB,EACJwB,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,CAAC,8EACTC,QAAQ,GACRC,OAAO,CAAC;QACXC,gBAAgB/B,EACbgC,MAAM,G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IAAI;QACF,MAAMgB,SAAS,MAAMH,QAAQI,kBAAkB,CAAC;YAC9CC,MAAMzC;YACNW;YACAU;YACAqB,gBAAgBR,cAAcQ,cAAc;YAC5CnB;YACAY;YACA,GAAIhB,iBAAiB;gBAAEA;YAAe,IAAI,CAAC,CAAC;YAC5C,GAAIG,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIE,eAAemB,YAAY;gBAAEnB;YAAW,IAAI,CAAC,CAAC;YAClD,GAAIE,WAAW;gBAAEA,UAAUA;YAAyB,IAAI,CAAC,CAAC;YAC1D,GAAIG,SAAS;gBAAEA,QAAQA;YAAqB,IAAI,CAAC,CAAC;YAClD,GAAIC,qBAAqBa,YAAY;gBAAEb;YAAiB,IAAI,CAAC,CAAC;YAC9D,GAAIC,OAAO;gBAAEA;YAAK,IAAI,CAAC,CAAC;YACxB,GAAIC,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;QAEA,OAAO;YACLY,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,qBAAqB,EAAE9C,WAAW,gBAAgB,EAAE+C,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBAC7F;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9DhB,OAAOa,KAAK,CAAC,CAAC,kCAAkC,EAAElD,WAAW,EAAE,EAAEmD,cAAc;QAC/E,OAAO;YACLP,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,uCAAuC,EAAE9C,WAAW,KAAK,EAAEmD,cAAc;gBAClF;aACD;YACDG,SAAS;QACX;IACF;AACF,GAAE"}
1
+ {"version":3,"sources":["../../../../src/mcp/builtin/globals/findVersionsTool.ts"],"sourcesContent":["import { findGlobalVersionsInputSchema } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineGlobalTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Find global versions in any version-enabled global by passing the global slug and optional where clause.'\n\nexport const findGlobalVersionsTool = defineGlobalTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.globals?.[args.slug]?.readVersions),\n annotations: {\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n readOnlyHint: true,\n title: 'Find Global Versions',\n },\n description: DEFAULT_DESCRIPTION,\n input: findGlobalVersionsInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { depth, fallbackLocale, limit, locale, page, pagination, populate, select, sort, where } =\n input\n\n logger.info(`Finding versions for global: ${slug}, limit: ${limit}, page: ${page}`)\n\n try {\n const result = await payload.findGlobalVersions({\n slug,\n depth,\n limit,\n overrideAccess: authorizedMCP.overrideAccess,\n page,\n req,\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(locale ? { locale } : {}),\n ...(pagination !== undefined ? { pagination } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n ...(sort ? { sort } : {}),\n ...(where ? { where } : {}),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Versions for global \"${slug}\":\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error finding versions for global ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error finding versions for global \"${slug}\":** ${errorMessage}`,\n },\n ],\n isError: true,\n }\n }\n})\n"],"names":["findGlobalVersionsInputSchema","defaultAccess","defineGlobalTool","getLogger","DEFAULT_DESCRIPTION","findGlobalVersionsTool","access","args","Boolean","permissions","globals","slug","readVersions","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","depth","fallbackLocale","limit","locale","page","pagination","populate","select","sort","where","info","result","findGlobalVersions","overrideAccess","undefined","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","isError"],"mappings":"AAAA,SAASA,6BAA6B,QAAQ,UAAS;AAEvD,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,gBAAgB,QAAQ,yBAAwB;AACzD,SAASC,SAAS,QAAQ,8BAA6B;AAEvD,MAAMC,sBACJ;AAEF,OAAO,MAAMC,yBAAyBH,iBAAiB;IACrDI,QAAQ,CAACC,OACPN,cAAcM,SAASC,QAAQD,KAAKE,WAAW,EAAEC,SAAS,CAACH,KAAKI,IAAI,CAAC,EAAEC;IACzEC,aAAa;QACXC,iBAAiB;QACjBC,gBAAgB;QAChBC,eAAe;QACfC,cAAc;QACdC,OAAO;IACT;IACAC,aAAaf;IACbgB,OAAOpB;AACT,GAAGqB,OAAO,CAAC,OAAO,EAAEV,IAAI,EAAEW,aAAa,EAAEF,KAAK,EAAEG,GAAG,EAAE;IACnD,MAAMC,UAAUD,IAAIC,OAAO;IAC3B,MAAMC,SAAStB,UAAU;QAAEqB;IAAQ;IACnC,MAAM,EAAEE,KAAK,EAAEC,cAAc,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAC7Ff;IAEFK,OAAOW,IAAI,CAAC,CAAC,6BAA6B,EAAEzB,KAAK,SAAS,EAAEiB,MAAM,QAAQ,EAAEE,MAAM;IAElF,IAAI;QACF,MAAMO,SAAS,MAAMb,QAAQc,kBAAkB,CAAC;YAC9C3B;YACAe;YACAE;YACAW,gBAAgBjB,cAAciB,cAAc;YAC5CT;YACAP;YACA,GAAII,mBAAmBa,YAAY;gBAAEb;YAAe,IAAI,CAAC,CAAC;YAC1D,GAAIE,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIE,eAAeS,YAAY;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