@payloadcms/plugin-mcp 4.0.0-internal.4cbdd50 → 4.0.0-internal.532221d

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 (187) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +7 -0
  3. package/dist/defaultAccess.d.ts.map +1 -1
  4. package/dist/defineTool.d.ts +8 -8
  5. package/dist/defineTool.d.ts.map +1 -1
  6. package/dist/endpoint/access.d.ts +2 -7
  7. package/dist/endpoint/access.d.ts.map +1 -1
  8. package/dist/endpoint/access.js +4 -11
  9. package/dist/endpoint/access.js.map +1 -1
  10. package/dist/endpoint/index.d.ts +1 -1
  11. package/dist/endpoint/index.d.ts.map +1 -1
  12. package/dist/endpoint/index.js +57 -17
  13. package/dist/endpoint/index.js.map +1 -1
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/buildMcpServer.d.ts +4 -4
  19. package/dist/mcp/buildMcpServer.d.ts.map +1 -1
  20. package/dist/mcp/buildMcpServer.js +32 -10
  21. package/dist/mcp/buildMcpServer.js.map +1 -1
  22. package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
  23. package/dist/mcp/builtin/collections/countTool.js +1 -2
  24. package/dist/mcp/builtin/collections/countTool.js.map +1 -1
  25. package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
  26. package/dist/mcp/builtin/collections/countVersionsTool.js +1 -2
  27. package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
  28. package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
  29. package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
  30. package/dist/mcp/builtin/collections/createTool.js +92 -42
  31. package/dist/mcp/builtin/collections/createTool.js.map +1 -1
  32. package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
  33. package/dist/mcp/builtin/collections/deleteTool.js +1 -2
  34. package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
  35. package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
  36. package/dist/mcp/builtin/collections/duplicateTool.js +2 -4
  37. package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
  38. package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
  39. package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
  40. package/dist/mcp/builtin/collections/fileInput.js +124 -0
  41. package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
  42. package/dist/mcp/builtin/collections/fileInput.spec.js +86 -0
  43. package/dist/mcp/builtin/collections/fileInput.spec.js.map +1 -0
  44. package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
  45. package/dist/mcp/builtin/collections/findDistinctTool.js +1 -2
  46. package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
  47. package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
  48. package/dist/mcp/builtin/collections/findTool.js +3 -4
  49. package/dist/mcp/builtin/collections/findTool.js.map +1 -1
  50. package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
  51. package/dist/mcp/builtin/collections/findVersionByIDTool.js +1 -2
  52. package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
  53. package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
  54. package/dist/mcp/builtin/collections/findVersionsTool.js +1 -2
  55. package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
  56. package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
  57. package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
  58. package/dist/mcp/builtin/collections/formatCollectionError.js +1 -1
  59. package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
  60. package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
  61. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +45 -6
  62. package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
  63. package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
  64. package/dist/mcp/builtin/collections/restoreVersionTool.js +1 -2
  65. package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
  66. package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
  67. package/dist/mcp/builtin/collections/updateTool.js +25 -15
  68. package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
  69. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
  70. package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
  71. package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
  72. package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
  73. package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
  74. package/dist/mcp/builtin/getConfigInfoTool.js +2 -5
  75. package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
  76. package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
  77. package/dist/mcp/builtin/globals/countVersionsTool.js +1 -2
  78. package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
  79. package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
  80. package/dist/mcp/builtin/globals/findTool.js +2 -2
  81. package/dist/mcp/builtin/globals/findTool.js.map +1 -1
  82. package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
  83. package/dist/mcp/builtin/globals/findVersionByIDTool.js +1 -2
  84. package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
  85. package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
  86. package/dist/mcp/builtin/globals/findVersionsTool.js +1 -2
  87. package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
  88. package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
  89. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +21 -4
  90. package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
  91. package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
  92. package/dist/mcp/builtin/globals/restoreVersionTool.js +1 -2
  93. package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
  94. package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
  95. package/dist/mcp/builtin/globals/updateTool.js +3 -4
  96. package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
  97. package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
  98. package/dist/mcp/builtin/validateEntityData.js +2 -2
  99. package/dist/mcp/builtin/validateEntityData.js.map +1 -1
  100. package/dist/mcp/builtinTools.d.ts +6 -0
  101. package/dist/mcp/builtinTools.d.ts.map +1 -1
  102. package/dist/mcp/builtinTools.js +9 -3
  103. package/dist/mcp/builtinTools.js.map +1 -1
  104. package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
  105. package/dist/mcp/sanitizeMCPConfig.js +5 -1
  106. package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
  107. package/dist/stdio.d.ts +3 -4
  108. package/dist/stdio.d.ts.map +1 -1
  109. package/dist/stdio.js +61 -42
  110. package/dist/stdio.js.map +1 -1
  111. package/dist/types.d.ts +57 -9
  112. package/dist/types.d.ts.map +1 -1
  113. package/dist/types.js +2 -4
  114. package/dist/types.js.map +1 -1
  115. package/dist/utils/camelCase.d.ts.map +1 -1
  116. package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
  117. package/dist/utils/toStandardSchema.d.ts.map +1 -1
  118. package/package.json +8 -10
  119. package/src/endpoint/access.ts +3 -10
  120. package/src/endpoint/index.ts +45 -16
  121. package/src/index.ts +4 -4
  122. package/src/mcp/buildMcpServer.ts +40 -20
  123. package/src/mcp/builtin/collections/countTool.ts +1 -2
  124. package/src/mcp/builtin/collections/countVersionsTool.ts +1 -2
  125. package/src/mcp/builtin/collections/createTool.ts +95 -39
  126. package/src/mcp/builtin/collections/deleteTool.ts +1 -2
  127. package/src/mcp/builtin/collections/duplicateTool.ts +6 -7
  128. package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
  129. package/src/mcp/builtin/collections/fileInput.ts +164 -0
  130. package/src/mcp/builtin/collections/findDistinctTool.ts +1 -2
  131. package/src/mcp/builtin/collections/findTool.ts +3 -4
  132. package/src/mcp/builtin/collections/findVersionByIDTool.ts +1 -2
  133. package/src/mcp/builtin/collections/findVersionsTool.ts +1 -2
  134. package/src/mcp/builtin/collections/formatCollectionError.ts +2 -2
  135. package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +43 -10
  136. package/src/mcp/builtin/collections/restoreVersionTool.ts +1 -2
  137. package/src/mcp/builtin/collections/updateTool.ts +32 -16
  138. package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
  139. package/src/mcp/builtin/getConfigInfoTool.ts +2 -4
  140. package/src/mcp/builtin/globals/countVersionsTool.ts +1 -2
  141. package/src/mcp/builtin/globals/findTool.ts +2 -2
  142. package/src/mcp/builtin/globals/findVersionByIDTool.ts +1 -2
  143. package/src/mcp/builtin/globals/findVersionsTool.ts +1 -2
  144. package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +25 -4
  145. package/src/mcp/builtin/globals/restoreVersionTool.ts +1 -2
  146. package/src/mcp/builtin/globals/updateTool.ts +7 -7
  147. package/src/mcp/builtin/validateEntityData.ts +4 -8
  148. package/src/mcp/builtinTools.ts +9 -2
  149. package/src/mcp/sanitizeMCPConfig.ts +5 -1
  150. package/src/stdio.ts +61 -43
  151. package/src/types.ts +57 -9
  152. package/dist/@types/assets.d.js +0 -2
  153. package/dist/@types/assets.d.js.map +0 -1
  154. package/dist/utils/getVirtualFieldNames.d.ts +0 -14
  155. package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
  156. package/dist/utils/getVirtualFieldNames.js +0 -35
  157. package/dist/utils/getVirtualFieldNames.js.map +0 -1
  158. package/dist/utils/localAPIDefaults.d.ts +0 -20
  159. package/dist/utils/localAPIDefaults.d.ts.map +0 -1
  160. package/dist/utils/localAPIDefaults.js +0 -19
  161. package/dist/utils/localAPIDefaults.js.map +0 -1
  162. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -11
  163. package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
  164. package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
  165. package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
  166. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
  167. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
  168. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
  169. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
  170. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
  171. package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
  172. package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
  173. package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
  174. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
  175. package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
  176. package/dist/utils/transformPointDataToPayload.d.ts +0 -7
  177. package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
  178. package/dist/utils/transformPointDataToPayload.js +0 -28
  179. package/dist/utils/transformPointDataToPayload.js.map +0 -1
  180. package/src/@types/assets.d.ts +0 -3
  181. package/src/utils/getVirtualFieldNames.ts +0 -53
  182. package/src/utils/localAPIDefaults.ts +0 -22
  183. package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
  184. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
  185. package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
  186. package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
  187. package/src/utils/transformPointDataToPayload.ts +0 -40
@@ -1,158 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { sanitizeEntitySchema } from './sanitizeEntitySchema.js';
3
- describe('sanitizeEntitySchema', ()=>{
4
- it('keeps a Lexical node union strict (oneOf) while simplifying relationship values to IDs', ()=>{
5
- // Shaped like the schema the MCP server prepares for a collection with a Lexical richText field:
6
- // a `$defs` node union (a `oneOf` of node shapes) where a relationship node's `value` is either
7
- // an ID or a `$ref` to the populated related collection.
8
- const standalone = {
9
- type: 'object',
10
- $defs: {
11
- LexicalNodes_ABCDEF12: {
12
- oneOf: [
13
- {
14
- type: 'object',
15
- additionalProperties: false,
16
- properties: {
17
- type: {
18
- const: 'paragraph'
19
- }
20
- },
21
- required: [
22
- 'type'
23
- ]
24
- },
25
- {
26
- type: 'object',
27
- additionalProperties: false,
28
- properties: {
29
- type: {
30
- const: 'relationship'
31
- },
32
- value: {
33
- oneOf: [
34
- {
35
- type: 'string'
36
- },
37
- {
38
- $ref: '#/$defs/posts'
39
- }
40
- ]
41
- }
42
- },
43
- required: [
44
- 'type'
45
- ]
46
- }
47
- ]
48
- },
49
- posts: {
50
- type: 'object',
51
- additionalProperties: false,
52
- properties: {
53
- id: {
54
- type: 'string'
55
- },
56
- title: {
57
- type: 'string'
58
- }
59
- }
60
- }
61
- },
62
- properties: {
63
- id: {
64
- type: 'string'
65
- },
66
- content: {
67
- type: 'object',
68
- properties: {
69
- root: {
70
- type: 'object',
71
- properties: {
72
- children: {
73
- type: 'array',
74
- items: {
75
- $ref: '#/$defs/LexicalNodes_ABCDEF12'
76
- }
77
- }
78
- }
79
- }
80
- }
81
- }
82
- }
83
- };
84
- expect(sanitizeEntitySchema(standalone)).toStrictEqual({
85
- type: 'object',
86
- $defs: {
87
- // The node union is renamed to a short, readable `node`, and stays a strict discriminated
88
- // `oneOf` - not loosened to `anyOf`...
89
- node: {
90
- oneOf: [
91
- {
92
- type: 'object',
93
- additionalProperties: false,
94
- properties: {
95
- type: {
96
- const: 'paragraph'
97
- }
98
- },
99
- required: [
100
- 'type'
101
- ]
102
- },
103
- {
104
- type: 'object',
105
- additionalProperties: false,
106
- properties: {
107
- type: {
108
- const: 'relationship'
109
- },
110
- // ...while the relationship `value` is simplified to a bare ID (the populated-doc `$ref` is dropped).
111
- value: {
112
- type: 'string',
113
- description: 'The ID of the related "posts" document.'
114
- }
115
- },
116
- required: [
117
- 'type'
118
- ]
119
- }
120
- ]
121
- },
122
- posts: {
123
- type: 'object',
124
- additionalProperties: false,
125
- properties: {
126
- id: {
127
- type: 'string'
128
- },
129
- title: {
130
- type: 'string'
131
- }
132
- }
133
- }
134
- },
135
- properties: {
136
- // `id` is dropped - it's a Payload-managed field MCP clients never set.
137
- content: {
138
- type: 'object',
139
- properties: {
140
- root: {
141
- type: 'object',
142
- properties: {
143
- children: {
144
- type: 'array',
145
- items: {
146
- $ref: '#/$defs/node'
147
- }
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
- });
155
- });
156
- });
157
-
158
- //# sourceMappingURL=sanitizeEntitySchema.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeEntitySchema.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport type { JsonSchemaType } from '../../types.js'\n\nimport { sanitizeEntitySchema } from './sanitizeEntitySchema.js'\n\ndescribe('sanitizeEntitySchema', () => {\n it('keeps a Lexical node union strict (oneOf) while simplifying relationship values to IDs', () => {\n // Shaped like the schema the MCP server prepares for a collection with a Lexical richText field:\n // a `$defs` node union (a `oneOf` of node shapes) where a relationship node's `value` is either\n // an ID or a `$ref` to the populated related collection.\n const standalone: JsonSchemaType = {\n type: 'object',\n $defs: {\n LexicalNodes_ABCDEF12: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: { type: { const: 'paragraph' } },\n required: ['type'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { const: 'relationship' },\n value: { oneOf: [{ type: 'string' }, { $ref: '#/$defs/posts' }] },\n },\n required: ['type'],\n },\n ],\n },\n posts: {\n type: 'object',\n additionalProperties: false,\n properties: { id: { type: 'string' }, title: { type: 'string' } },\n },\n },\n properties: {\n id: { type: 'string' },\n content: {\n type: 'object',\n properties: {\n root: {\n type: 'object',\n properties: {\n children: { type: 'array', items: { $ref: '#/$defs/LexicalNodes_ABCDEF12' } },\n },\n },\n },\n },\n },\n }\n\n expect(sanitizeEntitySchema(standalone)).toStrictEqual({\n type: 'object',\n $defs: {\n // The node union is renamed to a short, readable `node`, and stays a strict discriminated\n // `oneOf` - not loosened to `anyOf`...\n node: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: { type: { const: 'paragraph' } },\n required: ['type'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { const: 'relationship' },\n // ...while the relationship `value` is simplified to a bare ID (the populated-doc `$ref` is dropped).\n value: { type: 'string', description: 'The ID of the related \"posts\" document.' },\n },\n required: ['type'],\n },\n ],\n },\n posts: {\n type: 'object',\n additionalProperties: false,\n properties: { id: { type: 'string' }, title: { type: 'string' } },\n },\n },\n properties: {\n // `id` is dropped - it's a Payload-managed field MCP clients never set.\n content: {\n type: 'object',\n properties: {\n root: {\n type: 'object',\n properties: {\n children: { type: 'array', items: { $ref: '#/$defs/node' } },\n },\n },\n },\n },\n },\n })\n })\n})\n"],"names":["describe","expect","it","sanitizeEntitySchema","standalone","type","$defs","LexicalNodes_ABCDEF12","oneOf","additionalProperties","properties","const","required","value","$ref","posts","id","title","content","root","children","items","toStrictEqual","node","description"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhEH,SAAS,wBAAwB;IAC/BE,GAAG,0FAA0F;QAC3F,iGAAiG;QACjG,gGAAgG;QAChG,yDAAyD;QACzD,MAAME,aAA6B;YACjCC,MAAM;YACNC,OAAO;gBACLC,uBAAuB;oBACrBC,OAAO;wBACL;4BACEH,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCAAEL,MAAM;oCAAEM,OAAO;gCAAY;4BAAE;4BAC3CC,UAAU;gCAAC;6BAAO;wBACpB;wBACA;4BACEP,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCACVL,MAAM;oCAAEM,OAAO;gCAAe;gCAC9BE,OAAO;oCAAEL,OAAO;wCAAC;4CAAEH,MAAM;wCAAS;wCAAG;4CAAES,MAAM;wCAAgB;qCAAE;gCAAC;4BAClE;4BACAF,UAAU;gCAAC;6BAAO;wBACpB;qBACD;gBACH;gBACAG,OAAO;oBACLV,MAAM;oBACNI,sBAAsB;oBACtBC,YAAY;wBAAEM,IAAI;4BAAEX,MAAM;wBAAS;wBAAGY,OAAO;4BAAEZ,MAAM;wBAAS;oBAAE;gBAClE;YACF;YACAK,YAAY;gBACVM,IAAI;oBAAEX,MAAM;gBAAS;gBACrBa,SAAS;oBACPb,MAAM;oBACNK,YAAY;wBACVS,MAAM;4BACJd,MAAM;4BACNK,YAAY;gCACVU,UAAU;oCAAEf,MAAM;oCAASgB,OAAO;wCAAEP,MAAM;oCAAgC;gCAAE;4BAC9E;wBACF;oBACF;gBACF;YACF;QACF;QAEAb,OAAOE,qBAAqBC,aAAakB,aAAa,CAAC;YACrDjB,MAAM;YACNC,OAAO;gBACL,0FAA0F;gBAC1F,uCAAuC;gBACvCiB,MAAM;oBACJf,OAAO;wBACL;4BACEH,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCAAEL,MAAM;oCAAEM,OAAO;gCAAY;4BAAE;4BAC3CC,UAAU;gCAAC;6BAAO;wBACpB;wBACA;4BACEP,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCACVL,MAAM;oCAAEM,OAAO;gCAAe;gCAC9B,sGAAsG;gCACtGE,OAAO;oCAAER,MAAM;oCAAUmB,aAAa;gCAA0C;4BAClF;4BACAZ,UAAU;gCAAC;6BAAO;wBACpB;qBACD;gBACH;gBACAG,OAAO;oBACLV,MAAM;oBACNI,sBAAsB;oBACtBC,YAAY;wBAAEM,IAAI;4BAAEX,MAAM;wBAAS;wBAAGY,OAAO;4BAAEZ,MAAM;wBAAS;oBAAE;gBAClE;YACF;YACAK,YAAY;gBACV,wEAAwE;gBACxEQ,SAAS;oBACPb,MAAM;oBACNK,YAAY;wBACVS,MAAM;4BACJd,MAAM;4BACNK,YAAY;gCACVU,UAAU;oCAAEf,MAAM;oCAASgB,OAAO;wCAAEP,MAAM;oCAAe;gCAAE;4BAC7D;wBACF;oBACF;gBACF;YACF;QACF;IACF;AACF"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Transforms incoming MCP tool data from object format to tuple array format.
3
- * Converts { longitude: number, latitude: number } back to [longitude, latitude]
4
- * for Payload's internal point field representation.
5
- */
6
- export declare function transformPointDataToPayload(data: Record<string, unknown>): Record<string, unknown>;
7
- //# sourceMappingURL=transformPointDataToPayload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformPointDataToPayload.d.ts","sourceRoot":"","sources":["../../src/utils/transformPointDataToPayload.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Transforms incoming MCP tool data from object format to tuple array format.
3
- * Converts { longitude: number, latitude: number } back to [longitude, latitude]
4
- * for Payload's internal point field representation.
5
- */ export function transformPointDataToPayload(data) {
6
- if (!data || typeof data !== 'object') {
7
- return data;
8
- }
9
- const transformed = {};
10
- for (const [key, value] of Object.entries(data)){
11
- if (value && typeof value === 'object' && 'longitude' in value && 'latitude' in value && typeof value.longitude === 'number' && typeof value.latitude === 'number') {
12
- // Transform to tuple array [longitude, latitude]
13
- transformed[key] = [
14
- value.longitude,
15
- value.latitude
16
- ];
17
- } else if (Array.isArray(value)) {
18
- transformed[key] = value.map((item)=>typeof item === 'object' ? transformPointDataToPayload(item) : item);
19
- } else if (value && typeof value === 'object') {
20
- transformed[key] = transformPointDataToPayload(value);
21
- } else {
22
- transformed[key] = value;
23
- }
24
- }
25
- return transformed;
26
- }
27
-
28
- //# sourceMappingURL=transformPointDataToPayload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/transformPointDataToPayload.ts"],"sourcesContent":["/**\n * Transforms incoming MCP tool data from object format to tuple array format.\n * Converts { longitude: number, latitude: number } back to [longitude, latitude]\n * for Payload's internal point field representation.\n */\nexport function transformPointDataToPayload(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n if (!data || typeof data !== 'object') {\n return data\n }\n\n const transformed: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(data)) {\n if (\n value &&\n typeof value === 'object' &&\n 'longitude' in value &&\n 'latitude' in value &&\n typeof value.longitude === 'number' &&\n typeof value.latitude === 'number'\n ) {\n // Transform to tuple array [longitude, latitude]\n transformed[key] = [value.longitude, value.latitude]\n } else if (Array.isArray(value)) {\n transformed[key] = value.map((item) =>\n typeof item === 'object'\n ? transformPointDataToPayload(item as Record<string, unknown>)\n : item,\n )\n } else if (value && typeof value === 'object') {\n transformed[key] = transformPointDataToPayload(value as Record<string, unknown>)\n } else {\n transformed[key] = value\n }\n }\n\n return transformed\n}\n"],"names":["transformPointDataToPayload","data","transformed","key","value","Object","entries","longitude","latitude","Array","isArray","map","item"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,SAASA,4BACdC,IAA6B;IAE7B,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU;QACrC,OAAOA;IACT;IAEA,MAAMC,cAAuC,CAAC;IAE9C,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,MAAO;QAC/C,IACEG,SACA,OAAOA,UAAU,YACjB,eAAeA,SACf,cAAcA,SACd,OAAOA,MAAMG,SAAS,KAAK,YAC3B,OAAOH,MAAMI,QAAQ,KAAK,UAC1B;YACA,iDAAiD;YACjDN,WAAW,CAACC,IAAI,GAAG;gBAACC,MAAMG,SAAS;gBAAEH,MAAMI,QAAQ;aAAC;QACtD,OAAO,IAAIC,MAAMC,OAAO,CAACN,QAAQ;YAC/BF,WAAW,CAACC,IAAI,GAAGC,MAAMO,GAAG,CAAC,CAACC,OAC5B,OAAOA,SAAS,WACZZ,4BAA4BY,QAC5BA;QAER,OAAO,IAAIR,SAAS,OAAOA,UAAU,UAAU;YAC7CF,WAAW,CAACC,IAAI,GAAGH,4BAA4BI;QACjD,OAAO;YACLF,WAAW,CAACC,IAAI,GAAGC;QACrB;IACF;IAEA,OAAOF;AACT"}
@@ -1,3 +0,0 @@
1
- declare module '*.css'
2
-
3
- declare module '*.scss'
@@ -1,53 +0,0 @@
1
- import type { SanitizedConfig } from 'payload'
2
-
3
- import { fieldIsVirtual } from 'payload/shared'
4
-
5
- /**
6
- * Returns the names of all top-level virtual fields for a given collection slug.
7
- */
8
- export function getCollectionVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {
9
- const collection = config.collections.find((c) => c.slug === slug)
10
-
11
- if (!collection) {
12
- return []
13
- }
14
-
15
- return collection.flattenedFields
16
- .filter((field) => 'name' in field && fieldIsVirtual(field))
17
- .map((field) => (field as { name: string }).name)
18
- }
19
-
20
- /**
21
- * Returns the names of all top-level virtual fields for a given global slug.
22
- */
23
- export function getGlobalVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {
24
- const global = config.globals.find((g) => g.slug === slug)
25
-
26
- if (!global) {
27
- return []
28
- }
29
-
30
- return global.flattenedFields
31
- .filter((field) => 'name' in field && fieldIsVirtual(field))
32
- .map((field) => (field as { name: string }).name)
33
- }
34
-
35
- /**
36
- * Strips virtual field values from a data object given a list of virtual field names.
37
- */
38
- export function stripVirtualFields(
39
- data: Record<string, unknown>,
40
- virtualFieldNames: string[],
41
- ): Record<string, unknown> {
42
- if (virtualFieldNames.length === 0) {
43
- return data
44
- }
45
-
46
- const stripped = { ...data }
47
-
48
- for (const name of virtualFieldNames) {
49
- delete stripped[name]
50
- }
51
-
52
- return stripped
53
- }
@@ -1,22 +0,0 @@
1
- import type { AuthorizedMCP } from '../types.js'
2
-
3
- /**
4
- * Returns the `user` and `overrideAccess` arguments every Payload local API call
5
- * should receive when initiated from an MCP request. Spread the result into the
6
- * call's arg object so the two pieces of caller state can't drift apart.
7
- *
8
- * @example
9
- * ```ts
10
- * await req.payload.create({
11
- * collection: 'posts',
12
- * data,
13
- * ...localAPIDefaults(authorizedMCP),
14
- * })
15
- * ```
16
- */
17
- export const localAPIDefaults = (
18
- authorizedMCP: AuthorizedMCP,
19
- ): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({
20
- overrideAccess: authorizedMCP.overrideAccess,
21
- user: authorizedMCP.user,
22
- })
@@ -1,78 +0,0 @@
1
- import {
2
- type CollectionSlug,
3
- entityToStandaloneJSONSchema,
4
- type GlobalSlug,
5
- type PayloadRequest,
6
- type SanitizedCollectionConfig,
7
- type SanitizedGlobalConfig,
8
- } from 'payload'
9
-
10
- import type { JsonSchemaType } from '../../types.js'
11
-
12
- import {
13
- getCollectionVirtualFieldNames,
14
- getGlobalVirtualFieldNames,
15
- } from '../getVirtualFieldNames.js'
16
- import { removeVirtualFieldsFromSchema } from './removeVirtualFieldsFromSchema.js'
17
- import { sanitizeEntitySchema } from './sanitizeEntitySchema.js'
18
-
19
- export const getCollectionInputSchema = ({
20
- collectionSlug,
21
- req,
22
- }: {
23
- collectionSlug: CollectionSlug
24
- req: PayloadRequest
25
- }): JsonSchemaType | null => {
26
- const collection = req.payload.collections[collectionSlug]?.config
27
-
28
- if (!collection) {
29
- return null
30
- }
31
-
32
- return buildEntityInputSchema({
33
- entity: collection,
34
- req,
35
- virtualFieldNames: getCollectionVirtualFieldNames(req.payload.config, collectionSlug),
36
- })
37
- }
38
-
39
- export const getGlobalInputSchema = ({
40
- globalSlug,
41
- req,
42
- }: {
43
- globalSlug: GlobalSlug
44
- req: PayloadRequest
45
- }): JsonSchemaType | null => {
46
- const global = req.payload.config.globals.find((globalConfig) => globalConfig.slug === globalSlug)
47
-
48
- if (!global) {
49
- return null
50
- }
51
-
52
- return buildEntityInputSchema({
53
- entity: global,
54
- req,
55
- virtualFieldNames: getGlobalVirtualFieldNames(req.payload.config, globalSlug),
56
- })
57
- }
58
-
59
- const buildEntityInputSchema = ({
60
- entity,
61
- req,
62
- virtualFieldNames,
63
- }: {
64
- entity: SanitizedCollectionConfig | SanitizedGlobalConfig
65
- req: PayloadRequest
66
- virtualFieldNames: string[]
67
- }): JsonSchemaType =>
68
- sanitizeEntitySchema(
69
- removeVirtualFieldsFromSchema(
70
- entityToStandaloneJSONSchema({
71
- config: req.payload.config,
72
- defaultIDType: req.payload.db.defaultIDType,
73
- entity,
74
- i18n: req.i18n,
75
- }) as unknown as JsonSchemaType,
76
- virtualFieldNames,
77
- ),
78
- )
@@ -1,27 +0,0 @@
1
- import type { JsonSchemaType } from '../../types.js'
2
-
3
- /**
4
- * Removes virtual fields from a JSON Schema by name so they don't appear
5
- * in the generated MCP tool input schema.
6
- */
7
- export function removeVirtualFieldsFromSchema(
8
- schema: JsonSchemaType,
9
- virtualFieldNames: string[],
10
- ): JsonSchemaType {
11
- if (virtualFieldNames.length === 0) {
12
- return schema
13
- }
14
-
15
- for (const name of virtualFieldNames) {
16
- delete schema?.properties?.[name]
17
- }
18
-
19
- if (Array.isArray(schema.required)) {
20
- schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))
21
- if (schema.required.length === 0) {
22
- delete schema.required
23
- }
24
- }
25
-
26
- return schema
27
- }
@@ -1,103 +0,0 @@
1
- import { describe, expect, it } from 'vitest'
2
-
3
- import type { JsonSchemaType } from '../../types.js'
4
-
5
- import { sanitizeEntitySchema } from './sanitizeEntitySchema.js'
6
-
7
- describe('sanitizeEntitySchema', () => {
8
- it('keeps a Lexical node union strict (oneOf) while simplifying relationship values to IDs', () => {
9
- // Shaped like the schema the MCP server prepares for a collection with a Lexical richText field:
10
- // a `$defs` node union (a `oneOf` of node shapes) where a relationship node's `value` is either
11
- // an ID or a `$ref` to the populated related collection.
12
- const standalone: JsonSchemaType = {
13
- type: 'object',
14
- $defs: {
15
- LexicalNodes_ABCDEF12: {
16
- oneOf: [
17
- {
18
- type: 'object',
19
- additionalProperties: false,
20
- properties: { type: { const: 'paragraph' } },
21
- required: ['type'],
22
- },
23
- {
24
- type: 'object',
25
- additionalProperties: false,
26
- properties: {
27
- type: { const: 'relationship' },
28
- value: { oneOf: [{ type: 'string' }, { $ref: '#/$defs/posts' }] },
29
- },
30
- required: ['type'],
31
- },
32
- ],
33
- },
34
- posts: {
35
- type: 'object',
36
- additionalProperties: false,
37
- properties: { id: { type: 'string' }, title: { type: 'string' } },
38
- },
39
- },
40
- properties: {
41
- id: { type: 'string' },
42
- content: {
43
- type: 'object',
44
- properties: {
45
- root: {
46
- type: 'object',
47
- properties: {
48
- children: { type: 'array', items: { $ref: '#/$defs/LexicalNodes_ABCDEF12' } },
49
- },
50
- },
51
- },
52
- },
53
- },
54
- }
55
-
56
- expect(sanitizeEntitySchema(standalone)).toStrictEqual({
57
- type: 'object',
58
- $defs: {
59
- // The node union is renamed to a short, readable `node`, and stays a strict discriminated
60
- // `oneOf` - not loosened to `anyOf`...
61
- node: {
62
- oneOf: [
63
- {
64
- type: 'object',
65
- additionalProperties: false,
66
- properties: { type: { const: 'paragraph' } },
67
- required: ['type'],
68
- },
69
- {
70
- type: 'object',
71
- additionalProperties: false,
72
- properties: {
73
- type: { const: 'relationship' },
74
- // ...while the relationship `value` is simplified to a bare ID (the populated-doc `$ref` is dropped).
75
- value: { type: 'string', description: 'The ID of the related "posts" document.' },
76
- },
77
- required: ['type'],
78
- },
79
- ],
80
- },
81
- posts: {
82
- type: 'object',
83
- additionalProperties: false,
84
- properties: { id: { type: 'string' }, title: { type: 'string' } },
85
- },
86
- },
87
- properties: {
88
- // `id` is dropped - it's a Payload-managed field MCP clients never set.
89
- content: {
90
- type: 'object',
91
- properties: {
92
- root: {
93
- type: 'object',
94
- properties: {
95
- children: { type: 'array', items: { $ref: '#/$defs/node' } },
96
- },
97
- },
98
- },
99
- },
100
- },
101
- })
102
- })
103
- })