@payloadcms/plugin-mcp 4.0.0-internal.38b7f1d → 4.0.0-internal.5f0cd13
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/collection/getAccessField.d.ts +12 -0
- package/dist/collection/getAccessField.d.ts.map +1 -0
- package/dist/collection/getAccessField.js +57 -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 +59 -0
- package/dist/collection/index.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 +305 -0
- package/dist/components/AccessField/index.client.js.map +1 -0
- package/dist/components/AccessField/index.css +93 -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 +106 -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 +2 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +4 -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 +44 -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 +163 -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 +87 -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 +117 -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 +159 -0
- package/dist/mcp/builtin/collections/findTool.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 +187 -0
- package/dist/mcp/builtin/collections/updateTool.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/updateTool.d.ts +2 -0
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -0
- package/dist/mcp/builtin/globals/updateTool.js +92 -0
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -0
- package/dist/mcp/builtinTools.d.ts +37 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -0
- package/dist/mcp/builtinTools.js +64 -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 +167 -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/types.d.ts +262 -455
- 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/prepareCollectionSchema.d.ts +7 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.js +37 -0
- package/dist/utils/schemaConversion/prepareCollectionSchema.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/sanitizeJsonSchema.d.ts +2 -2
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts +2 -2
- package/dist/utils/schemaConversion/simplifyRelationshipFields.d.ts.map +1 -1
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js +7 -4
- package/dist/utils/schemaConversion/simplifyRelationshipFields.js.map +1 -1
- package/dist/utils/schemaConversion/transformPointFields.d.ts +2 -2
- package/dist/utils/schemaConversion/transformPointFields.d.ts.map +1 -1
- package/dist/utils/schemaConversion/transformPointFields.js +7 -1
- package/dist/utils/schemaConversion/transformPointFields.js.map +1 -1
- 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/package.json +35 -10
- package/src/collection/getAccessField.ts +64 -0
- package/src/collection/index.ts +63 -0
- package/src/components/AccessField/index.client.tsx +344 -0
- package/src/components/AccessField/index.css +93 -0
- package/src/defineTool.ts +44 -0
- package/src/endpoint/access.ts +132 -0
- package/src/endpoint/index.ts +35 -0
- package/src/exports/client.ts +2 -0
- package/src/index.ts +35 -85
- package/src/mcp/buildMcpServer.ts +224 -0
- package/src/mcp/builtin/collections/authTools.ts +233 -0
- package/src/mcp/builtin/collections/createTool.ts +116 -0
- package/src/mcp/builtin/collections/deleteTool.ts +123 -0
- package/src/mcp/builtin/collections/findTool.ts +187 -0
- package/src/mcp/builtin/collections/updateTool.ts +205 -0
- package/src/mcp/builtin/globals/findTool.ts +96 -0
- package/src/mcp/builtin/globals/updateTool.ts +118 -0
- package/src/mcp/builtinTools.ts +84 -0
- package/src/mcp/sanitizeMCPConfig.ts +239 -0
- package/src/stdio.ts +98 -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/prepareCollectionSchema.ts +39 -0
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +3 -3
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +4 -4
- package/src/utils/schemaConversion/simplifyRelationshipFields.ts +11 -6
- package/src/utils/schemaConversion/transformPointFields.ts +6 -5
- package/src/utils/toStandardSchema.ts +9 -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/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
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
import { APIError, configToJSONSchema } from 'payload';
|
|
3
|
+
import { toCamelCase } from '../utils/camelCase.js';
|
|
4
|
+
import { getLogger } from '../utils/getLogger.js';
|
|
5
|
+
import { getCollectionVirtualFieldNames, getGlobalVirtualFieldNames } from '../utils/getVirtualFieldNames.js';
|
|
6
|
+
import { removeVirtualFieldsFromSchema } from '../utils/schemaConversion/removeVirtualFieldsFromSchema.js';
|
|
7
|
+
import { toStandardSchema } from '../utils/toStandardSchema.js';
|
|
8
|
+
/** `findPosts`, `updateSiteSettings` — auto-prefixed wire name for collection/global tools. */ const wireName = (key, slug)=>{
|
|
9
|
+
const camel = toCamelCase(slug);
|
|
10
|
+
return `${key}${camel.charAt(0).toUpperCase()}${camel.slice(1)}`;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Transport-agnostic core: registers every authorized MCP item onto a fresh
|
|
14
|
+
* `McpServer` and returns it. The caller is responsible for picking a transport
|
|
15
|
+
* (`WebStandardStreamableHTTPServerTransport`, `StdioServerTransport`, …) and
|
|
16
|
+
* calling `server.connect(transport)`.
|
|
17
|
+
*
|
|
18
|
+
* `req` is the request context handlers see. For HTTP it's the live
|
|
19
|
+
* `PayloadRequest` derived from the incoming HTTP request; for stdio it's a
|
|
20
|
+
* synthesized one built via `createLocalReq`.
|
|
21
|
+
*/ export const buildMcpServer = ({ authorizedMCP, pluginConfig, req })=>{
|
|
22
|
+
const serverOptions = pluginConfig.mcp?.serverOptions || {};
|
|
23
|
+
const server = new McpServer({
|
|
24
|
+
name: 'Payload MCP Server',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
...serverOptions.serverInfo
|
|
27
|
+
}, serverOptions.options);
|
|
28
|
+
const logger = getLogger({
|
|
29
|
+
payload: req.payload
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Wrap a tool handler's response with the tool's `overrideResponse`, then
|
|
33
|
+
* strip the internal `doc` field so it doesn't leak onto the wire.
|
|
34
|
+
*/ const finalizeToolResponse = (response, overrideResponse)=>{
|
|
35
|
+
const overridden = overrideResponse?.(response, response.doc ?? {}, req) ?? response;
|
|
36
|
+
const { doc: _doc, ...rest } = overridden;
|
|
37
|
+
return rest;
|
|
38
|
+
};
|
|
39
|
+
const { jsonSchema: configSchema } = configToJSONSchema(req.payload.config, req.payload.db.defaultIDType, req.i18n, {
|
|
40
|
+
forceInlineBlocks: true
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
for (const item of authorizedMCP.items){
|
|
44
|
+
switch(item.type){
|
|
45
|
+
case 'collectionTool':
|
|
46
|
+
{
|
|
47
|
+
const tool = item.tool;
|
|
48
|
+
const name = wireName(item.key, item.collectionSlug);
|
|
49
|
+
let inputSchema = tool.input;
|
|
50
|
+
if (typeof inputSchema === 'function') {
|
|
51
|
+
const raw = configSchema.definitions?.[item.collectionSlug];
|
|
52
|
+
if (!raw) {
|
|
53
|
+
throw new APIError(`Collection schema not found for slug: ${item.collectionSlug}`, 500);
|
|
54
|
+
}
|
|
55
|
+
const collectionSchema = removeVirtualFieldsFromSchema(JSON.parse(JSON.stringify(raw)), getCollectionVirtualFieldNames(req.payload.config, item.collectionSlug));
|
|
56
|
+
inputSchema = inputSchema({
|
|
57
|
+
collectionSchema
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
server.registerTool(name, {
|
|
61
|
+
description: tool.description,
|
|
62
|
+
inputSchema: inputSchema ? toStandardSchema(inputSchema) : undefined
|
|
63
|
+
}, async (input, ctx)=>finalizeToolResponse(await tool.handler({
|
|
64
|
+
authorizedMCP,
|
|
65
|
+
collectionSlug: item.collectionSlug,
|
|
66
|
+
input: input ?? {},
|
|
67
|
+
req,
|
|
68
|
+
serverContext: ctx
|
|
69
|
+
}), tool.overrideResponse));
|
|
70
|
+
logger.info(`✅ Tool: ${name} Registered.`);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'globalTool':
|
|
74
|
+
{
|
|
75
|
+
const tool = item.tool;
|
|
76
|
+
const name = wireName(item.key, item.globalSlug);
|
|
77
|
+
let inputSchema = tool.input;
|
|
78
|
+
if (typeof inputSchema === 'function') {
|
|
79
|
+
const raw = configSchema.definitions?.[item.globalSlug];
|
|
80
|
+
if (!raw) {
|
|
81
|
+
throw new APIError(`Global schema not found for slug: ${item.globalSlug}`, 500);
|
|
82
|
+
}
|
|
83
|
+
const globalSchema = removeVirtualFieldsFromSchema(JSON.parse(JSON.stringify(raw)), getGlobalVirtualFieldNames(req.payload.config, item.globalSlug));
|
|
84
|
+
inputSchema = inputSchema({
|
|
85
|
+
globalSchema
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
server.registerTool(name, {
|
|
89
|
+
description: tool.description,
|
|
90
|
+
inputSchema: inputSchema ? toStandardSchema(inputSchema) : undefined
|
|
91
|
+
}, async (input, ctx)=>finalizeToolResponse(await tool.handler({
|
|
92
|
+
authorizedMCP,
|
|
93
|
+
globalSlug: item.globalSlug,
|
|
94
|
+
input: input ?? {},
|
|
95
|
+
req,
|
|
96
|
+
serverContext: ctx
|
|
97
|
+
}), tool.overrideResponse));
|
|
98
|
+
logger.info(`✅ Tool: ${name} Registered.`);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'prompt':
|
|
102
|
+
{
|
|
103
|
+
const prompt = item.prompt;
|
|
104
|
+
server.registerPrompt(item.key, {
|
|
105
|
+
argsSchema: prompt.argsSchema ? toStandardSchema(prompt.argsSchema) : undefined,
|
|
106
|
+
description: prompt.description,
|
|
107
|
+
title: prompt.title
|
|
108
|
+
}, async (input, ctx)=>prompt.handler({
|
|
109
|
+
input: input ?? {},
|
|
110
|
+
req,
|
|
111
|
+
serverContext: ctx
|
|
112
|
+
}));
|
|
113
|
+
logger.info(`✅ Prompt: ${prompt.title} Registered.`);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case 'resource':
|
|
117
|
+
{
|
|
118
|
+
const resource = item.resource;
|
|
119
|
+
server.registerResource(item.key, // @ts-expect-error - Overload type ambiguity (string OR ResourceTemplate is valid)
|
|
120
|
+
resource.uri, {
|
|
121
|
+
description: resource.description,
|
|
122
|
+
mimeType: resource.mimeType,
|
|
123
|
+
title: resource.title
|
|
124
|
+
}, // Static URIs call (uri, ctx); ResourceTemplates call (uri, params, ctx).
|
|
125
|
+
// The rest-params shape lets us collect either signature uniformly.
|
|
126
|
+
async (...sdkArgs)=>{
|
|
127
|
+
const ctx = sdkArgs[sdkArgs.length - 1];
|
|
128
|
+
const uri = sdkArgs[0];
|
|
129
|
+
const params = sdkArgs.length > 2 ? sdkArgs[1] : {};
|
|
130
|
+
return resource.handler({
|
|
131
|
+
params,
|
|
132
|
+
req,
|
|
133
|
+
serverContext: ctx,
|
|
134
|
+
uri
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
logger.info(`✅ Resource: ${resource.title} Registered.`);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'tool':
|
|
141
|
+
{
|
|
142
|
+
const tool = item.tool;
|
|
143
|
+
server.registerTool(item.key, {
|
|
144
|
+
description: tool.description,
|
|
145
|
+
inputSchema: tool.input ? toStandardSchema(tool.input) : undefined
|
|
146
|
+
}, async (input, ctx)=>finalizeToolResponse(await tool.handler({
|
|
147
|
+
authorizedMCP,
|
|
148
|
+
input: input ?? {},
|
|
149
|
+
req,
|
|
150
|
+
serverContext: ctx
|
|
151
|
+
}), tool.overrideResponse));
|
|
152
|
+
logger.info(`✅ Tool: ${item.key} Registered.`);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new APIError(`Error initializing MCP handler: ${String(error)}`, 500);
|
|
159
|
+
}
|
|
160
|
+
return server;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
//# sourceMappingURL=buildMcpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/buildMcpServer.ts"],"sourcesContent":["import { McpServer, type ServerContext } from '@modelcontextprotocol/server'\nimport { APIError, configToJSONSchema, type PayloadRequest } from 'payload'\n\nimport type {\n AuthorizedMCP,\n JsonSchemaType,\n MCPResponseOverride,\n MCPToolResponse,\n SanitizedMCPPluginConfig,\n} from '../types.js'\n\nimport { toCamelCase } from '../utils/camelCase.js'\nimport { getLogger } from '../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n getGlobalVirtualFieldNames,\n} from '../utils/getVirtualFieldNames.js'\nimport { removeVirtualFieldsFromSchema } from '../utils/schemaConversion/removeVirtualFieldsFromSchema.js'\nimport { toStandardSchema } from '../utils/toStandardSchema.js'\n\n/** `findPosts`, `updateSiteSettings` — auto-prefixed wire name for collection/global tools. */\nconst wireName = (key: string, slug: string): string => {\n const camel = toCamelCase(slug)\n return `${key}${camel.charAt(0).toUpperCase()}${camel.slice(1)}`\n}\n\n/**\n * Transport-agnostic core: registers every authorized MCP item onto a fresh\n * `McpServer` and returns it. The caller is responsible for picking a transport\n * (`WebStandardStreamableHTTPServerTransport`, `StdioServerTransport`, …) and\n * calling `server.connect(transport)`.\n *\n * `req` is the request context handlers see. For HTTP it's the live\n * `PayloadRequest` derived from the incoming HTTP request; for stdio it's a\n * synthesized one built via `createLocalReq`.\n */\nexport const buildMcpServer = ({\n authorizedMCP,\n pluginConfig,\n req,\n}: {\n authorizedMCP: AuthorizedMCP\n pluginConfig: SanitizedMCPPluginConfig\n req: PayloadRequest\n}): McpServer => {\n const serverOptions = pluginConfig.mcp?.serverOptions || {}\n const server = new McpServer(\n { name: 'Payload MCP Server', version: '1.0.0', ...serverOptions.serverInfo },\n serverOptions.options,\n )\n\n const logger = getLogger({ payload: req.payload })\n\n /**\n * Wrap a tool handler's response with the tool's `overrideResponse`, then\n * strip the internal `doc` field so it doesn't leak onto the wire.\n */\n const finalizeToolResponse = (\n response: MCPToolResponse,\n overrideResponse?: MCPResponseOverride,\n ): MCPToolResponse => {\n const overridden = overrideResponse?.(response, response.doc ?? {}, req) ?? response\n const { doc: _doc, ...rest } = overridden\n return rest\n }\n\n const { jsonSchema: configSchema } = configToJSONSchema(\n req.payload.config,\n req.payload.db.defaultIDType,\n req.i18n,\n { forceInlineBlocks: true },\n ) as { jsonSchema: JsonSchemaType; typeStringDefinitions: Set<string> }\n\n try {\n for (const item of authorizedMCP.items) {\n switch (item.type) {\n case 'collectionTool': {\n const tool = item.tool\n const name = wireName(item.key, item.collectionSlug)\n let inputSchema = tool.input\n if (typeof inputSchema === 'function') {\n const raw = configSchema.definitions?.[item.collectionSlug]\n if (!raw) {\n throw new APIError(\n `Collection schema not found for slug: ${item.collectionSlug}`,\n 500,\n )\n }\n const collectionSchema = removeVirtualFieldsFromSchema(\n JSON.parse(JSON.stringify(raw)) as JsonSchemaType,\n getCollectionVirtualFieldNames(req.payload.config, item.collectionSlug),\n )\n inputSchema = inputSchema({ collectionSchema })\n }\n server.registerTool(\n name,\n {\n description: tool.description,\n inputSchema: inputSchema ? toStandardSchema(inputSchema) : undefined,\n },\n async (input: unknown, ctx: ServerContext) =>\n finalizeToolResponse(\n await tool.handler({\n authorizedMCP,\n collectionSlug: item.collectionSlug,\n input: (input ?? {}) as Record<string, unknown>,\n req,\n serverContext: ctx,\n }),\n tool.overrideResponse,\n ),\n )\n logger.info(`✅ Tool: ${name} Registered.`)\n break\n }\n case 'globalTool': {\n const tool = item.tool\n const name = wireName(item.key, item.globalSlug)\n let inputSchema = tool.input\n if (typeof inputSchema === 'function') {\n const raw = configSchema.definitions?.[item.globalSlug]\n if (!raw) {\n throw new APIError(`Global schema not found for slug: ${item.globalSlug}`, 500)\n }\n const globalSchema = removeVirtualFieldsFromSchema(\n JSON.parse(JSON.stringify(raw)) as JsonSchemaType,\n getGlobalVirtualFieldNames(req.payload.config, item.globalSlug),\n )\n\n inputSchema = inputSchema({ globalSchema })\n }\n server.registerTool(\n name,\n {\n description: tool.description,\n inputSchema: inputSchema ? toStandardSchema(inputSchema) : undefined,\n },\n async (input: unknown, ctx: ServerContext) =>\n finalizeToolResponse(\n await tool.handler({\n authorizedMCP,\n globalSlug: item.globalSlug,\n input: (input ?? {}) as Record<string, unknown>,\n req,\n serverContext: ctx,\n }),\n tool.overrideResponse,\n ),\n )\n logger.info(`✅ Tool: ${name} Registered.`)\n break\n }\n case 'prompt': {\n const prompt = item.prompt\n server.registerPrompt(\n item.key,\n {\n argsSchema: prompt.argsSchema ? toStandardSchema(prompt.argsSchema) : undefined,\n description: prompt.description,\n title: prompt.title,\n },\n async (input: unknown, ctx: ServerContext) =>\n prompt.handler({\n input: (input ?? {}) as Record<string, unknown>,\n req,\n serverContext: ctx,\n }),\n )\n logger.info(`✅ Prompt: ${prompt.title} Registered.`)\n break\n }\n case 'resource': {\n const resource = item.resource\n server.registerResource(\n item.key,\n // @ts-expect-error - Overload type ambiguity (string OR ResourceTemplate is valid)\n resource.uri,\n {\n description: resource.description,\n mimeType: resource.mimeType,\n title: resource.title,\n },\n // Static URIs call (uri, ctx); ResourceTemplates call (uri, params, ctx).\n // The rest-params shape lets us collect either signature uniformly.\n async (...sdkArgs: unknown[]) => {\n const ctx = sdkArgs[sdkArgs.length - 1] as ServerContext\n const uri = sdkArgs[0] as URL\n const params = (sdkArgs.length > 2 ? sdkArgs[1] : {}) as Record<string, string>\n return resource.handler({ params, req, serverContext: ctx, uri })\n },\n )\n logger.info(`✅ Resource: ${resource.title} Registered.`)\n break\n }\n case 'tool': {\n const tool = item.tool\n server.registerTool(\n item.key,\n {\n description: tool.description,\n inputSchema: tool.input ? toStandardSchema(tool.input) : undefined,\n },\n async (input: unknown, ctx: ServerContext) =>\n finalizeToolResponse(\n await tool.handler({\n authorizedMCP,\n input: (input ?? {}) as Record<string, unknown>,\n req,\n serverContext: ctx,\n }),\n tool.overrideResponse,\n ),\n )\n logger.info(`✅ Tool: ${item.key} Registered.`)\n break\n }\n }\n }\n } catch (error) {\n throw new APIError(`Error initializing MCP handler: ${String(error)}`, 500)\n }\n\n return server\n}\n"],"names":["McpServer","APIError","configToJSONSchema","toCamelCase","getLogger","getCollectionVirtualFieldNames","getGlobalVirtualFieldNames","removeVirtualFieldsFromSchema","toStandardSchema","wireName","key","slug","camel","charAt","toUpperCase","slice","buildMcpServer","authorizedMCP","pluginConfig","req","serverOptions","mcp","server","name","version","serverInfo","options","logger","payload","finalizeToolResponse","response","overrideResponse","overridden","doc","_doc","rest","jsonSchema","configSchema","config","db","defaultIDType","i18n","forceInlineBlocks","item","items","type","tool","collectionSlug","inputSchema","input","raw","definitions","collectionSchema","JSON","parse","stringify","registerTool","description","undefined","ctx","handler","serverContext","info","globalSlug","globalSchema","prompt","registerPrompt","argsSchema","title","resource","registerResource","uri","mimeType","sdkArgs","length","params","error","String"],"mappings":"AAAA,SAASA,SAAS,QAA4B,+BAA8B;AAC5E,SAASC,QAAQ,EAAEC,kBAAkB,QAA6B,UAAS;AAU3E,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,mCAAkC;AACzC,SAASC,6BAA6B,QAAQ,6DAA4D;AAC1G,SAASC,gBAAgB,QAAQ,+BAA8B;AAE/D,6FAA6F,GAC7F,MAAMC,WAAW,CAACC,KAAaC;IAC7B,MAAMC,QAAQT,YAAYQ;IAC1B,OAAO,GAAGD,MAAME,MAAMC,MAAM,CAAC,GAAGC,WAAW,KAAKF,MAAMG,KAAK,CAAC,IAAI;AAClE;AAEA;;;;;;;;;CASC,GACD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,aAAa,EACbC,YAAY,EACZC,GAAG,EAKJ;IACC,MAAMC,gBAAgBF,aAAaG,GAAG,EAAED,iBAAiB,CAAC;IAC1D,MAAME,SAAS,IAAItB,UACjB;QAAEuB,MAAM;QAAsBC,SAAS;QAAS,GAAGJ,cAAcK,UAAU;IAAC,GAC5EL,cAAcM,OAAO;IAGvB,MAAMC,SAASvB,UAAU;QAAEwB,SAAST,IAAIS,OAAO;IAAC;IAEhD;;;GAGC,GACD,MAAMC,uBAAuB,CAC3BC,UACAC;QAEA,MAAMC,aAAaD,mBAAmBD,UAAUA,SAASG,GAAG,IAAI,CAAC,GAAGd,QAAQW;QAC5E,MAAM,EAAEG,KAAKC,IAAI,EAAE,GAAGC,MAAM,GAAGH;QAC/B,OAAOG;IACT;IAEA,MAAM,EAAEC,YAAYC,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E,OAAOkE,OAAO;QACd,MAAM,IAAI3E,SAAS,CAAC,gCAAgC,EAAE4E,OAAOD,QAAQ,EAAE;IACzE;IAEA,OAAOtD;AACT,EAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const authCollectionTool: import("../../../types.js").CollectionTool;
|
|
2
|
+
export declare const forgotPasswordCollectionTool: import("../../../types.js").CollectionTool;
|
|
3
|
+
export declare const loginCollectionTool: import("../../../types.js").CollectionTool;
|
|
4
|
+
export declare const resetPasswordCollectionTool: import("../../../types.js").CollectionTool;
|
|
5
|
+
export declare const unlockCollectionTool: import("../../../types.js").CollectionTool;
|
|
6
|
+
export declare const verifyCollectionTool: import("../../../types.js").CollectionTool;
|
|
7
|
+
//# sourceMappingURL=authTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authTools.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/authTools.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,kBAAkB,4CAoC7B,CAAA;AAEF,eAAO,MAAM,4BAA4B,4CAgCvC,CAAA;AAEF,eAAO,MAAM,mBAAmB,4CA0C9B,CAAA;AAEF,eAAO,MAAM,2BAA2B,4CA4BtC,CAAA;AAEF,eAAO,MAAM,oBAAoB,4CAyB/B,CAAA;AAEF,eAAO,MAAM,oBAAoB,4CA0B/B,CAAA"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCollectionTool } from '../../../defineTool.js';
|
|
3
|
+
import { getLogger } from '../../../utils/getLogger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Auth tools surfaced under `collections.<auth-collection>.tools`. Opt-in: they
|
|
6
|
+
* default off (an LLM with `login` access can probe passwords; not something
|
|
7
|
+
* to expose by default). Enable in plugin config via `tools: { login: true }`
|
|
8
|
+
* (or `{ description: '...' }`).
|
|
9
|
+
*
|
|
10
|
+
* `auth` (check current token) doesn't actually depend on the collection at
|
|
11
|
+
* runtime — `payload.auth({ headers })` is global — but it's grouped under the
|
|
12
|
+
* users collection so all auth-shaped tools live in one place.
|
|
13
|
+
*/ const emailSchema = z.string().email().describe('The user email address');
|
|
14
|
+
const wrapError = (name)=>({ collectionSlug, message })=>{
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: 'text',
|
|
19
|
+
text: `❌ **Error in ${name}** on ${collectionSlug}: ${message}`
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const authCollectionTool = defineCollectionTool({
|
|
25
|
+
description: 'Checks authentication status for the current user.',
|
|
26
|
+
input: z.object({
|
|
27
|
+
headers: z.string().describe('Optional JSON string containing custom headers to send with the authentication request').optional()
|
|
28
|
+
})
|
|
29
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
30
|
+
const logger = getLogger({
|
|
31
|
+
payload: req.payload
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
let authHeaders = new Headers();
|
|
35
|
+
if (input.headers) {
|
|
36
|
+
try {
|
|
37
|
+
authHeaders = new Headers(JSON.parse(input.headers));
|
|
38
|
+
} catch {
|
|
39
|
+
logger.warn(`Invalid headers JSON for auth: ${input.headers}, using empty headers`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const result = await req.payload.auth({
|
|
43
|
+
headers: authHeaders
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text',
|
|
49
|
+
text: `# Authentication Status\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
doc: result
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
56
|
+
logger.error(`Error in auth tool on ${collectionSlug}: ${errorMessage}`);
|
|
57
|
+
return wrapError('auth')({
|
|
58
|
+
collectionSlug,
|
|
59
|
+
message: errorMessage
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export const forgotPasswordCollectionTool = defineCollectionTool({
|
|
64
|
+
description: 'Sends a password reset email to a user.',
|
|
65
|
+
input: z.object({
|
|
66
|
+
disableEmail: z.boolean().describe('Whether to disable sending the email (for testing)').optional().default(false),
|
|
67
|
+
email: emailSchema
|
|
68
|
+
})
|
|
69
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
70
|
+
const logger = getLogger({
|
|
71
|
+
payload: req.payload
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
const result = await req.payload.forgotPassword({
|
|
75
|
+
collection: collectionSlug,
|
|
76
|
+
data: {
|
|
77
|
+
email: input.email
|
|
78
|
+
},
|
|
79
|
+
disableEmail: input.disableEmail
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: 'text',
|
|
85
|
+
text: `# Forgot Password Email Sent\n\n**Collection:** ${collectionSlug}\n**Email:** ${input.email}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
doc: {
|
|
89
|
+
result
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
} catch (error) {
|
|
93
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
94
|
+
logger.error(`Error in forgotPassword tool on ${collectionSlug}: ${errorMessage}`);
|
|
95
|
+
return wrapError('forgotPassword')({
|
|
96
|
+
collectionSlug,
|
|
97
|
+
message: errorMessage
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
export const loginCollectionTool = defineCollectionTool({
|
|
102
|
+
description: 'Authenticates a user with email and password.',
|
|
103
|
+
input: z.object({
|
|
104
|
+
depth: z.number().int().min(0).max(10).describe('Depth of population for relationships').optional().default(0),
|
|
105
|
+
email: emailSchema,
|
|
106
|
+
password: z.string().describe('The user password'),
|
|
107
|
+
showHiddenFields: z.boolean().describe('Whether to show hidden fields in the response').optional().default(false)
|
|
108
|
+
})
|
|
109
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
110
|
+
const logger = getLogger({
|
|
111
|
+
payload: req.payload
|
|
112
|
+
});
|
|
113
|
+
try {
|
|
114
|
+
const result = await req.payload.login({
|
|
115
|
+
collection: collectionSlug,
|
|
116
|
+
data: {
|
|
117
|
+
email: input.email,
|
|
118
|
+
password: input.password
|
|
119
|
+
},
|
|
120
|
+
depth: input.depth,
|
|
121
|
+
showHiddenFields: input.showHiddenFields
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
content: [
|
|
125
|
+
{
|
|
126
|
+
type: 'text',
|
|
127
|
+
text: `# Login Successful\n\n**User:** ${input.email}\n**Collection:** ${collectionSlug}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
doc: result
|
|
131
|
+
};
|
|
132
|
+
} catch (error) {
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
134
|
+
logger.error(`Error in login tool on ${collectionSlug}: ${errorMessage}`);
|
|
135
|
+
return wrapError('login')({
|
|
136
|
+
collectionSlug,
|
|
137
|
+
message: errorMessage
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
export const resetPasswordCollectionTool = defineCollectionTool({
|
|
142
|
+
description: 'Resets a user password with a reset token.',
|
|
143
|
+
input: z.object({
|
|
144
|
+
password: z.string().describe('The new password for the user'),
|
|
145
|
+
token: z.string().describe('The password reset token sent to the user email')
|
|
146
|
+
})
|
|
147
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
148
|
+
const logger = getLogger({
|
|
149
|
+
payload: req.payload
|
|
150
|
+
});
|
|
151
|
+
try {
|
|
152
|
+
const result = await req.payload.resetPassword({
|
|
153
|
+
collection: collectionSlug,
|
|
154
|
+
data: {
|
|
155
|
+
password: input.password,
|
|
156
|
+
token: input.token
|
|
157
|
+
},
|
|
158
|
+
overrideAccess: true
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
content: [
|
|
162
|
+
{
|
|
163
|
+
type: 'text',
|
|
164
|
+
text: `# Password Reset Successful\n\n**Collection:** ${collectionSlug}\n\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
doc: result
|
|
168
|
+
};
|
|
169
|
+
} catch (error) {
|
|
170
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
171
|
+
logger.error(`Error in resetPassword tool on ${collectionSlug}: ${errorMessage}`);
|
|
172
|
+
return wrapError('resetPassword')({
|
|
173
|
+
collectionSlug,
|
|
174
|
+
message: errorMessage
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
export const unlockCollectionTool = defineCollectionTool({
|
|
179
|
+
description: 'Unlocks a user account that has been locked due to failed login attempts.',
|
|
180
|
+
input: z.object({
|
|
181
|
+
email: emailSchema
|
|
182
|
+
})
|
|
183
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
184
|
+
const logger = getLogger({
|
|
185
|
+
payload: req.payload
|
|
186
|
+
});
|
|
187
|
+
try {
|
|
188
|
+
const result = await req.payload.unlock({
|
|
189
|
+
collection: collectionSlug,
|
|
190
|
+
data: {
|
|
191
|
+
email: input.email
|
|
192
|
+
},
|
|
193
|
+
overrideAccess: true
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
content: [
|
|
197
|
+
{
|
|
198
|
+
type: 'text',
|
|
199
|
+
text: `# Account Unlocked\n\n**Collection:** ${collectionSlug}\n**Email:** ${input.email}\n**Result:** ${result ? 'Success' : 'Failed'}`
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
doc: {
|
|
203
|
+
result
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
} catch (error) {
|
|
207
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
208
|
+
logger.error(`Error in unlock tool on ${collectionSlug}: ${errorMessage}`);
|
|
209
|
+
return wrapError('unlock')({
|
|
210
|
+
collectionSlug,
|
|
211
|
+
message: errorMessage
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
export const verifyCollectionTool = defineCollectionTool({
|
|
216
|
+
description: 'Verifies a user email with a verification token.',
|
|
217
|
+
input: z.object({
|
|
218
|
+
token: z.string().describe('The verification token sent to the user email')
|
|
219
|
+
})
|
|
220
|
+
}).handler(async ({ collectionSlug, input, req })=>{
|
|
221
|
+
const logger = getLogger({
|
|
222
|
+
payload: req.payload
|
|
223
|
+
});
|
|
224
|
+
try {
|
|
225
|
+
const result = await req.payload.verifyEmail({
|
|
226
|
+
collection: collectionSlug,
|
|
227
|
+
token: input.token
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
content: [
|
|
231
|
+
{
|
|
232
|
+
type: 'text',
|
|
233
|
+
text: `# Email Verification Successful\n\n**Collection:** ${collectionSlug}\n**Result:** ${result ? 'Success' : 'Failed'}`
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
doc: {
|
|
237
|
+
result
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
} catch (error) {
|
|
241
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
242
|
+
logger.error(`Error in verify tool on ${collectionSlug}: ${errorMessage}`);
|
|
243
|
+
return wrapError('verify')({
|
|
244
|
+
collectionSlug,
|
|
245
|
+
message: errorMessage
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
//# sourceMappingURL=authTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/authTools.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport type { MCPToolResponse } from '../../../types.js'\n\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\n/**\n * Auth tools surfaced under `collections.<auth-collection>.tools`. Opt-in: they\n * default off (an LLM with `login` access can probe passwords; not something\n * to expose by default). Enable in plugin config via `tools: { login: true }`\n * (or `{ description: '...' }`).\n *\n * `auth` (check current token) doesn't actually depend on the collection at\n * runtime — `payload.auth({ headers })` is global — but it's grouped under the\n * users collection so all auth-shaped tools live in one place.\n */\n\nconst emailSchema = z.string().email().describe('The user email address')\n\nconst wrapError =\n (name: string) =>\n ({ collectionSlug, message }: { collectionSlug: string; message: string }): MCPToolResponse => {\n return {\n content: [\n {\n type: 'text',\n text: `❌ **Error in ${name}** on ${collectionSlug}: ${message}`,\n },\n ],\n }\n }\n\nexport const authCollectionTool = defineCollectionTool({\n description: 'Checks authentication status for the current user.',\n input: z.object({\n headers: z\n .string()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n )\n .optional(),\n }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n let authHeaders = new Headers()\n if (input.headers) {\n try {\n authHeaders = new Headers(JSON.parse(input.headers) as Record<string, string>)\n } catch {\n logger.warn(`Invalid headers JSON for auth: ${input.headers}, using empty headers`)\n }\n }\n const result = await req.payload.auth({ headers: authHeaders })\n return {\n content: [\n {\n type: 'text',\n text: `# Authentication Status\\n\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in auth tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('auth')({ collectionSlug, message: errorMessage })\n }\n})\n\nexport const forgotPasswordCollectionTool = defineCollectionTool({\n description: 'Sends a password reset email to a user.',\n input: z.object({\n disableEmail: z\n .boolean()\n .describe('Whether to disable sending the email (for testing)')\n .optional()\n .default(false),\n email: emailSchema,\n }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n const result = await req.payload.forgotPassword({\n collection: collectionSlug,\n data: { email: input.email },\n disableEmail: input.disableEmail,\n })\n return {\n content: [\n {\n type: 'text',\n text: `# Forgot Password Email Sent\\n\\n**Collection:** ${collectionSlug}\\n**Email:** ${input.email}\\n\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: { result } as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in forgotPassword tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('forgotPassword')({ collectionSlug, message: errorMessage })\n }\n})\n\nexport const loginCollectionTool = defineCollectionTool({\n description: 'Authenticates a user with email and password.',\n input: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('Depth of population for relationships')\n .optional()\n .default(0),\n email: emailSchema,\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .describe('Whether to show hidden fields in the response')\n .optional()\n .default(false),\n }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n const result = await req.payload.login({\n collection: collectionSlug,\n data: { email: input.email, password: input.password },\n depth: input.depth,\n showHiddenFields: input.showHiddenFields,\n })\n return {\n content: [\n {\n type: 'text',\n text: `# Login Successful\\n\\n**User:** ${input.email}\\n**Collection:** ${collectionSlug}\\n\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in login tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('login')({ collectionSlug, message: errorMessage })\n }\n})\n\nexport const resetPasswordCollectionTool = defineCollectionTool({\n description: 'Resets a user password with a reset token.',\n input: z.object({\n password: z.string().describe('The new password for the user'),\n token: z.string().describe('The password reset token sent to the user email'),\n }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n const result = await req.payload.resetPassword({\n collection: collectionSlug,\n data: { password: input.password, token: input.token },\n overrideAccess: true,\n })\n return {\n content: [\n {\n type: 'text',\n text: `# Password Reset Successful\\n\\n**Collection:** ${collectionSlug}\\n\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in resetPassword tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('resetPassword')({ collectionSlug, message: errorMessage })\n }\n})\n\nexport const unlockCollectionTool = defineCollectionTool({\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n input: z.object({ email: emailSchema }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n const result = await req.payload.unlock({\n collection: collectionSlug,\n data: { email: input.email },\n overrideAccess: true,\n })\n return {\n content: [\n {\n type: 'text',\n text: `# Account Unlocked\\n\\n**Collection:** ${collectionSlug}\\n**Email:** ${input.email}\\n**Result:** ${result ? 'Success' : 'Failed'}`,\n },\n ],\n doc: { result } as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in unlock tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('unlock')({ collectionSlug, message: errorMessage })\n }\n})\n\nexport const verifyCollectionTool = defineCollectionTool({\n description: 'Verifies a user email with a verification token.',\n input: z.object({\n token: z.string().describe('The verification token sent to the user email'),\n }),\n}).handler(async ({ collectionSlug, input, req }) => {\n const logger = getLogger({ payload: req.payload })\n try {\n const result = await req.payload.verifyEmail({\n collection: collectionSlug,\n token: input.token,\n })\n return {\n content: [\n {\n type: 'text',\n text: `# Email Verification Successful\\n\\n**Collection:** ${collectionSlug}\\n**Result:** ${result ? 'Success' : 'Failed'}`,\n },\n ],\n doc: { result } as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error in verify tool on ${collectionSlug}: ${errorMessage}`)\n return wrapError('verify')({ collectionSlug, message: errorMessage })\n }\n})\n"],"names":["z","defineCollectionTool","getLogger","emailSchema","string","email","describe","wrapError","name","collectionSlug","message","content","type","text","authCollectionTool","description","input","object","headers","optional","handler","req","logger","payload","authHeaders","Headers","JSON","parse","warn","result","auth","stringify","doc","error","errorMessage","Error","forgotPasswordCollectionTool","disableEmail","boolean","default","forgotPassword","collection","data","loginCollectionTool","depth","number","int","min","max","password","showHiddenFields","login","resetPasswordCollectionTool","token","resetPassword","overrideAccess","unlockCollectionTool","unlock","verifyCollectionTool","verifyEmail"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAIvB,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AAEvD;;;;;;;;;CASC,GAED,MAAMC,cAAcH,EAAEI,MAAM,GAAGC,KAAK,GAAGC,QAAQ,CAAC;AAEhD,MAAMC,YACJ,CAACC,OACD,CAAC,EAAEC,cAAc,EAAEC,OAAO,EAA+C;QACvE,OAAO;YACLC,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,aAAa,EAAEL,KAAK,MAAM,EAAEC,eAAe,EAAE,EAAEC,SAAS;gBACjE;aACD;QACH;IACF;AAEF,OAAO,MAAMI,qBAAqBb,qBAAqB;IACrDc,aAAa;IACbC,OAAOhB,EAAEiB,MAAM,CAAC;QACdC,SAASlB,EACNI,MAAM,GACNE,QAAQ,CACP,0FAEDa,QAAQ;IACb;AACF,GAAGC,OAAO,CAAC,OAAO,EAAEX,cAAc,EAAEO,KAAK,EAAEK,GAAG,EAAE;IAC9C,MAAMC,SAASpB,UAAU;QAAEqB,SAASF,IAAIE,OAAO;IAAC;IAChD,IAAI;QACF,IAAIC,cAAc,IA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W,CAAC;YAC3ClB,YAAYhC;YACZ4C,OAAOrC,MAAMqC,KAAK;QACpB;QACA,OAAO;YACL1C,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,mDAAmD,EAAEJ,eAAe,cAAc,EAAEoB,SAAS,YAAY,UAAU;gBAC5H;aACD;YACDG,KAAK;gBAAEH;YAAO;QAChB;IACF,EAAE,OAAOI,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMvB,OAAO,GAAG;QAC9DY,OAAOW,KAAK,CAAC,CAAC,wBAAwB,EAAExB,eAAe,EAAE,EAAEyB,cAAc;QACzE,OAAO3B,UAAU,UAAU;YAAEE;YAAgBC,SAASwB;QAAa;IACrE;AACF,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,oBAAoB,4CAmG/B,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineCollectionTool } from '../../../defineTool.js';
|
|
3
|
+
import { getLogger } from '../../../utils/getLogger.js';
|
|
4
|
+
import { getCollectionVirtualFieldNames, stripVirtualFields } from '../../../utils/getVirtualFieldNames.js';
|
|
5
|
+
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
|
+
import { prepareCollectionSchema } from '../../../utils/schemaConversion/prepareCollectionSchema.js';
|
|
7
|
+
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
|
|
8
|
+
const DEFAULT_DESCRIPTION = 'Create a document in a collection.';
|
|
9
|
+
export const createCollectionTool = defineCollectionTool({
|
|
10
|
+
description: DEFAULT_DESCRIPTION,
|
|
11
|
+
input: ({ collectionSchema })=>z.object({
|
|
12
|
+
data: z.fromJSONSchema(prepareCollectionSchema(collectionSchema)).describe('The document fields to create'),
|
|
13
|
+
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in response').optional().default(0),
|
|
14
|
+
draft: z.boolean().describe('Whether to create the document as a draft').optional().default(false),
|
|
15
|
+
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
16
|
+
locale: z.string().describe('Optional: locale code to create the document in (e.g., "en", "es"). Defaults to the default locale').optional(),
|
|
17
|
+
select: z.string().describe('Optional: define exactly which fields you\'d like to create (JSON), e.g., \'{"title": "My Post"}\'').optional()
|
|
18
|
+
})
|
|
19
|
+
}).handler(async ({ authorizedMCP, collectionSlug, input, req })=>{
|
|
20
|
+
const payload = req.payload;
|
|
21
|
+
const logger = getLogger({
|
|
22
|
+
payload
|
|
23
|
+
});
|
|
24
|
+
const { data, depth, draft, fallbackLocale, locale, select } = input;
|
|
25
|
+
logger.info(`Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`);
|
|
26
|
+
try {
|
|
27
|
+
let parsedData = transformPointDataToPayload(data);
|
|
28
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug);
|
|
29
|
+
parsedData = stripVirtualFields(parsedData, virtualFieldNames);
|
|
30
|
+
let selectClause;
|
|
31
|
+
if (select) {
|
|
32
|
+
try {
|
|
33
|
+
selectClause = JSON.parse(select);
|
|
34
|
+
} catch {
|
|
35
|
+
logger.warn(`Invalid select clause JSON: ${select}`);
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: 'Error: Invalid JSON in select clause'
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const result = await payload.create({
|
|
47
|
+
collection: collectionSlug,
|
|
48
|
+
data: parsedData,
|
|
49
|
+
depth,
|
|
50
|
+
draft,
|
|
51
|
+
req,
|
|
52
|
+
...localAPIDefaults(authorizedMCP),
|
|
53
|
+
...locale ? {
|
|
54
|
+
locale
|
|
55
|
+
} : {},
|
|
56
|
+
...fallbackLocale ? {
|
|
57
|
+
fallbackLocale
|
|
58
|
+
} : {},
|
|
59
|
+
...selectClause ? {
|
|
60
|
+
select: selectClause
|
|
61
|
+
} : {}
|
|
62
|
+
});
|
|
63
|
+
logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`);
|
|
64
|
+
return {
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'text',
|
|
68
|
+
text: `Document created successfully in collection "${collectionSlug}"!\nCreated document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
doc: result
|
|
72
|
+
};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
75
|
+
logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`);
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: `Error creating document in collection "${collectionSlug}": ${errorMessage}`
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=createTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/createTool.ts"],"sourcesContent":["import type { SelectType } from 'payload'\n\nimport { z } from 'zod'\n\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport {\n getCollectionVirtualFieldNames,\n stripVirtualFields,\n} from '../../../utils/getVirtualFieldNames.js'\nimport { localAPIDefaults } from '../../../utils/localAPIDefaults.js'\nimport { prepareCollectionSchema } from '../../../utils/schemaConversion/prepareCollectionSchema.js'\nimport { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'\n\nconst DEFAULT_DESCRIPTION = 'Create a document in a collection.'\n\nexport const createCollectionTool = defineCollectionTool({\n description: DEFAULT_DESCRIPTION,\n input: ({ collectionSchema }) =>\n z.object({\n data: z\n .fromJSONSchema(\n prepareCollectionSchema(collectionSchema) as unknown as z.core.JSONSchema.JSONSchema,\n )\n .describe('The document fields to create'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .describe('How many levels deep to populate relationships in response')\n .optional()\n .default(0),\n draft: z\n .boolean()\n .describe('Whether to create the document as a draft')\n .optional()\n .default(false),\n fallbackLocale: z\n .string()\n .describe('Optional: fallback locale code to use when requested locale is not available')\n .optional(),\n locale: z\n .string()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n )\n .optional(),\n select: z\n .string()\n .describe(\n 'Optional: define exactly which fields you\\'d like to create (JSON), e.g., \\'{\"title\": \"My Post\"}\\'',\n )\n .optional(),\n }),\n}).handler(async ({ authorizedMCP, collectionSlug, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { data, depth, draft, fallbackLocale, locale, select } = input\n\n logger.info(\n `Creating document in collection: ${collectionSlug}${locale ? ` with locale: ${locale}` : ''}`,\n )\n\n try {\n let parsedData = transformPointDataToPayload(data as Record<string, unknown>)\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)\n parsedData = stripVirtualFields(parsedData, virtualFieldNames)\n\n let selectClause: SelectType | undefined\n if (select) {\n try {\n selectClause = JSON.parse(select) as SelectType\n } catch {\n logger.warn(`Invalid select clause JSON: ${select}`)\n return { content: [{ type: 'text', text: 'Error: Invalid JSON in select clause' }] }\n }\n }\n\n const result = await payload.create({\n collection: collectionSlug,\n data: parsedData,\n depth,\n draft,\n req,\n ...localAPIDefaults(authorizedMCP),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale ? { fallbackLocale } : {}),\n ...(selectClause ? { select: selectClause } : {}),\n })\n\n logger.info(`Successfully created document in ${collectionSlug} with ID: ${result.id}`)\n\n return {\n content: [\n {\n type: 'text',\n text: `Document created successfully in collection \"${collectionSlug}\"!\\nCreated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error creating document in ${collectionSlug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `Error creating document in collection \"${collectionSlug}\": ${errorMessage}`,\n },\n ],\n }\n }\n})\n"],"names":["z","defineCollectionTool","getLogger","getCollectionVirtualFieldNames","stripVirtualFields","localAPIDefaults","prepareCollectionSchema","transformPointDataToPayload","DEFAULT_DESCRIPTION","createCollectionTool","description","input","collectionSchema","object","data","fromJSONSchema","describe","depth","number","int","min","max","optional","default","draft","boolean","fallbackLocale","string","locale","select","handler","authorizedMCP","collectionSlug","req","payload","logger","info","parsedData","virtualFieldNames","config","selectClause","JSON","parse","warn","content","type","text","result","create","collection","id","stringify","doc","error","errorMessage","Error","message"],"mappings":"AAEA,SAASA,CAAC,QAAQ,MAAK;AAEvB,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,QAAQ,8BAA6B;AACvD,SACEC,8BAA8B,EAC9BC,kBAAkB,QACb,yCAAwC;AAC/C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,uBAAuB,QAAQ,6DAA4D;AACpG,SAASC,2BAA2B,QAAQ,gDAA+C;AAE3F,MAAMC,sBAAsB;AAE5B,OAAO,MAAMC,uBAAuBR,qBAAqB;IACvDS,aAAaF;IACbG,OAAO,CAAC,EAAEC,gBAAgB,EAAE,GAC1BZ,EAAEa,MAAM,CAAC;YACPC,MAAMd,EACHe,cAAc,CACbT,wBAAwBM,mBAEzBI,QAAQ,CAAC;YACZC,OAAOjB,EACJkB,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJL,QAAQ,CAAC,8DACTM,QAAQ,GACRC,OAAO,CAAC;YACXC,OAAOxB,EACJyB,OAA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