@payloadcms/plugin-mcp 4.0.0-internal.5b1e7cd → 4.0.0-internal.688c4d0
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/bin.js +39 -0
- package/dist/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/collection/getAccessField.d.ts +12 -0
- package/dist/collection/getAccessField.d.ts.map +1 -0
- package/dist/collection/getAccessField.js +72 -0
- package/dist/collection/getAccessField.js.map +1 -0
- package/dist/collection/index.d.ts +6 -0
- package/dist/collection/index.d.ts.map +1 -0
- package/dist/collection/index.js +105 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/components/APIKeyField/index.client.d.ts +9 -0
- package/dist/components/APIKeyField/index.client.d.ts.map +1 -0
- package/dist/components/APIKeyField/index.client.js +85 -0
- package/dist/components/APIKeyField/index.client.js.map +1 -0
- package/dist/components/APIKeyField/index.css +105 -0
- package/dist/components/APIKeysEmptyState/index.client.d.ts +4 -0
- package/dist/components/APIKeysEmptyState/index.client.d.ts.map +1 -0
- package/dist/components/APIKeysEmptyState/index.client.js +21 -0
- package/dist/components/APIKeysEmptyState/index.client.js.map +1 -0
- package/dist/components/AccessField/index.client.d.ts +10 -0
- package/dist/components/AccessField/index.client.d.ts.map +1 -0
- package/dist/components/AccessField/index.client.js +247 -0
- package/dist/components/AccessField/index.client.js.map +1 -0
- package/dist/components/AccessField/index.css +99 -0
- package/dist/components/SettingsMenu/index.client.d.ts +8 -0
- package/dist/components/SettingsMenu/index.client.d.ts.map +1 -0
- package/dist/components/SettingsMenu/index.client.js +29 -0
- package/dist/components/SettingsMenu/index.client.js.map +1 -0
- package/dist/defineTool.d.ts +26 -0
- package/dist/defineTool.d.ts.map +1 -0
- package/dist/defineTool.js +37 -0
- package/dist/defineTool.js.map +1 -0
- package/dist/endpoint/access.d.ts +10 -0
- package/dist/endpoint/access.d.ts.map +1 -0
- package/dist/endpoint/access.js +122 -0
- package/dist/endpoint/access.js.map +1 -0
- package/dist/endpoint/index.d.ts +3 -0
- package/dist/endpoint/index.d.ts.map +1 -0
- package/dist/endpoint/index.js +36 -0
- package/dist/endpoint/index.js.map +1 -0
- package/dist/exports/client.d.ts +5 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +7 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +87 -67
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +19 -0
- package/dist/mcp/buildMcpServer.d.ts.map +1 -0
- package/dist/mcp/buildMcpServer.js +199 -0
- package/dist/mcp/buildMcpServer.js.map +1 -0
- package/dist/mcp/builtin/collections/authTools.d.ts +7 -0
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/authTools.js +250 -0
- package/dist/mcp/builtin/collections/authTools.js.map +1 -0
- package/dist/mcp/builtin/collections/createTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/createTool.js +94 -0
- package/dist/mcp/builtin/collections/createTool.js.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/deleteTool.js +102 -0
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -0
- package/dist/mcp/builtin/collections/findTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/findTool.js +144 -0
- package/dist/mcp/builtin/collections/findTool.js.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +9 -0
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js +60 -0
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +35 -0
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/updateTool.js +199 -0
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts +2 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.js +49 -0
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -0
- package/dist/mcp/builtin/globals/findTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/findTool.js +76 -0
- package/dist/mcp/builtin/globals/findTool.js.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +35 -0
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +94 -0
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
- package/dist/mcp/builtin/validateEntityData.d.ts +14 -0
- package/dist/mcp/builtin/validateEntityData.d.ts.map +1 -0
- package/dist/mcp/builtin/validateEntityData.js +82 -0
- package/dist/mcp/builtin/validateEntityData.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +105 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -0
- package/dist/mcp/builtinTools.js +107 -0
- package/dist/mcp/builtinTools.js.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts +17 -0
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -0
- package/dist/mcp/sanitizeMCPConfig.js +188 -0
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -0
- package/dist/stdio.d.ts +8 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +89 -0
- package/dist/stdio.js.map +1 -0
- package/dist/translations/index.d.ts +11 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +92 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/translations/languages/ar.d.ts +31 -0
- package/dist/translations/languages/ar.d.ts.map +1 -0
- package/dist/translations/languages/ar.js +34 -0
- package/dist/translations/languages/ar.js.map +1 -0
- package/dist/translations/languages/az.d.ts +31 -0
- package/dist/translations/languages/az.d.ts.map +1 -0
- package/dist/translations/languages/az.js +34 -0
- package/dist/translations/languages/az.js.map +1 -0
- package/dist/translations/languages/bg.d.ts +31 -0
- package/dist/translations/languages/bg.d.ts.map +1 -0
- package/dist/translations/languages/bg.js +34 -0
- package/dist/translations/languages/bg.js.map +1 -0
- package/dist/translations/languages/bnBd.d.ts +31 -0
- package/dist/translations/languages/bnBd.d.ts.map +1 -0
- package/dist/translations/languages/bnBd.js +34 -0
- package/dist/translations/languages/bnBd.js.map +1 -0
- package/dist/translations/languages/bnIn.d.ts +31 -0
- package/dist/translations/languages/bnIn.d.ts.map +1 -0
- package/dist/translations/languages/bnIn.js +34 -0
- package/dist/translations/languages/bnIn.js.map +1 -0
- package/dist/translations/languages/ca.d.ts +31 -0
- package/dist/translations/languages/ca.d.ts.map +1 -0
- package/dist/translations/languages/ca.js +34 -0
- package/dist/translations/languages/ca.js.map +1 -0
- package/dist/translations/languages/cs.d.ts +31 -0
- package/dist/translations/languages/cs.d.ts.map +1 -0
- package/dist/translations/languages/cs.js +34 -0
- package/dist/translations/languages/cs.js.map +1 -0
- package/dist/translations/languages/da.d.ts +31 -0
- package/dist/translations/languages/da.d.ts.map +1 -0
- package/dist/translations/languages/da.js +34 -0
- package/dist/translations/languages/da.js.map +1 -0
- package/dist/translations/languages/de.d.ts +31 -0
- package/dist/translations/languages/de.d.ts.map +1 -0
- package/dist/translations/languages/de.js +34 -0
- package/dist/translations/languages/de.js.map +1 -0
- package/dist/translations/languages/en.d.ts +31 -0
- package/dist/translations/languages/en.d.ts.map +1 -0
- package/dist/translations/languages/en.js +34 -0
- package/dist/translations/languages/en.js.map +1 -0
- package/dist/translations/languages/es.d.ts +31 -0
- package/dist/translations/languages/es.d.ts.map +1 -0
- package/dist/translations/languages/es.js +34 -0
- package/dist/translations/languages/es.js.map +1 -0
- package/dist/translations/languages/et.d.ts +31 -0
- package/dist/translations/languages/et.d.ts.map +1 -0
- package/dist/translations/languages/et.js +34 -0
- package/dist/translations/languages/et.js.map +1 -0
- package/dist/translations/languages/fa.d.ts +31 -0
- package/dist/translations/languages/fa.d.ts.map +1 -0
- package/dist/translations/languages/fa.js +34 -0
- package/dist/translations/languages/fa.js.map +1 -0
- package/dist/translations/languages/fr.d.ts +31 -0
- package/dist/translations/languages/fr.d.ts.map +1 -0
- package/dist/translations/languages/fr.js +34 -0
- package/dist/translations/languages/fr.js.map +1 -0
- package/dist/translations/languages/he.d.ts +31 -0
- package/dist/translations/languages/he.d.ts.map +1 -0
- package/dist/translations/languages/he.js +34 -0
- package/dist/translations/languages/he.js.map +1 -0
- package/dist/translations/languages/hr.d.ts +31 -0
- package/dist/translations/languages/hr.d.ts.map +1 -0
- package/dist/translations/languages/hr.js +34 -0
- package/dist/translations/languages/hr.js.map +1 -0
- package/dist/translations/languages/hu.d.ts +31 -0
- package/dist/translations/languages/hu.d.ts.map +1 -0
- package/dist/translations/languages/hu.js +34 -0
- package/dist/translations/languages/hu.js.map +1 -0
- package/dist/translations/languages/hy.d.ts +31 -0
- package/dist/translations/languages/hy.d.ts.map +1 -0
- package/dist/translations/languages/hy.js +34 -0
- package/dist/translations/languages/hy.js.map +1 -0
- package/dist/translations/languages/id.d.ts +31 -0
- package/dist/translations/languages/id.d.ts.map +1 -0
- package/dist/translations/languages/id.js +34 -0
- package/dist/translations/languages/id.js.map +1 -0
- package/dist/translations/languages/is.d.ts +31 -0
- package/dist/translations/languages/is.d.ts.map +1 -0
- package/dist/translations/languages/is.js +34 -0
- package/dist/translations/languages/is.js.map +1 -0
- package/dist/translations/languages/it.d.ts +31 -0
- package/dist/translations/languages/it.d.ts.map +1 -0
- package/dist/translations/languages/it.js +34 -0
- package/dist/translations/languages/it.js.map +1 -0
- package/dist/translations/languages/ja.d.ts +31 -0
- package/dist/translations/languages/ja.d.ts.map +1 -0
- package/dist/translations/languages/ja.js +34 -0
- package/dist/translations/languages/ja.js.map +1 -0
- package/dist/translations/languages/ko.d.ts +31 -0
- package/dist/translations/languages/ko.d.ts.map +1 -0
- package/dist/translations/languages/ko.js +34 -0
- package/dist/translations/languages/ko.js.map +1 -0
- package/dist/translations/languages/lt.d.ts +31 -0
- package/dist/translations/languages/lt.d.ts.map +1 -0
- package/dist/translations/languages/lt.js +34 -0
- package/dist/translations/languages/lt.js.map +1 -0
- package/dist/translations/languages/lv.d.ts +31 -0
- package/dist/translations/languages/lv.d.ts.map +1 -0
- package/dist/translations/languages/lv.js +34 -0
- package/dist/translations/languages/lv.js.map +1 -0
- package/dist/translations/languages/my.d.ts +31 -0
- package/dist/translations/languages/my.d.ts.map +1 -0
- package/dist/translations/languages/my.js +34 -0
- package/dist/translations/languages/my.js.map +1 -0
- package/dist/translations/languages/nb.d.ts +31 -0
- package/dist/translations/languages/nb.d.ts.map +1 -0
- package/dist/translations/languages/nb.js +34 -0
- package/dist/translations/languages/nb.js.map +1 -0
- package/dist/translations/languages/nl.d.ts +31 -0
- package/dist/translations/languages/nl.d.ts.map +1 -0
- package/dist/translations/languages/nl.js +34 -0
- package/dist/translations/languages/nl.js.map +1 -0
- package/dist/translations/languages/pl.d.ts +31 -0
- package/dist/translations/languages/pl.d.ts.map +1 -0
- package/dist/translations/languages/pl.js +34 -0
- package/dist/translations/languages/pl.js.map +1 -0
- package/dist/translations/languages/pt.d.ts +31 -0
- package/dist/translations/languages/pt.d.ts.map +1 -0
- package/dist/translations/languages/pt.js +34 -0
- package/dist/translations/languages/pt.js.map +1 -0
- package/dist/translations/languages/ro.d.ts +31 -0
- package/dist/translations/languages/ro.d.ts.map +1 -0
- package/dist/translations/languages/ro.js +34 -0
- package/dist/translations/languages/ro.js.map +1 -0
- package/dist/translations/languages/rs.d.ts +31 -0
- package/dist/translations/languages/rs.d.ts.map +1 -0
- package/dist/translations/languages/rs.js +34 -0
- package/dist/translations/languages/rs.js.map +1 -0
- package/dist/translations/languages/rsLatin.d.ts +31 -0
- package/dist/translations/languages/rsLatin.d.ts.map +1 -0
- package/dist/translations/languages/rsLatin.js +34 -0
- package/dist/translations/languages/rsLatin.js.map +1 -0
- package/dist/translations/languages/ru.d.ts +31 -0
- package/dist/translations/languages/ru.d.ts.map +1 -0
- package/dist/translations/languages/ru.js +34 -0
- package/dist/translations/languages/ru.js.map +1 -0
- package/dist/translations/languages/sk.d.ts +31 -0
- package/dist/translations/languages/sk.d.ts.map +1 -0
- package/dist/translations/languages/sk.js +34 -0
- package/dist/translations/languages/sk.js.map +1 -0
- package/dist/translations/languages/sl.d.ts +31 -0
- package/dist/translations/languages/sl.d.ts.map +1 -0
- package/dist/translations/languages/sl.js +34 -0
- package/dist/translations/languages/sl.js.map +1 -0
- package/dist/translations/languages/sv.d.ts +31 -0
- package/dist/translations/languages/sv.d.ts.map +1 -0
- package/dist/translations/languages/sv.js +34 -0
- package/dist/translations/languages/sv.js.map +1 -0
- package/dist/translations/languages/ta.d.ts +31 -0
- package/dist/translations/languages/ta.d.ts.map +1 -0
- package/dist/translations/languages/ta.js +34 -0
- package/dist/translations/languages/ta.js.map +1 -0
- package/dist/translations/languages/th.d.ts +31 -0
- package/dist/translations/languages/th.d.ts.map +1 -0
- package/dist/translations/languages/th.js +34 -0
- package/dist/translations/languages/th.js.map +1 -0
- package/dist/translations/languages/tr.d.ts +31 -0
- package/dist/translations/languages/tr.d.ts.map +1 -0
- package/dist/translations/languages/tr.js +34 -0
- package/dist/translations/languages/tr.js.map +1 -0
- package/dist/translations/languages/uk.d.ts +31 -0
- package/dist/translations/languages/uk.d.ts.map +1 -0
- package/dist/translations/languages/uk.js +34 -0
- package/dist/translations/languages/uk.js.map +1 -0
- package/dist/translations/languages/vi.d.ts +31 -0
- package/dist/translations/languages/vi.d.ts.map +1 -0
- package/dist/translations/languages/vi.js +34 -0
- package/dist/translations/languages/vi.js.map +1 -0
- package/dist/translations/languages/zh.d.ts +31 -0
- package/dist/translations/languages/zh.d.ts.map +1 -0
- package/dist/translations/languages/zh.js +34 -0
- package/dist/translations/languages/zh.js.map +1 -0
- package/dist/translations/languages/zhTw.d.ts +31 -0
- package/dist/translations/languages/zhTw.d.ts.map +1 -0
- package/dist/translations/languages/zhTw.js +34 -0
- package/dist/translations/languages/zhTw.js.map +1 -0
- package/dist/translations/types.d.ts +32 -0
- package/dist/translations/types.d.ts.map +1 -0
- package/dist/translations/types.js +3 -0
- package/dist/translations/types.js.map +1 -0
- package/dist/types.d.ts +255 -454
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/getLogger.d.ts +10 -0
- package/dist/utils/getLogger.d.ts.map +1 -0
- package/dist/utils/getLogger.js +22 -0
- package/dist/utils/getLogger.js.map +1 -0
- package/dist/utils/getPluginConfig.d.ts +12 -0
- package/dist/utils/getPluginConfig.d.ts.map +1 -0
- package/dist/utils/getPluginConfig.js +15 -0
- package/dist/utils/getPluginConfig.js.map +1 -0
- package/dist/utils/localAPIDefaults.d.ts +20 -0
- package/dist/utils/localAPIDefaults.d.ts.map +1 -0
- package/dist/utils/localAPIDefaults.js +19 -0
- package/dist/utils/localAPIDefaults.js.map +1 -0
- package/dist/utils/resolveProjectRoot.d.ts +7 -0
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -0
- package/dist/utils/resolveProjectRoot.js +15 -0
- package/dist/utils/resolveProjectRoot.js.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +11 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js +34 -0
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +1 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +15 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +464 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +158 -0
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +1 -0
- package/dist/utils/toStandardSchema.d.ts +5 -0
- package/dist/utils/toStandardSchema.d.ts.map +1 -0
- package/dist/utils/toStandardSchema.js +4 -0
- package/dist/utils/toStandardSchema.js.map +1 -0
- package/dist/utils/whereSchema.d.ts +9 -0
- package/dist/utils/whereSchema.d.ts.map +1 -0
- package/dist/utils/whereSchema.js +13 -0
- package/dist/utils/whereSchema.js.map +1 -0
- package/package.json +36 -10
- package/src/@types/assets.d.ts +3 -0
- package/src/collection/getAccessField.ts +84 -0
- package/src/collection/index.ts +105 -0
- package/src/components/APIKeyField/index.client.tsx +73 -0
- package/src/components/APIKeyField/index.css +105 -0
- package/src/components/APIKeysEmptyState/index.client.tsx +36 -0
- package/src/components/AccessField/index.client.tsx +299 -0
- package/src/components/AccessField/index.css +99 -0
- package/src/components/SettingsMenu/index.client.tsx +34 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +144 -0
- package/src/endpoint/index.ts +35 -0
- package/src/exports/client.ts +5 -0
- package/src/index.ts +82 -86
- package/src/mcp/buildMcpServer.ts +257 -0
- package/src/mcp/builtin/collections/authTools.ts +233 -0
- package/src/mcp/builtin/collections/createTool.ts +112 -0
- package/src/mcp/builtin/collections/deleteTool.ts +116 -0
- package/src/mcp/builtin/collections/findTool.ts +177 -0
- package/src/mcp/builtin/collections/formatCollectionError.ts +84 -0
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +28 -0
- package/src/mcp/builtin/collections/updateTool.ts +211 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +44 -0
- package/src/mcp/builtin/globals/findTool.ts +96 -0
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +28 -0
- package/src/mcp/builtin/globals/updateTool.ts +115 -0
- package/src/mcp/builtin/validateEntityData.ts +132 -0
- package/src/mcp/builtinTools.ts +98 -0
- package/src/mcp/sanitizeMCPConfig.ts +260 -0
- package/src/stdio.ts +98 -0
- package/src/translations/index.ts +108 -0
- package/src/translations/languages/ar.ts +35 -0
- package/src/translations/languages/az.ts +35 -0
- package/src/translations/languages/bg.ts +35 -0
- package/src/translations/languages/bnBd.ts +35 -0
- package/src/translations/languages/bnIn.ts +35 -0
- package/src/translations/languages/ca.ts +35 -0
- package/src/translations/languages/cs.ts +35 -0
- package/src/translations/languages/da.ts +35 -0
- package/src/translations/languages/de.ts +35 -0
- package/src/translations/languages/en.ts +35 -0
- package/src/translations/languages/es.ts +35 -0
- package/src/translations/languages/et.ts +35 -0
- package/src/translations/languages/fa.ts +35 -0
- package/src/translations/languages/fr.ts +35 -0
- package/src/translations/languages/he.ts +35 -0
- package/src/translations/languages/hr.ts +35 -0
- package/src/translations/languages/hu.ts +35 -0
- package/src/translations/languages/hy.ts +35 -0
- package/src/translations/languages/id.ts +35 -0
- package/src/translations/languages/is.ts +35 -0
- package/src/translations/languages/it.ts +35 -0
- package/src/translations/languages/ja.ts +35 -0
- package/src/translations/languages/ko.ts +35 -0
- package/src/translations/languages/lt.ts +35 -0
- package/src/translations/languages/lv.ts +35 -0
- package/src/translations/languages/my.ts +35 -0
- package/src/translations/languages/nb.ts +35 -0
- package/src/translations/languages/nl.ts +35 -0
- package/src/translations/languages/pl.ts +35 -0
- package/src/translations/languages/pt.ts +35 -0
- package/src/translations/languages/ro.ts +35 -0
- package/src/translations/languages/rs.ts +35 -0
- package/src/translations/languages/rsLatin.ts +35 -0
- package/src/translations/languages/ru.ts +35 -0
- package/src/translations/languages/sk.ts +35 -0
- package/src/translations/languages/sl.ts +35 -0
- package/src/translations/languages/sv.ts +35 -0
- package/src/translations/languages/ta.ts +35 -0
- package/src/translations/languages/th.ts +35 -0
- package/src/translations/languages/tr.ts +35 -0
- package/src/translations/languages/uk.ts +35 -0
- package/src/translations/languages/vi.ts +35 -0
- package/src/translations/languages/zh.ts +35 -0
- package/src/translations/languages/zhTw.ts +35 -0
- package/src/translations/types.ts +34 -0
- package/src/types.ts +295 -490
- package/src/utils/getLogger.ts +22 -0
- package/src/utils/getPluginConfig.ts +24 -0
- package/src/utils/localAPIDefaults.ts +22 -0
- package/src/utils/resolveProjectRoot.ts +17 -0
- package/src/utils/schemaConversion/getEntityInputSchema.ts +78 -0
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +103 -0
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +529 -0
- package/src/utils/toStandardSchema.ts +9 -0
- package/src/utils/whereSchema.ts +24 -0
- package/dist/collections/createApiKeysCollection.d.ts +0 -7
- package/dist/collections/createApiKeysCollection.d.ts.map +0 -1
- package/dist/collections/createApiKeysCollection.js +0 -317
- package/dist/collections/createApiKeysCollection.js.map +0 -1
- package/dist/defaults.d.ts +0 -4
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js +0 -5
- package/dist/defaults.js.map +0 -1
- package/dist/endpoints/mcp.d.ts +0 -4
- package/dist/endpoints/mcp.d.ts.map +0 -1
- package/dist/endpoints/mcp.js +0 -71
- package/dist/endpoints/mcp.js.map +0 -1
- package/dist/mcp/createRequest.d.ts +0 -3
- package/dist/mcp/createRequest.d.ts.map +0 -1
- package/dist/mcp/createRequest.js +0 -14
- package/dist/mcp/createRequest.js.map +0 -1
- package/dist/mcp/getMcpHandler.d.ts +0 -4
- package/dist/mcp/getMcpHandler.d.ts.map +0 -1
- package/dist/mcp/getMcpHandler.js +0 -231
- package/dist/mcp/getMcpHandler.js.map +0 -1
- package/dist/mcp/helpers/config.d.ts +0 -22
- package/dist/mcp/helpers/config.d.ts.map +0 -1
- package/dist/mcp/helpers/config.js +0 -153
- package/dist/mcp/helpers/config.js.map +0 -1
- package/dist/mcp/helpers/fields.d.ts +0 -19
- package/dist/mcp/helpers/fields.d.ts.map +0 -1
- package/dist/mcp/helpers/fields.js +0 -102
- package/dist/mcp/helpers/fields.js.map +0 -1
- package/dist/mcp/helpers/fileValidation.d.ts +0 -67
- package/dist/mcp/helpers/fileValidation.d.ts.map +0 -1
- package/dist/mcp/helpers/fileValidation.js +0 -267
- package/dist/mcp/helpers/fileValidation.js.map +0 -1
- package/dist/mcp/registerTool.d.ts +0 -6
- package/dist/mcp/registerTool.d.ts.map +0 -1
- package/dist/mcp/registerTool.js +0 -18
- package/dist/mcp/registerTool.js.map +0 -1
- package/dist/mcp/tools/auth/auth.d.ts +0 -4
- package/dist/mcp/tools/auth/auth.d.ts.map +0 -1
- package/dist/mcp/tools/auth/auth.js +0 -57
- package/dist/mcp/tools/auth/auth.js.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/forgotPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/forgotPassword.js +0 -48
- package/dist/mcp/tools/auth/forgotPassword.js.map +0 -1
- package/dist/mcp/tools/auth/login.d.ts +0 -4
- package/dist/mcp/tools/auth/login.d.ts.map +0 -1
- package/dist/mcp/tools/auth/login.js +0 -51
- package/dist/mcp/tools/auth/login.js.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.d.ts +0 -4
- package/dist/mcp/tools/auth/resetPassword.d.ts.map +0 -1
- package/dist/mcp/tools/auth/resetPassword.js +0 -49
- package/dist/mcp/tools/auth/resetPassword.js.map +0 -1
- package/dist/mcp/tools/auth/unlock.d.ts +0 -4
- package/dist/mcp/tools/auth/unlock.d.ts.map +0 -1
- package/dist/mcp/tools/auth/unlock.js +0 -48
- package/dist/mcp/tools/auth/unlock.js.map +0 -1
- package/dist/mcp/tools/auth/verify.d.ts +0 -4
- package/dist/mcp/tools/auth/verify.d.ts.map +0 -1
- package/dist/mcp/tools/auth/verify.js +0 -45
- package/dist/mcp/tools/auth/verify.js.map +0 -1
- package/dist/mcp/tools/collection/create.d.ts +0 -10
- package/dist/mcp/tools/collection/create.d.ts.map +0 -1
- package/dist/mcp/tools/collection/create.js +0 -139
- package/dist/mcp/tools/collection/create.js.map +0 -1
- package/dist/mcp/tools/collection/delete.d.ts +0 -10
- package/dist/mcp/tools/collection/delete.d.ts.map +0 -1
- package/dist/mcp/tools/collection/delete.js +0 -154
- package/dist/mcp/tools/collection/delete.js.map +0 -1
- package/dist/mcp/tools/collection/find.d.ts +0 -10
- package/dist/mcp/tools/collection/find.d.ts.map +0 -1
- package/dist/mcp/tools/collection/find.js +0 -165
- package/dist/mcp/tools/collection/find.js.map +0 -1
- package/dist/mcp/tools/collection/update.d.ts +0 -10
- package/dist/mcp/tools/collection/update.d.ts.map +0 -1
- package/dist/mcp/tools/collection/update.js +0 -209
- package/dist/mcp/tools/collection/update.js.map +0 -1
- package/dist/mcp/tools/config/find.d.ts +0 -10
- package/dist/mcp/tools/config/find.d.ts.map +0 -1
- package/dist/mcp/tools/config/find.js +0 -97
- package/dist/mcp/tools/config/find.js.map +0 -1
- package/dist/mcp/tools/config/update.d.ts +0 -10
- package/dist/mcp/tools/config/update.d.ts.map +0 -1
- package/dist/mcp/tools/config/update.js +0 -215
- package/dist/mcp/tools/config/update.js.map +0 -1
- package/dist/mcp/tools/global/find.d.ts +0 -5
- package/dist/mcp/tools/global/find.d.ts.map +0 -1
- package/dist/mcp/tools/global/find.js +0 -82
- package/dist/mcp/tools/global/find.js.map +0 -1
- package/dist/mcp/tools/global/update.d.ts +0 -6
- package/dist/mcp/tools/global/update.d.ts.map +0 -1
- package/dist/mcp/tools/global/update.js +0 -124
- package/dist/mcp/tools/global/update.js.map +0 -1
- package/dist/mcp/tools/job/create.d.ts +0 -10
- package/dist/mcp/tools/job/create.d.ts.map +0 -1
- package/dist/mcp/tools/job/create.js +0 -293
- package/dist/mcp/tools/job/create.js.map +0 -1
- package/dist/mcp/tools/job/run.d.ts +0 -10
- package/dist/mcp/tools/job/run.d.ts.map +0 -1
- package/dist/mcp/tools/job/run.js +0 -129
- package/dist/mcp/tools/job/run.js.map +0 -1
- package/dist/mcp/tools/job/update.d.ts +0 -11
- package/dist/mcp/tools/job/update.d.ts.map +0 -1
- package/dist/mcp/tools/job/update.js +0 -186
- package/dist/mcp/tools/job/update.js.map +0 -1
- package/dist/mcp/tools/resource/create.d.ts +0 -6
- package/dist/mcp/tools/resource/create.d.ts.map +0 -1
- package/dist/mcp/tools/resource/create.js +0 -124
- package/dist/mcp/tools/resource/create.js.map +0 -1
- package/dist/mcp/tools/resource/delete.d.ts +0 -5
- package/dist/mcp/tools/resource/delete.d.ts.map +0 -1
- package/dist/mcp/tools/resource/delete.js +0 -151
- package/dist/mcp/tools/resource/delete.js.map +0 -1
- package/dist/mcp/tools/resource/find.d.ts +0 -5
- package/dist/mcp/tools/resource/find.d.ts.map +0 -1
- package/dist/mcp/tools/resource/find.js +0 -170
- package/dist/mcp/tools/resource/find.js.map +0 -1
- package/dist/mcp/tools/resource/update.d.ts +0 -6
- package/dist/mcp/tools/resource/update.d.ts.map +0 -1
- package/dist/mcp/tools/resource/update.js +0 -256
- package/dist/mcp/tools/resource/update.js.map +0 -1
- package/dist/mcp/tools/schemas.d.ts +0 -457
- package/dist/mcp/tools/schemas.d.ts.map +0 -1
- package/dist/mcp/tools/schemas.js +0 -243
- package/dist/mcp/tools/schemas.js.map +0 -1
- package/dist/utils/adminEntitySettings.d.ts +0 -17
- package/dist/utils/adminEntitySettings.d.ts.map +0 -1
- package/dist/utils/adminEntitySettings.js +0 -41
- package/dist/utils/adminEntitySettings.js.map +0 -1
- package/dist/utils/createApiKeyFields.d.ts +0 -15
- package/dist/utils/createApiKeyFields.d.ts.map +0 -1
- package/dist/utils/createApiKeyFields.js +0 -57
- package/dist/utils/createApiKeyFields.js.map +0 -1
- package/dist/utils/getEnabledSlugs.d.ts +0 -13
- package/dist/utils/getEnabledSlugs.d.ts.map +0 -1
- package/dist/utils/getEnabledSlugs.js +0 -32
- package/dist/utils/getEnabledSlugs.js.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts +0 -3
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +0 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +0 -43
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +0 -13
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +0 -56
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +0 -20
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +0 -53
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +0 -3
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +0 -1
- package/dist/utils/schemaConversion/transformPointFields.js +0 -51
- package/dist/utils/schemaConversion/transformPointFields.js.map +0 -1
- package/src/collections/createApiKeysCollection.ts +0 -373
- package/src/defaults.ts +0 -3
- package/src/endpoints/mcp.ts +0 -91
- package/src/mcp/createRequest.ts +0 -13
- package/src/mcp/getMcpHandler.ts +0 -545
- package/src/mcp/helpers/config.ts +0 -213
- package/src/mcp/helpers/fields.ts +0 -154
- package/src/mcp/helpers/fileValidation.ts +0 -362
- package/src/mcp/registerTool.ts +0 -22
- package/src/mcp/tools/auth/auth.ts +0 -71
- package/src/mcp/tools/auth/forgotPassword.ts +0 -70
- package/src/mcp/tools/auth/login.ts +0 -72
- package/src/mcp/tools/auth/resetPassword.ts +0 -61
- package/src/mcp/tools/auth/unlock.ts +0 -64
- package/src/mcp/tools/auth/verify.ts +0 -57
- package/src/mcp/tools/collection/create.ts +0 -210
- package/src/mcp/tools/collection/delete.ts +0 -211
- package/src/mcp/tools/collection/find.ts +0 -224
- package/src/mcp/tools/collection/update.ts +0 -290
- package/src/mcp/tools/config/find.ts +0 -128
- package/src/mcp/tools/config/update.ts +0 -280
- package/src/mcp/tools/global/find.ts +0 -128
- package/src/mcp/tools/global/update.ts +0 -207
- package/src/mcp/tools/job/create.ts +0 -416
- package/src/mcp/tools/job/run.ts +0 -167
- package/src/mcp/tools/job/update.ts +0 -274
- package/src/mcp/tools/resource/create.ts +0 -211
- package/src/mcp/tools/resource/delete.ts +0 -218
- package/src/mcp/tools/resource/find.ts +0 -246
- package/src/mcp/tools/resource/update.ts +0 -383
- package/src/mcp/tools/schemas.ts +0 -520
- package/src/utils/adminEntitySettings.ts +0 -40
- package/src/utils/createApiKeyFields.ts +0 -72
- package/src/utils/getEnabledSlugs.ts +0 -42
- package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +0 -52
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +0 -62
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +0 -65
- package/src/utils/schemaConversion/transformPointFields.ts +0 -55
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
/* Section wrapper: description + panel, closed off by a full-bleed divider
|
|
3
|
+
that spans the fields column past its horizontal gutter. */
|
|
4
|
+
.mcp-api-key-field {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--base);
|
|
8
|
+
margin-inline: calc(-1 * var(--gutter-h));
|
|
9
|
+
padding-inline: var(--gutter-h);
|
|
10
|
+
padding-block-end: var(--spacer-4);
|
|
11
|
+
border-block-end: var(--stroke-width-small) solid var(--color-border);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.mcp-api-key-field__description {
|
|
15
|
+
margin: 0;
|
|
16
|
+
color: var(--color-text);
|
|
17
|
+
font-family: var(--text-body-medium-font-family);
|
|
18
|
+
font-size: var(--text-body-medium-font-size);
|
|
19
|
+
font-weight: var(--text-body-medium-font-weight);
|
|
20
|
+
line-height: var(--text-body-medium-line-height);
|
|
21
|
+
letter-spacing: var(--text-body-medium-letter-spacing);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.mcp-api-key-field__panel {
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
background: var(--color-bg);
|
|
27
|
+
border: var(--stroke-width-small) solid var(--color-border);
|
|
28
|
+
border-radius: var(--button-radius);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.mcp-api-key-field__header {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: space-between;
|
|
35
|
+
gap: var(--spacer-2);
|
|
36
|
+
min-height: var(--spacer-5);
|
|
37
|
+
padding: var(--spacer-2) var(--spacer-3);
|
|
38
|
+
background: var(--color-bg-secondary);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Holds the warning + key row; its top border is the full-width divider
|
|
42
|
+
under the header. Only rendered once a key exists. */
|
|
43
|
+
.mcp-api-key-field__body {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
gap: var(--spacer-2);
|
|
47
|
+
padding: var(--spacer-3);
|
|
48
|
+
border-block-start: var(--stroke-width-small) solid var(--color-border);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.mcp-api-key-field__title {
|
|
52
|
+
color: var(--color-text);
|
|
53
|
+
font-family: var(--text-body-medium-strong-font-family);
|
|
54
|
+
font-size: var(--text-body-medium-strong-font-size);
|
|
55
|
+
font-weight: var(--text-body-medium-strong-font-weight);
|
|
56
|
+
line-height: var(--text-body-medium-strong-line-height);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.mcp-api-key-field__generate {
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Matches the core Banner's warning treatment: theme-adaptive warning-tertiary
|
|
64
|
+
bg with regular --color-text (NOT --color-text-onwarning, which is only
|
|
65
|
+
defined for light mode and reads as muddy dark-on-dark in dark mode). */
|
|
66
|
+
.mcp-api-key-field__warning {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: calc(var(--base) / 2);
|
|
70
|
+
padding: calc(var(--spacer-2) + (var(--spacer-1) / 2)) calc(var(--base) / 2);
|
|
71
|
+
background: var(--color-bg-warning-tertiary);
|
|
72
|
+
border: none;
|
|
73
|
+
border-radius: var(--radius-medium);
|
|
74
|
+
color: var(--color-text);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mcp-api-key-field__warning-icon {
|
|
78
|
+
flex-shrink: 0;
|
|
79
|
+
width: 15px;
|
|
80
|
+
height: 13px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.mcp-api-key-field__warning-text {
|
|
84
|
+
flex-grow: 1;
|
|
85
|
+
margin: 0;
|
|
86
|
+
font-family: var(--text-body-medium-font-family);
|
|
87
|
+
font-size: var(--text-body-medium-font-size);
|
|
88
|
+
line-height: var(--text-body-medium-line-height);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.mcp-api-key-field__warning-text strong {
|
|
92
|
+
font-weight: var(--text-body-medium-strong-font-weight);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.mcp-api-key-field__warning-dismiss {
|
|
96
|
+
appearance: none;
|
|
97
|
+
background: none;
|
|
98
|
+
border: none;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
color: inherit;
|
|
101
|
+
font-size: 1rem;
|
|
102
|
+
line-height: 1;
|
|
103
|
+
padding: 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { NoResultsClientProps } from 'payload'
|
|
4
|
+
|
|
5
|
+
import { Button, NoListResults, useTranslation } from '@payloadcms/ui'
|
|
6
|
+
import React from 'react'
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
PluginMCPTranslationKeys,
|
|
10
|
+
PluginMCPTranslations,
|
|
11
|
+
} from '../../translations/index.js'
|
|
12
|
+
|
|
13
|
+
export const APIKeysEmptyState: React.FC<NoResultsClientProps> = ({
|
|
14
|
+
hasCreatePermission,
|
|
15
|
+
newDocumentURL,
|
|
16
|
+
viewType,
|
|
17
|
+
}) => {
|
|
18
|
+
const { t } = useTranslation<PluginMCPTranslations, PluginMCPTranslationKeys>()
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<NoListResults
|
|
22
|
+
Actions={
|
|
23
|
+
hasCreatePermission && newDocumentURL && viewType !== 'trash'
|
|
24
|
+
? [
|
|
25
|
+
<Button el="link" key="create" to={newDocumentURL}>
|
|
26
|
+
{t('authentication:generateNewAPIKey')}
|
|
27
|
+
</Button>,
|
|
28
|
+
]
|
|
29
|
+
: []
|
|
30
|
+
}
|
|
31
|
+
description={t('plugin-mcp:apiKeyDescription')}
|
|
32
|
+
title={t('plugin-mcp:noAPIKeys')}
|
|
33
|
+
withMargin
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { JSONFieldClientProps } from 'payload'
|
|
4
|
+
|
|
5
|
+
import { CheckboxInput, Collapsible, Tabs, useField, useTranslation } from '@payloadcms/ui'
|
|
6
|
+
import React, { useState } from 'react'
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
PluginMCPTranslationKeys,
|
|
10
|
+
PluginMCPTranslations,
|
|
11
|
+
} from '../../translations/index.js'
|
|
12
|
+
import type { ClientMCPPluginConfig, MCPAPIKeysDocAccessTree } from '../../types.js'
|
|
13
|
+
|
|
14
|
+
import './index.css'
|
|
15
|
+
|
|
16
|
+
const baseClass = 'mcp-access-field'
|
|
17
|
+
|
|
18
|
+
type ClientItem = ClientMCPPluginConfig['items'][number]
|
|
19
|
+
type ScopeKey = 'collections' | 'globals'
|
|
20
|
+
type FlatKey = 'prompts' | 'resources' | 'tools'
|
|
21
|
+
type TabKey = 'collections' | 'globals' | 'server'
|
|
22
|
+
|
|
23
|
+
const LEAF_GROUP_KEYS = ['operations', 'auth', 'custom'] as const
|
|
24
|
+
|
|
25
|
+
type LeafGroupKey = (typeof LEAF_GROUP_KEYS)[number]
|
|
26
|
+
|
|
27
|
+
type Props = {
|
|
28
|
+
pluginConfig: ClientMCPPluginConfig
|
|
29
|
+
} & JSONFieldClientProps
|
|
30
|
+
|
|
31
|
+
/** Drop a key from an object and return a new object — or `undefined` if it'd be empty. */
|
|
32
|
+
const without = <T extends Record<string, unknown>>(
|
|
33
|
+
obj: T | undefined,
|
|
34
|
+
key: string,
|
|
35
|
+
): T | undefined => {
|
|
36
|
+
if (!obj || !(key in obj)) {
|
|
37
|
+
return obj
|
|
38
|
+
}
|
|
39
|
+
const { [key]: _omitted, ...rest } = obj
|
|
40
|
+
return Object.keys(rest).length === 0 ? undefined : (rest as T)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const setKey = <T extends Record<string, unknown>>(
|
|
44
|
+
obj: T | undefined,
|
|
45
|
+
key: string,
|
|
46
|
+
value: unknown,
|
|
47
|
+
): T => ({ ...(obj ?? {}), [key]: value }) as T
|
|
48
|
+
|
|
49
|
+
export const AccessField: React.FC<Props> = ({ path, pluginConfig }) => {
|
|
50
|
+
const { setValue, value } = useField<MCPAPIKeysDocAccessTree>({ path })
|
|
51
|
+
const { t } = useTranslation<PluginMCPTranslations, PluginMCPTranslationKeys>()
|
|
52
|
+
const [activeTab, setActiveTab] = useState<null | TabKey>(null)
|
|
53
|
+
const access = value ?? {}
|
|
54
|
+
const leafGroupLabels: Record<LeafGroupKey, string> = {
|
|
55
|
+
auth: t('plugin-mcp:authentication'),
|
|
56
|
+
custom: t('general:custom'),
|
|
57
|
+
operations: t('plugin-mcp:operations'),
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const collectionsBySlug: Record<string, ClientItem[]> = {}
|
|
61
|
+
const globalsBySlug: Record<string, ClientItem[]> = {}
|
|
62
|
+
const prompts: ClientItem[] = []
|
|
63
|
+
const resources: ClientItem[] = []
|
|
64
|
+
const tools: ClientItem[] = []
|
|
65
|
+
|
|
66
|
+
for (const item of pluginConfig.items) {
|
|
67
|
+
switch (item.type) {
|
|
68
|
+
case 'collectionTool':
|
|
69
|
+
;(collectionsBySlug[item.collectionSlug!] ??= []).push(item)
|
|
70
|
+
break
|
|
71
|
+
case 'globalTool':
|
|
72
|
+
;(globalsBySlug[item.globalSlug!] ??= []).push(item)
|
|
73
|
+
break
|
|
74
|
+
case 'prompt':
|
|
75
|
+
prompts.push(item)
|
|
76
|
+
break
|
|
77
|
+
case 'resource':
|
|
78
|
+
resources.push(item)
|
|
79
|
+
break
|
|
80
|
+
case 'tool':
|
|
81
|
+
tools.push(item)
|
|
82
|
+
break
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const isScopedAllowed = (scope: ScopeKey, slug: string, configKey: string): boolean =>
|
|
87
|
+
access[scope]?.[slug]?.[configKey] !== false
|
|
88
|
+
|
|
89
|
+
const isFlatAllowed = (scope: FlatKey, configKey: string): boolean =>
|
|
90
|
+
access[scope]?.[configKey] !== false
|
|
91
|
+
|
|
92
|
+
const toggleScoped = (scope: ScopeKey, slug: string, configKey: string, allow: boolean) => {
|
|
93
|
+
if (allow) {
|
|
94
|
+
const slugBucket = without(access[scope]?.[slug], configKey)
|
|
95
|
+
const scopeBucket = slugBucket
|
|
96
|
+
? setKey(access[scope], slug, slugBucket)
|
|
97
|
+
: without(access[scope], slug)
|
|
98
|
+
setValue(scopeBucket ? setKey(access, scope, scopeBucket) : (without(access, scope) ?? {}))
|
|
99
|
+
} else {
|
|
100
|
+
setValue(
|
|
101
|
+
setKey(
|
|
102
|
+
access,
|
|
103
|
+
scope,
|
|
104
|
+
setKey(access[scope], slug, setKey(access[scope]?.[slug], configKey, false)),
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const toggleFlat = (scope: FlatKey, configKey: string, allow: boolean) => {
|
|
111
|
+
if (allow) {
|
|
112
|
+
const bucket = without(access[scope], configKey)
|
|
113
|
+
setValue(bucket ? setKey(access, scope, bucket) : (without(access, scope) ?? {}))
|
|
114
|
+
} else {
|
|
115
|
+
setValue(setKey(access, scope, setKey(access[scope], configKey, false)))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const setAllScoped = (scope: ScopeKey, slug: string, leaves: ClientItem[], allow: boolean) => {
|
|
120
|
+
if (allow) {
|
|
121
|
+
const scopeBucket = without(access[scope], slug)
|
|
122
|
+
setValue(scopeBucket ? setKey(access, scope, scopeBucket) : (without(access, scope) ?? {}))
|
|
123
|
+
} else {
|
|
124
|
+
const slugBucket = leaves.reduce<Record<string, boolean>>(
|
|
125
|
+
(acc, leaf) => ({ ...acc, [leaf.configKey]: false }),
|
|
126
|
+
{},
|
|
127
|
+
)
|
|
128
|
+
setValue(setKey(access, scope, setKey(access[scope], slug, slugBucket)))
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const setAllFlat = (scope: FlatKey, leaves: ClientItem[], allow: boolean) => {
|
|
133
|
+
if (allow) {
|
|
134
|
+
setValue(without(access, scope) ?? {})
|
|
135
|
+
} else {
|
|
136
|
+
const bucket = leaves.reduce<Record<string, boolean>>(
|
|
137
|
+
(acc, leaf) => ({ ...acc, [leaf.configKey]: false }),
|
|
138
|
+
{},
|
|
139
|
+
)
|
|
140
|
+
setValue(setKey(access, scope, bucket))
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const renderLeaf = (
|
|
145
|
+
leaf: ClientItem,
|
|
146
|
+
id: string,
|
|
147
|
+
checked: boolean,
|
|
148
|
+
onToggle: (allow: boolean) => void,
|
|
149
|
+
) => (
|
|
150
|
+
<li className={`${baseClass}__leaf`} key={leaf.configKey}>
|
|
151
|
+
<CheckboxInput
|
|
152
|
+
checked={checked}
|
|
153
|
+
id={id}
|
|
154
|
+
label={leaf.label}
|
|
155
|
+
onToggle={(e) => onToggle(e.target.checked)}
|
|
156
|
+
/>
|
|
157
|
+
{leaf.description && <p className={`${baseClass}__leaf-description`}>{leaf.description}</p>}
|
|
158
|
+
</li>
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
const renderCard = ({
|
|
162
|
+
id,
|
|
163
|
+
isLeafAllowed,
|
|
164
|
+
label,
|
|
165
|
+
leaves,
|
|
166
|
+
onSetAll,
|
|
167
|
+
onToggleLeaf,
|
|
168
|
+
}: {
|
|
169
|
+
id: string
|
|
170
|
+
isLeafAllowed: (leaf: ClientItem) => boolean
|
|
171
|
+
label: string
|
|
172
|
+
leaves: ClientItem[]
|
|
173
|
+
onSetAll: (allow: boolean) => void
|
|
174
|
+
onToggleLeaf: (leaf: ClientItem, allow: boolean) => void
|
|
175
|
+
}) => {
|
|
176
|
+
const allowedCount = leaves.filter(isLeafAllowed).length
|
|
177
|
+
const groups = LEAF_GROUP_KEYS.map((key) => ({
|
|
178
|
+
key,
|
|
179
|
+
label: leafGroupLabels[key],
|
|
180
|
+
leaves: leaves.filter((leaf) => (leaf.group ?? 'custom') === key),
|
|
181
|
+
})).filter((group) => group.leaves.length > 0)
|
|
182
|
+
const hasGroupLabels = groups.length > 1
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Collapsible
|
|
186
|
+
className={`${baseClass}__card`}
|
|
187
|
+
header={
|
|
188
|
+
// Keep header clicks on the checkbox from also toggling the collapsible.
|
|
189
|
+
<span
|
|
190
|
+
className={`${baseClass}__card-checkbox`}
|
|
191
|
+
onClick={(e) => e.stopPropagation()}
|
|
192
|
+
role="presentation"
|
|
193
|
+
>
|
|
194
|
+
<CheckboxInput
|
|
195
|
+
checked={allowedCount === leaves.length}
|
|
196
|
+
id={`${id}._all`}
|
|
197
|
+
label={label}
|
|
198
|
+
onToggle={() => onSetAll(allowedCount < leaves.length)}
|
|
199
|
+
partialChecked={allowedCount > 0 && allowedCount < leaves.length}
|
|
200
|
+
/>
|
|
201
|
+
</span>
|
|
202
|
+
}
|
|
203
|
+
initCollapsed
|
|
204
|
+
key={id}
|
|
205
|
+
>
|
|
206
|
+
<div className={`${baseClass}__card-groups`}>
|
|
207
|
+
{groups.map((group) => (
|
|
208
|
+
<div className={`${baseClass}__leaf-group`} key={group.key}>
|
|
209
|
+
{hasGroupLabels && <p className={`${baseClass}__leaf-group-label`}>{group.label}</p>}
|
|
210
|
+
<ul className={`${baseClass}__list`}>
|
|
211
|
+
{group.leaves.map((leaf) =>
|
|
212
|
+
renderLeaf(leaf, `${id}.${leaf.configKey}`, isLeafAllowed(leaf), (allow) =>
|
|
213
|
+
onToggleLeaf(leaf, allow),
|
|
214
|
+
),
|
|
215
|
+
)}
|
|
216
|
+
</ul>
|
|
217
|
+
</div>
|
|
218
|
+
))}
|
|
219
|
+
</div>
|
|
220
|
+
</Collapsible>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const renderScope = (scope: ScopeKey, bySlug: Record<string, ClientItem[]>) =>
|
|
225
|
+
Object.entries(bySlug).map(([slug, leaves]) =>
|
|
226
|
+
renderCard({
|
|
227
|
+
id: `${path}.${scope}.${slug}`,
|
|
228
|
+
isLeafAllowed: (leaf) => isScopedAllowed(scope, slug, leaf.configKey),
|
|
229
|
+
label: titleCase(slug),
|
|
230
|
+
leaves,
|
|
231
|
+
onSetAll: (allow) => setAllScoped(scope, slug, leaves, allow),
|
|
232
|
+
onToggleLeaf: (leaf, allow) => toggleScoped(scope, slug, leaf.configKey, allow),
|
|
233
|
+
}),
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
const renderFlat = (scope: FlatKey, label: string, leaves: ClientItem[]) =>
|
|
237
|
+
leaves.length > 0 &&
|
|
238
|
+
renderCard({
|
|
239
|
+
id: `${path}.${scope}`,
|
|
240
|
+
isLeafAllowed: (leaf) => isFlatAllowed(scope, leaf.configKey),
|
|
241
|
+
label,
|
|
242
|
+
leaves,
|
|
243
|
+
onSetAll: (allow) => setAllFlat(scope, leaves, allow),
|
|
244
|
+
onToggleLeaf: (leaf, allow) => toggleFlat(scope, leaf.configKey, allow),
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
const tabs: Array<{ key: TabKey; label: string }> = [
|
|
248
|
+
...(Object.keys(collectionsBySlug).length > 0
|
|
249
|
+
? [{ key: 'collections' as const, label: t('general:collections') }]
|
|
250
|
+
: []),
|
|
251
|
+
...(Object.keys(globalsBySlug).length > 0
|
|
252
|
+
? [{ key: 'globals' as const, label: t('general:globals') }]
|
|
253
|
+
: []),
|
|
254
|
+
...(prompts.length > 0 || resources.length > 0 || tools.length > 0
|
|
255
|
+
? [{ key: 'server' as const, label: t('plugin-mcp:server') }]
|
|
256
|
+
: []),
|
|
257
|
+
]
|
|
258
|
+
if (tabs.length === 0) {
|
|
259
|
+
return null
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const currentTab = activeTab ?? tabs[0]!.key
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div className={baseClass}>
|
|
266
|
+
<header className={`${baseClass}__header`}>
|
|
267
|
+
<h4>{t('plugin-mcp:permissions')}</h4>
|
|
268
|
+
<p>{t('plugin-mcp:permissionsDescription')}</p>
|
|
269
|
+
</header>
|
|
270
|
+
<div className={`${baseClass}__tabbed-content`}>
|
|
271
|
+
<Tabs
|
|
272
|
+
className={`${baseClass}__tabs`}
|
|
273
|
+
onChange={setActiveTab}
|
|
274
|
+
tabs={tabs.map((tab) => ({
|
|
275
|
+
label: tab.label,
|
|
276
|
+
value: tab.key,
|
|
277
|
+
}))}
|
|
278
|
+
value={currentTab}
|
|
279
|
+
/>
|
|
280
|
+
<div className={`${baseClass}__cards`}>
|
|
281
|
+
{currentTab === 'collections' && renderScope('collections', collectionsBySlug)}
|
|
282
|
+
{currentTab === 'globals' && renderScope('globals', globalsBySlug)}
|
|
283
|
+
{currentTab === 'server' && (
|
|
284
|
+
<>
|
|
285
|
+
{renderFlat('prompts', t('plugin-mcp:prompts'), prompts)}
|
|
286
|
+
{renderFlat('resources', t('plugin-mcp:resources'), resources)}
|
|
287
|
+
{renderFlat('tools', t('plugin-mcp:tools'), tools)}
|
|
288
|
+
</>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const titleCase = (slug: string): string =>
|
|
297
|
+
slug.replace(/(^|[-_])(.)/g, (_, sep: string, ch: string) =>
|
|
298
|
+
sep ? ` ${ch.toUpperCase()}` : ch.toUpperCase(),
|
|
299
|
+
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
@layer payload-default {
|
|
2
|
+
.mcp-access-field {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--base);
|
|
6
|
+
/* Breathing room below the API-key section's divider - the fields
|
|
7
|
+
container itself adds no gap between these two fields. */
|
|
8
|
+
padding-block-start: var(--spacer-4);
|
|
9
|
+
/* This custom field renders straight into `render-fields` (no `.field-type`
|
|
10
|
+
wrapper), so it must carry the standard inter-field margin itself -
|
|
11
|
+
otherwise the next field (e.g. an overrideApiKeyCollection field) butts
|
|
12
|
+
against the last card. */
|
|
13
|
+
margin-block-end: var(--spacer-3);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.mcp-access-field__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.mcp-access-field__header h4 {
|
|
22
|
+
margin: 0;
|
|
23
|
+
color: var(--color-text);
|
|
24
|
+
font-family: var(--text-heading-small-font-family);
|
|
25
|
+
font-size: var(--text-heading-small-font-size);
|
|
26
|
+
font-weight: var(--text-heading-small-font-weight);
|
|
27
|
+
line-height: var(--text-heading-small-line-height);
|
|
28
|
+
letter-spacing: var(--text-heading-small-letter-spacing);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.mcp-access-field__header p {
|
|
32
|
+
margin: 0;
|
|
33
|
+
color: var(--color-text-secondary);
|
|
34
|
+
font-family: var(--text-body-medium-font-family);
|
|
35
|
+
font-size: var(--text-body-medium-font-size);
|
|
36
|
+
font-weight: var(--text-body-medium-font-weight);
|
|
37
|
+
line-height: var(--text-body-medium-line-height);
|
|
38
|
+
letter-spacing: var(--text-body-medium-letter-spacing);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.mcp-access-field__tabbed-content {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.mcp-access-field__cards {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
gap: calc(var(--base) / 2);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* The collapsible header is pointer-events: none so clicks reach the toggle
|
|
53
|
+
overlay; re-enable events on the checkbox and lift it above the toggle. */
|
|
54
|
+
.mcp-access-field__card-checkbox {
|
|
55
|
+
position: relative;
|
|
56
|
+
z-index: 1;
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
pointer-events: auto;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mcp-access-field__leaf-group {
|
|
62
|
+
padding-block: calc(var(--base) / 2);
|
|
63
|
+
border-block-end: 1px solid var(--theme-elevation-100);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.mcp-access-field__leaf-group:first-child {
|
|
67
|
+
padding-block-start: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.mcp-access-field__leaf-group:last-child {
|
|
71
|
+
border-block-end: none;
|
|
72
|
+
padding-block-end: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.mcp-access-field__leaf-group-label {
|
|
76
|
+
margin: 0 0 calc(var(--base) / 2);
|
|
77
|
+
color: var(--color-text-secondary);
|
|
78
|
+
font-family: var(--text-body-medium-font-family);
|
|
79
|
+
font-size: var(--text-body-medium-font-size);
|
|
80
|
+
line-height: var(--text-body-medium-line-height);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.mcp-access-field__list {
|
|
84
|
+
list-style: none;
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
gap: calc(var(--base) / 2);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.mcp-access-field__leaf-description {
|
|
93
|
+
margin: calc(var(--base) / 6) 0 0;
|
|
94
|
+
color: var(--color-text-secondary);
|
|
95
|
+
font-family: var(--text-body-medium-font-family);
|
|
96
|
+
font-size: var(--text-body-medium-font-size);
|
|
97
|
+
line-height: var(--text-body-medium-line-height);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { PopupList, useConfig, useTranslation } from '@payloadcms/ui'
|
|
4
|
+
import { formatAdminURL } from 'payload/shared'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
PluginMCPTranslationKeys,
|
|
9
|
+
PluginMCPTranslations,
|
|
10
|
+
} from '../../translations/index.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Entry in the user menu's Settings sub-popup linking to the API keys
|
|
14
|
+
* collection. The collection is excluded from the main nav
|
|
15
|
+
* (`admin.group: false`) and managed from here instead.
|
|
16
|
+
*/
|
|
17
|
+
export const MCPSettingsMenu: React.FC = () => {
|
|
18
|
+
const { config } = useConfig()
|
|
19
|
+
const { t } = useTranslation<PluginMCPTranslations, PluginMCPTranslationKeys>()
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<PopupList.MenuItem>
|
|
23
|
+
<PopupList.GroupLabel label={t('plugin-mcp:mcp')} />
|
|
24
|
+
<PopupList.Button
|
|
25
|
+
href={formatAdminURL({
|
|
26
|
+
adminRoute: config.routes.admin,
|
|
27
|
+
path: '/collections/payload-mcp-api-keys',
|
|
28
|
+
})}
|
|
29
|
+
>
|
|
30
|
+
{t('plugin-mcp:manageAPIKeys')}
|
|
31
|
+
</PopupList.Button>
|
|
32
|
+
</PopupList.MenuItem>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CollectionTool, GlobalTool, Prompt, Tool, ToolInputSchema } from './types.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Two-stage builder: pass the schema/metadata first, then chain `.handler(fn)`. Splitting the
|
|
5
|
+
* call lets TypeScript resolve `TSchema` from `input` (call 1) before contextually typing the
|
|
6
|
+
* handler (call 2). A single-call API hit a TS limitation where property order in the literal
|
|
7
|
+
* decided whether `TSchema` was inferred or pinned to its default.
|
|
8
|
+
*
|
|
9
|
+
* defineCollectionTool({ description, input })
|
|
10
|
+
* .handler(({ input }) => …) // ← input is fully typed here regardless of order
|
|
11
|
+
*
|
|
12
|
+
* Config and handler signatures are derived from `Tool` / `CollectionTool` / `GlobalTool` /
|
|
13
|
+
* `Prompt` via `Omit` + indexed access so there's no duplication with `types.ts`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const defineTool = <
|
|
17
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
18
|
+
>(
|
|
19
|
+
args: Omit<Tool<TSchema>, 'handler'>,
|
|
20
|
+
): { handler: (fn: Tool<TSchema>['handler']) => Tool } => ({
|
|
21
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as Tool,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const defineCollectionTool = <
|
|
25
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
26
|
+
>(
|
|
27
|
+
args: Omit<CollectionTool<TSchema>, 'handler'>,
|
|
28
|
+
): { handler: (fn: CollectionTool<TSchema>['handler']) => CollectionTool } => ({
|
|
29
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as CollectionTool,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export const defineGlobalTool = <
|
|
33
|
+
TSchema extends ToolInputSchema | undefined = ToolInputSchema | undefined,
|
|
34
|
+
>(
|
|
35
|
+
args: Omit<GlobalTool<TSchema>, 'handler'>,
|
|
36
|
+
): { handler: (fn: GlobalTool<TSchema>['handler']) => GlobalTool } => ({
|
|
37
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as GlobalTool,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const definePrompt = <TSchema extends ToolInputSchema = ToolInputSchema>(
|
|
41
|
+
args: Omit<Prompt<TSchema>, 'handler'>,
|
|
42
|
+
): { handler: (fn: Prompt<TSchema>['handler']) => Prompt } => ({
|
|
43
|
+
handler: (fn) => ({ ...args, handler: fn }) as unknown as Prompt,
|
|
44
|
+
})
|