@payloadcms/plugin-mcp 4.0.0-internal.1f9ae9a → 4.0.0-internal.2fddfc0

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 (227) hide show
  1. package/dist/@types/assets.d.js +2 -0
  2. package/dist/@types/assets.d.js.map +1 -0
  3. package/dist/defaultAccess.d.ts +3 -0
  4. package/dist/defaultAccess.d.ts.map +1 -0
  5. package/dist/defaultAccess.js +3 -0
  6. package/dist/defaultAccess.js.map +1 -0
  7. package/dist/endpoint/access.d.ts +17 -5
  8. package/dist/endpoint/access.d.ts.map +1 -1
  9. package/dist/endpoint/access.js +82 -88
  10. package/dist/endpoint/access.js.map +1 -1
  11. package/dist/endpoint/index.d.ts.map +1 -1
  12. package/dist/endpoint/index.js +11 -0
  13. package/dist/endpoint/index.js.map +1 -1
  14. package/dist/exports/client.d.ts +1 -1
  15. package/dist/exports/client.d.ts.map +1 -1
  16. package/dist/exports/client.js +1 -1
  17. package/dist/exports/client.js.map +1 -1
  18. package/dist/exports/internal.d.ts +2 -0
  19. package/dist/exports/internal.d.ts.map +1 -0
  20. package/dist/exports/internal.js +3 -0
  21. package/dist/exports/internal.js.map +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +13 -18
  24. package/dist/index.js.map +1 -1
  25. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  26. package/dist/mcp/buildMcpServer.js +102 -64
  27. package/dist/mcp/buildMcpServer.js.map +1 -1
  28. package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
  29. package/dist/mcp/builtin/collections/authTools.js +44 -6
  30. package/dist/mcp/builtin/collections/authTools.js.map +1 -1
  31. package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
  32. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
  33. package/dist/mcp/builtin/collections/countTool.js +69 -0
  34. package/dist/mcp/builtin/collections/countTool.js.map +1 -0
  35. package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
  36. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
  37. package/dist/mcp/builtin/collections/countVersionsTool.js +65 -0
  38. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
  39. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  40. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  41. package/dist/mcp/builtin/collections/createTool.js +38 -38
  42. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  43. package/dist/mcp/builtin/collections/deleteTool.d.ts +1 -1
  44. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  45. package/dist/mcp/builtin/collections/deleteTool.js +14 -20
  46. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  47. package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
  48. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
  49. package/dist/mcp/builtin/collections/duplicateTool.js +97 -0
  50. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
  51. package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
  52. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
  53. package/dist/mcp/builtin/collections/findDistinctTool.js +93 -0
  54. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
  55. package/dist/mcp/builtin/collections/findTool.d.ts +1 -1
  56. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  57. package/dist/mcp/builtin/collections/findTool.js +49 -43
  58. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  59. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
  60. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
  61. package/dist/mcp/builtin/collections/findVersionByIDTool.js +84 -0
  62. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
  63. package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
  64. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
  65. package/dist/mcp/builtin/collections/findVersionsTool.js +99 -0
  66. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
  67. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
  68. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
  69. package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
  70. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
  71. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
  72. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
  73. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +47 -0
  74. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
  75. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
  76. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
  77. package/dist/mcp/builtin/collections/restoreVersionTool.js +82 -0
  78. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
  79. package/dist/mcp/builtin/collections/updateTool.d.ts +1 -1
  80. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  81. package/dist/mcp/builtin/collections/updateTool.js +87 -82
  82. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  83. package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
  84. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
  85. package/dist/mcp/builtin/getConfigInfoTool.js +71 -0
  86. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
  87. package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
  88. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
  89. package/dist/mcp/builtin/globals/countVersionsTool.js +65 -0
  90. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
  91. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  92. package/dist/mcp/builtin/globals/findTool.js +18 -21
  93. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  94. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
  95. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
  96. package/dist/mcp/builtin/globals/findVersionByIDTool.js +80 -0
  97. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
  98. package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
  99. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
  100. package/dist/mcp/builtin/globals/findVersionsTool.js +95 -0
  101. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
  102. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
  103. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
  104. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +47 -0
  105. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
  106. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
  107. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
  108. package/dist/mcp/builtin/globals/restoreVersionTool.js +78 -0
  109. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
  110. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  111. package/dist/mcp/builtin/globals/updateTool.js +31 -36
  112. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  113. package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
  114. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
  115. package/dist/mcp/builtin/validateEntityData.js +82 -0
  116. package/dist/mcp/builtin/validateEntityData.js.map +1 -0
  117. package/dist/mcp/builtinTools.d.ts +144 -19
  118. package/dist/mcp/builtinTools.d.ts.map +1 -1
  119. package/dist/mcp/builtinTools.js +119 -20
  120. package/dist/mcp/builtinTools.js.map +1 -1
  121. package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
  122. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  123. package/dist/mcp/sanitizeMCPConfig.js +120 -58
  124. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  125. package/dist/stdio.d.ts +3 -2
  126. package/dist/stdio.d.ts.map +1 -1
  127. package/dist/stdio.js +27 -8
  128. package/dist/stdio.js.map +1 -1
  129. package/dist/types.d.ts +62 -108
  130. package/dist/types.d.ts.map +1 -1
  131. package/dist/types.js +4 -4
  132. package/dist/types.js.map +1 -1
  133. package/dist/utils/getPluginConfig.d.ts +1 -1
  134. package/dist/utils/getPluginConfig.js +1 -1
  135. package/dist/utils/getPluginConfig.js.map +1 -1
  136. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
  137. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
  138. package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
  139. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
  140. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
  141. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
  142. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
  143. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
  144. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
  145. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
  146. package/dist/utils/whereSchema.d.ts +9 -0
  147. package/dist/utils/whereSchema.d.ts.map +1 -0
  148. package/dist/utils/whereSchema.js +13 -0
  149. package/dist/utils/whereSchema.js.map +1 -0
  150. package/package.json +8 -11
  151. package/src/@types/assets.d.ts +3 -0
  152. package/src/defaultAccess.ts +3 -0
  153. package/src/endpoint/access.ts +88 -101
  154. package/src/endpoint/index.ts +14 -1
  155. package/src/exports/client.ts +2 -1
  156. package/src/exports/internal.ts +1 -0
  157. package/src/index.ts +8 -16
  158. package/src/mcp/buildMcpServer.ts +130 -90
  159. package/src/mcp/builtin/collections/authTools.ts +45 -9
  160. package/src/mcp/builtin/collections/countTool.ts +74 -0
  161. package/src/mcp/builtin/collections/countVersionsTool.ts +70 -0
  162. package/src/mcp/builtin/collections/createTool.ts +55 -59
  163. package/src/mcp/builtin/collections/deleteTool.ts +19 -16
  164. package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
  165. package/src/mcp/builtin/collections/findDistinctTool.ts +120 -0
  166. package/src/mcp/builtin/collections/findTool.ts +63 -33
  167. package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
  168. package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
  169. package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
  170. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +46 -0
  171. package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
  172. package/src/mcp/builtin/collections/updateTool.ts +111 -105
  173. package/src/mcp/builtin/getConfigInfoTool.ts +69 -0
  174. package/src/mcp/builtin/globals/countVersionsTool.ts +69 -0
  175. package/src/mcp/builtin/globals/findTool.ts +26 -17
  176. package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
  177. package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
  178. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +41 -0
  179. package/src/mcp/builtin/globals/restoreVersionTool.ts +100 -0
  180. package/src/mcp/builtin/globals/updateTool.ts +50 -53
  181. package/src/mcp/builtin/validateEntityData.ts +132 -0
  182. package/src/mcp/builtinTools.ts +111 -41
  183. package/src/mcp/sanitizeMCPConfig.ts +116 -78
  184. package/src/stdio.ts +23 -8
  185. package/src/types.ts +77 -112
  186. package/src/utils/getPluginConfig.ts +1 -1
  187. package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
  188. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
  189. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
  190. package/src/utils/whereSchema.ts +24 -0
  191. package/dist/collection/getAccessField.d.ts +0 -12
  192. package/dist/collection/getAccessField.d.ts.map +0 -1
  193. package/dist/collection/getAccessField.js +0 -57
  194. package/dist/collection/getAccessField.js.map +0 -1
  195. package/dist/collection/index.d.ts +0 -6
  196. package/dist/collection/index.d.ts.map +0 -1
  197. package/dist/collection/index.js +0 -59
  198. package/dist/collection/index.js.map +0 -1
  199. package/dist/components/AccessField/index.client.d.ts +0 -10
  200. package/dist/components/AccessField/index.client.d.ts.map +0 -1
  201. package/dist/components/AccessField/index.client.js +0 -305
  202. package/dist/components/AccessField/index.client.js.map +0 -1
  203. package/dist/components/AccessField/index.css +0 -93
  204. package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts +0 -7
  205. package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +0 -1
  206. package/dist/utils/schemaConversion/prepareCollectionSchema.js +0 -37
  207. package/dist/utils/schemaConversion/prepareCollectionSchema.js.map +0 -1
  208. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
  209. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
  210. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
  211. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
  212. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
  213. package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
  214. package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -56
  215. package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
  216. package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
  217. package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
  218. package/dist/utils/schemaConversion/transformPointFields.js +0 -57
  219. package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
  220. package/src/collection/getAccessField.ts +0 -64
  221. package/src/collection/index.ts +0 -63
  222. package/src/components/AccessField/index.client.tsx +0 -344
  223. package/src/components/AccessField/index.css +0 -93
  224. package/src/utils/schemaConversion/prepareCollectionSchema.ts +0 -39
  225. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
  226. package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -70
  227. package/src/utils/schemaConversion/transformPointFields.ts +0 -56
@@ -1,56 +0,0 @@
1
- /**
2
- * Removes internal Payload properties (id, createdAt, updatedAt) from a
3
- * JSON Schema so they don't appear in the generated Zod validation schema.
4
- * Also strips `id` from the `required` array when present.
5
- *
6
- * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
7
- * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
8
- * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
9
- * the concrete `type` from the output and breaking schema introspection.
10
- */ export function sanitizeJsonSchema(schema) {
11
- delete schema?.properties?.id;
12
- delete schema?.properties?.createdAt;
13
- delete schema?.properties?.updatedAt;
14
- if (Array.isArray(schema.required)) {
15
- schema.required = schema.required.filter((field)=>field !== 'id');
16
- if (schema.required.length === 0) {
17
- delete schema.required;
18
- }
19
- }
20
- if (schema.properties && typeof schema.properties === 'object') {
21
- for (const key of Object.keys(schema.properties)){
22
- const prop = schema.properties[key];
23
- if (!prop || typeof prop !== 'object') {
24
- continue;
25
- }
26
- normalizeNullableType(prop);
27
- if (prop.properties) {
28
- sanitizeJsonSchema(prop);
29
- }
30
- if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
31
- sanitizeJsonSchema(prop.items);
32
- }
33
- }
34
- }
35
- return schema;
36
- }
37
- /**
38
- * Strips `'null'` from a `type` array only when the remaining type is a
39
- * complex structural type (`array` or `object`).
40
- *
41
- * Simple scalar types (`string`, `number`, `boolean`) are intentionally
42
- * preserved as `['string', 'null']` so that the MCP SDK serialises them as a
43
- * compact inline `type` array. Complex types however cause `zodToJsonSchema`
44
- * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which
45
- * has no top-level `type` property and breaks schema introspection by clients.
46
- */ function normalizeNullableType(schema) {
47
- if (!Array.isArray(schema.type)) {
48
- return;
49
- }
50
- const nonNullTypes = schema.type.filter((t)=>t !== 'null');
51
- if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {
52
- schema.type = nonNullTypes[0];
53
- }
54
- }
55
-
56
- //# sourceMappingURL=sanitizeJsonSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n *\n * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →\n * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`\n * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping\n * the concrete `type` from the output and breaking schema introspection.\n */\nexport function sanitizeJsonSchema(schema: JsonSchemaType): JsonSchemaType {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const key of Object.keys(schema.properties)) {\n const prop = schema.properties[key] as JsonSchemaType\n if (!prop || typeof prop !== 'object') {\n continue\n }\n normalizeNullableType(prop)\n if (prop.properties) {\n sanitizeJsonSchema(prop)\n }\n if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {\n sanitizeJsonSchema(prop.items)\n }\n }\n }\n\n return schema\n}\n\n/**\n * Strips `'null'` from a `type` array only when the remaining type is a\n * complex structural type (`array` or `object`).\n *\n * Simple scalar types (`string`, `number`, `boolean`) are intentionally\n * preserved as `['string', 'null']` so that the MCP SDK serialises them as a\n * compact inline `type` array. Complex types however cause `zodToJsonSchema`\n * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which\n * has no top-level `type` property and breaks schema introspection by clients.\n */\nfunction normalizeNullableType(schema: JsonSchemaType): void {\n if (!Array.isArray(schema.type)) {\n return\n }\n const nonNullTypes = schema.type.filter((t) => t !== 'null')\n if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {\n schema.type = nonNullTypes[0]\n }\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length","key","Object","keys","prop","normalizeNullableType","items","type","nonNullTypes","t"],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,SAASA,mBAAmBC,MAAsB;IACvD,OAAOA,QAAQC,YAAYC;IAC3B,OAAOF,QAAQC,YAAYE;IAC3B,OAAOH,QAAQC,YAAYG;IAE3B,IAAIC,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAUA,UAAU;QAC9D,IAAIT,OAAOO,QAAQ,CAACG,MAAM,KAAK,GAAG;YAChC,OAAOV,OAAOO,QAAQ;QACxB;IACF;IAEA,IAAIP,OAAOC,UAAU,IAAI,OAAOD,OAAOC,UAAU,KAAK,UAAU;QAC9D,KAAK,MAAMU,OAAOC,OAAOC,IAAI,CAACb,OAAOC,UAAU,EAAG;YAChD,MAAMa,OAAOd,OAAOC,UAAU,CAACU,IAAI;YACnC,IAAI,CAACG,QAAQ,OAAOA,SAAS,UAAU;gBACrC;YACF;YACAC,sBAAsBD;YACtB,IAAIA,KAAKb,UAAU,EAAE;gBACnBF,mBAAmBe;YACrB;YACA,IAAIA,KAAKE,KAAK,IAAI,OAAOF,KAAKE,KAAK,KAAK,YAAY,CAACX,MAAMC,OAAO,CAACQ,KAAKE,KAAK,GAAG;gBAC9EjB,mBAAmBe,KAAKE,KAAK;YAC/B;QACF;IACF;IAEA,OAAOhB;AACT;AAEA;;;;;;;;;CASC,GACD,SAASe,sBAAsBf,MAAsB;IACnD,IAAI,CAACK,MAAMC,OAAO,CAACN,OAAOiB,IAAI,GAAG;QAC/B;IACF;IACA,MAAMC,eAAelB,OAAOiB,IAAI,CAACT,MAAM,CAAC,CAACW,IAAMA,MAAM;IACrD,IAAID,aAAaR,MAAM,KAAK,KAAMQ,CAAAA,YAAY,CAAC,EAAE,KAAK,WAAWA,YAAY,CAAC,EAAE,KAAK,QAAO,GAAI;QAC9FlB,OAAOiB,IAAI,GAAGC,YAAY,CAAC,EAAE;IAC/B;AACF"}
@@ -1,20 +0,0 @@
1
- import type { JsonSchemaType } from '../../types.js';
2
- /**
3
- * Recursively processes JSON schema properties to simplify relationship fields
4
- * and convert `oneOf` constructs into MCP-friendly schemas.
5
- *
6
- * For create/update validation we only need to accept IDs (string/number),
7
- * not populated objects. `$ref` options pointing to full entity definitions
8
- * are removed entirely from `oneOf` unions. When a single option remains the
9
- * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
10
- *
11
- * This matters because `json-schema-to-zod` converts `oneOf` into a strict
12
- * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
13
- * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
14
- * tool input schema. `anyOf` instead produces a clean `z.union([...])`.
15
- *
16
- * NOTE: This function must operate on a cloned schema to avoid mutating
17
- * the original JSON schema used for tool listing.
18
- */
19
- export declare function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType;
20
- //# sourceMappingURL=simplifyRelationshipFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simplifyRelationshipFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAkDjF"}
@@ -1,56 +0,0 @@
1
- /**
2
- * Recursively processes JSON schema properties to simplify relationship fields
3
- * and convert `oneOf` constructs into MCP-friendly schemas.
4
- *
5
- * For create/update validation we only need to accept IDs (string/number),
6
- * not populated objects. `$ref` options pointing to full entity definitions
7
- * are removed entirely from `oneOf` unions. When a single option remains the
8
- * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
9
- *
10
- * This matters because `json-schema-to-zod` converts `oneOf` into a strict
11
- * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
12
- * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
13
- * tool input schema. `anyOf` instead produces a clean `z.union([...])`.
14
- *
15
- * NOTE: This function must operate on a cloned schema to avoid mutating
16
- * the original JSON schema used for tool listing.
17
- */ export function simplifyRelationshipFields(schema) {
18
- if (!schema || typeof schema !== 'object') {
19
- return schema;
20
- }
21
- const processed = {
22
- ...schema
23
- };
24
- if (Array.isArray(processed.oneOf)) {
25
- const hasRef = processed.oneOf.some((option)=>option && typeof option === 'object' && '$ref' in option);
26
- const recurse = (option)=>typeof option === 'object' ? simplifyRelationshipFields(option) : option;
27
- if (hasRef) {
28
- const nonRefOptions = processed.oneOf.filter((option)=>!(option && typeof option === 'object' && '$ref' in option)).map(recurse);
29
- if (nonRefOptions.length === 1) {
30
- const single = nonRefOptions[0];
31
- delete processed.oneOf;
32
- if (typeof single === 'object') {
33
- Object.assign(processed, single);
34
- }
35
- } else if (nonRefOptions.length > 1) {
36
- delete processed.oneOf;
37
- processed.anyOf = nonRefOptions;
38
- }
39
- } else {
40
- processed.anyOf = processed.oneOf.map(recurse);
41
- delete processed.oneOf;
42
- }
43
- }
44
- if (processed.properties && typeof processed.properties === 'object') {
45
- processed.properties = Object.fromEntries(Object.entries(processed.properties).map(([key, value])=>[
46
- key,
47
- typeof value === 'object' ? simplifyRelationshipFields(value) : value
48
- ]));
49
- }
50
- if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
51
- processed.items = simplifyRelationshipFields(processed.items);
52
- }
53
- return processed;
54
- }
55
-
56
- //# sourceMappingURL=simplifyRelationshipFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Recursively processes JSON schema properties to simplify relationship fields\n * and convert `oneOf` constructs into MCP-friendly schemas.\n *\n * For create/update validation we only need to accept IDs (string/number),\n * not populated objects. `$ref` options pointing to full entity definitions\n * are removed entirely from `oneOf` unions. When a single option remains the\n * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.\n *\n * This matters because `json-schema-to-zod` converts `oneOf` into a strict\n * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing\n * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP\n * tool input schema. `anyOf` instead produces a clean `z.union([...])`.\n *\n * NOTE: This function must operate on a cloned schema to avoid mutating\n * the original JSON schema used for tool listing.\n */\nexport function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const processed = { ...schema }\n\n if (Array.isArray(processed.oneOf)) {\n const hasRef = processed.oneOf.some(\n (option) => option && typeof option === 'object' && '$ref' in option,\n )\n\n const recurse = (option: boolean | JsonSchemaType): boolean | JsonSchemaType =>\n typeof option === 'object' ? simplifyRelationshipFields(option) : option\n\n if (hasRef) {\n const nonRefOptions = processed.oneOf\n .filter((option) => !(option && typeof option === 'object' && '$ref' in option))\n .map(recurse)\n\n if (nonRefOptions.length === 1) {\n const single = nonRefOptions[0]!\n delete processed.oneOf\n if (typeof single === 'object') {\n Object.assign(processed, single)\n }\n } else if (nonRefOptions.length > 1) {\n delete processed.oneOf\n processed.anyOf = nonRefOptions\n }\n } else {\n processed.anyOf = processed.oneOf.map(recurse)\n delete processed.oneOf\n }\n }\n\n if (processed.properties && typeof processed.properties === 'object') {\n processed.properties = Object.fromEntries(\n Object.entries(processed.properties).map(([key, value]) => [\n key,\n typeof value === 'object' ? simplifyRelationshipFields(value) : value,\n ]),\n )\n }\n\n if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {\n processed.items = simplifyRelationshipFields(processed.items)\n }\n\n return processed\n}\n"],"names":["simplifyRelationshipFields","schema","processed","Array","isArray","oneOf","hasRef","some","option","recurse","nonRefOptions","filter","map","length","single","Object","assign","anyOf","properties","fromEntries","entries","key","value","items"],"mappings":"AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASA,2BAA2BC,MAAsB;IAC/D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,YAAY;QAAE,GAAGD,MAAM;IAAC;IAE9B,IAAIE,MAAMC,OAAO,CAACF,UAAUG,KAAK,GAAG;QAClC,MAAMC,SAASJ,UAAUG,KAAK,CAACE,IAAI,CACjC,CAACC,SAAWA,UAAU,OAAOA,WAAW,YAAY,UAAUA;QAGhE,MAAMC,UAAU,CAACD,SACf,OAAOA,WAAW,WAAWR,2BAA2BQ,UAAUA;QAEpE,IAAIF,QAAQ;YACV,MAAMI,gBAAgBR,UAAUG,KAAK,CAClCM,MAAM,CAAC,CAACH,SAAW,CAAEA,CAAAA,UAAU,OAAOA,WAAW,YAAY,UAAUA,MAAK,GAC5EI,GAAG,CAACH;YAEP,IAAIC,cAAcG,MAAM,KAAK,GAAG;gBAC9B,MAAMC,SAASJ,aAAa,CAAC,EAAE;gBAC/B,OAAOR,UAAUG,KAAK;gBACtB,IAAI,OAAOS,WAAW,UAAU;oBAC9BC,OAAOC,MAAM,CAACd,WAAWY;gBAC3B;YACF,OAAO,IAAIJ,cAAcG,MAAM,GAAG,GAAG;gBACnC,OAAOX,UAAUG,KAAK;gBACtBH,UAAUe,KAAK,GAAGP;YACpB;QACF,OAAO;YACLR,UAAUe,KAAK,GAAGf,UAAUG,KAAK,CAACO,GAAG,CAACH;YACtC,OAAOP,UAAUG,KAAK;QACxB;IACF;IAEA,IAAIH,UAAUgB,UAAU,IAAI,OAAOhB,UAAUgB,UAAU,KAAK,UAAU;QACpEhB,UAAUgB,UAAU,GAAGH,OAAOI,WAAW,CACvCJ,OAAOK,OAAO,CAAClB,UAAUgB,UAAU,EAAEN,GAAG,CAAC,CAAC,CAACS,KAAKC,MAAM,GAAK;gBACzDD;gBACA,OAAOC,UAAU,WAAWtB,2BAA2BsB,SAASA;aACjE;IAEL;IAEA,IAAIpB,UAAUqB,KAAK,IAAI,OAAOrB,UAAUqB,KAAK,KAAK,YAAY,CAACpB,MAAMC,OAAO,CAACF,UAAUqB,KAAK,GAAG;QAC7FrB,UAAUqB,KAAK,GAAGvB,2BAA2BE,UAAUqB,KAAK;IAC9D;IAEA,OAAOrB;AACT"}
@@ -1,3 +0,0 @@
1
- import type { JsonSchemaType } from '../../types.js';
2
- export declare function transformPointFieldsForMCP(schema: JsonSchemaType): JsonSchemaType;
3
- //# sourceMappingURL=transformPointFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformPointFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAqDjF"}
@@ -1,57 +0,0 @@
1
- export function transformPointFieldsForMCP(schema) {
2
- if (!schema || typeof schema !== 'object') {
3
- return schema;
4
- }
5
- const transformed = {
6
- ...schema
7
- };
8
- if (transformed.properties && typeof transformed.properties === 'object') {
9
- transformed.properties = Object.fromEntries(Object.entries(transformed.properties).map(([key, value])=>{
10
- if (!value || typeof value !== 'object') {
11
- return [
12
- key,
13
- value
14
- ];
15
- }
16
- const isArrayType = value.type === 'array' || Array.isArray(value.type) && value.type.includes('array');
17
- if (isArrayType && Array.isArray(value.items) && value.items.length === 2 && value.items.every((item)=>item && typeof item === 'object' && item.type === 'number')) {
18
- // Transform to object format
19
- const isNullable = Array.isArray(value.type) && value.type.includes('null');
20
- return [
21
- key,
22
- {
23
- type: isNullable ? [
24
- 'object',
25
- 'null'
26
- ] : 'object',
27
- description: value.description || 'Geographic coordinates (longitude, latitude)',
28
- properties: {
29
- latitude: {
30
- type: 'number',
31
- description: 'Latitude coordinate'
32
- },
33
- longitude: {
34
- type: 'number',
35
- description: 'Longitude coordinate'
36
- }
37
- },
38
- required: [
39
- 'longitude',
40
- 'latitude'
41
- ]
42
- }
43
- ];
44
- }
45
- return [
46
- key,
47
- transformPointFieldsForMCP(value)
48
- ];
49
- }));
50
- }
51
- if (transformed.items && typeof transformed.items === 'object' && !Array.isArray(transformed.items)) {
52
- transformed.items = transformPointFieldsForMCP(transformed.items);
53
- }
54
- return transformed;
55
- }
56
-
57
- //# sourceMappingURL=transformPointFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\nexport function transformPointFieldsForMCP(schema: JsonSchemaType): JsonSchemaType {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const transformed = { ...schema }\n\n if (transformed.properties && typeof transformed.properties === 'object') {\n transformed.properties = Object.fromEntries(\n Object.entries(transformed.properties).map(([key, value]) => {\n if (!value || typeof value !== 'object') {\n return [key, value]\n }\n const isArrayType =\n value.type === 'array' || (Array.isArray(value.type) && value.type.includes('array'))\n\n if (\n isArrayType &&\n Array.isArray(value.items) &&\n value.items.length === 2 &&\n value.items.every((item) => item && typeof item === 'object' && item.type === 'number')\n ) {\n // Transform to object format\n const isNullable = Array.isArray(value.type) && value.type.includes('null')\n\n return [\n key,\n {\n type: isNullable ? ['object', 'null'] : 'object',\n description: value.description || 'Geographic coordinates (longitude, latitude)',\n properties: {\n latitude: { type: 'number', description: 'Latitude coordinate' },\n longitude: { type: 'number', description: 'Longitude coordinate' },\n },\n required: ['longitude', 'latitude'],\n },\n ]\n }\n\n return [key, transformPointFieldsForMCP(value)]\n }),\n )\n }\n\n if (\n transformed.items &&\n typeof transformed.items === 'object' &&\n !Array.isArray(transformed.items)\n ) {\n transformed.items = transformPointFieldsForMCP(transformed.items)\n }\n\n return transformed\n}\n"],"names":["transformPointFieldsForMCP","schema","transformed","properties","Object","fromEntries","entries","map","key","value","isArrayType","type","Array","isArray","includes","items","length","every","item","isNullable","description","latitude","longitude","required"],"mappings":"AAEA,OAAO,SAASA,2BAA2BC,MAAsB;IAC/D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,cAAc;QAAE,GAAGD,MAAM;IAAC;IAEhC,IAAIC,YAAYC,UAAU,IAAI,OAAOD,YAAYC,UAAU,KAAK,UAAU;QACxED,YAAYC,UAAU,GAAGC,OAAOC,WAAW,CACzCD,OAAOE,OAAO,CAACJ,YAAYC,UAAU,EAAEI,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM;YACtD,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU;gBACvC,OAAO;oBAACD;oBAAKC;iBAAM;YACrB;YACA,MAAMC,cACJD,MAAME,IAAI,KAAK,WAAYC,MAAMC,OAAO,CAACJ,MAAME,IAAI,KAAKF,MAAME,IAAI,CAACG,QAAQ,CAAC;YAE9E,IACEJ,eACAE,MAAMC,OAAO,CAACJ,MAAMM,KAAK,KACzBN,MAAMM,KAAK,CAACC,MAAM,KAAK,KACvBP,MAAMM,KAAK,CAACE,KAAK,CAAC,CAACC,OAASA,QAAQ,OAAOA,SAAS,YAAYA,KAAKP,IAAI,KAAK,WAC9E;gBACA,6BAA6B;gBAC7B,MAAMQ,aAAaP,MAAMC,OAAO,CAACJ,MAAME,IAAI,KAAKF,MAAME,IAAI,CAACG,QAAQ,CAAC;gBAEpE,OAAO;oBACLN;oBACA;wBACEG,MAAMQ,aAAa;4BAAC;4BAAU;yBAAO,GAAG;wBACxCC,aAAaX,MAAMW,WAAW,IAAI;wBAClCjB,YAAY;4BACVkB,UAAU;gCAAEV,MAAM;gCAAUS,aAAa;4BAAsB;4BAC/DE,WAAW;gCAAEX,MAAM;gCAAUS,aAAa;4BAAuB;wBACnE;wBACAG,UAAU;4BAAC;4BAAa;yBAAW;oBACrC;iBACD;YACH;YAEA,OAAO;gBAACf;gBAAKR,2BAA2BS;aAAO;QACjD;IAEJ;IAEA,IACEP,YAAYa,KAAK,IACjB,OAAOb,YAAYa,KAAK,KAAK,YAC7B,CAACH,MAAMC,OAAO,CAACX,YAAYa,KAAK,GAChC;QACAb,YAAYa,KAAK,GAAGf,2BAA2BE,YAAYa,KAAK;IAClE;IAEA,OAAOb;AACT"}
@@ -1,64 +0,0 @@
1
- import type { JSONField } from 'payload'
2
-
3
- import type { ClientMCPPluginConfig, MCPItem, SanitizedMCPPluginConfig } from '../types.js'
4
-
5
- /**
6
- * Returns the API key collection's `access` field — a JSON field whose value
7
- * is the `MCPAPIKeysDocAccessTree` the endpoint consults. The actual UI is
8
- * a custom client component (`AccessField`) which renders a permissions
9
- * matrix; the field's stored shape is just the runtime access tree.
10
- */
11
- export const getAccessField = ({
12
- pluginConfig,
13
- }: {
14
- pluginConfig: SanitizedMCPPluginConfig
15
- }): JSONField => {
16
- const clientPluginConfig = sanitizeClientPluginConfig(pluginConfig)
17
-
18
- return {
19
- name: 'access',
20
- type: 'json',
21
- admin: {
22
- components: {
23
- Field: {
24
- clientProps: { pluginConfig: clientPluginConfig },
25
- path: '@payloadcms/plugin-mcp/client#AccessField',
26
- },
27
- },
28
- // TODO: needs i18n once design is finalized
29
- description: 'Access for this API key — uncheck to revoke individual tools.',
30
- position: 'sidebar',
31
- },
32
- defaultValue: {},
33
- // TODO: needs i18n once design is finalized
34
- label: 'Access',
35
- }
36
- }
37
-
38
- /**
39
- * Strips the non-serializable parts of `SanitizedMCPPluginConfig` (handlers,
40
- * input/argsSchema functions, etc.) so the result is safe to thread to a
41
- * client component via `clientProps`.
42
- */
43
- const sanitizeClientPluginConfig = (
44
- pluginConfig: SanitizedMCPPluginConfig,
45
- ): ClientMCPPluginConfig => ({
46
- items: pluginConfig.items.map((item) => ({
47
- ...(item.type === 'collectionTool' ? { collectionSlug: item.collectionSlug } : {}),
48
- ...(item.type === 'globalTool' ? { globalSlug: item.globalSlug } : {}),
49
- type: item.type,
50
- description: itemDescription(item),
51
- key: item.key,
52
- label: item.label,
53
- })),
54
- })
55
-
56
- const itemDescription = (item: MCPItem): string => {
57
- if (item.type === 'prompt') {
58
- return item.prompt.description
59
- }
60
- if (item.type === 'resource') {
61
- return item.resource.description
62
- }
63
- return item.tool.description
64
- }
@@ -1,63 +0,0 @@
1
- import type { CollectionConfig } from 'payload'
2
-
3
- import type { SanitizedMCPPluginConfig } from '../types.js'
4
-
5
- import { getAccessField } from './getAccessField.js'
6
-
7
- export const getAPIKeysCollection = ({
8
- pluginConfig,
9
- }: {
10
- pluginConfig: SanitizedMCPPluginConfig
11
- }): CollectionConfig => {
12
- const collection: CollectionConfig = {
13
- slug: 'payload-mcp-api-keys',
14
- admin: {
15
- description:
16
- 'API keys control which collections, resources, tools, and prompts MCP clients can access',
17
- group: 'MCP',
18
- useAsTitle: 'label',
19
- },
20
- auth: {
21
- disableLocalStrategy: true,
22
- useAPIKey: true,
23
- },
24
- fields: [
25
- {
26
- name: 'user',
27
- type: 'relationship',
28
- admin: { description: 'The user that the API key is associated with.' },
29
- relationTo: pluginConfig.userCollection,
30
- required: true,
31
- },
32
- {
33
- name: 'label',
34
- type: 'text',
35
- admin: { description: 'A useful label for the API key.' },
36
- },
37
- {
38
- name: 'description',
39
- type: 'text',
40
- admin: { description: 'The purpose of the API key.' },
41
- },
42
- {
43
- name: 'overrideAccess',
44
- type: 'checkbox',
45
- admin: {
46
- description:
47
- 'When checked, this key bypasses Payload access control on every operation it performs. Leave unchecked unless you have a specific reason.',
48
- },
49
- defaultValue: false,
50
- label: 'Override access control',
51
- },
52
- getAccessField({ pluginConfig }),
53
- ],
54
- labels: {
55
- plural: 'API Keys',
56
- singular: 'API Key',
57
- },
58
- }
59
-
60
- return pluginConfig.overrideApiKeyCollection
61
- ? pluginConfig.overrideApiKeyCollection(collection)
62
- : collection
63
- }