@payloadcms/plugin-mcp 4.0.0-internal.688c4d0 → 4.0.0-internal.697830c
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 +12 -5
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +74 -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 +68 -0
- package/dist/mcp/builtin/collections/countTool.js.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +13 -21
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +10 -2
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/duplicateTool.js +96 -0
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js +92 -0
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +45 -25
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +83 -0
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js +98 -0
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +32 -2
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js +81 -0
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +16 -24
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +27 -8
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js +64 -0
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +19 -22
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +79 -0
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js +94 -0
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +32 -2
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js +77 -0
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +14 -21
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtin/validateEntityData.js +1 -1
- package/dist/mcp/builtin/validateEntityData.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +69 -12
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +66 -10
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts +0 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +69 -27
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +82 -45
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +100 -92
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -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/filterFieldsByAccess.d.ts +28 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.d.ts.map +1 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js +71 -0
- package/dist/utils/schemaConversion/filterFieldsByAccess.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +5 -3
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +44 -12
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +5 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +15 -95
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +15 -40
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -1
- package/package.json +10 -16
- package/src/defaultAccess.ts +3 -0
- package/src/endpoint/access.ts +80 -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 +73 -0
- package/src/mcp/builtin/collections/countVersionsTool.ts +69 -0
- package/src/mcp/builtin/collections/createTool.ts +14 -15
- package/src/mcp/builtin/collections/deleteTool.ts +11 -2
- package/src/mcp/builtin/collections/duplicateTool.ts +134 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +119 -0
- package/src/mcp/builtin/collections/findTool.ts +58 -19
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +109 -0
- package/src/mcp/builtin/collections/findVersionsTool.ts +154 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +1 -1
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +37 -2
- package/src/mcp/builtin/collections/restoreVersionTool.ts +107 -0
- package/src/mcp/builtin/collections/updateTool.ts +16 -17
- package/src/mcp/builtin/getConfigInfoTool.ts +27 -4
- package/src/mcp/builtin/globals/countVersionsTool.ts +68 -0
- package/src/mcp/builtin/globals/findTool.ts +27 -18
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +103 -0
- package/src/mcp/builtin/globals/findVersionsTool.ts +147 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +37 -2
- package/src/mcp/builtin/globals/restoreVersionTool.ts +99 -0
- package/src/mcp/builtin/globals/updateTool.ts +16 -16
- package/src/mcp/builtin/validateEntityData.ts +1 -1
- package/src/mcp/builtinTools.ts +72 -16
- package/src/mcp/sanitizeMCPConfig.ts +48 -30
- package/src/stdio.ts +77 -45
- package/src/types.ts +108 -95
- package/src/utils/getPluginConfig.ts +1 -1
- package/src/utils/schemaConversion/filterFieldsByAccess.ts +123 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +45 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +12 -19
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +17 -114
- package/dist/@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/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/src/@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/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'
|
|
2
2
|
|
|
3
|
-
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server'
|
|
3
|
+
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker'
|
|
4
4
|
|
|
5
5
|
import type { JsonSchemaType, MCPToolResponse } from '../../types.js'
|
|
6
6
|
|
package/src/mcp/builtinTools.ts
CHANGED
|
@@ -8,19 +8,43 @@ import {
|
|
|
8
8
|
unlockCollectionTool,
|
|
9
9
|
verifyCollectionTool,
|
|
10
10
|
} from './builtin/collections/authTools.js'
|
|
11
|
+
import { countDocumentsTool } from './builtin/collections/countTool.js'
|
|
12
|
+
import { countVersionsTool } from './builtin/collections/countVersionsTool.js'
|
|
11
13
|
import { createDocumentTool } from './builtin/collections/createTool.js'
|
|
12
14
|
import { deleteDocumentsTool } from './builtin/collections/deleteTool.js'
|
|
15
|
+
import { duplicateDocumentTool } from './builtin/collections/duplicateTool.js'
|
|
16
|
+
import { findDistinctTool } from './builtin/collections/findDistinctTool.js'
|
|
13
17
|
import { findDocumentsTool } from './builtin/collections/findTool.js'
|
|
18
|
+
import { findVersionByIDTool } from './builtin/collections/findVersionByIDTool.js'
|
|
19
|
+
import { findVersionsTool } from './builtin/collections/findVersionsTool.js'
|
|
14
20
|
import { getCollectionSchemaTool } from './builtin/collections/getCollectionSchemaTool.js'
|
|
21
|
+
import { restoreVersionTool } from './builtin/collections/restoreVersionTool.js'
|
|
15
22
|
import { updateDocumentTool } from './builtin/collections/updateTool.js'
|
|
16
23
|
import { getConfigInfoTool } from './builtin/getConfigInfoTool.js'
|
|
24
|
+
import { countGlobalVersionsTool } from './builtin/globals/countVersionsTool.js'
|
|
17
25
|
import { findGlobalTool } from './builtin/globals/findTool.js'
|
|
26
|
+
import { findGlobalVersionByIDTool } from './builtin/globals/findVersionByIDTool.js'
|
|
27
|
+
import { findGlobalVersionsTool } from './builtin/globals/findVersionsTool.js'
|
|
18
28
|
import { getGlobalSchemaTool } from './builtin/globals/getGlobalSchemaTool.js'
|
|
29
|
+
import { restoreGlobalVersionTool } from './builtin/globals/restoreVersionTool.js'
|
|
19
30
|
import { updateGlobalTool } from './builtin/globals/updateTool.js'
|
|
20
31
|
|
|
32
|
+
type CollectionBuiltin = {
|
|
33
|
+
mcpName: string
|
|
34
|
+
requiresDuplicateEnabled?: boolean
|
|
35
|
+
requiresVersions?: boolean
|
|
36
|
+
tool: CollectionTool
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type GlobalBuiltin = {
|
|
40
|
+
mcpName: string
|
|
41
|
+
requiresVersions?: boolean
|
|
42
|
+
tool: GlobalTool
|
|
43
|
+
}
|
|
44
|
+
|
|
21
45
|
export const TOOL_BUILTINS = {
|
|
22
|
-
getConfigInfo: {
|
|
23
|
-
} satisfies Record<string, {
|
|
46
|
+
getConfigInfo: { mcpName: 'getConfigInfo', tool: getConfigInfoTool },
|
|
47
|
+
} satisfies Record<string, { mcpName: string; tool: Tool }>
|
|
24
48
|
|
|
25
49
|
/**
|
|
26
50
|
* The static built-in collection CRUD tools. Keys here are the source of truth
|
|
@@ -28,44 +52,76 @@ export const TOOL_BUILTINS = {
|
|
|
28
52
|
* automatically.
|
|
29
53
|
*/
|
|
30
54
|
export const COLLECTION_BUILTINS = {
|
|
55
|
+
count: { mcpName: 'countDocuments', tool: countDocumentsTool },
|
|
56
|
+
countVersions: { mcpName: 'countVersions', requiresVersions: true, tool: countVersionsTool },
|
|
31
57
|
create: { mcpName: 'createDocument', tool: createDocumentTool },
|
|
32
58
|
delete: { mcpName: 'deleteDocuments', tool: deleteDocumentsTool },
|
|
59
|
+
duplicate: {
|
|
60
|
+
mcpName: 'duplicateDocument',
|
|
61
|
+
requiresDuplicateEnabled: true,
|
|
62
|
+
tool: duplicateDocumentTool,
|
|
63
|
+
},
|
|
33
64
|
find: { mcpName: 'findDocuments', tool: findDocumentsTool },
|
|
65
|
+
findDistinct: { mcpName: 'findDistinct', tool: findDistinctTool },
|
|
66
|
+
findVersionByID: {
|
|
67
|
+
mcpName: 'findVersionByID',
|
|
68
|
+
requiresVersions: true,
|
|
69
|
+
tool: findVersionByIDTool,
|
|
70
|
+
},
|
|
71
|
+
findVersions: { mcpName: 'findVersions', requiresVersions: true, tool: findVersionsTool },
|
|
34
72
|
getCollectionSchema: { mcpName: 'getCollectionSchema', tool: getCollectionSchemaTool },
|
|
73
|
+
restoreVersion: { mcpName: 'restoreVersion', requiresVersions: true, tool: restoreVersionTool },
|
|
35
74
|
update: { mcpName: 'updateDocument', tool: updateDocumentTool },
|
|
36
|
-
} satisfies Record<string,
|
|
75
|
+
} satisfies Record<string, CollectionBuiltin>
|
|
37
76
|
|
|
38
77
|
/**
|
|
39
|
-
* The static auth tools surfaced under auth-enabled collections.
|
|
40
|
-
*
|
|
41
|
-
* for `MCPCollectionAuthToolName`.
|
|
78
|
+
* The static auth tools surfaced under auth-enabled collections. Keys are the
|
|
79
|
+
* source of truth for `MCPCollectionAuthToolName`.
|
|
42
80
|
*/
|
|
43
81
|
export const COLLECTION_AUTH_BUILTINS = {
|
|
44
|
-
auth: {
|
|
82
|
+
auth: { mcpName: 'auth', tool: authCollectionTool },
|
|
45
83
|
forgotPassword: {
|
|
46
|
-
label: 'Forgot Password',
|
|
47
84
|
mcpName: 'forgotPassword',
|
|
48
85
|
tool: forgotPasswordCollectionTool,
|
|
49
86
|
},
|
|
50
|
-
login: {
|
|
87
|
+
login: { mcpName: 'login', tool: loginCollectionTool },
|
|
51
88
|
resetPassword: {
|
|
52
|
-
label: 'Reset Password',
|
|
53
89
|
mcpName: 'resetPassword',
|
|
54
90
|
tool: resetPasswordCollectionTool,
|
|
55
91
|
},
|
|
56
|
-
unlock: {
|
|
57
|
-
verify: {
|
|
58
|
-
} satisfies Record<string, {
|
|
92
|
+
unlock: { mcpName: 'unlock', tool: unlockCollectionTool },
|
|
93
|
+
verify: { mcpName: 'verify', tool: verifyCollectionTool },
|
|
94
|
+
} satisfies Record<string, { mcpName: string; tool: CollectionTool }>
|
|
59
95
|
|
|
60
96
|
/**
|
|
61
97
|
* The static built-in global tools. Keys are the source of truth for
|
|
62
98
|
* `MCPGlobalBuiltinName`.
|
|
63
99
|
*/
|
|
64
100
|
export const GLOBAL_BUILTINS = {
|
|
101
|
+
countGlobalVersions: {
|
|
102
|
+
mcpName: 'countGlobalVersions',
|
|
103
|
+
requiresVersions: true,
|
|
104
|
+
tool: countGlobalVersionsTool,
|
|
105
|
+
},
|
|
65
106
|
find: { mcpName: 'findGlobal', tool: findGlobalTool },
|
|
107
|
+
findGlobalVersionByID: {
|
|
108
|
+
mcpName: 'findGlobalVersionByID',
|
|
109
|
+
requiresVersions: true,
|
|
110
|
+
tool: findGlobalVersionByIDTool,
|
|
111
|
+
},
|
|
112
|
+
findGlobalVersions: {
|
|
113
|
+
mcpName: 'findGlobalVersions',
|
|
114
|
+
requiresVersions: true,
|
|
115
|
+
tool: findGlobalVersionsTool,
|
|
116
|
+
},
|
|
66
117
|
getGlobalSchema: { mcpName: 'getGlobalSchema', tool: getGlobalSchemaTool },
|
|
118
|
+
restoreGlobalVersion: {
|
|
119
|
+
mcpName: 'restoreGlobalVersion',
|
|
120
|
+
requiresVersions: true,
|
|
121
|
+
tool: restoreGlobalVersionTool,
|
|
122
|
+
},
|
|
67
123
|
update: { mcpName: 'updateGlobal', tool: updateGlobalTool },
|
|
68
|
-
} satisfies Record<string,
|
|
124
|
+
} satisfies Record<string, GlobalBuiltin>
|
|
69
125
|
|
|
70
126
|
export type MCPCollectionBuiltinName = keyof typeof COLLECTION_BUILTINS
|
|
71
127
|
|
|
@@ -86,7 +142,7 @@ export const TOOL_BUILTIN_ENTRIES = Object.entries(TOOL_BUILTINS) as Array<
|
|
|
86
142
|
>
|
|
87
143
|
|
|
88
144
|
export const COLLECTION_BUILTIN_ENTRIES = Object.entries(COLLECTION_BUILTINS) as Array<
|
|
89
|
-
[MCPCollectionBuiltinName,
|
|
145
|
+
[MCPCollectionBuiltinName, CollectionBuiltin]
|
|
90
146
|
>
|
|
91
147
|
|
|
92
148
|
export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BUILTINS) as Array<
|
|
@@ -94,5 +150,5 @@ export const COLLECTION_AUTH_BUILTIN_ENTRIES = Object.entries(COLLECTION_AUTH_BU
|
|
|
94
150
|
>
|
|
95
151
|
|
|
96
152
|
export const GLOBAL_BUILTIN_ENTRIES = Object.entries(GLOBAL_BUILTINS) as Array<
|
|
97
|
-
[MCPGlobalBuiltinName,
|
|
153
|
+
[MCPGlobalBuiltinName, GlobalBuiltin]
|
|
98
154
|
>
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
SanitizedMCPPluginConfig,
|
|
18
18
|
} from '../types.js'
|
|
19
19
|
|
|
20
|
+
import { defaultAccess } from '../defaultAccess.js'
|
|
20
21
|
import {
|
|
21
22
|
COLLECTION_AUTH_BUILTIN_ENTRIES,
|
|
22
23
|
COLLECTION_AUTH_BUILTINS,
|
|
@@ -33,7 +34,6 @@ import {
|
|
|
33
34
|
* - Flattens `tools` / `prompts` / `resources` / per-collection / per-global
|
|
34
35
|
* tool maps into a single `items` array.
|
|
35
36
|
* - Applies built-in tools for collections and globals, respecting opt-out user overrides.
|
|
36
|
-
* - Applies the `userCollection` default
|
|
37
37
|
*
|
|
38
38
|
* Called once during plugin init. After that, `plugins['@payloadcms/plugin-mcp']
|
|
39
39
|
* ?.options` holds the sanitized result
|
|
@@ -55,13 +55,13 @@ export const sanitizeMCPConfig = ({
|
|
|
55
55
|
items.push(...sanitizeGlobalConfig({ global, pluginConfig }))
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
for (const [configKey, {
|
|
58
|
+
for (const [configKey, { mcpName, tool }] of TOOL_BUILTIN_ENTRIES) {
|
|
59
59
|
items.push({
|
|
60
60
|
type: 'tool',
|
|
61
61
|
configKey,
|
|
62
|
-
label,
|
|
62
|
+
label: tool.annotations?.title ?? configKey,
|
|
63
63
|
mcpName,
|
|
64
|
-
tool,
|
|
64
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
65
65
|
})
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -72,9 +72,9 @@ export const sanitizeMCPConfig = ({
|
|
|
72
72
|
items.push({
|
|
73
73
|
type: 'tool',
|
|
74
74
|
configKey,
|
|
75
|
-
label: configKey,
|
|
75
|
+
label: tool.annotations?.title ?? configKey,
|
|
76
76
|
mcpName: configKey,
|
|
77
|
-
tool,
|
|
77
|
+
tool: { ...tool, access: tool.access ?? defaultAccess },
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ export const sanitizeMCPConfig = ({
|
|
|
84
84
|
configKey,
|
|
85
85
|
label: prompt.title ?? configKey,
|
|
86
86
|
mcpName: configKey,
|
|
87
|
-
prompt,
|
|
87
|
+
prompt: { ...prompt, access: prompt.access ?? defaultAccess },
|
|
88
88
|
})
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -94,21 +94,16 @@ export const sanitizeMCPConfig = ({
|
|
|
94
94
|
configKey,
|
|
95
95
|
label: resource.title ?? configKey,
|
|
96
96
|
mcpName: configKey,
|
|
97
|
-
resource,
|
|
97
|
+
resource: { ...resource, access: resource.access ?? defaultAccess },
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// Mirror Payload's own admin.user detection (sanitize.ts) since plugins run first.
|
|
102
|
-
const firstCollectionWithAuth = config.collections!.find(({ auth }) => Boolean(auth))
|
|
103
|
-
|
|
104
101
|
return {
|
|
105
102
|
disabled: pluginConfig.disabled,
|
|
103
|
+
hooks: pluginConfig.hooks,
|
|
106
104
|
items,
|
|
107
105
|
mcp: pluginConfig.mcp,
|
|
108
|
-
|
|
109
|
-
overrideAuth: pluginConfig.overrideAuth,
|
|
110
|
-
userCollection:
|
|
111
|
-
pluginConfig.userCollection ?? config.admin?.user ?? firstCollectionWithAuth?.slug ?? 'users',
|
|
106
|
+
overrideGetAuthorizedMCP: pluginConfig.overrideGetAuthorizedMCP,
|
|
112
107
|
}
|
|
113
108
|
}
|
|
114
109
|
|
|
@@ -119,27 +114,43 @@ const sanitizeCollectionConfig = ({
|
|
|
119
114
|
collection: CollectionConfig | SanitizedCollectionConfig
|
|
120
115
|
pluginConfig: MCPPluginConfig
|
|
121
116
|
}): CollectionMCPItem[] => {
|
|
122
|
-
if (collection.slug === 'payload-mcp-api-keys') {
|
|
123
|
-
return []
|
|
124
|
-
}
|
|
125
117
|
const slug = collection.slug
|
|
126
118
|
const collectionPluginConfig = pluginConfig.collections?.[slug]
|
|
127
119
|
const items: CollectionMCPItem[] = []
|
|
120
|
+
/**
|
|
121
|
+
* Payload disables duplicate for auth collections by default unless the
|
|
122
|
+
* collection explicitly opts back in with `disableDuplicate: false`.
|
|
123
|
+
*/
|
|
124
|
+
const isDuplicateDisabled =
|
|
125
|
+
collection.disableDuplicate === true ||
|
|
126
|
+
(Boolean(collection.auth) && collection.disableDuplicate !== false)
|
|
128
127
|
|
|
129
|
-
for (const [
|
|
128
|
+
for (const [
|
|
129
|
+
toolKey,
|
|
130
|
+
{ mcpName, requiresDuplicateEnabled, requiresVersions, tool },
|
|
131
|
+
] of COLLECTION_BUILTIN_ENTRIES) {
|
|
132
|
+
if (requiresVersions && !collection.versions) {
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
135
|
+
if (requiresDuplicateEnabled && isDuplicateDisabled) {
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
130
138
|
const matchedConfigEntry = collectionPluginConfig?.tools?.[toolKey]
|
|
131
139
|
if (matchedConfigEntry === false) {
|
|
132
140
|
continue
|
|
133
141
|
}
|
|
134
142
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
143
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
135
144
|
items.push({
|
|
136
145
|
type: 'collectionTool',
|
|
137
146
|
collectionSlug: slug,
|
|
138
147
|
configKey: toolKey,
|
|
139
|
-
label:
|
|
148
|
+
label: annotations.title ?? toolKey,
|
|
140
149
|
mcpName,
|
|
141
150
|
tool: {
|
|
142
151
|
...tool,
|
|
152
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
153
|
+
annotations,
|
|
143
154
|
description: override?.description ?? tool.description,
|
|
144
155
|
overrideResponse:
|
|
145
156
|
override?.overrideResponse ??
|
|
@@ -150,21 +161,24 @@ const sanitizeCollectionConfig = ({
|
|
|
150
161
|
}
|
|
151
162
|
|
|
152
163
|
if (collection.auth) {
|
|
153
|
-
for (const [authToolKey, {
|
|
164
|
+
for (const [authToolKey, { mcpName, tool }] of COLLECTION_AUTH_BUILTIN_ENTRIES) {
|
|
154
165
|
const matchedConfigEntry = collectionPluginConfig?.tools?.[authToolKey]
|
|
155
166
|
if (!matchedConfigEntry) {
|
|
156
167
|
continue
|
|
157
168
|
}
|
|
158
169
|
// `true` means "enable, no override"; only the object form carries fields.
|
|
159
170
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
171
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
160
172
|
items.push({
|
|
161
173
|
type: 'collectionTool',
|
|
162
174
|
collectionSlug: slug,
|
|
163
175
|
configKey: authToolKey,
|
|
164
|
-
label,
|
|
176
|
+
label: annotations.title ?? authToolKey,
|
|
165
177
|
mcpName,
|
|
166
178
|
tool: {
|
|
167
179
|
...tool,
|
|
180
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
181
|
+
annotations,
|
|
168
182
|
description: override?.description ?? tool.description,
|
|
169
183
|
overrideResponse:
|
|
170
184
|
override?.overrideResponse ??
|
|
@@ -191,9 +205,9 @@ const sanitizeCollectionConfig = ({
|
|
|
191
205
|
type: 'collectionTool',
|
|
192
206
|
collectionSlug: slug,
|
|
193
207
|
configKey,
|
|
194
|
-
label: configKey,
|
|
208
|
+
label: customTool.annotations?.title ?? configKey,
|
|
195
209
|
mcpName: configKey,
|
|
196
|
-
tool: customTool,
|
|
210
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
197
211
|
})
|
|
198
212
|
}
|
|
199
213
|
|
|
@@ -211,20 +225,26 @@ const sanitizeGlobalConfig = ({
|
|
|
211
225
|
const globalPluginConfig = pluginConfig.globals?.[slug]
|
|
212
226
|
const items: GlobalMCPItem[] = []
|
|
213
227
|
|
|
214
|
-
for (const [toolKey, { mcpName, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
228
|
+
for (const [toolKey, { mcpName, requiresVersions, tool }] of GLOBAL_BUILTIN_ENTRIES) {
|
|
229
|
+
if (requiresVersions && !global.versions) {
|
|
230
|
+
continue
|
|
231
|
+
}
|
|
215
232
|
const matchedConfigEntry = globalPluginConfig?.tools?.[toolKey]
|
|
216
233
|
if (matchedConfigEntry === false) {
|
|
217
234
|
continue
|
|
218
235
|
}
|
|
219
236
|
const override = typeof matchedConfigEntry === 'object' ? matchedConfigEntry : undefined
|
|
237
|
+
const annotations = { ...tool.annotations, ...override?.annotations }
|
|
220
238
|
items.push({
|
|
221
239
|
type: 'globalTool',
|
|
222
240
|
configKey: toolKey,
|
|
223
241
|
globalSlug: slug,
|
|
224
|
-
label:
|
|
242
|
+
label: annotations.title ?? toolKey,
|
|
225
243
|
mcpName,
|
|
226
244
|
tool: {
|
|
227
245
|
...tool,
|
|
246
|
+
access: override?.access ?? tool.access ?? defaultAccess,
|
|
247
|
+
annotations,
|
|
228
248
|
description: override?.description ?? tool.description,
|
|
229
249
|
overrideResponse:
|
|
230
250
|
override?.overrideResponse ??
|
|
@@ -248,13 +268,11 @@ const sanitizeGlobalConfig = ({
|
|
|
248
268
|
type: 'globalTool',
|
|
249
269
|
configKey,
|
|
250
270
|
globalSlug: slug,
|
|
251
|
-
label: configKey,
|
|
271
|
+
label: customTool.annotations?.title ?? configKey,
|
|
252
272
|
mcpName: configKey,
|
|
253
|
-
tool: customTool,
|
|
273
|
+
tool: { ...customTool, access: customTool.access ?? defaultAccess },
|
|
254
274
|
})
|
|
255
275
|
}
|
|
256
276
|
|
|
257
277
|
return items
|
|
258
278
|
}
|
|
259
|
-
|
|
260
|
-
const capitalize = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1)
|
package/src/stdio.ts
CHANGED
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config, Plugin, SanitizedConfig } from 'payload'
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
|
-
import {
|
|
4
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio'
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
6
6
|
import { createLocalReq, getPayload } from 'payload'
|
|
7
7
|
import { findConfig } from 'payload/node'
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { SanitizedMCPPluginConfig } from './types.js'
|
|
10
10
|
|
|
11
|
+
import { getAuthorizedMCP } from './endpoint/access.js'
|
|
11
12
|
import { buildMcpServer } from './mcp/buildMcpServer.js'
|
|
12
13
|
import { sanitizeMCPConfig } from './mcp/sanitizeMCPConfig.js'
|
|
13
14
|
import { getPluginConfig } from './utils/getPluginConfig.js'
|
|
14
15
|
import { resolveProjectRoot } from './utils/resolveProjectRoot.js'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Starts Payload's MCP server over stdin and stdout.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* Set `PAYLOAD_MCP_AUTHORIZATION` to authenticate. In development,
|
|
21
|
+
* `PAYLOAD_MCP_OVERRIDE_ACCESS=true` skips access checks.
|
|
21
22
|
*/
|
|
22
23
|
export const runMcpStdio = async (): Promise<void> => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Payload's cwd-anchored `findConfig()` can't locate the project on
|
|
26
|
-
* its own. This module always lives inside the project's `node_modules`, so
|
|
27
|
-
* we derive the project root from its own path and `chdir` into it.
|
|
28
|
-
*
|
|
29
|
-
* An absolute `PAYLOAD_CONFIG_PATH` still overrides everything; unusual
|
|
30
|
-
* layouts (e.g. a monorepo where the package is hoisted above the app) can
|
|
31
|
-
* fall back to it. See the implementation of findConfig for details.
|
|
32
|
-
*/
|
|
24
|
+
// MCP clients may start this command from another folder. Move to the Payload
|
|
25
|
+
// project so findConfig() can find the config.
|
|
33
26
|
const projectRoot = resolveProjectRoot(fileURLToPath(import.meta.url))
|
|
34
27
|
if (projectRoot) {
|
|
35
28
|
process.chdir(projectRoot)
|
|
@@ -37,62 +30,101 @@ export const runMcpStdio = async (): Promise<void> => {
|
|
|
37
30
|
|
|
38
31
|
const configPath = findConfig()
|
|
39
32
|
const configModule = await import(pathToFileURL(configPath).toString())
|
|
40
|
-
const config = (await (configModule.default ?? configModule)) as
|
|
41
|
-
|
|
42
|
-
const payload = await getPayload({ config })
|
|
33
|
+
const config = (await (configModule.default ?? configModule)) as SanitizedConfig
|
|
43
34
|
|
|
44
35
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
36
|
+
* stdout is only for MCP messages. The spec says the server must not write
|
|
37
|
+
* logs there and may write them to stderr instead.
|
|
38
|
+
*
|
|
39
|
+
* The 2.0 client library recovers from stray stdout logs, but that behavior is not
|
|
40
|
+
* guaranteed. Move Payload logs to stderr so Payload does not add invalid data
|
|
41
|
+
* to stdout. Keep options from configurable loggers. Replace pre-built loggers
|
|
42
|
+
* because their output cannot be redirected.
|
|
43
|
+
*
|
|
44
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#stdio
|
|
49
45
|
*/
|
|
46
|
+
const loggerConfig: { logger?: Config['logger'] } = config
|
|
47
|
+
if (
|
|
48
|
+
loggerConfig.logger &&
|
|
49
|
+
typeof loggerConfig.logger === 'object' &&
|
|
50
|
+
'options' in loggerConfig.logger
|
|
51
|
+
) {
|
|
52
|
+
loggerConfig.logger.destination = process.stderr
|
|
53
|
+
} else {
|
|
54
|
+
loggerConfig.logger = { destination: process.stderr, options: {} }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const payload = await getPayload({ config, cron: false, disableOnInit: true })
|
|
58
|
+
|
|
50
59
|
let pluginConfig: SanitizedMCPPluginConfig
|
|
51
60
|
try {
|
|
52
61
|
pluginConfig = getPluginConfig({ config: payload.config })
|
|
53
62
|
} catch {
|
|
63
|
+
// The command also works when mcpPlugin() is not in the Payload config.
|
|
54
64
|
pluginConfig = sanitizeMCPConfig({ config: payload.config, pluginConfig: {} })
|
|
55
65
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
const fallbackPlugin: Plugin = (config) => config
|
|
67
|
+
Object.assign(fallbackPlugin, {
|
|
68
|
+
slug: '@payloadcms/plugin-mcp',
|
|
69
|
+
sanitizedOptions: pluginConfig,
|
|
70
|
+
})
|
|
71
|
+
payload.config.plugins ??= []
|
|
72
|
+
payload.config.plugins.push(fallbackPlugin)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const overrideAccessEnv = process.env.PAYLOAD_MCP_OVERRIDE_ACCESS
|
|
76
|
+
let overrideAccess = false
|
|
77
|
+
|
|
78
|
+
if (overrideAccessEnv === 'true') {
|
|
79
|
+
overrideAccess = true
|
|
80
|
+
} else if (overrideAccessEnv && overrideAccessEnv !== 'false') {
|
|
81
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS must be "true" or "false".')
|
|
82
|
+
}
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
if (overrideAccess && process.env.NODE_ENV !== 'development') {
|
|
85
|
+
throw new Error('PAYLOAD_MCP_OVERRIDE_ACCESS is only available in development.')
|
|
63
86
|
}
|
|
64
87
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
user: null,
|
|
88
|
+
const headers = new Headers()
|
|
89
|
+
if (process.env.PAYLOAD_MCP_AUTHORIZATION) {
|
|
90
|
+
headers.set('Authorization', process.env.PAYLOAD_MCP_AUTHORIZATION)
|
|
69
91
|
}
|
|
70
92
|
|
|
71
|
-
const req = await createLocalReq({}, payload)
|
|
93
|
+
const req = await createLocalReq({ req: { headers } }, payload)
|
|
72
94
|
req.payloadAPI = 'MCP' as const
|
|
95
|
+
const authorizedMCP = await getAuthorizedMCP({ overrideAccess, req })
|
|
73
96
|
|
|
74
|
-
const
|
|
97
|
+
const stdioServer = serveStdio(() => buildMcpServer({ authorizedMCP, pluginConfig, req }), {
|
|
98
|
+
onerror: (err) => {
|
|
99
|
+
// MCP messages use stdout, so write SDK errors to stderr.
|
|
100
|
+
console.error('[payload-mcp] error serving MCP over stdio:', err)
|
|
101
|
+
},
|
|
102
|
+
})
|
|
75
103
|
|
|
76
|
-
|
|
77
|
-
|
|
104
|
+
// Close the MCP server and Payload when the client disconnects or the process stops.
|
|
105
|
+
let isShuttingDown = false
|
|
106
|
+
const shutdown = async () => {
|
|
107
|
+
if (isShuttingDown) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
isShuttingDown = true
|
|
78
111
|
|
|
79
|
-
// Process now lives until stdin closes. Wire graceful shutdown so DB
|
|
80
|
-
// connections (and any other Payload-managed resources) get released.
|
|
81
|
-
const shutdown = async (code = 0) => {
|
|
82
112
|
try {
|
|
83
|
-
await
|
|
113
|
+
await stdioServer.close()
|
|
84
114
|
} catch (err) {
|
|
85
115
|
console.error('[payload-mcp] error closing server:', err)
|
|
86
116
|
}
|
|
117
|
+
|
|
87
118
|
try {
|
|
88
119
|
await payload.destroy()
|
|
89
120
|
} catch (err) {
|
|
90
121
|
console.error('[payload-mcp] error destroying payload:', err)
|
|
91
122
|
}
|
|
92
|
-
|
|
123
|
+
|
|
124
|
+
process.exit(0)
|
|
93
125
|
}
|
|
94
126
|
|
|
95
|
-
process.
|
|
96
|
-
process.
|
|
97
|
-
process.stdin.
|
|
127
|
+
process.once('SIGINT', () => void shutdown())
|
|
128
|
+
process.once('SIGTERM', () => void shutdown())
|
|
129
|
+
process.stdin.once('close', () => void shutdown())
|
|
98
130
|
}
|