@payloadcms/plugin-mcp 4.0.0-canary.1 → 4.0.0-canary.10
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/bin.js +7 -0
- 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 +75 -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 +68 -17
- package/dist/endpoint/index.js.map +1 -1
- 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 +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -20
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +4 -4
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +34 -10
- 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 +44 -6
- 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 +68 -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 +64 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +26 -24
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +10 -2
- 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 +96 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts +20 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +100 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.spec.js +72 -0
- package/dist/mcp/builtin/collections/fileInput.spec.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 +92 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +46 -26
- 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 +83 -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 +98 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +55 -4
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- 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 +81 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +37 -32
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +27 -8
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- 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 +64 -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 +19 -22
- 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 +79 -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 +94 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +32 -2
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- 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 +77 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +14 -21
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -1
- package/dist/mcp/builtin/validateEntityData.js +1 -1
- package/dist/mcp/builtin/validateEntityData.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +69 -12
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +66 -10
- 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 +69 -27
- 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 +82 -45
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +100 -87
- 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/schemaConversion/filterFieldsByAccess.d.ts +28 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +10 -15
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +81 -101
- package/src/endpoint/index.ts +58 -16
- package/src/exports/client.ts +2 -1
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +12 -20
- package/src/mcp/buildMcpServer.ts +48 -21
- package/src/mcp/builtin/collections/authTools.ts +45 -9
- package/src/mcp/builtin/collections/countTool.ts +73 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/collections/createTool.ts +27 -18
- package/src/mcp/builtin/collections/deleteTool.ts +11 -2
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/fileInput.spec.ts +79 -0
- package/src/mcp/builtin/collections/fileInput.ts +139 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +59 -20
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +51 -3
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +39 -23
- package/src/mcp/builtin/getConfigInfoTool.ts +27 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +27 -18
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +37 -2
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +16 -16
- package/src/mcp/builtin/validateEntityData.ts +1 -1
- package/src/mcp/builtinTools.ts +72 -16
- package/src/mcp/sanitizeMCPConfig.ts +48 -30
- package/src/stdio.ts +77 -45
- package/src/types.ts +108 -90
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- 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/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/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/src/collection/getAccessField.ts +0 -64
- package/src/collection/index.ts +0 -64
- package/src/components/AccessField/index.client.tsx +0 -347
- package/src/components/AccessField/index.css +0 -93
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CheckboxInput, Collapsible, useField } from '@payloadcms/ui';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import './index.css';
|
|
6
|
-
const baseClass = 'mcp-access-field';
|
|
7
|
-
/** Drop a key from an object and return a new object — or `undefined` if it'd be empty. */ const without = (obj, key)=>{
|
|
8
|
-
if (!obj || !(key in obj)) {
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
const { [key]: _omitted, ...rest } = obj;
|
|
12
|
-
return Object.keys(rest).length === 0 ? undefined : rest;
|
|
13
|
-
};
|
|
14
|
-
const setKey = (obj, key, value)=>({
|
|
15
|
-
...obj ?? {},
|
|
16
|
-
[key]: value
|
|
17
|
-
});
|
|
18
|
-
export const AccessField = ({ path, pluginConfig })=>{
|
|
19
|
-
const { setValue, value } = useField({
|
|
20
|
-
path
|
|
21
|
-
});
|
|
22
|
-
const access = value ?? {};
|
|
23
|
-
// Bucket items for rendering. (Bucketing is cheap and runs once per render;
|
|
24
|
-
// memoizing would mean managing inputs/refs for marginal benefit.)
|
|
25
|
-
const collectionsBySlug = {};
|
|
26
|
-
const globalsBySlug = {};
|
|
27
|
-
const tools = [];
|
|
28
|
-
const prompts = [];
|
|
29
|
-
const resources = [];
|
|
30
|
-
for (const item of pluginConfig.items){
|
|
31
|
-
switch(item.type){
|
|
32
|
-
case 'collectionTool':
|
|
33
|
-
;
|
|
34
|
-
(collectionsBySlug[item.collectionSlug] ??= []).push(item);
|
|
35
|
-
break;
|
|
36
|
-
case 'globalTool':
|
|
37
|
-
;
|
|
38
|
-
(globalsBySlug[item.globalSlug] ??= []).push(item);
|
|
39
|
-
break;
|
|
40
|
-
case 'prompt':
|
|
41
|
-
prompts.push(item);
|
|
42
|
-
break;
|
|
43
|
-
case 'resource':
|
|
44
|
-
resources.push(item);
|
|
45
|
-
break;
|
|
46
|
-
case 'tool':
|
|
47
|
-
tools.push(item);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
const isScopedAllowed = (scope, slug, configKey)=>access[scope]?.[slug]?.[configKey] !== false;
|
|
52
|
-
const isFlatAllowed = (scope, configKey)=>access[scope]?.[configKey] !== false;
|
|
53
|
-
const toggleScoped = (scope, slug, configKey, allow)=>{
|
|
54
|
-
if (allow) {
|
|
55
|
-
const slugBucket = without(access[scope]?.[slug], configKey);
|
|
56
|
-
const scopeBucket = slugBucket ? setKey(access[scope], slug, slugBucket) : without(access[scope], slug);
|
|
57
|
-
setValue(scopeBucket ? setKey(access, scope, scopeBucket) : without(access, scope) ?? {});
|
|
58
|
-
} else {
|
|
59
|
-
setValue(setKey(access, scope, setKey(access[scope], slug, setKey(access[scope]?.[slug], configKey, false))));
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const toggleFlat = (scope, configKey, allow)=>{
|
|
63
|
-
if (allow) {
|
|
64
|
-
const bucket = without(access[scope], configKey);
|
|
65
|
-
setValue(bucket ? setKey(access, scope, bucket) : without(access, scope) ?? {});
|
|
66
|
-
} else {
|
|
67
|
-
setValue(setKey(access, scope, setKey(access[scope], configKey, false)));
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const setAllScoped = (scope, slug, leaves, allow)=>{
|
|
71
|
-
if (allow) {
|
|
72
|
-
const scopeBucket = without(access[scope], slug);
|
|
73
|
-
setValue(scopeBucket ? setKey(access, scope, scopeBucket) : without(access, scope) ?? {});
|
|
74
|
-
} else {
|
|
75
|
-
const slugBucket = leaves.reduce((acc, leaf)=>({
|
|
76
|
-
...acc,
|
|
77
|
-
[leaf.configKey]: false
|
|
78
|
-
}), {});
|
|
79
|
-
setValue(setKey(access, scope, setKey(access[scope], slug, slugBucket)));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const setAllFlat = (scope, leaves, allow)=>{
|
|
83
|
-
if (allow) {
|
|
84
|
-
setValue(without(access, scope) ?? {});
|
|
85
|
-
} else {
|
|
86
|
-
const bucket = leaves.reduce((acc, leaf)=>({
|
|
87
|
-
...acc,
|
|
88
|
-
[leaf.configKey]: false
|
|
89
|
-
}), {});
|
|
90
|
-
setValue(setKey(access, scope, bucket));
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const collectionSlugs = Object.keys(collectionsBySlug);
|
|
94
|
-
const globalSlugs = Object.keys(globalsBySlug);
|
|
95
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
96
|
-
className: baseClass,
|
|
97
|
-
children: [
|
|
98
|
-
collectionSlugs.length > 0 && /*#__PURE__*/ _jsxs("section", {
|
|
99
|
-
className: `${baseClass}__section`,
|
|
100
|
-
children: [
|
|
101
|
-
/*#__PURE__*/ _jsxs("header", {
|
|
102
|
-
className: `${baseClass}__section-header`,
|
|
103
|
-
children: [
|
|
104
|
-
/*#__PURE__*/ _jsx("h4", {
|
|
105
|
-
children: "Collection-level permissions"
|
|
106
|
-
}),
|
|
107
|
-
/*#__PURE__*/ _jsx("p", {
|
|
108
|
-
children: "Allow MCP clients to perform the following actions within these collections:"
|
|
109
|
-
})
|
|
110
|
-
]
|
|
111
|
-
}),
|
|
112
|
-
collectionSlugs.map((slug)=>{
|
|
113
|
-
const leaves = collectionsBySlug[slug];
|
|
114
|
-
return /*#__PURE__*/ _jsx(Collapsible, {
|
|
115
|
-
actions: /*#__PURE__*/ _jsx(GroupActions, {
|
|
116
|
-
onSetAll: (allow)=>setAllScoped('collections', slug, leaves, allow)
|
|
117
|
-
}),
|
|
118
|
-
className: `${baseClass}__group`,
|
|
119
|
-
header: /*#__PURE__*/ _jsx("span", {
|
|
120
|
-
className: `${baseClass}__group-label`,
|
|
121
|
-
children: titleCase(slug)
|
|
122
|
-
}),
|
|
123
|
-
initCollapsed: true,
|
|
124
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
125
|
-
className: `${baseClass}__list`,
|
|
126
|
-
children: leaves.map((leaf)=>/*#__PURE__*/ _jsx("li", {
|
|
127
|
-
children: /*#__PURE__*/ _jsx(CheckboxInput, {
|
|
128
|
-
checked: isScopedAllowed('collections', slug, leaf.configKey),
|
|
129
|
-
id: `${path}.collections.${slug}.${leaf.configKey}`,
|
|
130
|
-
label: leaf.label,
|
|
131
|
-
onToggle: (e)=>toggleScoped('collections', slug, leaf.configKey, e.target.checked),
|
|
132
|
-
tooltip: leaf.description
|
|
133
|
-
})
|
|
134
|
-
}, leaf.configKey))
|
|
135
|
-
})
|
|
136
|
-
}, `collection-${slug}`);
|
|
137
|
-
})
|
|
138
|
-
]
|
|
139
|
-
}),
|
|
140
|
-
globalSlugs.length > 0 && /*#__PURE__*/ _jsxs("section", {
|
|
141
|
-
className: `${baseClass}__section`,
|
|
142
|
-
children: [
|
|
143
|
-
/*#__PURE__*/ _jsxs("header", {
|
|
144
|
-
className: `${baseClass}__section-header`,
|
|
145
|
-
children: [
|
|
146
|
-
/*#__PURE__*/ _jsx("h4", {
|
|
147
|
-
children: "Global-level permissions"
|
|
148
|
-
}),
|
|
149
|
-
/*#__PURE__*/ _jsx("p", {
|
|
150
|
-
children: "Allow MCP clients to perform the following actions on these globals:"
|
|
151
|
-
})
|
|
152
|
-
]
|
|
153
|
-
}),
|
|
154
|
-
globalSlugs.map((slug)=>{
|
|
155
|
-
const leaves = globalsBySlug[slug];
|
|
156
|
-
return /*#__PURE__*/ _jsx(Collapsible, {
|
|
157
|
-
actions: /*#__PURE__*/ _jsx(GroupActions, {
|
|
158
|
-
onSetAll: (allow)=>setAllScoped('globals', slug, leaves, allow)
|
|
159
|
-
}),
|
|
160
|
-
className: `${baseClass}__group`,
|
|
161
|
-
header: /*#__PURE__*/ _jsx("span", {
|
|
162
|
-
className: `${baseClass}__group-label`,
|
|
163
|
-
children: titleCase(slug)
|
|
164
|
-
}),
|
|
165
|
-
initCollapsed: true,
|
|
166
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
167
|
-
className: `${baseClass}__list`,
|
|
168
|
-
children: leaves.map((leaf)=>/*#__PURE__*/ _jsx("li", {
|
|
169
|
-
children: /*#__PURE__*/ _jsx(CheckboxInput, {
|
|
170
|
-
checked: isScopedAllowed('globals', slug, leaf.configKey),
|
|
171
|
-
id: `${path}.globals.${slug}.${leaf.configKey}`,
|
|
172
|
-
label: leaf.label,
|
|
173
|
-
onToggle: (e)=>toggleScoped('globals', slug, leaf.configKey, e.target.checked),
|
|
174
|
-
tooltip: leaf.description
|
|
175
|
-
})
|
|
176
|
-
}, leaf.configKey))
|
|
177
|
-
})
|
|
178
|
-
}, `global-${slug}`);
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
}),
|
|
182
|
-
(tools.length > 0 || prompts.length > 0 || resources.length > 0) && /*#__PURE__*/ _jsxs("section", {
|
|
183
|
-
className: `${baseClass}__section`,
|
|
184
|
-
children: [
|
|
185
|
-
/*#__PURE__*/ _jsxs("header", {
|
|
186
|
-
className: `${baseClass}__section-header`,
|
|
187
|
-
children: [
|
|
188
|
-
/*#__PURE__*/ _jsx("h4", {
|
|
189
|
-
children: "Project-level permissions"
|
|
190
|
-
}),
|
|
191
|
-
/*#__PURE__*/ _jsx("p", {
|
|
192
|
-
children: "Cross-cutting tools, prompts, and resources not scoped to a single collection."
|
|
193
|
-
})
|
|
194
|
-
]
|
|
195
|
-
}),
|
|
196
|
-
tools.length > 0 && /*#__PURE__*/ _jsx(Collapsible, {
|
|
197
|
-
actions: /*#__PURE__*/ _jsx(GroupActions, {
|
|
198
|
-
onSetAll: (allow)=>setAllFlat('tools', tools, allow)
|
|
199
|
-
}),
|
|
200
|
-
className: `${baseClass}__group`,
|
|
201
|
-
header: /* TODO: needs i18n once design is finalized */ /*#__PURE__*/ _jsx("span", {
|
|
202
|
-
className: `${baseClass}__group-label`,
|
|
203
|
-
children: "Tools"
|
|
204
|
-
}),
|
|
205
|
-
initCollapsed: true,
|
|
206
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
207
|
-
className: `${baseClass}__list`,
|
|
208
|
-
children: tools.map((leaf)=>/*#__PURE__*/ _jsx("li", {
|
|
209
|
-
children: /*#__PURE__*/ _jsx(CheckboxInput, {
|
|
210
|
-
checked: isFlatAllowed('tools', leaf.configKey),
|
|
211
|
-
id: `${path}.tools.${leaf.configKey}`,
|
|
212
|
-
label: leaf.label,
|
|
213
|
-
onToggle: (e)=>toggleFlat('tools', leaf.configKey, e.target.checked),
|
|
214
|
-
tooltip: leaf.description
|
|
215
|
-
})
|
|
216
|
-
}, leaf.configKey))
|
|
217
|
-
})
|
|
218
|
-
}),
|
|
219
|
-
prompts.length > 0 && /*#__PURE__*/ _jsx(Collapsible, {
|
|
220
|
-
actions: /*#__PURE__*/ _jsx(GroupActions, {
|
|
221
|
-
onSetAll: (allow)=>setAllFlat('prompts', prompts, allow)
|
|
222
|
-
}),
|
|
223
|
-
className: `${baseClass}__group`,
|
|
224
|
-
header: /* TODO: needs i18n once design is finalized */ /*#__PURE__*/ _jsx("span", {
|
|
225
|
-
className: `${baseClass}__group-label`,
|
|
226
|
-
children: "Prompts"
|
|
227
|
-
}),
|
|
228
|
-
initCollapsed: true,
|
|
229
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
230
|
-
className: `${baseClass}__list`,
|
|
231
|
-
children: prompts.map((leaf)=>/*#__PURE__*/ _jsx("li", {
|
|
232
|
-
children: /*#__PURE__*/ _jsx(CheckboxInput, {
|
|
233
|
-
checked: isFlatAllowed('prompts', leaf.configKey),
|
|
234
|
-
id: `${path}.prompts.${leaf.configKey}`,
|
|
235
|
-
label: leaf.label,
|
|
236
|
-
onToggle: (e)=>toggleFlat('prompts', leaf.configKey, e.target.checked),
|
|
237
|
-
tooltip: leaf.description
|
|
238
|
-
})
|
|
239
|
-
}, leaf.configKey))
|
|
240
|
-
})
|
|
241
|
-
}),
|
|
242
|
-
resources.length > 0 && /*#__PURE__*/ _jsx(Collapsible, {
|
|
243
|
-
actions: /*#__PURE__*/ _jsx(GroupActions, {
|
|
244
|
-
onSetAll: (allow)=>setAllFlat('resources', resources, allow)
|
|
245
|
-
}),
|
|
246
|
-
className: `${baseClass}__group`,
|
|
247
|
-
header: /* TODO: needs i18n once design is finalized */ /*#__PURE__*/ _jsx("span", {
|
|
248
|
-
className: `${baseClass}__group-label`,
|
|
249
|
-
children: "Resources"
|
|
250
|
-
}),
|
|
251
|
-
initCollapsed: true,
|
|
252
|
-
children: /*#__PURE__*/ _jsx("ul", {
|
|
253
|
-
className: `${baseClass}__list`,
|
|
254
|
-
children: resources.map((leaf)=>/*#__PURE__*/ _jsx("li", {
|
|
255
|
-
children: /*#__PURE__*/ _jsx(CheckboxInput, {
|
|
256
|
-
checked: isFlatAllowed('resources', leaf.configKey),
|
|
257
|
-
id: `${path}.resources.${leaf.configKey}`,
|
|
258
|
-
label: leaf.label,
|
|
259
|
-
onToggle: (e)=>toggleFlat('resources', leaf.configKey, e.target.checked),
|
|
260
|
-
tooltip: leaf.description
|
|
261
|
-
})
|
|
262
|
-
}, leaf.configKey))
|
|
263
|
-
})
|
|
264
|
-
})
|
|
265
|
-
]
|
|
266
|
-
})
|
|
267
|
-
]
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
const GroupActions = ({ onSetAll })=>// TODO: button labels + aria-labels need i18n once design is finalized
|
|
271
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
272
|
-
className: `${baseClass}__group-actions`,
|
|
273
|
-
children: [
|
|
274
|
-
/*#__PURE__*/ _jsx("button", {
|
|
275
|
-
"aria-label": "Select all",
|
|
276
|
-
className: `${baseClass}__action`,
|
|
277
|
-
onClick: (e)=>{
|
|
278
|
-
e.stopPropagation();
|
|
279
|
-
onSetAll(true);
|
|
280
|
-
},
|
|
281
|
-
title: "Select all",
|
|
282
|
-
type: "button",
|
|
283
|
-
children: "all"
|
|
284
|
-
}),
|
|
285
|
-
/*#__PURE__*/ _jsx("span", {
|
|
286
|
-
"aria-hidden": true,
|
|
287
|
-
className: `${baseClass}__action-sep`,
|
|
288
|
-
children: "/"
|
|
289
|
-
}),
|
|
290
|
-
/*#__PURE__*/ _jsx("button", {
|
|
291
|
-
"aria-label": "Clear all",
|
|
292
|
-
className: `${baseClass}__action`,
|
|
293
|
-
onClick: (e)=>{
|
|
294
|
-
e.stopPropagation();
|
|
295
|
-
onSetAll(false);
|
|
296
|
-
},
|
|
297
|
-
title: "Clear all",
|
|
298
|
-
type: "button",
|
|
299
|
-
children: "none"
|
|
300
|
-
})
|
|
301
|
-
]
|
|
302
|
-
});
|
|
303
|
-
const titleCase = (slug)=>slug.replace(/(^|[-_])(.)/g, (_, sep, ch)=>sep ? ` ${ch.toUpperCase()}` : ch.toUpperCase());
|
|
304
|
-
|
|
305
|
-
//# sourceMappingURL=index.client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/AccessField/index.client.tsx"],"sourcesContent":["'use client'\n\nimport type { JSONFieldClientProps } from 'payload'\n\nimport { CheckboxInput, Collapsible, useField } from '@payloadcms/ui'\nimport React from 'react'\n\nimport type { ClientMCPPluginConfig, MCPAPIKeysDocAccessTree } from '../../types.js'\n\nimport './index.css'\n\nconst baseClass = 'mcp-access-field'\n\ntype ClientItem = ClientMCPPluginConfig['items'][number]\ntype ScopeKey = 'collections' | 'globals'\ntype FlatKey = 'prompts' | 'resources' | 'tools'\n\ntype Props = {\n pluginConfig: ClientMCPPluginConfig\n} & JSONFieldClientProps\n\n/** Drop a key from an object and return a new object — or `undefined` if it'd be empty. */\nconst without = <T extends Record<string, unknown>>(\n obj: T | undefined,\n key: string,\n): T | undefined => {\n if (!obj || !(key in obj)) {\n return obj\n }\n const { [key]: _omitted, ...rest } = obj\n return Object.keys(rest).length === 0 ? undefined : (rest as T)\n}\n\nconst setKey = <T extends Record<string, unknown>>(\n obj: T | undefined,\n key: string,\n value: unknown,\n): T => ({ ...(obj ?? {}), [key]: value }) as T\n\nexport const AccessField: React.FC<Props> = ({ path, pluginConfig }) => {\n const { setValue, value } = useField<MCPAPIKeysDocAccessTree>({ path })\n const access = value ?? {}\n\n // Bucket items for rendering. (Bucketing is cheap and runs once per render;\n // memoizing would mean managing inputs/refs for marginal benefit.)\n const collectionsBySlug: Record<string, ClientItem[]> = {}\n const globalsBySlug: Record<string, ClientItem[]> = {}\n const tools: ClientItem[] = []\n const prompts: ClientItem[] = []\n const resources: ClientItem[] = []\n for (const item of pluginConfig.items) {\n switch (item.type) {\n case 'collectionTool':\n ;(collectionsBySlug[item.collectionSlug!] ??= []).push(item)\n break\n case 'globalTool':\n ;(globalsBySlug[item.globalSlug!] ??= []).push(item)\n break\n case 'prompt':\n prompts.push(item)\n break\n case 'resource':\n resources.push(item)\n break\n case 'tool':\n tools.push(item)\n break\n }\n }\n\n const isScopedAllowed = (scope: ScopeKey, slug: string, configKey: string): boolean =>\n access[scope]?.[slug]?.[configKey] !== false\n\n const isFlatAllowed = (scope: FlatKey, configKey: string): boolean =>\n access[scope]?.[configKey] !== false\n\n const toggleScoped = (scope: ScopeKey, slug: string, configKey: string, allow: boolean) => {\n if (allow) {\n const slugBucket = without(access[scope]?.[slug], configKey)\n const scopeBucket = slugBucket\n ? setKey(access[scope], slug, slugBucket)\n : without(access[scope], slug)\n setValue(scopeBucket ? setKey(access, scope, scopeBucket) : (without(access, scope) ?? {}))\n } else {\n setValue(\n setKey(\n access,\n scope,\n setKey(access[scope], slug, setKey(access[scope]?.[slug], configKey, false)),\n ),\n )\n }\n }\n\n const toggleFlat = (scope: FlatKey, configKey: string, allow: boolean) => {\n if (allow) {\n const bucket = without(access[scope], configKey)\n setValue(bucket ? setKey(access, scope, bucket) : (without(access, scope) ?? {}))\n } else {\n setValue(setKey(access, scope, setKey(access[scope], configKey, false)))\n }\n }\n\n const setAllScoped = (scope: ScopeKey, slug: string, leaves: ClientItem[], allow: boolean) => {\n if (allow) {\n const scopeBucket = without(access[scope], slug)\n setValue(scopeBucket ? setKey(access, scope, scopeBucket) : (without(access, scope) ?? {}))\n } else {\n const slugBucket = leaves.reduce<Record<string, boolean>>(\n (acc, leaf) => ({ ...acc, [leaf.configKey]: false }),\n {},\n )\n setValue(setKey(access, scope, setKey(access[scope], slug, slugBucket)))\n }\n }\n\n const setAllFlat = (scope: FlatKey, leaves: ClientItem[], allow: boolean) => {\n if (allow) {\n setValue(without(access, scope) ?? {})\n } else {\n const bucket = leaves.reduce<Record<string, boolean>>(\n (acc, leaf) => ({ ...acc, [leaf.configKey]: false }),\n {},\n )\n setValue(setKey(access, scope, bucket))\n }\n }\n\n const collectionSlugs = Object.keys(collectionsBySlug)\n const globalSlugs = Object.keys(globalsBySlug)\n\n return (\n <div className={baseClass}>\n {collectionSlugs.length > 0 && (\n <section className={`${baseClass}__section`}>\n <header className={`${baseClass}__section-header`}>\n {/* TODO: needs i18n once design is finalized */}\n <h4>Collection-level permissions</h4>\n {/* TODO: needs i18n once design is finalized */}\n <p>Allow MCP clients to perform the following actions within these collections:</p>\n </header>\n {collectionSlugs.map((slug) => {\n const leaves = collectionsBySlug[slug]!\n return (\n <Collapsible\n actions={\n <GroupActions\n onSetAll={(allow) => setAllScoped('collections', slug, leaves, allow)}\n />\n }\n className={`${baseClass}__group`}\n header={<span className={`${baseClass}__group-label`}>{titleCase(slug)}</span>}\n initCollapsed\n key={`collection-${slug}`}\n >\n <ul className={`${baseClass}__list`}>\n {leaves.map((leaf) => (\n <li key={leaf.configKey}>\n <CheckboxInput\n checked={isScopedAllowed('collections', slug, leaf.configKey)}\n id={`${path}.collections.${slug}.${leaf.configKey}`}\n label={leaf.label}\n onToggle={(e) =>\n toggleScoped('collections', slug, leaf.configKey, e.target.checked)\n }\n tooltip={leaf.description}\n />\n </li>\n ))}\n </ul>\n </Collapsible>\n )\n })}\n </section>\n )}\n\n {globalSlugs.length > 0 && (\n <section className={`${baseClass}__section`}>\n <header className={`${baseClass}__section-header`}>\n {/* TODO: needs i18n once design is finalized */}\n <h4>Global-level permissions</h4>\n {/* TODO: needs i18n once design is finalized */}\n <p>Allow MCP clients to perform the following actions on these globals:</p>\n </header>\n {globalSlugs.map((slug) => {\n const leaves = globalsBySlug[slug]!\n return (\n <Collapsible\n actions={\n <GroupActions\n onSetAll={(allow) => setAllScoped('globals', slug, leaves, allow)}\n />\n }\n className={`${baseClass}__group`}\n header={<span className={`${baseClass}__group-label`}>{titleCase(slug)}</span>}\n initCollapsed\n key={`global-${slug}`}\n >\n <ul className={`${baseClass}__list`}>\n {leaves.map((leaf) => (\n <li key={leaf.configKey}>\n <CheckboxInput\n checked={isScopedAllowed('globals', slug, leaf.configKey)}\n id={`${path}.globals.${slug}.${leaf.configKey}`}\n label={leaf.label}\n onToggle={(e) =>\n toggleScoped('globals', slug, leaf.configKey, e.target.checked)\n }\n tooltip={leaf.description}\n />\n </li>\n ))}\n </ul>\n </Collapsible>\n )\n })}\n </section>\n )}\n\n {(tools.length > 0 || prompts.length > 0 || resources.length > 0) && (\n <section className={`${baseClass}__section`}>\n <header className={`${baseClass}__section-header`}>\n {/* TODO: needs i18n once design is finalized */}\n <h4>Project-level permissions</h4>\n {/* TODO: needs i18n once design is finalized */}\n <p>Cross-cutting tools, prompts, and resources not scoped to a single collection.</p>\n </header>\n {tools.length > 0 && (\n <Collapsible\n actions={<GroupActions onSetAll={(allow) => setAllFlat('tools', tools, allow)} />}\n className={`${baseClass}__group`}\n header={\n /* TODO: needs i18n once design is finalized */\n <span className={`${baseClass}__group-label`}>Tools</span>\n }\n initCollapsed\n >\n <ul className={`${baseClass}__list`}>\n {tools.map((leaf) => (\n <li key={leaf.configKey}>\n <CheckboxInput\n checked={isFlatAllowed('tools', leaf.configKey)}\n id={`${path}.tools.${leaf.configKey}`}\n label={leaf.label}\n onToggle={(e) => toggleFlat('tools', leaf.configKey, e.target.checked)}\n tooltip={leaf.description}\n />\n </li>\n ))}\n </ul>\n </Collapsible>\n )}\n {prompts.length > 0 && (\n <Collapsible\n actions={<GroupActions onSetAll={(allow) => setAllFlat('prompts', prompts, allow)} />}\n className={`${baseClass}__group`}\n header={\n /* TODO: needs i18n once design is finalized */\n <span className={`${baseClass}__group-label`}>Prompts</span>\n }\n initCollapsed\n >\n <ul className={`${baseClass}__list`}>\n {prompts.map((leaf) => (\n <li key={leaf.configKey}>\n <CheckboxInput\n checked={isFlatAllowed('prompts', leaf.configKey)}\n id={`${path}.prompts.${leaf.configKey}`}\n label={leaf.label}\n onToggle={(e) => toggleFlat('prompts', leaf.configKey, e.target.checked)}\n tooltip={leaf.description}\n />\n </li>\n ))}\n </ul>\n </Collapsible>\n )}\n {resources.length > 0 && (\n <Collapsible\n actions={\n <GroupActions onSetAll={(allow) => setAllFlat('resources', resources, allow)} />\n }\n className={`${baseClass}__group`}\n header={\n /* TODO: needs i18n once design is finalized */\n <span className={`${baseClass}__group-label`}>Resources</span>\n }\n initCollapsed\n >\n <ul className={`${baseClass}__list`}>\n {resources.map((leaf) => (\n <li key={leaf.configKey}>\n <CheckboxInput\n checked={isFlatAllowed('resources', leaf.configKey)}\n id={`${path}.resources.${leaf.configKey}`}\n label={leaf.label}\n onToggle={(e) => toggleFlat('resources', leaf.configKey, e.target.checked)}\n tooltip={leaf.description}\n />\n </li>\n ))}\n </ul>\n </Collapsible>\n )}\n </section>\n )}\n </div>\n )\n}\n\nconst GroupActions: React.FC<{ onSetAll: (allow: boolean) => void }> = ({ onSetAll }) => (\n // TODO: button labels + aria-labels need i18n once design is finalized\n <div className={`${baseClass}__group-actions`}>\n <button\n aria-label=\"Select all\"\n className={`${baseClass}__action`}\n onClick={(e) => {\n e.stopPropagation()\n onSetAll(true)\n }}\n title=\"Select all\"\n type=\"button\"\n >\n all\n </button>\n <span aria-hidden className={`${baseClass}__action-sep`}>\n /\n </span>\n <button\n aria-label=\"Clear all\"\n className={`${baseClass}__action`}\n onClick={(e) => {\n e.stopPropagation()\n onSetAll(false)\n }}\n title=\"Clear all\"\n type=\"button\"\n >\n none\n </button>\n </div>\n)\n\nconst titleCase = (slug: string): string =>\n slug.replace(/(^|[-_])(.)/g, (_, sep: string, ch: string) =>\n sep ? ` ${ch.toUpperCase()}` : ch.toUpperCase(),\n )\n"],"names":["CheckboxInput","Collapsible","useField","React","baseClass","without","obj","key","_omitted","rest","Object","keys","length","undefined","setKey","value","AccessField","path","pluginConfig","setValue","access","collectionsBySlug","globalsBySlug","tools","prompts","resources","item","items","type","collectionSlug","push","globalSlug","isScopedAllowed","scope","slug","configKey","isFlatAllowed","toggleScoped","allow","slugBucket","scopeBucket","toggleFlat","bucket","setAllScoped","leaves","reduce","acc","leaf","setAllFlat","collectionSlugs","globalSlugs","div","className","section","header","h4","p","map","actions","GroupActions","onSetAll","span","titleCase","initCollapsed","ul","li","checked","id","label","onToggle","e","target","tooltip","description","button","aria-label","onClick","stopPropagation","title","aria-hidden","replace","_","sep","ch","toUpperCase"],"mappings":"AAAA;;AAIA,SAASA,aAAa,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,iBAAgB;AACrE,OAAOC,WAAW,QAAO;AAIzB,OAAO,cAAa;AAEpB,MAAMC,YAAY;AAUlB,yFAAyF,GACzF,MAAMC,UAAU,CACdC,KACAC;IAEA,I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,UAAU,eAAe,CAAC;;0BAC3C,KAACsE;gBACCC,cAAW;gBACXvB,WAAW,GAAGhD,UAAU,QAAQ,CAAC;gBACjCwE,SAAS,CAACN;oBACRA,EAAEO,eAAe;oBACjBjB,SAAS;gBACX;gBACAkB,OAAM;gBACNlD,MAAK;0BACN;;0BAGD,KAACiC;gBAAKkB,aAAW;gBAAC3B,WAAW,GAAGhD,UAAU,YAAY,CAAC;0BAAE;;0BAGzD,KAACsE;gBACCC,cAAW;gBACXvB,WAAW,GAAGhD,UAAU,QAAQ,CAAC;gBACjCwE,SAAS,CAACN;oBACRA,EAAEO,eAAe;oBACjBjB,SAAS;gBACX;gBACAkB,OAAM;gBACNlD,MAAK;0BACN;;;;AAML,MAAMkC,YAAY,CAAC5B,OACjBA,KAAK8C,OAAO,CAAC,gBAAgB,CAACC,GAAGC,KAAaC,KAC5CD,MAAM,CAAC,CAAC,EAAEC,GAAGC,WAAW,IAAI,GAAGD,GAAGC,WAAW"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
@layer payload-default {
|
|
2
|
-
.mcp-access-field {
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
gap: var(--base);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.mcp-access-field__section {
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
gap: calc(var(--base) / 2);
|
|
12
|
-
padding-bottom: var(--base);
|
|
13
|
-
/* Full-bleed separator: extend past the sidebar's horizontal gutter so the
|
|
14
|
-
border-block-end spans the entire sidebar width. */
|
|
15
|
-
margin-inline-start: calc(-1 * var(--sidebar-gutter-h-left, var(--gutter-h)));
|
|
16
|
-
margin-inline-end: calc(-1 * var(--sidebar-gutter-h-right, var(--gutter-h)));
|
|
17
|
-
padding-inline-start: var(--sidebar-gutter-h-left, var(--gutter-h));
|
|
18
|
-
padding-inline-end: var(--sidebar-gutter-h-right, var(--gutter-h));
|
|
19
|
-
border-block-end: 1px solid var(--theme-elevation-100);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.mcp-access-field__section:last-child {
|
|
23
|
-
border-block-end: none;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.mcp-access-field__section-header {
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: column;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.mcp-access-field__section-header h4 {
|
|
32
|
-
margin: 0;
|
|
33
|
-
color: var(--color-text);
|
|
34
|
-
font-family: var(--text-heading-small-font-family);
|
|
35
|
-
font-size: var(--text-heading-small-font-size);
|
|
36
|
-
font-weight: var(--text-heading-small-font-weight);
|
|
37
|
-
line-height: var(--text-heading-small-line-height);
|
|
38
|
-
letter-spacing: var(--text-heading-small-letter-spacing);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.mcp-access-field__section-header p {
|
|
42
|
-
margin: 0;
|
|
43
|
-
color: var(--color-text-secondary);
|
|
44
|
-
font-family: var(--text-body-medium-font-family);
|
|
45
|
-
font-size: var(--text-body-medium-font-size);
|
|
46
|
-
font-weight: var(--text-body-medium-font-weight);
|
|
47
|
-
line-height: var(--text-body-medium-line-height);
|
|
48
|
-
letter-spacing: var(--text-body-medium-letter-spacing);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.mcp-access-field__group {
|
|
52
|
-
margin-block-end: calc(var(--base) / 2);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.mcp-access-field__group-label {
|
|
56
|
-
font-weight: 600;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.mcp-access-field__group-actions {
|
|
60
|
-
display: flex;
|
|
61
|
-
align-items: center;
|
|
62
|
-
gap: calc(var(--base) / 6);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.mcp-access-field__action {
|
|
66
|
-
appearance: none;
|
|
67
|
-
background: none;
|
|
68
|
-
border: none;
|
|
69
|
-
color: var(--theme-elevation-500);
|
|
70
|
-
cursor: pointer;
|
|
71
|
-
font-size: 0.75rem;
|
|
72
|
-
padding: 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.mcp-access-field__action:hover {
|
|
76
|
-
color: var(--theme-text);
|
|
77
|
-
text-decoration: underline;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.mcp-access-field__action-sep {
|
|
81
|
-
color: var(--theme-elevation-300);
|
|
82
|
-
font-size: 0.75rem;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.mcp-access-field__list {
|
|
86
|
-
list-style: none;
|
|
87
|
-
margin: 0;
|
|
88
|
-
padding: 0;
|
|
89
|
-
display: flex;
|
|
90
|
-
flex-direction: column;
|
|
91
|
-
gap: calc(var(--base) / 3);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AuthorizedMCP } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the `user` and `overrideAccess` arguments every Payload local API call
|
|
4
|
-
* should receive when initiated from an MCP request. Spread the result into the
|
|
5
|
-
* call's arg object so the two pieces of caller state can't drift apart.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* await req.payload.create({
|
|
10
|
-
* collection: 'posts',
|
|
11
|
-
* data,
|
|
12
|
-
* ...localAPIDefaults(authorizedMCP),
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare const localAPIDefaults: (authorizedMCP: AuthorizedMCP) => {
|
|
17
|
-
overrideAccess: boolean;
|
|
18
|
-
user: AuthorizedMCP["user"];
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=localAPIDefaults.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localAPIDefaults.d.ts","sourceRoot":"","sources":["../../src/utils/localAPIDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,eAAe,aAAa,KAC3B;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAGvD,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the `user` and `overrideAccess` arguments every Payload local API call
|
|
3
|
-
* should receive when initiated from an MCP request. Spread the result into the
|
|
4
|
-
* call's arg object so the two pieces of caller state can't drift apart.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* await req.payload.create({
|
|
9
|
-
* collection: 'posts',
|
|
10
|
-
* data,
|
|
11
|
-
* ...localAPIDefaults(authorizedMCP),
|
|
12
|
-
* })
|
|
13
|
-
* ```
|
|
14
|
-
*/ export const localAPIDefaults = (authorizedMCP)=>({
|
|
15
|
-
overrideAccess: authorizedMCP.overrideAccess,
|
|
16
|
-
user: authorizedMCP.user
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=localAPIDefaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/localAPIDefaults.ts"],"sourcesContent":["import type { AuthorizedMCP } from '../types.js'\n\n/**\n * Returns the `user` and `overrideAccess` arguments every Payload local API call\n * should receive when initiated from an MCP request. Spread the result into the\n * call's arg object so the two pieces of caller state can't drift apart.\n *\n * @example\n * ```ts\n * await req.payload.create({\n * collection: 'posts',\n * data,\n * ...localAPIDefaults(authorizedMCP),\n * })\n * ```\n */\nexport const localAPIDefaults = (\n authorizedMCP: AuthorizedMCP,\n): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({\n overrideAccess: authorizedMCP.overrideAccess,\n user: authorizedMCP.user,\n})\n"],"names":["localAPIDefaults","authorizedMCP","overrideAccess","user"],"mappings":"AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMA,mBAAmB,CAC9BC,gBAC8D,CAAA;QAC9DC,gBAAgBD,cAAcC,cAAc;QAC5CC,MAAMF,cAAcE,IAAI;IAC1B,CAAA,EAAE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { JsonSchemaType } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Removes virtual fields from a JSON Schema by name so they don't appear
|
|
4
|
-
* in the generated MCP tool input schema.
|
|
5
|
-
*/
|
|
6
|
-
export declare function removeVirtualFieldsFromSchema(schema: JsonSchemaType, virtualFieldNames: string[]): JsonSchemaType;
|
|
7
|
-
//# sourceMappingURL=removeVirtualFieldsFromSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeVirtualFieldsFromSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,cAAc,EACtB,iBAAiB,EAAE,MAAM,EAAE,GAC1B,cAAc,CAiBhB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes virtual fields from a JSON Schema by name so they don't appear
|
|
3
|
-
* in the generated MCP tool input schema.
|
|
4
|
-
*/ export function removeVirtualFieldsFromSchema(schema, virtualFieldNames) {
|
|
5
|
-
if (virtualFieldNames.length === 0) {
|
|
6
|
-
return schema;
|
|
7
|
-
}
|
|
8
|
-
for (const name of virtualFieldNames){
|
|
9
|
-
delete schema?.properties?.[name];
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(schema.required)) {
|
|
12
|
-
schema.required = schema.required.filter((field)=>!virtualFieldNames.includes(field));
|
|
13
|
-
if (schema.required.length === 0) {
|
|
14
|
-
delete schema.required;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return schema;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=removeVirtualFieldsFromSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes virtual fields from a JSON Schema by name so they don't appear\n * in the generated MCP tool input schema.\n */\nexport function removeVirtualFieldsFromSchema(\n schema: JsonSchemaType,\n virtualFieldNames: string[],\n): JsonSchemaType {\n if (virtualFieldNames.length === 0) {\n return schema\n }\n\n for (const name of virtualFieldNames) {\n delete schema?.properties?.[name]\n }\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n return schema\n}\n"],"names":["removeVirtualFieldsFromSchema","schema","virtualFieldNames","length","name","properties","Array","isArray","required","filter","field","includes"],"mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,8BACdC,MAAsB,EACtBC,iBAA2B;IAE3B,IAAIA,kBAAkBC,MAAM,KAAK,GAAG;QAClC,OAAOF;IACT;IAEA,KAAK,MAAMG,QAAQF,kBAAmB;QACpC,OAAOD,QAAQI,YAAY,CAACD,KAAK;IACnC;IAEA,IAAIE,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAU,CAACR,kBAAkBS,QAAQ,CAACD;QAChF,IAAIT,OAAOO,QAAQ,CAACL,MAAM,KAAK,GAAG;YAChC,OAAOF,OAAOO,QAAQ;QACxB;IACF;IAEA,OAAOP;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
|
-
configKey: item.configKey,
|
|
51
|
-
description: itemDescription(item),
|
|
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
|
-
}
|