@payloadcms/plugin-mcp 4.0.0-internal.293e026 → 4.0.0-internal.2a3c3bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/dist/defaultAccess.d.ts +3 -0
- package/dist/defaultAccess.d.ts.map +1 -0
- package/dist/defaultAccess.js +3 -0
- package/dist/defaultAccess.js.map +1 -0
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +12 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +76 -88
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +102 -16
- package/dist/endpoint/index.js.map +1 -1
- package/dist/endpoint/oauth.d.ts +27 -0
- package/dist/endpoint/oauth.d.ts.map +1 -0
- package/dist/endpoint/oauth.js +61 -0
- package/dist/endpoint/oauth.js.map +1 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -0
- package/dist/exports/internal.js +3 -0
- package/dist/exports/internal.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +6 -6
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +146 -81
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/authTools.js +123 -61
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countTool.js +63 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +60 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +114 -68
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +55 -61
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +90 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +88 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +77 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +61 -74
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +74 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +84 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +103 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +69 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +118 -137
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
- package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
- package/dist/mcp/builtin/formatEntityError.js +55 -0
- package/dist/mcp/builtin/formatEntityError.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.js +69 -0
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +60 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +27 -36
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +68 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +78 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +81 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +70 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +44 -62
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +150 -19
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +125 -20
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +125 -58
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +86 -47
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +138 -114
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getPluginConfig.d.ts +1 -1
- package/dist/utils/getPluginConfig.js +1 -1
- package/dist/utils/getPluginConfig.js.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +11 -18
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +81 -101
- package/src/endpoint/index.ts +93 -15
- package/src/endpoint/oauth.ts +72 -0
- package/src/exports/client.ts +2 -1
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +19 -20
- package/src/mcp/buildMcpServer.ts +181 -116
- package/src/mcp/builtin/collections/authTools.ts +122 -75
- package/src/mcp/builtin/collections/countTool.ts +61 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/collections/createTool.ts +117 -88
- package/src/mcp/builtin/collections/deleteTool.ts +48 -74
- package/src/mcp/builtin/collections/duplicateTool.ts +84 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +127 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +67 -0
- package/src/mcp/builtin/collections/findTool.ts +57 -110
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +66 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +83 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +91 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +65 -0
- package/src/mcp/builtin/collections/updateTool.ts +106 -143
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/formatEntityError.ts +77 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +68 -0
- package/src/mcp/builtin/globals/countVersionsTool.ts +60 -0
- package/src/mcp/builtin/globals/findTool.ts +27 -57
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +64 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +69 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +73 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +68 -0
- package/src/mcp/builtin/globals/updateTool.ts +51 -79
- package/src/mcp/builtinTools.ts +118 -41
- package/src/mcp/sanitizeMCPConfig.ts +121 -78
- package/src/stdio.ts +80 -47
- package/src/types.ts +156 -120
- package/src/utils/getPluginConfig.ts +1 -1
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/collection/getAccessField.d.ts +0 -12
- package/dist/collection/getAccessField.d.ts.map +0 -1
- package/dist/collection/getAccessField.js +0 -57
- package/dist/collection/getAccessField.js.map +0 -1
- package/dist/collection/index.d.ts +0 -6
- package/dist/collection/index.d.ts.map +0 -1
- package/dist/collection/index.js +0 -60
- package/dist/collection/index.js.map +0 -1
- package/dist/components/AccessField/index.client.d.ts +0 -10
- package/dist/components/AccessField/index.client.d.ts.map +0 -1
- package/dist/components/AccessField/index.client.js +0 -305
- package/dist/components/AccessField/index.client.js.map +0 -1
- package/dist/components/AccessField/index.css +0 -93
- package/dist/utils/getVirtualFieldNames.d.ts +0 -14
- package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
- package/dist/utils/getVirtualFieldNames.js +0 -35
- package/dist/utils/getVirtualFieldNames.js.map +0 -1
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/buildToolInput.d.ts +0 -29
- package/dist/utils/schemaConversion/buildToolInput.d.ts.map +0 -1
- package/dist/utils/schemaConversion/buildToolInput.js +0 -51
- package/dist/utils/schemaConversion/buildToolInput.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
- package/dist/utils/transformPointDataToPayload.d.ts +0 -7
- package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
- package/dist/utils/transformPointDataToPayload.js +0 -28
- package/dist/utils/transformPointDataToPayload.js.map +0 -1
- package/src/@types/assets.d.ts +0 -3
- package/src/collection/getAccessField.ts +0 -64
- package/src/collection/index.ts +0 -64
- package/src/components/AccessField/index.client.tsx +0 -344
- package/src/components/AccessField/index.css +0 -93
- package/src/utils/getVirtualFieldNames.ts +0 -53
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/buildToolInput.ts +0 -68
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
- 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"}
|
package/src/@types/assets.d.ts
DELETED
|
@@ -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
|
-
}
|
package/src/collection/index.ts
DELETED
|
@@ -1,64 +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
|
-
versions: false,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return pluginConfig.overrideApiKeyCollection
|
|
62
|
-
? pluginConfig.overrideApiKeyCollection(collection)
|
|
63
|
-
: collection
|
|
64
|
-
}
|