@payloadcms/plugin-mcp 4.0.0-internal.c2b57ce → 4.0.0-internal.c6494b5
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 +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 +98 -18
- 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 +6 -6
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +146 -74
- 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 -64
- 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 -133
- 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 -58
- 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 +124 -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 +123 -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 +14 -21
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +80 -101
- package/src/endpoint/index.ts +88 -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 +180 -110
- 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 -138
- 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 -77
- package/src/mcp/builtinTools.ts +118 -41
- package/src/mcp/sanitizeMCPConfig.ts +120 -78
- package/src/stdio.ts +80 -47
- package/src/types.ts +141 -120
- package/src/utils/getPluginConfig.ts +1 -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 -59
- 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/prepareCollectionSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/prepareCollectionSchema.js +0 -37
- package/dist/utils/schemaConversion/prepareCollectionSchema.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/sanitizeJsonSchema.d.ts +0 -13
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -56
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.js +0 -57
- package/dist/utils/schemaConversion/transformPointFields.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/collection/getAccessField.ts +0 -64
- package/src/collection/index.ts +0 -63
- 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/prepareCollectionSchema.ts +0 -39
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -70
- package/src/utils/schemaConversion/transformPointFields.ts +0 -56
- package/src/utils/transformPointDataToPayload.ts +0 -40
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { fieldIsVirtual } from 'payload/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Returns the names of all top-level virtual fields for a given collection slug.
|
|
4
|
-
*/ export function getCollectionVirtualFieldNames(config, slug) {
|
|
5
|
-
const collection = config.collections.find((c)=>c.slug === slug);
|
|
6
|
-
if (!collection) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
return collection.flattenedFields.filter((field)=>'name' in field && fieldIsVirtual(field)).map((field)=>field.name);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Returns the names of all top-level virtual fields for a given global slug.
|
|
13
|
-
*/ export function getGlobalVirtualFieldNames(config, slug) {
|
|
14
|
-
const global = config.globals.find((g)=>g.slug === slug);
|
|
15
|
-
if (!global) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
return global.flattenedFields.filter((field)=>'name' in field && fieldIsVirtual(field)).map((field)=>field.name);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Strips virtual field values from a data object given a list of virtual field names.
|
|
22
|
-
*/ export function stripVirtualFields(data, virtualFieldNames) {
|
|
23
|
-
if (virtualFieldNames.length === 0) {
|
|
24
|
-
return data;
|
|
25
|
-
}
|
|
26
|
-
const stripped = {
|
|
27
|
-
...data
|
|
28
|
-
};
|
|
29
|
-
for (const name of virtualFieldNames){
|
|
30
|
-
delete stripped[name];
|
|
31
|
-
}
|
|
32
|
-
return stripped;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=getVirtualFieldNames.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getVirtualFieldNames.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { fieldIsVirtual } from 'payload/shared'\n\n/**\n * Returns the names of all top-level virtual fields for a given collection slug.\n */\nexport function getCollectionVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {\n const collection = config.collections.find((c) => c.slug === slug)\n\n if (!collection) {\n return []\n }\n\n return collection.flattenedFields\n .filter((field) => 'name' in field && fieldIsVirtual(field))\n .map((field) => (field as { name: string }).name)\n}\n\n/**\n * Returns the names of all top-level virtual fields for a given global slug.\n */\nexport function getGlobalVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {\n const global = config.globals.find((g) => g.slug === slug)\n\n if (!global) {\n return []\n }\n\n return global.flattenedFields\n .filter((field) => 'name' in field && fieldIsVirtual(field))\n .map((field) => (field as { name: string }).name)\n}\n\n/**\n * Strips virtual field values from a data object given a list of virtual field names.\n */\nexport function stripVirtualFields(\n data: Record<string, unknown>,\n virtualFieldNames: string[],\n): Record<string, unknown> {\n if (virtualFieldNames.length === 0) {\n return data\n }\n\n const stripped = { ...data }\n\n for (const name of virtualFieldNames) {\n delete stripped[name]\n }\n\n return stripped\n}\n"],"names":["fieldIsVirtual","getCollectionVirtualFieldNames","config","slug","collection","collections","find","c","flattenedFields","filter","field","map","name","getGlobalVirtualFieldNames","global","globals","g","stripVirtualFields","data","virtualFieldNames","length","stripped"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAE/C;;CAEC,GACD,OAAO,SAASC,+BAA+BC,MAAuB,EAAEC,IAAY;IAClF,MAAMC,aAAaF,OAAOG,WAAW,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEJ,IAAI,KAAKA;IAE7D,IAAI,CAACC,YAAY;QACf,OAAO,EAAE;IACX;IAEA,OAAOA,WAAWI,eAAe,CAC9BC,MAAM,CAAC,CAACC,QAAU,UAAUA,SAASV,eAAeU,QACpDC,GAAG,CAAC,CAACD,QAAU,AAACA,MAA2BE,IAAI;AACpD;AAEA;;CAEC,GACD,OAAO,SAASC,2BAA2BX,MAAuB,EAAEC,IAAY;IAC9E,MAAMW,SAASZ,OAAOa,OAAO,CAACT,IAAI,CAAC,CAACU,IAAMA,EAAEb,IAAI,KAAKA;IAErD,IAAI,CAACW,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,OAAOA,OAAON,eAAe,CAC1BC,MAAM,CAAC,CAACC,QAAU,UAAUA,SAASV,eAAeU,QACpDC,GAAG,CAAC,CAACD,QAAU,AAACA,MAA2BE,IAAI;AACpD;AAEA;;CAEC,GACD,OAAO,SAASK,mBACdC,IAA6B,EAC7BC,iBAA2B;IAE3B,IAAIA,kBAAkBC,MAAM,KAAK,GAAG;QAClC,OAAOF;IACT;IAEA,MAAMG,WAAW;QAAE,GAAGH,IAAI;IAAC;IAE3B,KAAK,MAAMN,QAAQO,kBAAmB;QACpC,OAAOE,QAAQ,CAACT,KAAK;IACvB;IAEA,OAAOS;AACT"}
|
|
@@ -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
|
-
* Sanitizes Payload's auto-generated collection JSON Schema so it can be safely
|
|
4
|
-
* fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).
|
|
5
|
-
*/
|
|
6
|
-
export declare const prepareCollectionSchema: (schema: JsonSchemaType) => JsonSchemaType;
|
|
7
|
-
//# sourceMappingURL=prepareCollectionSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCollectionSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/prepareCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAapD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,cAAc,KAAG,cAqBhE,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { sanitizeJsonSchema } from './sanitizeJsonSchema.js';
|
|
2
|
-
import { simplifyRelationshipFields } from './simplifyRelationshipFields.js';
|
|
3
|
-
import { transformPointFieldsForMCP } from './transformPointFields.js';
|
|
4
|
-
/**
|
|
5
|
-
* Fields Payload manages automatically — clients should never be required to provide
|
|
6
|
-
* them. Stripped from `required` and `properties` so they don't appear in tool
|
|
7
|
-
* inputs.
|
|
8
|
-
*/ const PAYLOAD_MANAGED_FIELDS = new Set([
|
|
9
|
-
'_status',
|
|
10
|
-
'createdAt',
|
|
11
|
-
'id',
|
|
12
|
-
'updatedAt'
|
|
13
|
-
]);
|
|
14
|
-
/**
|
|
15
|
-
* Sanitizes Payload's auto-generated collection JSON Schema so it can be safely
|
|
16
|
-
* fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).
|
|
17
|
-
*/ export const prepareCollectionSchema = (schema)=>{
|
|
18
|
-
// Clone to avoid mutating the original schema (used elsewhere for tool listing)
|
|
19
|
-
const schemaClone = JSON.parse(JSON.stringify(schema));
|
|
20
|
-
const sanitized = sanitizeJsonSchema(schemaClone);
|
|
21
|
-
const pointTransformed = transformPointFieldsForMCP(sanitized);
|
|
22
|
-
const simplified = simplifyRelationshipFields(pointTransformed);
|
|
23
|
-
if (simplified.properties) {
|
|
24
|
-
for (const field of PAYLOAD_MANAGED_FIELDS){
|
|
25
|
-
delete simplified.properties[field];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(simplified.required)) {
|
|
29
|
-
simplified.required = simplified.required.filter((name)=>!PAYLOAD_MANAGED_FIELDS.has(name));
|
|
30
|
-
if (simplified.required.length === 0) {
|
|
31
|
-
delete simplified.required;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return simplified;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=prepareCollectionSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/prepareCollectionSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\n/**\n * Fields Payload manages automatically — clients should never be required to provide\n * them. Stripped from `required` and `properties` so they don't appear in tool\n * inputs.\n */\nconst PAYLOAD_MANAGED_FIELDS = new Set(['_status', 'createdAt', 'id', 'updatedAt'])\n\n/**\n * Sanitizes Payload's auto-generated collection JSON Schema so it can be safely\n * fed into the MCP server's `fromJsonSchema()` adapter (no zod intermediate step).\n */\nexport const prepareCollectionSchema = (schema: JsonSchemaType): JsonSchemaType => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JsonSchemaType\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const simplified = simplifyRelationshipFields(pointTransformed)\n\n if (simplified.properties) {\n for (const field of PAYLOAD_MANAGED_FIELDS) {\n delete simplified.properties[field]\n }\n }\n if (Array.isArray(simplified.required)) {\n simplified.required = simplified.required.filter((name) => !PAYLOAD_MANAGED_FIELDS.has(name))\n if (simplified.required.length === 0) {\n delete simplified.required\n }\n }\n\n return simplified\n}\n"],"names":["sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","PAYLOAD_MANAGED_FIELDS","Set","prepareCollectionSchema","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","simplified","properties","field","Array","isArray","required","filter","name","has","length"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE;;;;CAIC,GACD,MAAMC,yBAAyB,IAAIC,IAAI;IAAC;IAAW;IAAa;IAAM;CAAY;AAElF;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CAACC;IACtC,gFAAgF;IAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAE9C,MAAMK,YAAYX,mBAAmBO;IACrC,MAAMK,mBAAmBV,2BAA2BS;IACpD,MAAME,aAAaZ,2BAA2BW;IAE9C,IAAIC,WAAWC,UAAU,EAAE;QACzB,KAAK,MAAMC,SAASZ,uBAAwB;YAC1C,OAAOU,WAAWC,UAAU,CAACC,MAAM;QACrC;IACF;IACA,IAAIC,MAAMC,OAAO,CAACJ,WAAWK,QAAQ,GAAG;QACtCL,WAAWK,QAAQ,GAAGL,WAAWK,QAAQ,CAACC,MAAM,CAAC,CAACC,OAAS,CAACjB,uBAAuBkB,GAAG,CAACD;QACvF,IAAIP,WAAWK,QAAQ,CAACI,MAAM,KAAK,GAAG;YACpC,OAAOT,WAAWK,QAAQ;QAC5B;IACF;IAEA,OAAOL;AACT,EAAC"}
|
|
@@ -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,13 +0,0 @@
|
|
|
1
|
-
import type { JsonSchemaType } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Removes internal Payload properties (id, createdAt, updatedAt) from a
|
|
4
|
-
* JSON Schema so they don't appear in the generated Zod validation schema.
|
|
5
|
-
* Also strips `id` from the `required` array when present.
|
|
6
|
-
*
|
|
7
|
-
* Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
|
|
8
|
-
* `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
|
|
9
|
-
* emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
|
|
10
|
-
* the concrete `type` from the output and breaking schema introspection.
|
|
11
|
-
*/
|
|
12
|
-
export declare function sanitizeJsonSchema(schema: JsonSchemaType): JsonSchemaType;
|
|
13
|
-
//# sourceMappingURL=sanitizeJsonSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CA6BzE"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes internal Payload properties (id, createdAt, updatedAt) from a
|
|
3
|
-
* JSON Schema so they don't appear in the generated Zod validation schema.
|
|
4
|
-
* Also strips `id` from the `required` array when present.
|
|
5
|
-
*
|
|
6
|
-
* Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
|
|
7
|
-
* `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
|
|
8
|
-
* emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
|
|
9
|
-
* the concrete `type` from the output and breaking schema introspection.
|
|
10
|
-
*/ export function sanitizeJsonSchema(schema) {
|
|
11
|
-
delete schema?.properties?.id;
|
|
12
|
-
delete schema?.properties?.createdAt;
|
|
13
|
-
delete schema?.properties?.updatedAt;
|
|
14
|
-
if (Array.isArray(schema.required)) {
|
|
15
|
-
schema.required = schema.required.filter((field)=>field !== 'id');
|
|
16
|
-
if (schema.required.length === 0) {
|
|
17
|
-
delete schema.required;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (schema.properties && typeof schema.properties === 'object') {
|
|
21
|
-
for (const key of Object.keys(schema.properties)){
|
|
22
|
-
const prop = schema.properties[key];
|
|
23
|
-
if (!prop || typeof prop !== 'object') {
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
normalizeNullableType(prop);
|
|
27
|
-
if (prop.properties) {
|
|
28
|
-
sanitizeJsonSchema(prop);
|
|
29
|
-
}
|
|
30
|
-
if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
|
|
31
|
-
sanitizeJsonSchema(prop.items);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return schema;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Strips `'null'` from a `type` array only when the remaining type is a
|
|
39
|
-
* complex structural type (`array` or `object`).
|
|
40
|
-
*
|
|
41
|
-
* Simple scalar types (`string`, `number`, `boolean`) are intentionally
|
|
42
|
-
* preserved as `['string', 'null']` so that the MCP SDK serialises them as a
|
|
43
|
-
* compact inline `type` array. Complex types however cause `zodToJsonSchema`
|
|
44
|
-
* to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which
|
|
45
|
-
* has no top-level `type` property and breaks schema introspection by clients.
|
|
46
|
-
*/ function normalizeNullableType(schema) {
|
|
47
|
-
if (!Array.isArray(schema.type)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const nonNullTypes = schema.type.filter((t)=>t !== 'null');
|
|
51
|
-
if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {
|
|
52
|
-
schema.type = nonNullTypes[0];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=sanitizeJsonSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n *\n * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →\n * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`\n * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping\n * the concrete `type` from the output and breaking schema introspection.\n */\nexport function sanitizeJsonSchema(schema: JsonSchemaType): JsonSchemaType {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const key of Object.keys(schema.properties)) {\n const prop = schema.properties[key] as JsonSchemaType\n if (!prop || typeof prop !== 'object') {\n continue\n }\n normalizeNullableType(prop)\n if (prop.properties) {\n sanitizeJsonSchema(prop)\n }\n if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {\n sanitizeJsonSchema(prop.items)\n }\n }\n }\n\n return schema\n}\n\n/**\n * Strips `'null'` from a `type` array only when the remaining type is a\n * complex structural type (`array` or `object`).\n *\n * Simple scalar types (`string`, `number`, `boolean`) are intentionally\n * preserved as `['string', 'null']` so that the MCP SDK serialises them as a\n * compact inline `type` array. Complex types however cause `zodToJsonSchema`\n * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which\n * has no top-level `type` property and breaks schema introspection by clients.\n */\nfunction normalizeNullableType(schema: JsonSchemaType): void {\n if (!Array.isArray(schema.type)) {\n return\n }\n const nonNullTypes = schema.type.filter((t) => t !== 'null')\n if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {\n schema.type = nonNullTypes[0]\n }\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length","key","Object","keys","prop","normalizeNullableType","items","type","nonNullTypes","t"],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,SAASA,mBAAmBC,MAAsB;IACvD,OAAOA,QAAQC,YAAYC;IAC3B,OAAOF,QAAQC,YAAYE;IAC3B,OAAOH,QAAQC,YAAYG;IAE3B,IAAIC,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAUA,UAAU;QAC9D,IAAIT,OAAOO,QAAQ,CAACG,MAAM,KAAK,GAAG;YAChC,OAAOV,OAAOO,QAAQ;QACxB;IACF;IAEA,IAAIP,OAAOC,UAAU,IAAI,OAAOD,OAAOC,UAAU,KAAK,UAAU;QAC9D,KAAK,MAAMU,OAAOC,OAAOC,IAAI,CAACb,OAAOC,UAAU,EAAG;YAChD,MAAMa,OAAOd,OAAOC,UAAU,CAACU,IAAI;YACnC,IAAI,CAACG,QAAQ,OAAOA,SAAS,UAAU;gBACrC;YACF;YACAC,sBAAsBD;YACtB,IAAIA,KAAKb,UAAU,EAAE;gBACnBF,mBAAmBe;YACrB;YACA,IAAIA,KAAKE,KAAK,IAAI,OAAOF,KAAKE,KAAK,KAAK,YAAY,CAACX,MAAMC,OAAO,CAACQ,KAAKE,KAAK,GAAG;gBAC9EjB,mBAAmBe,KAAKE,KAAK;YAC/B;QACF;IACF;IAEA,OAAOhB;AACT;AAEA;;;;;;;;;CASC,GACD,SAASe,sBAAsBf,MAAsB;IACnD,IAAI,CAACK,MAAMC,OAAO,CAACN,OAAOiB,IAAI,GAAG;QAC/B;IACF;IACA,MAAMC,eAAelB,OAAOiB,IAAI,CAACT,MAAM,CAAC,CAACW,IAAMA,MAAM;IACrD,IAAID,aAAaR,MAAM,KAAK,KAAMQ,CAAAA,YAAY,CAAC,EAAE,KAAK,WAAWA,YAAY,CAAC,EAAE,KAAK,QAAO,GAAI;QAC9FlB,OAAOiB,IAAI,GAAGC,YAAY,CAAC,EAAE;IAC/B;AACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { JsonSchemaType } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Recursively processes JSON schema properties to simplify relationship fields
|
|
4
|
-
* and convert `oneOf` constructs into MCP-friendly schemas.
|
|
5
|
-
*
|
|
6
|
-
* For create/update validation we only need to accept IDs (string/number),
|
|
7
|
-
* not populated objects. `$ref` options pointing to full entity definitions
|
|
8
|
-
* are removed entirely from `oneOf` unions. When a single option remains the
|
|
9
|
-
* `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
|
|
10
|
-
*
|
|
11
|
-
* This matters because `json-schema-to-zod` converts `oneOf` into a strict
|
|
12
|
-
* `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
|
|
13
|
-
* `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
|
|
14
|
-
* tool input schema. `anyOf` instead produces a clean `z.union([...])`.
|
|
15
|
-
*
|
|
16
|
-
* NOTE: This function must operate on a cloned schema to avoid mutating
|
|
17
|
-
* the original JSON schema used for tool listing.
|
|
18
|
-
*/
|
|
19
|
-
export declare function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType;
|
|
20
|
-
//# sourceMappingURL=simplifyRelationshipFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simplifyRelationshipFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAkDjF"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursively processes JSON schema properties to simplify relationship fields
|
|
3
|
-
* and convert `oneOf` constructs into MCP-friendly schemas.
|
|
4
|
-
*
|
|
5
|
-
* For create/update validation we only need to accept IDs (string/number),
|
|
6
|
-
* not populated objects. `$ref` options pointing to full entity definitions
|
|
7
|
-
* are removed entirely from `oneOf` unions. When a single option remains the
|
|
8
|
-
* `oneOf` is unwrapped; otherwise it is converted to `anyOf`.
|
|
9
|
-
*
|
|
10
|
-
* This matters because `json-schema-to-zod` converts `oneOf` into a strict
|
|
11
|
-
* `z.any().superRefine(...)` validator whose base type is `z.any()`, causing
|
|
12
|
-
* `zodToJsonSchema` to emit `{}` and losing all type information in the MCP
|
|
13
|
-
* tool input schema. `anyOf` instead produces a clean `z.union([...])`.
|
|
14
|
-
*
|
|
15
|
-
* NOTE: This function must operate on a cloned schema to avoid mutating
|
|
16
|
-
* the original JSON schema used for tool listing.
|
|
17
|
-
*/ export function simplifyRelationshipFields(schema) {
|
|
18
|
-
if (!schema || typeof schema !== 'object') {
|
|
19
|
-
return schema;
|
|
20
|
-
}
|
|
21
|
-
const processed = {
|
|
22
|
-
...schema
|
|
23
|
-
};
|
|
24
|
-
if (Array.isArray(processed.oneOf)) {
|
|
25
|
-
const hasRef = processed.oneOf.some((option)=>option && typeof option === 'object' && '$ref' in option);
|
|
26
|
-
const recurse = (option)=>typeof option === 'object' ? simplifyRelationshipFields(option) : option;
|
|
27
|
-
if (hasRef) {
|
|
28
|
-
const nonRefOptions = processed.oneOf.filter((option)=>!(option && typeof option === 'object' && '$ref' in option)).map(recurse);
|
|
29
|
-
if (nonRefOptions.length === 1) {
|
|
30
|
-
const single = nonRefOptions[0];
|
|
31
|
-
delete processed.oneOf;
|
|
32
|
-
if (typeof single === 'object') {
|
|
33
|
-
Object.assign(processed, single);
|
|
34
|
-
}
|
|
35
|
-
} else if (nonRefOptions.length > 1) {
|
|
36
|
-
delete processed.oneOf;
|
|
37
|
-
processed.anyOf = nonRefOptions;
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
processed.anyOf = processed.oneOf.map(recurse);
|
|
41
|
-
delete processed.oneOf;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (processed.properties && typeof processed.properties === 'object') {
|
|
45
|
-
processed.properties = Object.fromEntries(Object.entries(processed.properties).map(([key, value])=>[
|
|
46
|
-
key,
|
|
47
|
-
typeof value === 'object' ? simplifyRelationshipFields(value) : value
|
|
48
|
-
]));
|
|
49
|
-
}
|
|
50
|
-
if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
|
|
51
|
-
processed.items = simplifyRelationshipFields(processed.items);
|
|
52
|
-
}
|
|
53
|
-
return processed;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=simplifyRelationshipFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/simplifyRelationshipFields.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\n/**\n * Recursively processes JSON schema properties to simplify relationship fields\n * and convert `oneOf` constructs into MCP-friendly schemas.\n *\n * For create/update validation we only need to accept IDs (string/number),\n * not populated objects. `$ref` options pointing to full entity definitions\n * are removed entirely from `oneOf` unions. When a single option remains the\n * `oneOf` is unwrapped; otherwise it is converted to `anyOf`.\n *\n * This matters because `json-schema-to-zod` converts `oneOf` into a strict\n * `z.any().superRefine(...)` validator whose base type is `z.any()`, causing\n * `zodToJsonSchema` to emit `{}` and losing all type information in the MCP\n * tool input schema. `anyOf` instead produces a clean `z.union([...])`.\n *\n * NOTE: This function must operate on a cloned schema to avoid mutating\n * the original JSON schema used for tool listing.\n */\nexport function simplifyRelationshipFields(schema: JsonSchemaType): JsonSchemaType {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const processed = { ...schema }\n\n if (Array.isArray(processed.oneOf)) {\n const hasRef = processed.oneOf.some(\n (option) => option && typeof option === 'object' && '$ref' in option,\n )\n\n const recurse = (option: boolean | JsonSchemaType): boolean | JsonSchemaType =>\n typeof option === 'object' ? simplifyRelationshipFields(option) : option\n\n if (hasRef) {\n const nonRefOptions = processed.oneOf\n .filter((option) => !(option && typeof option === 'object' && '$ref' in option))\n .map(recurse)\n\n if (nonRefOptions.length === 1) {\n const single = nonRefOptions[0]!\n delete processed.oneOf\n if (typeof single === 'object') {\n Object.assign(processed, single)\n }\n } else if (nonRefOptions.length > 1) {\n delete processed.oneOf\n processed.anyOf = nonRefOptions\n }\n } else {\n processed.anyOf = processed.oneOf.map(recurse)\n delete processed.oneOf\n }\n }\n\n if (processed.properties && typeof processed.properties === 'object') {\n processed.properties = Object.fromEntries(\n Object.entries(processed.properties).map(([key, value]) => [\n key,\n typeof value === 'object' ? simplifyRelationshipFields(value) : value,\n ]),\n )\n }\n\n if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {\n processed.items = simplifyRelationshipFields(processed.items)\n }\n\n return processed\n}\n"],"names":["simplifyRelationshipFields","schema","processed","Array","isArray","oneOf","hasRef","some","option","recurse","nonRefOptions","filter","map","length","single","Object","assign","anyOf","properties","fromEntries","entries","key","value","items"],"mappings":"AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASA,2BAA2BC,MAAsB;IAC/D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,YAAY;QAAE,GAAGD,MAAM;IAAC;IAE9B,IAAIE,MAAMC,OAAO,CAACF,UAAUG,KAAK,GAAG;QAClC,MAAMC,SAASJ,UAAUG,KAAK,CAACE,IAAI,CACjC,CAACC,SAAWA,UAAU,OAAOA,WAAW,YAAY,UAAUA;QAGhE,MAAMC,UAAU,CAACD,SACf,OAAOA,WAAW,WAAWR,2BAA2BQ,UAAUA;QAEpE,IAAIF,QAAQ;YACV,MAAMI,gBAAgBR,UAAUG,KAAK,CAClCM,MAAM,CAAC,CAACH,SAAW,CAAEA,CAAAA,UAAU,OAAOA,WAAW,YAAY,UAAUA,MAAK,GAC5EI,GAAG,CAACH;YAEP,IAAIC,cAAcG,MAAM,KAAK,GAAG;gBAC9B,MAAMC,SAASJ,aAAa,CAAC,EAAE;gBAC/B,OAAOR,UAAUG,KAAK;gBACtB,IAAI,OAAOS,WAAW,UAAU;oBAC9BC,OAAOC,MAAM,CAACd,WAAWY;gBAC3B;YACF,OAAO,IAAIJ,cAAcG,MAAM,GAAG,GAAG;gBACnC,OAAOX,UAAUG,KAAK;gBACtBH,UAAUe,KAAK,GAAGP;YACpB;QACF,OAAO;YACLR,UAAUe,KAAK,GAAGf,UAAUG,KAAK,CAACO,GAAG,CAACH;YACtC,OAAOP,UAAUG,KAAK;QACxB;IACF;IAEA,IAAIH,UAAUgB,UAAU,IAAI,OAAOhB,UAAUgB,UAAU,KAAK,UAAU;QACpEhB,UAAUgB,UAAU,GAAGH,OAAOI,WAAW,CACvCJ,OAAOK,OAAO,CAAClB,UAAUgB,UAAU,EAAEN,GAAG,CAAC,CAAC,CAACS,KAAKC,MAAM,GAAK;gBACzDD;gBACA,OAAOC,UAAU,WAAWtB,2BAA2BsB,SAASA;aACjE;IAEL;IAEA,IAAIpB,UAAUqB,KAAK,IAAI,OAAOrB,UAAUqB,KAAK,KAAK,YAAY,CAACpB,MAAMC,OAAO,CAACF,UAAUqB,KAAK,GAAG;QAC7FrB,UAAUqB,KAAK,GAAGvB,2BAA2BE,UAAUqB,KAAK;IAC9D;IAEA,OAAOrB;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformPointFields.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAqDjF"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export function transformPointFieldsForMCP(schema) {
|
|
2
|
-
if (!schema || typeof schema !== 'object') {
|
|
3
|
-
return schema;
|
|
4
|
-
}
|
|
5
|
-
const transformed = {
|
|
6
|
-
...schema
|
|
7
|
-
};
|
|
8
|
-
if (transformed.properties && typeof transformed.properties === 'object') {
|
|
9
|
-
transformed.properties = Object.fromEntries(Object.entries(transformed.properties).map(([key, value])=>{
|
|
10
|
-
if (!value || typeof value !== 'object') {
|
|
11
|
-
return [
|
|
12
|
-
key,
|
|
13
|
-
value
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
const isArrayType = value.type === 'array' || Array.isArray(value.type) && value.type.includes('array');
|
|
17
|
-
if (isArrayType && Array.isArray(value.items) && value.items.length === 2 && value.items.every((item)=>item && typeof item === 'object' && item.type === 'number')) {
|
|
18
|
-
// Transform to object format
|
|
19
|
-
const isNullable = Array.isArray(value.type) && value.type.includes('null');
|
|
20
|
-
return [
|
|
21
|
-
key,
|
|
22
|
-
{
|
|
23
|
-
type: isNullable ? [
|
|
24
|
-
'object',
|
|
25
|
-
'null'
|
|
26
|
-
] : 'object',
|
|
27
|
-
description: value.description || 'Geographic coordinates (longitude, latitude)',
|
|
28
|
-
properties: {
|
|
29
|
-
latitude: {
|
|
30
|
-
type: 'number',
|
|
31
|
-
description: 'Latitude coordinate'
|
|
32
|
-
},
|
|
33
|
-
longitude: {
|
|
34
|
-
type: 'number',
|
|
35
|
-
description: 'Longitude coordinate'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
required: [
|
|
39
|
-
'longitude',
|
|
40
|
-
'latitude'
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
return [
|
|
46
|
-
key,
|
|
47
|
-
transformPointFieldsForMCP(value)
|
|
48
|
-
];
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
if (transformed.items && typeof transformed.items === 'object' && !Array.isArray(transformed.items)) {
|
|
52
|
-
transformed.items = transformPointFieldsForMCP(transformed.items);
|
|
53
|
-
}
|
|
54
|
-
return transformed;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=transformPointFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/transformPointFields.ts"],"sourcesContent":["import type { JsonSchemaType } from '../../types.js'\n\nexport function transformPointFieldsForMCP(schema: JsonSchemaType): JsonSchemaType {\n if (!schema || typeof schema !== 'object') {\n return schema\n }\n\n const transformed = { ...schema }\n\n if (transformed.properties && typeof transformed.properties === 'object') {\n transformed.properties = Object.fromEntries(\n Object.entries(transformed.properties).map(([key, value]) => {\n if (!value || typeof value !== 'object') {\n return [key, value]\n }\n const isArrayType =\n value.type === 'array' || (Array.isArray(value.type) && value.type.includes('array'))\n\n if (\n isArrayType &&\n Array.isArray(value.items) &&\n value.items.length === 2 &&\n value.items.every((item) => item && typeof item === 'object' && item.type === 'number')\n ) {\n // Transform to object format\n const isNullable = Array.isArray(value.type) && value.type.includes('null')\n\n return [\n key,\n {\n type: isNullable ? ['object', 'null'] : 'object',\n description: value.description || 'Geographic coordinates (longitude, latitude)',\n properties: {\n latitude: { type: 'number', description: 'Latitude coordinate' },\n longitude: { type: 'number', description: 'Longitude coordinate' },\n },\n required: ['longitude', 'latitude'],\n },\n ]\n }\n\n return [key, transformPointFieldsForMCP(value)]\n }),\n )\n }\n\n if (\n transformed.items &&\n typeof transformed.items === 'object' &&\n !Array.isArray(transformed.items)\n ) {\n transformed.items = transformPointFieldsForMCP(transformed.items)\n }\n\n return transformed\n}\n"],"names":["transformPointFieldsForMCP","schema","transformed","properties","Object","fromEntries","entries","map","key","value","isArrayType","type","Array","isArray","includes","items","length","every","item","isNullable","description","latitude","longitude","required"],"mappings":"AAEA,OAAO,SAASA,2BAA2BC,MAAsB;IAC/D,IAAI,CAACA,UAAU,OAAOA,WAAW,UAAU;QACzC,OAAOA;IACT;IAEA,MAAMC,cAAc;QAAE,GAAGD,MAAM;IAAC;IAEhC,IAAIC,YAAYC,UAAU,IAAI,OAAOD,YAAYC,UAAU,KAAK,UAAU;QACxED,YAAYC,UAAU,GAAGC,OAAOC,WAAW,CACzCD,OAAOE,OAAO,CAACJ,YAAYC,UAAU,EAAEI,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAM;YACtD,IAAI,CAACA,SAAS,OAAOA,UAAU,UAAU;gBACvC,OAAO;oBAACD;oBAAKC;iBAAM;YACrB;YACA,MAAMC,cACJD,MAAME,IAAI,KAAK,WAAYC,MAAMC,OAAO,CAACJ,MAAME,IAAI,KAAKF,MAAME,IAAI,CAACG,QAAQ,CAAC;YAE9E,IACEJ,eACAE,MAAMC,OAAO,CAACJ,MAAMM,KAAK,KACzBN,MAAMM,KAAK,CAACC,MAAM,KAAK,KACvBP,MAAMM,KAAK,CAACE,KAAK,CAAC,CAACC,OAASA,QAAQ,OAAOA,SAAS,YAAYA,KAAKP,IAAI,KAAK,WAC9E;gBACA,6BAA6B;gBAC7B,MAAMQ,aAAaP,MAAMC,OAAO,CAACJ,MAAME,IAAI,KAAKF,MAAME,IAAI,CAACG,QAAQ,CAAC;gBAEpE,OAAO;oBACLN;oBACA;wBACEG,MAAMQ,aAAa;4BAAC;4BAAU;yBAAO,GAAG;wBACxCC,aAAaX,MAAMW,WAAW,IAAI;wBAClCjB,YAAY;4BACVkB,UAAU;gCAAEV,MAAM;gCAAUS,aAAa;4BAAsB;4BAC/DE,WAAW;gCAAEX,MAAM;gCAAUS,aAAa;4BAAuB;wBACnE;wBACAG,UAAU;4BAAC;4BAAa;yBAAW;oBACrC;iBACD;YACH;YAEA,OAAO;gBAACf;gBAAKR,2BAA2BS;aAAO;QACjD;IAEJ;IAEA,IACEP,YAAYa,KAAK,IACjB,OAAOb,YAAYa,KAAK,KAAK,YAC7B,CAACH,MAAMC,OAAO,CAACX,YAAYa,KAAK,GAChC;QACAb,YAAYa,KAAK,GAAGf,2BAA2BE,YAAYa,KAAK;IAClE;IAEA,OAAOb;AACT"}
|
|
@@ -1,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,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,63 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload'
|
|
2
|
-
|
|
3
|
-
import type { SanitizedMCPPluginConfig } from '../types.js'
|
|
4
|
-
|
|
5
|
-
import { getAccessField } from './getAccessField.js'
|
|
6
|
-
|
|
7
|
-
export const getAPIKeysCollection = ({
|
|
8
|
-
pluginConfig,
|
|
9
|
-
}: {
|
|
10
|
-
pluginConfig: SanitizedMCPPluginConfig
|
|
11
|
-
}): CollectionConfig => {
|
|
12
|
-
const collection: CollectionConfig = {
|
|
13
|
-
slug: 'payload-mcp-api-keys',
|
|
14
|
-
admin: {
|
|
15
|
-
description:
|
|
16
|
-
'API keys control which collections, resources, tools, and prompts MCP clients can access',
|
|
17
|
-
group: 'MCP',
|
|
18
|
-
useAsTitle: 'label',
|
|
19
|
-
},
|
|
20
|
-
auth: {
|
|
21
|
-
disableLocalStrategy: true,
|
|
22
|
-
useAPIKey: true,
|
|
23
|
-
},
|
|
24
|
-
fields: [
|
|
25
|
-
{
|
|
26
|
-
name: 'user',
|
|
27
|
-
type: 'relationship',
|
|
28
|
-
admin: { description: 'The user that the API key is associated with.' },
|
|
29
|
-
relationTo: pluginConfig.userCollection,
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: 'label',
|
|
34
|
-
type: 'text',
|
|
35
|
-
admin: { description: 'A useful label for the API key.' },
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'description',
|
|
39
|
-
type: 'text',
|
|
40
|
-
admin: { description: 'The purpose of the API key.' },
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'overrideAccess',
|
|
44
|
-
type: 'checkbox',
|
|
45
|
-
admin: {
|
|
46
|
-
description:
|
|
47
|
-
'When checked, this key bypasses Payload access control on every operation it performs. Leave unchecked unless you have a specific reason.',
|
|
48
|
-
},
|
|
49
|
-
defaultValue: false,
|
|
50
|
-
label: 'Override access control',
|
|
51
|
-
},
|
|
52
|
-
getAccessField({ pluginConfig }),
|
|
53
|
-
],
|
|
54
|
-
labels: {
|
|
55
|
-
plural: 'API Keys',
|
|
56
|
-
singular: 'API Key',
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return pluginConfig.overrideApiKeyCollection
|
|
61
|
-
? pluginConfig.overrideApiKeyCollection(collection)
|
|
62
|
-
: collection
|
|
63
|
-
}
|