@payloadcms/plugin-mcp 4.0.0-internal.688c4d0 → 4.0.0-internal.811e0a4
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/endpoint/access.d.ts +17 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +81 -103
- 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 -4
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +1 -4
- 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 +3 -51
- 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 +69 -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 +65 -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 +12 -19
- 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 +9 -0
- 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 +97 -0
- package/dist/mcp/builtin/collections/duplicateTool.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 +93 -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 +43 -22
- 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 +84 -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 +99 -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 +12 -0
- 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 +82 -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 +14 -21
- 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 -5
- 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 +65 -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 +17 -20
- 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 +80 -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 +95 -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 +12 -0
- 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 +78 -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 +12 -19
- package/dist/mcp/builtin/globals/updateTool.js.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 +63 -92
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -4
- package/dist/types.js.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/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +7 -9
- 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/package.json +10 -16
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +87 -112
- package/src/endpoint/index.ts +58 -16
- package/src/exports/client.ts +2 -4
- package/src/exports/internal.ts +1 -0
- package/src/index.ts +5 -59
- package/src/mcp/buildMcpServer.ts +48 -21
- package/src/mcp/builtin/collections/authTools.ts +45 -9
- package/src/mcp/builtin/collections/countTool.ts +74 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +73 -0
- package/src/mcp/builtin/collections/createTool.ts +13 -13
- package/src/mcp/builtin/collections/deleteTool.ts +10 -0
- package/src/mcp/builtin/collections/duplicateTool.ts +135 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +56 -16
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +110 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +155 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +18 -0
- package/src/mcp/builtin/collections/restoreVersionTool.ts +108 -0
- package/src/mcp/builtin/collections/updateTool.ts +14 -14
- package/src/mcp/builtin/getConfigInfoTool.ts +29 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +72 -0
- package/src/mcp/builtin/globals/findTool.ts +25 -16
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +104 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +148 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +13 -0
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +14 -14
- 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 +72 -95
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/getEntityInputSchema.ts +10 -26
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/collection/getAccessField.d.ts +0 -12
- package/dist/collection/getAccessField.d.ts.map +0 -1
- package/dist/collection/getAccessField.js +0 -72
- 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 -105
- package/dist/collection/index.js.map +0 -1
- package/dist/components/APIKeyField/index.client.d.ts +0 -9
- package/dist/components/APIKeyField/index.client.d.ts.map +0 -1
- package/dist/components/APIKeyField/index.client.js +0 -85
- package/dist/components/APIKeyField/index.client.js.map +0 -1
- package/dist/components/APIKeyField/index.css +0 -105
- package/dist/components/APIKeysEmptyState/index.client.d.ts +0 -4
- package/dist/components/APIKeysEmptyState/index.client.d.ts.map +0 -1
- package/dist/components/APIKeysEmptyState/index.client.js +0 -21
- package/dist/components/APIKeysEmptyState/index.client.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 -247
- package/dist/components/AccessField/index.client.js.map +0 -1
- package/dist/components/AccessField/index.css +0 -99
- package/dist/components/SettingsMenu/index.client.d.ts +0 -8
- package/dist/components/SettingsMenu/index.client.d.ts.map +0 -1
- package/dist/components/SettingsMenu/index.client.js +0 -29
- package/dist/components/SettingsMenu/index.client.js.map +0 -1
- package/dist/translations/index.d.ts +0 -11
- package/dist/translations/index.d.ts.map +0 -1
- package/dist/translations/index.js +0 -92
- package/dist/translations/index.js.map +0 -1
- package/dist/translations/languages/ar.d.ts +0 -31
- package/dist/translations/languages/ar.d.ts.map +0 -1
- package/dist/translations/languages/ar.js +0 -34
- package/dist/translations/languages/ar.js.map +0 -1
- package/dist/translations/languages/az.d.ts +0 -31
- package/dist/translations/languages/az.d.ts.map +0 -1
- package/dist/translations/languages/az.js +0 -34
- package/dist/translations/languages/az.js.map +0 -1
- package/dist/translations/languages/bg.d.ts +0 -31
- package/dist/translations/languages/bg.d.ts.map +0 -1
- package/dist/translations/languages/bg.js +0 -34
- package/dist/translations/languages/bg.js.map +0 -1
- package/dist/translations/languages/bnBd.d.ts +0 -31
- package/dist/translations/languages/bnBd.d.ts.map +0 -1
- package/dist/translations/languages/bnBd.js +0 -34
- package/dist/translations/languages/bnBd.js.map +0 -1
- package/dist/translations/languages/bnIn.d.ts +0 -31
- package/dist/translations/languages/bnIn.d.ts.map +0 -1
- package/dist/translations/languages/bnIn.js +0 -34
- package/dist/translations/languages/bnIn.js.map +0 -1
- package/dist/translations/languages/ca.d.ts +0 -31
- package/dist/translations/languages/ca.d.ts.map +0 -1
- package/dist/translations/languages/ca.js +0 -34
- package/dist/translations/languages/ca.js.map +0 -1
- package/dist/translations/languages/cs.d.ts +0 -31
- package/dist/translations/languages/cs.d.ts.map +0 -1
- package/dist/translations/languages/cs.js +0 -34
- package/dist/translations/languages/cs.js.map +0 -1
- package/dist/translations/languages/da.d.ts +0 -31
- package/dist/translations/languages/da.d.ts.map +0 -1
- package/dist/translations/languages/da.js +0 -34
- package/dist/translations/languages/da.js.map +0 -1
- package/dist/translations/languages/de.d.ts +0 -31
- package/dist/translations/languages/de.d.ts.map +0 -1
- package/dist/translations/languages/de.js +0 -34
- package/dist/translations/languages/de.js.map +0 -1
- package/dist/translations/languages/en.d.ts +0 -31
- package/dist/translations/languages/en.d.ts.map +0 -1
- package/dist/translations/languages/en.js +0 -34
- package/dist/translations/languages/en.js.map +0 -1
- package/dist/translations/languages/es.d.ts +0 -31
- package/dist/translations/languages/es.d.ts.map +0 -1
- package/dist/translations/languages/es.js +0 -34
- package/dist/translations/languages/es.js.map +0 -1
- package/dist/translations/languages/et.d.ts +0 -31
- package/dist/translations/languages/et.d.ts.map +0 -1
- package/dist/translations/languages/et.js +0 -34
- package/dist/translations/languages/et.js.map +0 -1
- package/dist/translations/languages/fa.d.ts +0 -31
- package/dist/translations/languages/fa.d.ts.map +0 -1
- package/dist/translations/languages/fa.js +0 -34
- package/dist/translations/languages/fa.js.map +0 -1
- package/dist/translations/languages/fr.d.ts +0 -31
- package/dist/translations/languages/fr.d.ts.map +0 -1
- package/dist/translations/languages/fr.js +0 -34
- package/dist/translations/languages/fr.js.map +0 -1
- package/dist/translations/languages/he.d.ts +0 -31
- package/dist/translations/languages/he.d.ts.map +0 -1
- package/dist/translations/languages/he.js +0 -34
- package/dist/translations/languages/he.js.map +0 -1
- package/dist/translations/languages/hr.d.ts +0 -31
- package/dist/translations/languages/hr.d.ts.map +0 -1
- package/dist/translations/languages/hr.js +0 -34
- package/dist/translations/languages/hr.js.map +0 -1
- package/dist/translations/languages/hu.d.ts +0 -31
- package/dist/translations/languages/hu.d.ts.map +0 -1
- package/dist/translations/languages/hu.js +0 -34
- package/dist/translations/languages/hu.js.map +0 -1
- package/dist/translations/languages/hy.d.ts +0 -31
- package/dist/translations/languages/hy.d.ts.map +0 -1
- package/dist/translations/languages/hy.js +0 -34
- package/dist/translations/languages/hy.js.map +0 -1
- package/dist/translations/languages/id.d.ts +0 -31
- package/dist/translations/languages/id.d.ts.map +0 -1
- package/dist/translations/languages/id.js +0 -34
- package/dist/translations/languages/id.js.map +0 -1
- package/dist/translations/languages/is.d.ts +0 -31
- package/dist/translations/languages/is.d.ts.map +0 -1
- package/dist/translations/languages/is.js +0 -34
- package/dist/translations/languages/is.js.map +0 -1
- package/dist/translations/languages/it.d.ts +0 -31
- package/dist/translations/languages/it.d.ts.map +0 -1
- package/dist/translations/languages/it.js +0 -34
- package/dist/translations/languages/it.js.map +0 -1
- package/dist/translations/languages/ja.d.ts +0 -31
- package/dist/translations/languages/ja.d.ts.map +0 -1
- package/dist/translations/languages/ja.js +0 -34
- package/dist/translations/languages/ja.js.map +0 -1
- package/dist/translations/languages/ko.d.ts +0 -31
- package/dist/translations/languages/ko.d.ts.map +0 -1
- package/dist/translations/languages/ko.js +0 -34
- package/dist/translations/languages/ko.js.map +0 -1
- package/dist/translations/languages/lt.d.ts +0 -31
- package/dist/translations/languages/lt.d.ts.map +0 -1
- package/dist/translations/languages/lt.js +0 -34
- package/dist/translations/languages/lt.js.map +0 -1
- package/dist/translations/languages/lv.d.ts +0 -31
- package/dist/translations/languages/lv.d.ts.map +0 -1
- package/dist/translations/languages/lv.js +0 -34
- package/dist/translations/languages/lv.js.map +0 -1
- package/dist/translations/languages/my.d.ts +0 -31
- package/dist/translations/languages/my.d.ts.map +0 -1
- package/dist/translations/languages/my.js +0 -34
- package/dist/translations/languages/my.js.map +0 -1
- package/dist/translations/languages/nb.d.ts +0 -31
- package/dist/translations/languages/nb.d.ts.map +0 -1
- package/dist/translations/languages/nb.js +0 -34
- package/dist/translations/languages/nb.js.map +0 -1
- package/dist/translations/languages/nl.d.ts +0 -31
- package/dist/translations/languages/nl.d.ts.map +0 -1
- package/dist/translations/languages/nl.js +0 -34
- package/dist/translations/languages/nl.js.map +0 -1
- package/dist/translations/languages/pl.d.ts +0 -31
- package/dist/translations/languages/pl.d.ts.map +0 -1
- package/dist/translations/languages/pl.js +0 -34
- package/dist/translations/languages/pl.js.map +0 -1
- package/dist/translations/languages/pt.d.ts +0 -31
- package/dist/translations/languages/pt.d.ts.map +0 -1
- package/dist/translations/languages/pt.js +0 -34
- package/dist/translations/languages/pt.js.map +0 -1
- package/dist/translations/languages/ro.d.ts +0 -31
- package/dist/translations/languages/ro.d.ts.map +0 -1
- package/dist/translations/languages/ro.js +0 -34
- package/dist/translations/languages/ro.js.map +0 -1
- package/dist/translations/languages/rs.d.ts +0 -31
- package/dist/translations/languages/rs.d.ts.map +0 -1
- package/dist/translations/languages/rs.js +0 -34
- package/dist/translations/languages/rs.js.map +0 -1
- package/dist/translations/languages/rsLatin.d.ts +0 -31
- package/dist/translations/languages/rsLatin.d.ts.map +0 -1
- package/dist/translations/languages/rsLatin.js +0 -34
- package/dist/translations/languages/rsLatin.js.map +0 -1
- package/dist/translations/languages/ru.d.ts +0 -31
- package/dist/translations/languages/ru.d.ts.map +0 -1
- package/dist/translations/languages/ru.js +0 -34
- package/dist/translations/languages/ru.js.map +0 -1
- package/dist/translations/languages/sk.d.ts +0 -31
- package/dist/translations/languages/sk.d.ts.map +0 -1
- package/dist/translations/languages/sk.js +0 -34
- package/dist/translations/languages/sk.js.map +0 -1
- package/dist/translations/languages/sl.d.ts +0 -31
- package/dist/translations/languages/sl.d.ts.map +0 -1
- package/dist/translations/languages/sl.js +0 -34
- package/dist/translations/languages/sl.js.map +0 -1
- package/dist/translations/languages/sv.d.ts +0 -31
- package/dist/translations/languages/sv.d.ts.map +0 -1
- package/dist/translations/languages/sv.js +0 -34
- package/dist/translations/languages/sv.js.map +0 -1
- package/dist/translations/languages/ta.d.ts +0 -31
- package/dist/translations/languages/ta.d.ts.map +0 -1
- package/dist/translations/languages/ta.js +0 -34
- package/dist/translations/languages/ta.js.map +0 -1
- package/dist/translations/languages/th.d.ts +0 -31
- package/dist/translations/languages/th.d.ts.map +0 -1
- package/dist/translations/languages/th.js +0 -34
- package/dist/translations/languages/th.js.map +0 -1
- package/dist/translations/languages/tr.d.ts +0 -31
- package/dist/translations/languages/tr.d.ts.map +0 -1
- package/dist/translations/languages/tr.js +0 -34
- package/dist/translations/languages/tr.js.map +0 -1
- package/dist/translations/languages/uk.d.ts +0 -31
- package/dist/translations/languages/uk.d.ts.map +0 -1
- package/dist/translations/languages/uk.js +0 -34
- package/dist/translations/languages/uk.js.map +0 -1
- package/dist/translations/languages/vi.d.ts +0 -31
- package/dist/translations/languages/vi.d.ts.map +0 -1
- package/dist/translations/languages/vi.js +0 -34
- package/dist/translations/languages/vi.js.map +0 -1
- package/dist/translations/languages/zh.d.ts +0 -31
- package/dist/translations/languages/zh.d.ts.map +0 -1
- package/dist/translations/languages/zh.js +0 -34
- package/dist/translations/languages/zh.js.map +0 -1
- package/dist/translations/languages/zhTw.d.ts +0 -31
- package/dist/translations/languages/zhTw.d.ts.map +0 -1
- package/dist/translations/languages/zhTw.js +0 -34
- package/dist/translations/languages/zhTw.js.map +0 -1
- package/dist/translations/types.d.ts +0 -32
- package/dist/translations/types.d.ts.map +0 -1
- package/dist/translations/types.js +0 -3
- package/dist/translations/types.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/@types/assets.d.ts +0 -3
- package/src/collection/getAccessField.ts +0 -84
- package/src/collection/index.ts +0 -105
- package/src/components/APIKeyField/index.client.tsx +0 -73
- package/src/components/APIKeyField/index.css +0 -105
- package/src/components/APIKeysEmptyState/index.client.tsx +0 -36
- package/src/components/AccessField/index.client.tsx +0 -299
- package/src/components/AccessField/index.css +0 -99
- package/src/components/SettingsMenu/index.client.tsx +0 -34
- package/src/translations/index.ts +0 -108
- package/src/translations/languages/ar.ts +0 -35
- package/src/translations/languages/az.ts +0 -35
- package/src/translations/languages/bg.ts +0 -35
- package/src/translations/languages/bnBd.ts +0 -35
- package/src/translations/languages/bnIn.ts +0 -35
- package/src/translations/languages/ca.ts +0 -35
- package/src/translations/languages/cs.ts +0 -35
- package/src/translations/languages/da.ts +0 -35
- package/src/translations/languages/de.ts +0 -35
- package/src/translations/languages/en.ts +0 -35
- package/src/translations/languages/es.ts +0 -35
- package/src/translations/languages/et.ts +0 -35
- package/src/translations/languages/fa.ts +0 -35
- package/src/translations/languages/fr.ts +0 -35
- package/src/translations/languages/he.ts +0 -35
- package/src/translations/languages/hr.ts +0 -35
- package/src/translations/languages/hu.ts +0 -35
- package/src/translations/languages/hy.ts +0 -35
- package/src/translations/languages/id.ts +0 -35
- package/src/translations/languages/is.ts +0 -35
- package/src/translations/languages/it.ts +0 -35
- package/src/translations/languages/ja.ts +0 -35
- package/src/translations/languages/ko.ts +0 -35
- package/src/translations/languages/lt.ts +0 -35
- package/src/translations/languages/lv.ts +0 -35
- package/src/translations/languages/my.ts +0 -35
- package/src/translations/languages/nb.ts +0 -35
- package/src/translations/languages/nl.ts +0 -35
- package/src/translations/languages/pl.ts +0 -35
- package/src/translations/languages/pt.ts +0 -35
- package/src/translations/languages/ro.ts +0 -35
- package/src/translations/languages/rs.ts +0 -35
- package/src/translations/languages/rsLatin.ts +0 -35
- package/src/translations/languages/ru.ts +0 -35
- package/src/translations/languages/sk.ts +0 -35
- package/src/translations/languages/sl.ts +0 -35
- package/src/translations/languages/sv.ts +0 -35
- package/src/translations/languages/ta.ts +0 -35
- package/src/translations/languages/th.ts +0 -35
- package/src/translations/languages/tr.ts +0 -35
- package/src/translations/languages/uk.ts +0 -35
- package/src/translations/languages/vi.ts +0 -35
- package/src/translations/languages/zh.ts +0 -35
- package/src/translations/languages/zhTw.ts +0 -35
- package/src/translations/types.ts +0 -34
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
package/src/types.ts
CHANGED
|
@@ -6,18 +6,19 @@ import type {
|
|
|
6
6
|
ResourceTemplate,
|
|
7
7
|
ServerContext,
|
|
8
8
|
StandardSchemaWithJSON,
|
|
9
|
+
ToolAnnotations,
|
|
9
10
|
} from '@modelcontextprotocol/server'
|
|
10
11
|
import type {
|
|
11
12
|
AuthCollectionSlug,
|
|
12
|
-
CollectionConfig,
|
|
13
13
|
CollectionSlug,
|
|
14
|
-
DefaultDocumentIDType,
|
|
15
14
|
GlobalSlug,
|
|
16
15
|
MaybePromise,
|
|
17
16
|
PayloadRequest,
|
|
18
|
-
|
|
17
|
+
SanitizedPermissions,
|
|
18
|
+
User,
|
|
19
19
|
} from 'payload'
|
|
20
20
|
|
|
21
|
+
import type { GetAuthorizedMCPArgs } from './endpoint/access.js'
|
|
21
22
|
import type {
|
|
22
23
|
MCPCollectionAuthToolName,
|
|
23
24
|
MCPCollectionBuiltinName,
|
|
@@ -26,36 +27,16 @@ import type {
|
|
|
26
27
|
|
|
27
28
|
export type { MCPCollectionAuthToolName, MCPCollectionBuiltinName, MCPGlobalBuiltinName }
|
|
28
29
|
|
|
29
|
-
/** Re-exported from `@modelcontextprotocol/server` —
|
|
30
|
-
export type { JsonSchemaType, StandardSchemaWithJSON }
|
|
30
|
+
/** Re-exported from `@modelcontextprotocol/server` — common MCP types used in plugin config. */
|
|
31
|
+
export type { JsonSchemaType, StandardSchemaWithJSON, ToolAnnotations }
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* What a tool's `input` (or a prompt's `argsSchema`) can be — either a raw
|
|
34
|
-
* JSON Schema literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
35
|
+
* JSON Schema 2020-12 literal, or a Standard Schema instance (Zod, Valibot, …).
|
|
36
|
+
* Raw schemas may omit `$schema`; when present it must declare the 2020-12 dialect.
|
|
35
37
|
*/
|
|
36
38
|
export type ToolInputSchema = JsonSchemaType | StandardSchemaWithJSON
|
|
37
39
|
|
|
38
|
-
/**
|
|
39
|
-
* Serializable mirror of `SanitizedMCPPluginConfig` for client components —
|
|
40
|
-
* the full sanitized config carries functions (tool handlers, etc.) that can't
|
|
41
|
-
* cross the server→client boundary. Built by `sanitizeClientPluginConfig` and
|
|
42
|
-
* passed to the `AccessField` component via `clientProps`.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export type ClientMCPPluginConfig = {
|
|
47
|
-
items: Array<{
|
|
48
|
-
collectionSlug?: string
|
|
49
|
-
configKey: string
|
|
50
|
-
description?: string
|
|
51
|
-
globalSlug?: string
|
|
52
|
-
/** Admin-UI bucket for collection/global tools: built-in CRUD, auth, or custom. */
|
|
53
|
-
group?: 'auth' | 'custom' | 'operations'
|
|
54
|
-
label: string
|
|
55
|
-
type: 'collectionTool' | 'globalTool' | 'prompt' | 'resource' | 'tool'
|
|
56
|
-
}>
|
|
57
|
-
}
|
|
58
|
-
|
|
59
40
|
export type MCPToolResponse = {
|
|
60
41
|
content: ContentBlock[]
|
|
61
42
|
/**
|
|
@@ -72,6 +53,13 @@ export type MCPResponseOverride = (
|
|
|
72
53
|
req: PayloadRequest,
|
|
73
54
|
) => MCPToolResponse
|
|
74
55
|
|
|
56
|
+
export type MCPAfterToolCallHook = (args: {
|
|
57
|
+
input: unknown
|
|
58
|
+
req: PayloadRequest
|
|
59
|
+
response: MCPToolResponse
|
|
60
|
+
toolName: string
|
|
61
|
+
}) => MaybePromise<MCPToolResponse>
|
|
62
|
+
|
|
75
63
|
/**
|
|
76
64
|
* The handler's `input` type. A specific Standard Schema (Zod, Valibot, …) gets
|
|
77
65
|
* its inferred output; anything else falls back to `Record<string, unknown>`.
|
|
@@ -82,6 +70,19 @@ export type TypedInput<TSchema> = TSchema extends StandardSchemaWithJSON
|
|
|
82
70
|
: StandardSchemaWithJSON.InferOutput<TSchema>
|
|
83
71
|
: Record<string, unknown>
|
|
84
72
|
|
|
73
|
+
export type MCPAccessArgs = {
|
|
74
|
+
permissions?: SanitizedPermissions
|
|
75
|
+
req: PayloadRequest
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type CollectionMCPAccessArgs = {
|
|
79
|
+
collectionSlug: CollectionSlug
|
|
80
|
+
} & MCPAccessArgs
|
|
81
|
+
|
|
82
|
+
export type GlobalMCPAccessArgs = {
|
|
83
|
+
globalSlug: GlobalSlug
|
|
84
|
+
} & MCPAccessArgs
|
|
85
|
+
|
|
85
86
|
export type ToolHandlerArgs<TSchema = undefined> = {
|
|
86
87
|
authorizedMCP: AuthorizedMCP
|
|
87
88
|
input: TypedInput<TSchema>
|
|
@@ -98,6 +99,8 @@ export type GlobalToolHandlerArgs<TSchema = undefined> = {
|
|
|
98
99
|
} & ToolHandlerArgs<TSchema>
|
|
99
100
|
|
|
100
101
|
export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> = {
|
|
102
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
103
|
+
annotations?: ToolAnnotations
|
|
101
104
|
description: string
|
|
102
105
|
handler: (args: ToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
103
106
|
input?: TSchema
|
|
@@ -110,22 +113,34 @@ export type Tool<TSchema extends ToolInputSchema | undefined = ToolInputSchema |
|
|
|
110
113
|
export type CollectionTool<
|
|
111
114
|
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
112
115
|
> = {
|
|
116
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
113
117
|
handler: (args: CollectionToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
114
118
|
input?: TSchema
|
|
115
|
-
} & Pick<Tool, 'description' | 'overrideResponse'>
|
|
119
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
116
120
|
|
|
117
121
|
export type GlobalTool<TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined> =
|
|
118
122
|
{
|
|
123
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
119
124
|
handler: (args: GlobalToolHandlerArgs<TSchema>) => MaybePromise<MCPToolResponse>
|
|
120
125
|
input?: TSchema
|
|
121
|
-
} & Pick<Tool, 'description' | 'overrideResponse'>
|
|
126
|
+
} & Pick<Tool, 'annotations' | 'description' | 'overrideResponse'>
|
|
122
127
|
|
|
123
128
|
/**
|
|
124
129
|
* Configures (or disables) a built-in tool without replacing it.
|
|
125
130
|
* `handler?: never` prevents a full `CollectionTool`/`GlobalTool` (which has a
|
|
126
131
|
* required handler) from being silently accepted at a built-in key slot.
|
|
127
132
|
*/
|
|
128
|
-
export type
|
|
133
|
+
export type MCPBuiltInCollectionToolOverride = {
|
|
134
|
+
access?: (args: CollectionMCPAccessArgs) => MaybePromise<boolean>
|
|
135
|
+
annotations?: ToolAnnotations
|
|
136
|
+
description?: string
|
|
137
|
+
handler?: never
|
|
138
|
+
overrideResponse?: MCPResponseOverride
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type MCPBuiltInGlobalToolOverride = {
|
|
142
|
+
access?: (args: GlobalMCPAccessArgs) => MaybePromise<boolean>
|
|
143
|
+
annotations?: ToolAnnotations
|
|
129
144
|
description?: string
|
|
130
145
|
handler?: never
|
|
131
146
|
overrideResponse?: MCPResponseOverride
|
|
@@ -139,13 +154,13 @@ export type MCPBuiltInToolOverride = {
|
|
|
139
154
|
export type MCPTopLevelToolEntry = Tool
|
|
140
155
|
|
|
141
156
|
export type MCPCollectionToolsMap = {
|
|
142
|
-
[customToolName: string]: boolean | CollectionTool |
|
|
157
|
+
[customToolName: string]: boolean | CollectionTool | MCPBuiltInCollectionToolOverride | undefined
|
|
143
158
|
} & {
|
|
144
|
-
[K in MCPCollectionBuiltinName]?: false |
|
|
159
|
+
[K in MCPCollectionBuiltinName]?: false | MCPBuiltInCollectionToolOverride
|
|
145
160
|
}
|
|
146
161
|
|
|
147
162
|
export type MCPAuthCollectionToolsMap = {
|
|
148
|
-
[K in MCPCollectionAuthToolName]?:
|
|
163
|
+
[K in MCPCollectionAuthToolName]?: MCPBuiltInCollectionToolOverride | true
|
|
149
164
|
} & MCPCollectionToolsMap
|
|
150
165
|
|
|
151
166
|
/** Auth-enabled collections get auth-tool name autocomplete; others get CRUD-only. */
|
|
@@ -154,9 +169,9 @@ export type MCPToolsMapForCollection<Slug extends CollectionSlug> = Slug extends
|
|
|
154
169
|
: MCPCollectionToolsMap
|
|
155
170
|
|
|
156
171
|
export type MCPGlobalToolsMap = {
|
|
157
|
-
[customToolName: string]: boolean | GlobalTool |
|
|
172
|
+
[customToolName: string]: boolean | GlobalTool | MCPBuiltInGlobalToolOverride | undefined
|
|
158
173
|
} & {
|
|
159
|
-
[K in MCPGlobalBuiltinName]?: false |
|
|
174
|
+
[K in MCPGlobalBuiltinName]?: false | MCPBuiltInGlobalToolOverride
|
|
160
175
|
}
|
|
161
176
|
|
|
162
177
|
export type MCPTopLevelToolsMap = Record<string, Tool>
|
|
@@ -168,6 +183,7 @@ export type PromptHandlerArgs<TSchema = undefined> = {
|
|
|
168
183
|
}
|
|
169
184
|
|
|
170
185
|
export type Prompt<TSchema extends ToolInputSchema = ToolInputSchema> = {
|
|
186
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
171
187
|
argsSchema: TSchema
|
|
172
188
|
description: string
|
|
173
189
|
handler: (args: PromptHandlerArgs<TSchema>) => MaybePromise<{
|
|
@@ -185,6 +201,7 @@ export type ResourceHandlerArgs = {
|
|
|
185
201
|
}
|
|
186
202
|
|
|
187
203
|
export type Resource = {
|
|
204
|
+
access?: (args: MCPAccessArgs) => MaybePromise<boolean>
|
|
188
205
|
description: string
|
|
189
206
|
handler: (args: ResourceHandlerArgs) => MaybePromise<{
|
|
190
207
|
contents: Array<{ text: string; uri: string }>
|
|
@@ -218,34 +235,34 @@ export type MCPPluginConfig = {
|
|
|
218
235
|
collections?: {
|
|
219
236
|
[Slug in CollectionSlug]?: MCPPluginCollectionConfig<Slug>
|
|
220
237
|
}
|
|
221
|
-
/** Skip MCP registration.
|
|
238
|
+
/** Skip MCP endpoint registration. */
|
|
222
239
|
disabled?: boolean
|
|
223
240
|
globals?: {
|
|
224
241
|
[Slug in GlobalSlug]?: MCPPluginGlobalConfig
|
|
225
242
|
}
|
|
243
|
+
hooks?: {
|
|
244
|
+
/** Transform a tool response after its handler returns */
|
|
245
|
+
afterToolCall?: MCPAfterToolCallHook[]
|
|
246
|
+
}
|
|
226
247
|
mcp?: {
|
|
227
248
|
serverOptions?: MCPServerOptions
|
|
228
249
|
verboseLogs?: boolean
|
|
229
250
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
req: PayloadRequest
|
|
237
|
-
}) => MaybePromise<AuthorizedMCP>
|
|
251
|
+
/** Replace the default MCP authorization resolver. */
|
|
252
|
+
overrideGetAuthorizedMCP?: (
|
|
253
|
+
args: {
|
|
254
|
+
pluginConfig: SanitizedMCPPluginConfig
|
|
255
|
+
} & GetAuthorizedMCPArgs,
|
|
256
|
+
) => MaybePromise<AuthorizedMCP>
|
|
238
257
|
prompts?: Record<string, Prompt>
|
|
239
258
|
resources?: Record<string, Resource>
|
|
240
259
|
/** Cross-cutting tools (not scoped to any collection or global). */
|
|
241
260
|
tools?: MCPTopLevelToolsMap
|
|
242
|
-
userCollection?: CollectionSlug
|
|
243
261
|
}
|
|
244
262
|
|
|
245
263
|
export type SanitizedMCPPluginConfig = {
|
|
246
264
|
items: MCPItem[]
|
|
247
|
-
|
|
248
|
-
} & Pick<MCPPluginConfig, 'disabled' | 'mcp' | 'overrideApiKeyCollection' | 'overrideAuth'>
|
|
265
|
+
} & Pick<MCPPluginConfig, 'disabled' | 'hooks' | 'mcp' | 'overrideGetAuthorizedMCP'>
|
|
249
266
|
|
|
250
267
|
export type MCPServerOptions = {
|
|
251
268
|
options?: ConstructorParameters<typeof McpServer>[1]
|
|
@@ -253,52 +270,12 @@ export type MCPServerOptions = {
|
|
|
253
270
|
}
|
|
254
271
|
|
|
255
272
|
/**
|
|
256
|
-
*
|
|
257
|
-
* A `false` leaf disables that tool; missing keys defer to
|
|
258
|
-
* defaults (built-in CRUD is on, opt-in tools are off).
|
|
259
|
-
*/
|
|
260
|
-
export type MCPAPIKeysDocAccessTree = {
|
|
261
|
-
collections?: {
|
|
262
|
-
[CollectionSlug: CollectionSlug]: {
|
|
263
|
-
[ToolKey: string]: boolean
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
globals?: {
|
|
267
|
-
[GlobalSlug: GlobalSlug]: {
|
|
268
|
-
[ToolKey: string]: boolean
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
prompts?: {
|
|
272
|
-
[PromptKey: string]: boolean
|
|
273
|
-
}
|
|
274
|
-
resources?: {
|
|
275
|
-
[ResourceKey: string]: boolean
|
|
276
|
-
}
|
|
277
|
-
tools?: {
|
|
278
|
-
[ToolKey: string]: boolean
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Stored on `payload-mcp-api-keys` docs
|
|
284
|
-
*/
|
|
285
|
-
export type MCPAPIKeysDoc = {
|
|
286
|
-
access: MCPAPIKeysDocAccessTree
|
|
287
|
-
apiKey?: string
|
|
288
|
-
apiKeyIndex?: string
|
|
289
|
-
id: DefaultDocumentIDType
|
|
290
|
-
lastUsed?: string
|
|
291
|
-
overrideAccess?: boolean
|
|
292
|
-
user: null | TypedUser
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* One MCP primitive plus the metadata needed for access checks, admin UI, and
|
|
273
|
+
* One MCP primitive plus the metadata needed for config-driven filtering and
|
|
297
274
|
* registration.
|
|
298
275
|
*
|
|
299
|
-
* - `configKey`: the config
|
|
276
|
+
* - `configKey`: the config identifier, e.g. `find` or `echo`.
|
|
300
277
|
* - `mcpName`: the MCP wire name, e.g. `findDocuments` or `echo`.
|
|
301
|
-
* - `label`: human-readable
|
|
278
|
+
* - `label`: human-readable display text.
|
|
302
279
|
*/
|
|
303
280
|
export type MCPItemBase = {
|
|
304
281
|
configKey: string
|
|
@@ -335,13 +312,13 @@ export type MCPItem =
|
|
|
335
312
|
| GlobalMCPItem
|
|
336
313
|
|
|
337
314
|
/**
|
|
338
|
-
* The caller's identity + the MCP items
|
|
339
|
-
*
|
|
340
|
-
* receive this via `args.authorizedMCP` so
|
|
341
|
-
* `localAPIDefaults(authorizedMCP)` into every local API call.
|
|
315
|
+
* The caller's identity + the MCP items authorized for this request. Disabled
|
|
316
|
+
* items and items blocked by access callbacks or Payload operation access are
|
|
317
|
+
* absent from `items`. Tool handlers receive this via `args.authorizedMCP` so
|
|
318
|
+
* they can spread `localAPIDefaults(authorizedMCP)` into every local API call.
|
|
342
319
|
*/
|
|
343
320
|
export type AuthorizedMCP = {
|
|
344
321
|
items: MCPItem[]
|
|
345
322
|
overrideAccess: boolean
|
|
346
|
-
user: null |
|
|
323
|
+
user: null | User
|
|
347
324
|
}
|
|
@@ -5,7 +5,7 @@ import type { SanitizedMCPPluginConfig } from '../types.js'
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the sanitized plugin config — the form produced by
|
|
7
7
|
* `sanitizeMCPConfig` and stashed back on the plugin's `options` during init.
|
|
8
|
-
* Callers downstream of plugin init can rely on `items
|
|
8
|
+
* Callers downstream of plugin init can rely on `items` and other defaults
|
|
9
9
|
* being fully resolved.
|
|
10
10
|
*/
|
|
11
11
|
export const getPluginConfig: (args: { config: SanitizedConfig }) => SanitizedMCPPluginConfig = ({
|
|
@@ -9,11 +9,6 @@ import {
|
|
|
9
9
|
|
|
10
10
|
import type { JsonSchemaType } from '../../types.js'
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
getCollectionVirtualFieldNames,
|
|
14
|
-
getGlobalVirtualFieldNames,
|
|
15
|
-
} from '../getVirtualFieldNames.js'
|
|
16
|
-
import { removeVirtualFieldsFromSchema } from './removeVirtualFieldsFromSchema.js'
|
|
17
12
|
import { sanitizeEntitySchema } from './sanitizeEntitySchema.js'
|
|
18
13
|
|
|
19
14
|
export const getCollectionInputSchema = ({
|
|
@@ -29,11 +24,7 @@ export const getCollectionInputSchema = ({
|
|
|
29
24
|
return null
|
|
30
25
|
}
|
|
31
26
|
|
|
32
|
-
return buildEntityInputSchema({
|
|
33
|
-
entity: collection,
|
|
34
|
-
req,
|
|
35
|
-
virtualFieldNames: getCollectionVirtualFieldNames(req.payload.config, collectionSlug),
|
|
36
|
-
})
|
|
27
|
+
return buildEntityInputSchema({ entity: collection, req })
|
|
37
28
|
}
|
|
38
29
|
|
|
39
30
|
export const getGlobalInputSchema = ({
|
|
@@ -49,30 +40,23 @@ export const getGlobalInputSchema = ({
|
|
|
49
40
|
return null
|
|
50
41
|
}
|
|
51
42
|
|
|
52
|
-
return buildEntityInputSchema({
|
|
53
|
-
entity: global,
|
|
54
|
-
req,
|
|
55
|
-
virtualFieldNames: getGlobalVirtualFieldNames(req.payload.config, globalSlug),
|
|
56
|
-
})
|
|
43
|
+
return buildEntityInputSchema({ entity: global, req })
|
|
57
44
|
}
|
|
58
45
|
|
|
59
46
|
const buildEntityInputSchema = ({
|
|
60
47
|
entity,
|
|
61
48
|
req,
|
|
62
|
-
virtualFieldNames,
|
|
63
49
|
}: {
|
|
64
50
|
entity: SanitizedCollectionConfig | SanitizedGlobalConfig
|
|
65
51
|
req: PayloadRequest
|
|
66
|
-
virtualFieldNames: string[]
|
|
67
52
|
}): JsonSchemaType =>
|
|
53
|
+
// The `input` variant is already the write shape; sanitizeEntitySchema only adds MCP-specific passes.
|
|
68
54
|
sanitizeEntitySchema(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
virtualFieldNames,
|
|
77
|
-
),
|
|
55
|
+
entityToStandaloneJSONSchema({
|
|
56
|
+
config: req.payload.config,
|
|
57
|
+
defaultIDType: req.payload.db.defaultIDType,
|
|
58
|
+
entity,
|
|
59
|
+
i18n: req.i18n,
|
|
60
|
+
variant: 'input',
|
|
61
|
+
}) as unknown as JsonSchemaType,
|
|
78
62
|
)
|
|
@@ -5,10 +5,11 @@ import type { JsonSchemaType } from '../../types.js'
|
|
|
5
5
|
import { sanitizeEntitySchema } from './sanitizeEntitySchema.js'
|
|
6
6
|
|
|
7
7
|
describe('sanitizeEntitySchema', () => {
|
|
8
|
-
it('
|
|
9
|
-
// Shaped like the schema the MCP server prepares for a collection with a Lexical richText field
|
|
10
|
-
// a `$defs` node union (a `oneOf` of node shapes)
|
|
11
|
-
//
|
|
8
|
+
it('renames the Lexical node-union definition to a short name and keeps it a strict oneOf', () => {
|
|
9
|
+
// Shaped like the schema the MCP server prepares for a collection with a Lexical richText field
|
|
10
|
+
// (Payload's `input` variant): a `$defs` node union (a `oneOf` of node shapes). The input variant
|
|
11
|
+
// already types the relationship node's `value` as a bare ID - there is no populated-doc `$ref` to
|
|
12
|
+
// reduce here (the variant did that upstream), so sanitize leaves the value untouched.
|
|
12
13
|
const standalone: JsonSchemaType = {
|
|
13
14
|
type: 'object',
|
|
14
15
|
$defs: {
|
|
@@ -25,17 +26,12 @@ describe('sanitizeEntitySchema', () => {
|
|
|
25
26
|
additionalProperties: false,
|
|
26
27
|
properties: {
|
|
27
28
|
type: { const: 'relationship' },
|
|
28
|
-
value: {
|
|
29
|
+
value: { type: 'string', description: 'The related document ID.' },
|
|
29
30
|
},
|
|
30
31
|
required: ['type'],
|
|
31
32
|
},
|
|
32
33
|
],
|
|
33
34
|
},
|
|
34
|
-
posts: {
|
|
35
|
-
type: 'object',
|
|
36
|
-
additionalProperties: false,
|
|
37
|
-
properties: { id: { type: 'string' }, title: { type: 'string' } },
|
|
38
|
-
},
|
|
39
35
|
},
|
|
40
36
|
properties: {
|
|
41
37
|
id: { type: 'string' },
|
|
@@ -57,7 +53,7 @@ describe('sanitizeEntitySchema', () => {
|
|
|
57
53
|
type: 'object',
|
|
58
54
|
$defs: {
|
|
59
55
|
// The node union is renamed to a short, readable `node`, and stays a strict discriminated
|
|
60
|
-
// `oneOf` - not loosened to `anyOf
|
|
56
|
+
// `oneOf` - not loosened to `anyOf`.
|
|
61
57
|
node: {
|
|
62
58
|
oneOf: [
|
|
63
59
|
{
|
|
@@ -71,21 +67,18 @@ describe('sanitizeEntitySchema', () => {
|
|
|
71
67
|
additionalProperties: false,
|
|
72
68
|
properties: {
|
|
73
69
|
type: { const: 'relationship' },
|
|
74
|
-
//
|
|
75
|
-
value: { type: 'string', description: 'The
|
|
70
|
+
// The value is already ID-only from the input variant - left as-is.
|
|
71
|
+
value: { type: 'string', description: 'The related document ID.' },
|
|
76
72
|
},
|
|
77
73
|
required: ['type'],
|
|
78
74
|
},
|
|
79
75
|
],
|
|
80
76
|
},
|
|
81
|
-
posts: {
|
|
82
|
-
type: 'object',
|
|
83
|
-
additionalProperties: false,
|
|
84
|
-
properties: { id: { type: 'string' }, title: { type: 'string' } },
|
|
85
|
-
},
|
|
86
77
|
},
|
|
87
78
|
properties: {
|
|
88
|
-
//
|
|
79
|
+
// Managed fields (createdAt/updatedAt/_status) are excluded upstream by the `input` variant;
|
|
80
|
+
// `id` stays because it's a valid optional input (a client may supply a custom ID).
|
|
81
|
+
id: { type: 'string' },
|
|
89
82
|
content: {
|
|
90
83
|
type: 'object',
|
|
91
84
|
properties: {
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import type { JsonSchemaType } from '../../types.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - and shrinks the result so it's cheaper for the model to read,
|
|
10
|
-
*
|
|
11
|
-
* while keeping every node valid JSON Schema draft 2020-12. Each step below is tagged with why it runs -
|
|
12
|
-
* **Correctness** (valid input the API accepts), **Size** (equivalence-preserving shrink), or **LLM
|
|
13
|
-
* ergonomics** (easier for the model to read/fill) - and carries a before/after example on its definition.
|
|
4
|
+
* Refines Payload's `input`-variant JSON Schema into an MCP create/update tool's input schema. The
|
|
5
|
+
* variant already covers correctness (ID-only relationships, no managed/virtual/join fields); the
|
|
6
|
+
* passes here are MCP-specific - reshaping fields for the model and shrinking the result - and keep
|
|
7
|
+
* every node valid JSON Schema draft 2020-12. Each is tagged **Correctness**, **Size**, or **LLM
|
|
8
|
+
* ergonomics**, with a before/after example on its definition.
|
|
14
9
|
*/
|
|
15
10
|
export const sanitizeEntitySchema = (schema: JsonSchemaType): JsonSchemaType => {
|
|
16
11
|
// Work on a copy — the caller reuses the original schema elsewhere (e.g. when listing tools).
|
|
17
12
|
let result = structuredClone(schema)
|
|
18
13
|
|
|
19
|
-
//
|
|
20
|
-
result =
|
|
14
|
+
// LLM ergonomics — drop the redundant `'null'` from optional arrays/objects (`['array','null']` → `'array'`).
|
|
15
|
+
result = collapseOptionalContainerTypes(result)
|
|
21
16
|
|
|
22
17
|
// LLM ergonomics — rewrite point fields from a `[number, number]` tuple into a `{ longitude, latitude }` object.
|
|
23
18
|
result = pointFieldsToObjects(result)
|
|
24
19
|
|
|
25
|
-
// Correctness — a relationship value can be an ID or a populated doc; on input only the ID is valid, so keep that.
|
|
26
|
-
result = relationshipsToIds(result)
|
|
27
|
-
|
|
28
20
|
// Size — strip inert type-gen leftovers that only bloat the schema (`tsType`, block-collision notes).
|
|
29
21
|
result = removeTypeGenArtifacts(result)
|
|
30
22
|
|
|
@@ -58,26 +50,20 @@ const mapNodes = (node: unknown, visit: (node: JsonSchemaType) => JsonSchemaType
|
|
|
58
50
|
for (const [key, value] of Object.entries(node)) {
|
|
59
51
|
out[key] = mapNodes(value, visit)
|
|
60
52
|
}
|
|
61
|
-
return visit(out
|
|
53
|
+
return visit(out)
|
|
62
54
|
}
|
|
63
55
|
|
|
64
|
-
// Payload sets these on every document, so an MCP client never provides them when creating/updating.
|
|
65
|
-
const PAYLOAD_MANAGED_FIELDS = new Set(['_status', 'createdAt', 'id', 'updatedAt'])
|
|
66
|
-
|
|
67
56
|
/**
|
|
68
|
-
* **
|
|
69
|
-
*
|
|
70
|
-
*
|
|
57
|
+
* **LLM ergonomics.** Collapses optional array/object types (`['array', 'null']` → `'array'`) via
|
|
58
|
+
* {@link collapseNullableType}, recursing through `properties` and array items. The `required` list
|
|
59
|
+
* already conveys optionality, so the `'null'` is redundant noise for the model.
|
|
71
60
|
*
|
|
72
61
|
* @example
|
|
73
|
-
* { properties: {
|
|
74
|
-
* → { properties: { tags: { type: 'array', items: {} } }, required: [
|
|
62
|
+
* { properties: { tags: { type: ['array', 'null'], items: {} } }, required: [] }
|
|
63
|
+
* → { properties: { tags: { type: 'array', items: {} } }, required: [] }
|
|
75
64
|
*/
|
|
76
|
-
const
|
|
65
|
+
const collapseOptionalContainerTypes = (schema: JsonSchemaType): JsonSchemaType => {
|
|
77
66
|
if (schema.properties && typeof schema.properties === 'object') {
|
|
78
|
-
for (const field of PAYLOAD_MANAGED_FIELDS) {
|
|
79
|
-
delete schema.properties[field]
|
|
80
|
-
}
|
|
81
67
|
for (const key of Object.keys(schema.properties)) {
|
|
82
68
|
const prop = schema.properties[key] as JsonSchemaType
|
|
83
69
|
if (!prop || typeof prop !== 'object') {
|
|
@@ -86,21 +72,14 @@ const removeManagedFields = (schema: JsonSchemaType): JsonSchemaType => {
|
|
|
86
72
|
const isRequired = Array.isArray(schema.required) && schema.required.includes(key)
|
|
87
73
|
collapseNullableType(prop, isRequired)
|
|
88
74
|
if (prop.properties) {
|
|
89
|
-
|
|
75
|
+
collapseOptionalContainerTypes(prop)
|
|
90
76
|
}
|
|
91
77
|
if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
|
|
92
|
-
|
|
78
|
+
collapseOptionalContainerTypes(prop.items)
|
|
93
79
|
}
|
|
94
80
|
}
|
|
95
81
|
}
|
|
96
82
|
|
|
97
|
-
if (Array.isArray(schema.required)) {
|
|
98
|
-
schema.required = schema.required.filter((name) => !PAYLOAD_MANAGED_FIELDS.has(name))
|
|
99
|
-
if (schema.required.length === 0) {
|
|
100
|
-
delete schema.required
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
83
|
return schema
|
|
105
84
|
}
|
|
106
85
|
|
|
@@ -193,82 +172,6 @@ const pointFieldsToObjects = (schema: JsonSchemaType): JsonSchemaType => {
|
|
|
193
172
|
return transformed
|
|
194
173
|
}
|
|
195
174
|
|
|
196
|
-
/**
|
|
197
|
-
* **Correctness.** Reduces relationship/upload fields to the IDs a client actually sends. Payload types the value as
|
|
198
|
-
* "an ID or the full related document" - but the populated-document form only appears in read responses;
|
|
199
|
-
* on create/update you always reference a relationship by its ID. So we drop that `$ref` option, leaving
|
|
200
|
-
* the bare ID. A single remaining target collapses inline (with a description naming the target
|
|
201
|
-
* collection); several targets become an `anyOf` of IDs.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* { oneOf: [{ type: 'string' }, { $ref: '#/$defs/posts' }] }
|
|
205
|
-
* → { type: 'string', description: 'The ID of the related "posts" document.' }
|
|
206
|
-
*/
|
|
207
|
-
const relationshipsToIds = (schema: JsonSchemaType): JsonSchemaType => {
|
|
208
|
-
if (!schema || typeof schema !== 'object') {
|
|
209
|
-
return schema
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const processed = { ...schema }
|
|
213
|
-
|
|
214
|
-
if (Array.isArray(processed.oneOf)) {
|
|
215
|
-
const isRelatedDocRef = (option: unknown): option is { $ref: string } =>
|
|
216
|
-
!!option && typeof option === 'object' && '$ref' in option
|
|
217
|
-
|
|
218
|
-
if (processed.oneOf.some(isRelatedDocRef)) {
|
|
219
|
-
// A relationship value is "an ID, or the populated related document". Keep the ID option(s) and
|
|
220
|
-
// drop the `$ref`s to the related collections, since a client only ever sends the ID.
|
|
221
|
-
const idOptions = processed.oneOf
|
|
222
|
-
.filter((option) => !isRelatedDocRef(option))
|
|
223
|
-
.map((option) => (typeof option === 'object' ? relationshipsToIds(option) : option))
|
|
224
|
-
const targetCollections = processed.oneOf
|
|
225
|
-
.filter(isRelatedDocRef)
|
|
226
|
-
.map((option) => option.$ref.replace('#/$defs/', ''))
|
|
227
|
-
|
|
228
|
-
if (idOptions.length === 1) {
|
|
229
|
-
delete processed.oneOf
|
|
230
|
-
Object.assign(processed, idOptions[0])
|
|
231
|
-
if (targetCollections.length > 0 && !processed.description) {
|
|
232
|
-
processed.description = `The ID of the related "${targetCollections.join('" or "')}" document.`
|
|
233
|
-
}
|
|
234
|
-
} else if (idOptions.length > 1) {
|
|
235
|
-
delete processed.oneOf
|
|
236
|
-
processed.anyOf = idOptions
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
processed.oneOf = processed.oneOf.map((option) =>
|
|
240
|
-
typeof option === 'object' ? relationshipsToIds(option) : option,
|
|
241
|
-
)
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (processed.properties && typeof processed.properties === 'object') {
|
|
246
|
-
processed.properties = Object.fromEntries(
|
|
247
|
-
Object.entries(processed.properties).map(([key, value]) => [
|
|
248
|
-
key,
|
|
249
|
-
typeof value === 'object' ? relationshipsToIds(value) : value,
|
|
250
|
-
]),
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (processed.items && typeof processed.items === 'object' && !Array.isArray(processed.items)) {
|
|
255
|
-
processed.items = relationshipsToIds(processed.items)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Lexical node unions and blocks live under `$defs` and have their own relationship fields, so walk
|
|
259
|
-
// those too — otherwise their `$ref`s would dangle once we don't bundle the related collections.
|
|
260
|
-
if (processed.$defs && typeof processed.$defs === 'object') {
|
|
261
|
-
processed.$defs = Object.fromEntries(
|
|
262
|
-
Object.entries(processed.$defs).map(([key, value]) => [
|
|
263
|
-
key,
|
|
264
|
-
typeof value === 'object' ? relationshipsToIds(value) : value,
|
|
265
|
-
]),
|
|
266
|
-
)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return processed
|
|
270
|
-
}
|
|
271
|
-
|
|
272
175
|
/**
|
|
273
176
|
* **Size.** Strips type-generation leftovers that bloat the schema without helping the model: the `tsType`
|
|
274
177
|
* hint (a `json-schema-to-typescript` extension; JSON Schema validators just ignore it, they don't reject it)
|
|
@@ -448,7 +351,7 @@ const deduplicateIntoDefinitions = (schema: JsonSchemaType): JsonSchemaType => {
|
|
|
448
351
|
if (!name) {
|
|
449
352
|
name = `shared_${nameByKey.size}`
|
|
450
353
|
nameByKey.set(key, name)
|
|
451
|
-
sharedEntries[name] = node
|
|
354
|
+
sharedEntries[name] = node
|
|
452
355
|
}
|
|
453
356
|
return { $ref: `#/$defs/${name}` }
|
|
454
357
|
}
|
package/dist/@types/assets.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/@types/assets.d.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { JSONField } from 'payload';
|
|
2
|
-
import type { SanitizedMCPPluginConfig } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Returns the API key collection's `access` field — a JSON field whose value
|
|
5
|
-
* is the `MCPAPIKeysDocAccessTree` the endpoint consults. The actual UI is
|
|
6
|
-
* a custom client component (`AccessField`) which renders a permissions
|
|
7
|
-
* matrix; the field's stored shape is just the runtime access tree.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getAccessField: ({ pluginConfig, }: {
|
|
10
|
-
pluginConfig: SanitizedMCPPluginConfig;
|
|
11
|
-
}) => JSONField;
|
|
12
|
-
//# sourceMappingURL=getAccessField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAccessField.d.ts","sourceRoot":"","sources":["../../src/collection/getAccessField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,OAAO,KAAK,EAAkC,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAQ3F;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,mBAE5B;IACD,YAAY,EAAE,wBAAwB,CAAA;CACvC,KAAG,SAiBH,CAAA"}
|