@payloadcms/plugin-mcp 3.78.0-canary.1 → 3.78.0-canary.3
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/dist/mcp/helpers/config.d.ts +1 -9
- package/dist/mcp/helpers/config.d.ts.map +1 -1
- package/dist/mcp/helpers/config.js +0 -62
- package/dist/mcp/helpers/config.js.map +1 -1
- package/dist/mcp/helpers/fields.d.ts +6 -25
- package/dist/mcp/helpers/fields.d.ts.map +1 -1
- package/dist/mcp/helpers/fields.js +35 -29
- package/dist/mcp/helpers/fields.js.map +1 -1
- package/dist/mcp/helpers/fileValidation.d.ts +0 -2
- package/dist/mcp/helpers/fileValidation.d.ts.map +1 -1
- package/dist/mcp/helpers/fileValidation.js +44 -82
- package/dist/mcp/helpers/fileValidation.js.map +1 -1
- package/dist/mcp/tools/collection/create.d.ts.map +1 -1
- package/dist/mcp/tools/collection/create.js +2 -25
- package/dist/mcp/tools/collection/create.js.map +1 -1
- package/dist/mcp/tools/collection/delete.d.ts.map +1 -1
- package/dist/mcp/tools/collection/delete.js +1 -12
- package/dist/mcp/tools/collection/delete.js.map +1 -1
- package/dist/mcp/tools/config/update.d.ts +1 -1
- package/dist/mcp/tools/config/update.d.ts.map +1 -1
- package/dist/mcp/tools/config/update.js +3 -3
- package/dist/mcp/tools/config/update.js.map +1 -1
- package/dist/mcp/tools/job/create.d.ts.map +1 -1
- package/dist/mcp/tools/job/create.js +3 -6
- package/dist/mcp/tools/job/create.js.map +1 -1
- package/dist/mcp/tools/job/run.d.ts +1 -1
- package/dist/mcp/tools/job/run.d.ts.map +1 -1
- package/dist/mcp/tools/job/run.js +5 -26
- package/dist/mcp/tools/job/run.js.map +1 -1
- package/dist/mcp/tools/job/update.d.ts.map +1 -1
- package/dist/mcp/tools/job/update.js +10 -38
- package/dist/mcp/tools/job/update.js.map +1 -1
- package/dist/mcp/tools/schemas.d.ts +0 -3
- package/dist/mcp/tools/schemas.d.ts.map +1 -1
- package/dist/mcp/tools/schemas.js +0 -1
- package/dist/mcp/tools/schemas.js.map +1 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +1 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +1 -2
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +5 -0
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +38 -0
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -1
- package/package.json +3 -3
- package/src/mcp/helpers/config.ts +1 -114
- package/src/mcp/helpers/fields.ts +46 -50
- package/src/mcp/helpers/fileValidation.ts +38 -93
- package/src/mcp/tools/collection/create.ts +2 -30
- package/src/mcp/tools/collection/delete.ts +1 -19
- package/src/mcp/tools/config/update.ts +0 -4
- package/src/mcp/tools/job/create.ts +5 -11
- package/src/mcp/tools/job/run.ts +14 -38
- package/src/mcp/tools/job/update.ts +29 -77
- package/src/mcp/tools/schemas.ts +0 -1
- package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +1 -3
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +41 -0
- package/dist/mcp/helpers/conversion.d.ts +0 -2
- package/dist/mcp/helpers/conversion.d.ts.map +0 -1
- package/dist/mcp/helpers/conversion.js +0 -5
- package/dist/mcp/helpers/conversion.js.map +0 -1
- package/dist/mcp/helpers/validation.d.ts +0 -9
- package/dist/mcp/helpers/validation.d.ts.map +0 -1
- package/dist/mcp/helpers/validation.js +0 -22
- package/dist/mcp/helpers/validation.js.map +0 -1
- package/src/mcp/helpers/conversion.ts +0 -3
- package/src/mcp/helpers/validation.ts +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/tools/job/run.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { toolSchemas } from '../schemas.js'\n\n// Reusable function for running jobs\nexport const runJob = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobSlug: string,\n input: Record<string,
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/tools/job/run.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { toolSchemas } from '../schemas.js'\n\n// Reusable function for running jobs\nexport const runJob = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobSlug: string,\n input: Record<string, unknown>,\n queue?: string,\n priority?: number,\n delay?: number,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Running job: ${jobSlug}`)\n }\n\n try {\n // Actually run the job using Payload's job queue\n const jobQueueOptions: Record<string, unknown> = {\n input,\n task: jobSlug,\n }\n\n if (queue && queue !== 'default') {\n jobQueueOptions.queue = queue\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Using custom queue: ${queue}`)\n }\n }\n\n if (priority && priority > 0) {\n jobQueueOptions.priority = priority\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Setting job priority: ${priority}`)\n }\n }\n\n if (delay && delay > 0) {\n jobQueueOptions.waitUntil = new Date(Date.now() + delay)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Setting job delay: ${delay}ms`)\n }\n }\n\n if (verboseLogs) {\n payload.logger.info(\n `[payload-mcp] Queuing job with options: ${JSON.stringify(jobQueueOptions)}`,\n )\n }\n\n const job = await payload.jobs.queue(\n jobQueueOptions as Parameters<typeof payload.jobs.queue>[0],\n )\n\n const jobId = (job as { id?: string })?.id || 'unknown'\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Job created successfully: ${jobId}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `# Job Queued Successfully: ${jobSlug}\n\n## Job Details\n- **Job ID**: ${jobId}\n- **Job Slug**: ${jobSlug}\n- **Queue**: ${queue || 'default'}\n- **Priority**: ${priority || 'default'}\n- **Delay**: ${delay ? `${delay}ms` : 'none'}\n- **Status**: Queued and Running\n\n## Input Data\n\\`\\`\\`json\n${JSON.stringify(input, null, 2)}\n\\`\\`\\`\n\n## Job Status\nThe job has been successfully queued and will be processed according to the queue settings.\n\n## Monitoring the Job\nYou can monitor the job status using:\n\n\\`\\`\\`typescript\n// Check job status\nconst jobStatus = await payload.jobs.status('${jobId}')\nconsole.log('Job status:', jobStatus)\n\n// Wait for completion\nconst result = await payload.jobs.wait('${jobId}')\nconsole.log('Job result:', result)\n\\`\\`\\`\n\n✅ Job successfully queued with ID: ${jobId}`,\n },\n ],\n }\n } catch (error) {\n const errorMsg = (error as Error).message\n payload.logger.error(`[payload-mcp] Error running job \"${jobSlug}\": ${errorMsg}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ Error running job \"${jobSlug}\": ${errorMsg}\n\n## Common Issues:\n1. **Job not found**: The job \"${jobSlug}\" may not be registered in your Payload configuration\n2. **Invalid input format**: Ensure the input matches the job's input schema\n3. **Queue not configured**: The queue \"${queue || 'default'}\" may not be properly set up\n4. **Permission issues**: Ensure proper access rights for job execution\n5. **Job handler error**: The job implementation may have errors\n\n## Input Data Provided:\n\\`\\`\\`json\n${JSON.stringify(input, null, 2)}\n\\`\\`\\`\n\n## Next Steps:\n1. **Verify job exists**: Check that the job \"${jobSlug}\" is properly registered\n2. **Check input format**: Ensure the input data matches the expected schema\n3. **Review job configuration**: Verify the job is properly configured in your Payload setup\n4. **Check permissions**: Ensure you have the necessary permissions to run jobs\n5. **Review error logs**: Check the server logs for more detailed error information\n\n## Troubleshooting:\n- **Job not found**: Verify the job slug and check your jobs configuration\n- **Schema mismatch**: Ensure input data matches the job's input schema\n- **Queue issues**: Check that the specified queue is properly configured\n- **Permission errors**: Verify user permissions for job execution`,\n },\n ],\n }\n }\n}\n\nexport const runJobTool = (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => {\n server.registerTool(\n 'runJob',\n {\n description: 'Runs a Payload job with specified input data and queue options',\n inputSchema: toolSchemas.runJob.parameters.shape,\n },\n async ({ delay, input, jobSlug, priority, queue }) => {\n if (verboseLogs) {\n req.payload.logger.info(`[payload-mcp] Run Job Tool called with: ${jobSlug}`)\n }\n return runJob(\n req,\n verboseLogs,\n jobSlug,\n input as Record<string, unknown>,\n queue,\n priority,\n delay,\n )\n },\n )\n}\n"],"names":["toolSchemas","runJob","req","verboseLogs","jobSlug","input","queue","priority","delay","payload","logger","info","jobQueueOptions","task","waitUntil","Date","now","JSON","stringify","job","jobs","jobId","id","content","type","text","error","errorMsg","message","runJobTool","server","registerTool","description","inputSchema","parameters","shape"],"mappings":"AAGA,SAASA,WAAW,QAAQ,gBAAe;AAE3C,qCAAqC;AACrC,OAAO,MAAMC,SAAS,OACpBC,KACAC,aACAC,SACAC,OACAC,OACAC,UACAC;IAEA,MAAMC,UAAUP,IAAIO,OAAO;IAE3B,IAAIN,aAAa;QACfM,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,2BAA2B,EAAEP,SAAS;IAC7D;IAEA,IAAI;QACF,iDAAiD;QACjD,MAAMQ,kBAA2C;YAC/CP;YACAQ,MAAMT;QACR;QAEA,IAAIE,SAASA,UAAU,WAAW;YAChCM,gBAAgBN,KAAK,GAAGA;YACxB,IAAIH,aAAa;gBACfM,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,kCAAkC,EAAEL,OAAO;YAClE;QACF;QAEA,IAAIC,YAAYA,WAAW,GAAG;YAC5BK,gBAAgBL,QAAQ,GAAGA;YAC3B,IAAIJ,aAAa;gBACfM,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,oCAAoC,EAAEJ,UAAU;YACvE;QACF;QAEA,IAAIC,SAASA,QAAQ,GAAG;YACtBI,gBAAgBE,SAAS,GAAG,IAAIC,KAAKA,KAAKC,GAAG,KAAKR;YAClD,IAAIL,aAAa;gBACfM,QAAQC,MAAM,CAACC,IAAI,CA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,CAACC,QAAmB5B,KAAqBC;IACjE2B,OAAOC,YAAY,CACjB,UACA;QACEC,aAAa;QACbC,aAAajC,YAAYC,MAAM,CAACiC,UAAU,CAACC,KAAK;IAClD,GACA,OAAO,EAAE3B,KAAK,EAAEH,KAAK,EAAED,OAAO,EAAEG,QAAQ,EAAED,KAAK,EAAE;QAC/C,IAAIH,aAAa;YACfD,IAAIO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,wCAAwC,EAAEP,SAAS;QAC9E;QACA,OAAOH,OACLC,KACAC,aACAC,SACAC,OACAC,OACAC,UACAC;IAEJ;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/job/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/job/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAOvF,eAAO,MAAM,SAAS,QACf,cAAc,eACN,OAAO,WACX,MAAM,WACN,MAAM,cACH,MAAM,gBACJ,WAAW,EAAE,iBACZ,WAAW,EAAE,iBACb,gBAAgB,EAAE,iBAClB,eAAe,gBAChB,MAAM;;;;;EAiLrB,CAAA;AAgCD,eAAO,MAAM,aAAa,WAChB,SAAS,OACZ,cAAc,eACN,OAAO,WACX,MAAM,SAqChB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import { toCamelCase } from '../../../utils/camelCase.js';
|
|
3
4
|
import { validatePayloadFile } from '../../helpers/fileValidation.js';
|
|
4
5
|
import { toolSchemas } from '../schemas.js';
|
|
5
6
|
// Reusable function for updating jobs
|
|
@@ -153,61 +154,32 @@ export const updateJob = async (req, verboseLogs, jobsDir, jobSlug, updateType,
|
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
156
|
};
|
|
156
|
-
// Helper function to convert to camel case
|
|
157
|
-
function toCamelCase(str) {
|
|
158
|
-
return str.replace(/[-_\s]+(.)?/g, (_, chr)=>chr ? chr.toUpperCase() : '').replace(/^(.)/, (_, chr)=>chr.toLowerCase());
|
|
159
|
-
}
|
|
160
157
|
// Helper functions for different update types
|
|
161
|
-
function updateSchema(content,
|
|
158
|
+
function updateSchema(content, _camelCaseJobSlug, _inputSchema, _outputSchema) {
|
|
162
159
|
// TODO: Implementation for schema updates
|
|
163
|
-
// This would modify the inputSchema and outputSchema in the job file
|
|
164
160
|
return content;
|
|
165
161
|
}
|
|
166
|
-
function updateWorkflowTasks(content,
|
|
162
|
+
function updateWorkflowTasks(content, _taskSequence) {
|
|
167
163
|
// TODO: Implementation for updating workflow tasks
|
|
168
|
-
// This would modify the steps array in the workflow
|
|
169
164
|
return content;
|
|
170
165
|
}
|
|
171
|
-
function updateConfig(content,
|
|
166
|
+
function updateConfig(content, _jobSlug, _configUpdate) {
|
|
172
167
|
// TODO: Implementation for updating job configuration
|
|
173
|
-
// This would modify various config properties
|
|
174
168
|
return content;
|
|
175
169
|
}
|
|
176
|
-
function updateHandler(content,
|
|
170
|
+
function updateHandler(content, _handlerCode, _jobType) {
|
|
177
171
|
// TODO: Implementation for replacing handler code
|
|
178
|
-
// This would replace the handler function in the job file
|
|
179
172
|
return content;
|
|
180
173
|
}
|
|
181
174
|
export const updateJobTool = (server, req, verboseLogs, jobsDir)=>{
|
|
182
|
-
const tool = async (jobSlug, updateType, inputSchema, outputSchema, taskSequence, configUpdate, handlerCode)=>{
|
|
183
|
-
if (verboseLogs) {
|
|
184
|
-
req.payload.logger.info(`[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`);
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const result = await updateJob(req, verboseLogs, jobsDir, jobSlug, updateType, inputSchema, outputSchema, taskSequence, configUpdate, handlerCode);
|
|
188
|
-
if (verboseLogs) {
|
|
189
|
-
req.payload.logger.info(`[payload-mcp] Update Job Tool completed successfully`);
|
|
190
|
-
}
|
|
191
|
-
return result;
|
|
192
|
-
} catch (error) {
|
|
193
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
194
|
-
req.payload.logger.error(`[payload-mcp] Error in Update Job Tool: ${errorMessage}`);
|
|
195
|
-
return {
|
|
196
|
-
content: [
|
|
197
|
-
{
|
|
198
|
-
type: 'text',
|
|
199
|
-
text: `❌ **Error in Update Job Tool**: ${errorMessage}`
|
|
200
|
-
}
|
|
201
|
-
]
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
175
|
server.registerTool('updateJob', {
|
|
206
176
|
description: 'Updates an existing Payload job with new configuration, schema, or handler code',
|
|
207
177
|
inputSchema: toolSchemas.updateJob.parameters.shape
|
|
208
|
-
}, async (
|
|
209
|
-
|
|
210
|
-
|
|
178
|
+
}, async ({ configUpdate, handlerCode, inputSchema, jobSlug, outputSchema, taskSequence, updateType })=>{
|
|
179
|
+
if (verboseLogs) {
|
|
180
|
+
req.payload.logger.info(`[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`);
|
|
181
|
+
}
|
|
182
|
+
return updateJob(req, verboseLogs, jobsDir, jobSlug, updateType, inputSchema, outputSchema, taskSequence, configUpdate, handlerCode);
|
|
211
183
|
});
|
|
212
184
|
};
|
|
213
185
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/tools/job/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { existsSync, readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport type { JobConfigUpdate, SchemaField, TaskSequenceItem } from '../../../types.js'\n\nimport { validatePayloadFile } from '../../helpers/fileValidation.js'\nimport { toolSchemas } from '../schemas.js'\n\n// Reusable function for updating jobs\nexport const updateJob = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n jobSlug: string,\n updateType: string,\n inputSchema?: SchemaField[],\n outputSchema?: SchemaField[],\n taskSequence?: TaskSequenceItem[],\n configUpdate?: JobConfigUpdate,\n handlerCode?: string,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating job: ${jobSlug} (${updateType})`)\n }\n\n try {\n const camelCaseJobSlug = toCamelCase(jobSlug)\n\n // Find the job file - check both tasks and workflows\n let filePath: null | string = null\n let jobType: 'task' | 'workflow' | null = null\n\n const taskPath = join(jobsDir, 'tasks', `${camelCaseJobSlug}.ts`)\n const workflowPath = join(jobsDir, 'workflows', `${camelCaseJobSlug}.ts`)\n\n if (existsSync(taskPath)) {\n filePath = taskPath\n jobType = 'task'\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found task file: ${taskPath}`)\n }\n } else if (existsSync(workflowPath)) {\n filePath = workflowPath\n jobType = 'workflow'\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found workflow file: ${workflowPath}`)\n }\n } else {\n throw new Error(`No task or workflow file found for job slug: ${jobSlug}`)\n }\n\n // Read the current file content\n let content = readFileSync(filePath, 'utf8')\n const originalContent = content\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Applying update type: ${updateType}`)\n }\n\n // Apply updates based on type\n switch (updateType) {\n case 'change_config':\n if (!configUpdate) {\n throw new Error('config must be provided for change_config')\n }\n\n content = updateConfig(content, jobSlug, configUpdate)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Configuration updated successfully`)\n }\n break\n\n case 'modify_schema':\n if (!inputSchema && !outputSchema) {\n throw new Error('Either inputSchema or outputSchema must be provided for modify_schema')\n }\n\n content = updateSchema(content, camelCaseJobSlug, inputSchema, outputSchema)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Schema updated successfully`)\n }\n break\n\n case 'replace_handler':\n if (!handlerCode) {\n throw new Error('handlerCode must be provided for replace_handler')\n }\n\n content = updateHandler(content, handlerCode, jobType)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Handler code replaced successfully`)\n }\n break\n\n case 'update_tasks':\n if (!taskSequence) {\n throw new Error('taskSequence must be provided for update_tasks')\n }\n\n if (jobType !== 'workflow') {\n throw new Error('update_tasks is only supported for workflow jobs')\n }\n\n content = updateWorkflowTasks(content, taskSequence)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Workflow tasks updated successfully`)\n }\n break\n }\n\n // Only write if content changed\n if (content !== originalContent) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Writing updated content to file`)\n }\n\n // Write the updated content\n writeFileSync(filePath, content)\n\n // Validate the updated file\n const fileName = `${camelCaseJobSlug}.ts`\n const validationType = jobType === 'task' ? 'task' : 'workflow'\n\n try {\n const validationResult = await validatePayloadFile(fileName, validationType)\n\n if (!validationResult.success) {\n if (verboseLogs) {\n payload.logger.warn(`[payload-mcp] Validation warning: ${validationResult.error}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `⚠️ **Warning**: Job updated but validation failed:\\n\\n${validationResult.error}\\n\\nPlease review the generated code for any syntax errors.`,\n },\n ],\n }\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] File validation successful`)\n }\n } catch (validationError) {\n if (verboseLogs) {\n payload.logger.warn(`[payload-mcp] Validation error: ${validationError}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `⚠️ **Warning**: Job updated but validation could not be completed:\\n\\n${validationError}\\n\\nPlease review the generated code manually.`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `✅ **Job updated successfully!**\\n\\n**Job**: \\`${jobSlug}\\`\\n**Type**: \\`${jobType}\\`\\n**Update**: \\`${updateType}\\`\\n**File**: \\`${fileName}\\`\\n\\n**Next steps**:\\n1. Restart your development server to load the updated job\\n2. Test the updated functionality\\n3. Verify the changes meet your requirements`,\n },\n ],\n }\n } else {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] No changes detected, file not modified`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `ℹ️ **No changes made**: The job file was not modified as no changes were detected.\\n\\n**Job**: \\`${jobSlug}\\`\\n**Type**: \\`${jobType}\\`\\n**Update**: \\`${updateType}\\``,\n },\n ],\n }\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error updating job: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error updating job**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// Helper function to convert to camel case\nfunction toCamelCase(str: string): string {\n return str\n .replace(/[-_\\s]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : ''))\n .replace(/^(.)/, (_, chr) => chr.toLowerCase())\n}\n\n// Helper functions for different update types\nfunction updateSchema(\n content: string,\n camelCaseJobSlug: string,\n inputSchema?: SchemaField[],\n outputSchema?: SchemaField[],\n): string {\n // TODO: Implementation for schema updates\n // This would modify the inputSchema and outputSchema in the job file\n return content\n}\n\nfunction updateWorkflowTasks(content: string, taskSequence: TaskSequenceItem[]): string {\n // TODO: Implementation for updating workflow tasks\n // This would modify the steps array in the workflow\n return content\n}\n\nfunction updateConfig(content: string, jobSlug: string, configUpdate: JobConfigUpdate): string {\n // TODO: Implementation for updating job configuration\n // This would modify various config properties\n return content\n}\n\nfunction updateHandler(content: string, handlerCode: string, jobType: 'task' | 'workflow'): string {\n // TODO: Implementation for replacing handler code\n // This would replace the handler function in the job file\n return content\n}\n\nexport const updateJobTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n) => {\n const tool = async (\n jobSlug: string,\n updateType: string,\n inputSchema?: SchemaField[],\n outputSchema?: SchemaField[],\n taskSequence?: TaskSequenceItem[],\n configUpdate?: JobConfigUpdate,\n handlerCode?: string,\n ) => {\n if (verboseLogs) {\n req.payload.logger.info(\n `[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`,\n )\n }\n\n try {\n const result = await updateJob(\n req,\n verboseLogs,\n jobsDir,\n jobSlug,\n updateType,\n inputSchema,\n outputSchema,\n taskSequence,\n configUpdate,\n handlerCode,\n )\n\n if (verboseLogs) {\n req.payload.logger.info(`[payload-mcp] Update Job Tool completed successfully`)\n }\n\n return result\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n req.payload.logger.error(`[payload-mcp] Error in Update Job Tool: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error in Update Job Tool**: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.registerTool(\n 'updateJob',\n {\n description:\n 'Updates an existing Payload job with new configuration, schema, or handler code',\n inputSchema: toolSchemas.updateJob.parameters.shape,\n },\n async (args) => {\n const {\n configUpdate,\n handlerCode,\n inputSchema,\n jobSlug,\n outputSchema,\n taskSequence,\n updateType,\n } = args\n return await tool(\n jobSlug,\n updateType,\n inputSchema as unknown as SchemaField[],\n outputSchema as unknown as SchemaField[],\n taskSequence,\n configUpdate,\n handlerCode,\n )\n },\n )\n}\n"],"names":["existsSync","readFileSync","writeFileSync","join","validatePayloadFile","toolSchemas","updateJob","req","verboseLogs","jobsDir","jobSlug","updateType","inputSchema","outputSchema","taskSequence","configUpdate","handlerCode","payload","logger","info","camelCaseJobSlug","toCamelCase","filePath","jobType","taskPath","workflowPath","Error","content","originalContent","updateConfig","updateSchema","updateHandler","updateWorkflowTasks","fileName","validationType","validationResult","success","warn","error","type","text","validationError","errorMessage","message","str","replace","_","chr","toUpperCase","toLowerCase","updateJobTool","server","tool","result","registerTool","description","parameters","shape","args"],"mappings":"AAGA,SAASA,UAAU,EAAEC,YAAY,EAAEC,aAAa,QAAQ,KAAI;AAC5D,SAASC,IAAI,QAAQ,OAAM;AAI3B,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,sCAAsC;AACtC,OAAO,MAAMC,YAAY,OACvBC,KACAC,aACAC,SACAC,SACAC,YACAC,aACAC,cACAC,cACAC,cACAC;IAEA,MAAMC,UAAUV,IAAIU,OAAO;IAE3B,IAAIT,aAAa;QACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,4BAA4B,EAAET,QAAQ,EAAE,EAAEC,WAAW,CAAC,CAAC;IAC9E;IAEA,IAAI;QACF,MAAMS,mBAAmBC,YAAYX;QAErC,qDAAqD;QACrD,IAAIY,WAA0B;QAC9B,IAAIC,UAAsC;QAE1C,MAAMC,WAAWrB,KAAKM,SAAS,SAAS,GAAGW,iBAAiB,GAAG,CAAC;QAChE,MAAMK,eAAetB,KAAKM,SAAS,aAAa,GAAGW,iBAAiB,GAAG,CAAC;QAExE,IAAIpB,WAAWwB,WAAW;YACxBF,WAAWE;YACXD,UAAU;YACV,IAAIf,aAAa;gBACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,+BAA+B,EAAEK,UAAU;YAClE;QACF,OAAO,IAAIxB,WAAWyB,eAAe;YACnCH,WAAWG;YACXF,UAAU;YACV,IAAIf,aAAa;gBACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,mCAAmC,EAAEM,cAAc;YAC1E;QACF,OAAO;YACL,MAAM,IAAIC,MAAM,CAAC,6CAA6C,EAAEhB,SAAS;QAC3E;QAEA,gCAAgC;QAChC,IAAIiB,UAAU1B,aAAaqB,UAAU;QACrC,MAAMM,kBAAk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CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,oDAAoD,CAAC;YAChF;YAEA,OAAOkC;QACT,EAAE,OAAOf,OAAO;YACd,MAAMI,eAAeJ,iBAAiBZ,QAAQY,MAAMK,OAAO,GAAG;YAC9DpC,IAAIU,OAAO,CAACC,MAAM,CAACoB,KAAK,CAAC,CAAC,wCAAwC,EAAEI,cAAc;YAElF,OAAO;gBACLf,SAAS;oBACP;wBACEY,MAAM;wBACNC,MAAM,CAAC,gCAAgC,EAAEE,cAAc;oBACzD;iBACD;YACH;QACF;IACF;IAEAS,OAAOG,YAAY,CACjB,aACA;QACEC,aACE;QACF3C,aAAaP,YAAYC,SAAS,CAACkD,UAAU,CAACC,KAAK;IACrD,GACA,OAAOC;QACL,MAAM,EACJ3C,YAAY,EACZC,WAAW,EACXJ,WAAW,EACXF,OAAO,EACPG,YAAY,EACZC,YAAY,EACZH,UAAU,EACX,GAAG+C;QACJ,OAAO,MAAMN,KACX1C,SACAC,YACAC,aACAC,cACAC,cACAC,cACAC;IAEJ;AAEJ,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/tools/job/update.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { existsSync, readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport type { JobConfigUpdate, SchemaField, TaskSequenceItem } from '../../../types.js'\n\nimport { toCamelCase } from '../../../utils/camelCase.js'\nimport { validatePayloadFile } from '../../helpers/fileValidation.js'\nimport { toolSchemas } from '../schemas.js'\n\n// Reusable function for updating jobs\nexport const updateJob = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n jobSlug: string,\n updateType: string,\n inputSchema?: SchemaField[],\n outputSchema?: SchemaField[],\n taskSequence?: TaskSequenceItem[],\n configUpdate?: JobConfigUpdate,\n handlerCode?: string,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating job: ${jobSlug} (${updateType})`)\n }\n\n try {\n const camelCaseJobSlug = toCamelCase(jobSlug)\n\n // Find the job file - check both tasks and workflows\n let filePath: null | string = null\n let jobType: 'task' | 'workflow' | null = null\n\n const taskPath = join(jobsDir, 'tasks', `${camelCaseJobSlug}.ts`)\n const workflowPath = join(jobsDir, 'workflows', `${camelCaseJobSlug}.ts`)\n\n if (existsSync(taskPath)) {\n filePath = taskPath\n jobType = 'task'\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found task file: ${taskPath}`)\n }\n } else if (existsSync(workflowPath)) {\n filePath = workflowPath\n jobType = 'workflow'\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Found workflow file: ${workflowPath}`)\n }\n } else {\n throw new Error(`No task or workflow file found for job slug: ${jobSlug}`)\n }\n\n // Read the current file content\n let content = readFileSync(filePath, 'utf8')\n const originalContent = content\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Applying update type: ${updateType}`)\n }\n\n // Apply updates based on type\n switch (updateType) {\n case 'change_config':\n if (!configUpdate) {\n throw new Error('config must be provided for change_config')\n }\n\n content = updateConfig(content, jobSlug, configUpdate)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Configuration updated successfully`)\n }\n break\n\n case 'modify_schema':\n if (!inputSchema && !outputSchema) {\n throw new Error('Either inputSchema or outputSchema must be provided for modify_schema')\n }\n\n content = updateSchema(content, camelCaseJobSlug, inputSchema, outputSchema)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Schema updated successfully`)\n }\n break\n\n case 'replace_handler':\n if (!handlerCode) {\n throw new Error('handlerCode must be provided for replace_handler')\n }\n\n content = updateHandler(content, handlerCode, jobType)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Handler code replaced successfully`)\n }\n break\n\n case 'update_tasks':\n if (!taskSequence) {\n throw new Error('taskSequence must be provided for update_tasks')\n }\n\n if (jobType !== 'workflow') {\n throw new Error('update_tasks is only supported for workflow jobs')\n }\n\n content = updateWorkflowTasks(content, taskSequence)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Workflow tasks updated successfully`)\n }\n break\n }\n\n // Only write if content changed\n if (content !== originalContent) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Writing updated content to file`)\n }\n\n // Write the updated content\n writeFileSync(filePath, content)\n\n // Validate the updated file\n const fileName = `${camelCaseJobSlug}.ts`\n const validationType = jobType === 'task' ? 'task' : 'workflow'\n\n try {\n const validationResult = await validatePayloadFile(fileName, validationType)\n\n if (!validationResult.success) {\n if (verboseLogs) {\n payload.logger.warn(`[payload-mcp] Validation warning: ${validationResult.error}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `⚠️ **Warning**: Job updated but validation failed:\\n\\n${validationResult.error}\\n\\nPlease review the generated code for any syntax errors.`,\n },\n ],\n }\n }\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] File validation successful`)\n }\n } catch (validationError) {\n if (verboseLogs) {\n payload.logger.warn(`[payload-mcp] Validation error: ${validationError}`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `⚠️ **Warning**: Job updated but validation could not be completed:\\n\\n${validationError}\\n\\nPlease review the generated code manually.`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `✅ **Job updated successfully!**\\n\\n**Job**: \\`${jobSlug}\\`\\n**Type**: \\`${jobType}\\`\\n**Update**: \\`${updateType}\\`\\n**File**: \\`${fileName}\\`\\n\\n**Next steps**:\\n1. Restart your development server to load the updated job\\n2. Test the updated functionality\\n3. Verify the changes meet your requirements`,\n },\n ],\n }\n } else {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] No changes detected, file not modified`)\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `ℹ️ **No changes made**: The job file was not modified as no changes were detected.\\n\\n**Job**: \\`${jobSlug}\\`\\n**Type**: \\`${jobType}\\`\\n**Update**: \\`${updateType}\\``,\n },\n ],\n }\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error updating job: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error updating job**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// Helper functions for different update types\nfunction updateSchema(\n content: string,\n _camelCaseJobSlug: string,\n _inputSchema?: SchemaField[],\n _outputSchema?: SchemaField[],\n): string {\n // TODO: Implementation for schema updates\n return content\n}\n\nfunction updateWorkflowTasks(content: string, _taskSequence: TaskSequenceItem[]): string {\n // TODO: Implementation for updating workflow tasks\n return content\n}\n\nfunction updateConfig(content: string, _jobSlug: string, _configUpdate: JobConfigUpdate): string {\n // TODO: Implementation for updating job configuration\n return content\n}\n\nfunction updateHandler(\n content: string,\n _handlerCode: string,\n _jobType: 'task' | 'workflow',\n): string {\n // TODO: Implementation for replacing handler code\n return content\n}\n\nexport const updateJobTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n) => {\n server.registerTool(\n 'updateJob',\n {\n description:\n 'Updates an existing Payload job with new configuration, schema, or handler code',\n inputSchema: toolSchemas.updateJob.parameters.shape,\n },\n async ({\n configUpdate,\n handlerCode,\n inputSchema,\n jobSlug,\n outputSchema,\n taskSequence,\n updateType,\n }) => {\n if (verboseLogs) {\n req.payload.logger.info(\n `[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`,\n )\n }\n return updateJob(\n req,\n verboseLogs,\n jobsDir,\n jobSlug,\n updateType,\n inputSchema as unknown as SchemaField[],\n outputSchema as unknown as SchemaField[],\n taskSequence,\n configUpdate,\n handlerCode,\n )\n },\n )\n}\n"],"names":["existsSync","readFileSync","writeFileSync","join","toCamelCase","validatePayloadFile","toolSchemas","updateJob","req","verboseLogs","jobsDir","jobSlug","updateType","inputSchema","outputSchema","taskSequence","configUpdate","handlerCode","payload","logger","info","camelCaseJobSlug","filePath","jobType","taskPath","workflowPath","Error","content","originalContent","updateConfig","updateSchema","updateHandler","updateWorkflowTasks","fileName","validationType","validationResult","success","warn","error","type","text","validationError","errorMessage","message","_camelCaseJobSlug","_inputSchema","_outputSchema","_taskSequence","_jobSlug","_configUpdate","_handlerCode","_jobType","updateJobTool","server","registerTool","description","parameters","shape"],"mappings":"AAGA,SAASA,UAAU,EAAEC,YAAY,EAAEC,aAAa,QAAQ,KAAI;AAC5D,SAASC,IAAI,QAAQ,OAAM;AAI3B,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,sCAAsC;AACtC,OAAO,MAAMC,YAAY,OACvBC,KACAC,aACAC,SACAC,SACAC,YACAC,aACAC,cACAC,cACAC,cACAC;IAEA,MAAMC,UAAUV,IAAIU,OAAO;IAE3B,IAAIT,aAAa;QACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,4BAA4B,EAAET,QAAQ,EAAE,EAAEC,WAAW,CAAC,CAAC;IAC9E;IAEA,IAAI;QACF,MAAMS,mBAAmBjB,YAAYO;QAErC,qDAAqD;QACrD,IAAIW,WAA0B;QAC9B,IAAIC,UAAsC;QAE1C,MAAMC,WAAWrB,KAAKO,SAAS,SAAS,GAAGW,iBAAiB,GAAG,CAAC;QAChE,MAAMI,eAAetB,KAAKO,SAAS,aAAa,GAAGW,iBAAiB,GAAG,CAAC;QAExE,IAAIrB,WAAWwB,WAAW;YACxBF,WAAWE;YACXD,UAAU;YACV,IAAId,aAAa;gBACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,+BAA+B,EAAEI,UAAU;YAClE;QACF,OAAO,IAAIxB,WAAWyB,eAAe;YACnCH,WAAWG;YACXF,UAAU;YACV,IAAId,aAAa;gBACfS,QAAQC,MAAM,CAACC,IAAI,CAAC,CAAC,mCAAmC,EAAEK,cAAc;YAC1E;QACF,OAAO;YACL,MAAM,IAAIC,MAAM,CAAC,6CAA6C,EAAEf,SAAS;QAC3E;QAEA,gCAAgC;QAChC,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;iBACD;YACH;QACF;IACF,EAAE,OAAO0B,OAAO;QACd,MAAMI,eAAe,AAACJ,MAAgBK,OAAO;QAC7CzB,QAAQC,MAAM,CAACmB,KAAK,CAAC,CAAC,kCAAkC,EAAEI,cAAc;QAExE,OAAO;YACLf,SAAS;gBACP;oBACEY,MAAM;oBACNC,MAAM,CAAC,0BAA0B,EAAEE,cAAc;gBACnD;aACD;QACH;IACF;AACF,EAAC;AAED,8CAA8C;AAC9C,SAASZ,aACPH,OAAe,EACfiB,iBAAyB,EACzBC,YAA4B,EAC5BC,aAA6B;IAE7B,0CAA0C;IAC1C,OAAOnB;AACT;AAEA,SAASK,oBAAoBL,OAAe,EAAEoB,aAAiC;IAC7E,mDAAmD;IACnD,OAAOpB;AACT;AAEA,SAASE,aAAaF,OAAe,EAAEqB,QAAgB,EAAEC,aAA8B;IACrF,sDAAsD;IACtD,OAAOtB;AACT;AAEA,SAASI,cACPJ,OAAe,EACfuB,YAAoB,EACpBC,QAA6B;IAE7B,kDAAkD;IAClD,OAAOxB;AACT;AAEA,OAAO,MAAMyB,gBAAgB,CAC3BC,QACA7C,KACAC,aACAC;IAEA2C,OAAOC,YAAY,CACjB,aACA;QACEC,aACE;QACF1C,aAAaP,YAAYC,SAAS,CAACiD,UAAU,CAACC,KAAK;IACrD,GACA,OAAO,EACLzC,YAAY,EACZC,WAAW,EACXJ,WAAW,EACXF,OAAO,EACPG,YAAY,EACZC,YAAY,EACZH,UAAU,EACX;QACC,IAAIH,aAAa;YACfD,IAAIU,OAAO,CAACC,MAAM,CAACC,IAAI,CACrB,CAAC,2CAA2C,EAAET,QAAQ,EAAE,EAAEC,YAAY;QAE1E;QACA,OAAOL,UACLC,KACAC,aACAC,SACAC,SACAC,YACAC,aACAC,cACAC,cACAC,cACAC;IAEJ;AAEJ,EAAC"}
|
|
@@ -263,7 +263,6 @@ export declare const toolSchemas: {
|
|
|
263
263
|
adminConfig: z.ZodOptional<z.ZodAny>;
|
|
264
264
|
collectionName: z.ZodOptional<z.ZodString>;
|
|
265
265
|
databaseConfig: z.ZodOptional<z.ZodAny>;
|
|
266
|
-
generalConfig: z.ZodOptional<z.ZodAny>;
|
|
267
266
|
newContent: z.ZodOptional<z.ZodString>;
|
|
268
267
|
pluginUpdates: z.ZodOptional<z.ZodAny>;
|
|
269
268
|
updateType: z.ZodEnum<["add_collection", "remove_collection", "update_admin", "update_database", "update_plugins", "replace_content"]>;
|
|
@@ -273,7 +272,6 @@ export declare const toolSchemas: {
|
|
|
273
272
|
newContent?: string | undefined;
|
|
274
273
|
adminConfig?: any;
|
|
275
274
|
databaseConfig?: any;
|
|
276
|
-
generalConfig?: any;
|
|
277
275
|
pluginUpdates?: any;
|
|
278
276
|
}, {
|
|
279
277
|
updateType: "replace_content" | "add_collection" | "remove_collection" | "update_admin" | "update_database" | "update_plugins";
|
|
@@ -281,7 +279,6 @@ export declare const toolSchemas: {
|
|
|
281
279
|
newContent?: string | undefined;
|
|
282
280
|
adminConfig?: any;
|
|
283
281
|
databaseConfig?: any;
|
|
284
|
-
generalConfig?: any;
|
|
285
282
|
pluginUpdates?: any;
|
|
286
283
|
}>;
|
|
287
284
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqgBvB,CAAA"}
|
|
@@ -137,7 +137,6 @@ export const toolSchemas = {
|
|
|
137
137
|
adminConfig: z.any().optional().describe('Admin configuration updates (for update_admin type)'),
|
|
138
138
|
collectionName: z.string().optional().describe('Collection name (required for add_collection and remove_collection)'),
|
|
139
139
|
databaseConfig: z.any().optional().describe('Database configuration updates (for update_database type)'),
|
|
140
|
-
generalConfig: z.any().optional().describe('General configuration updates'),
|
|
141
140
|
newContent: z.string().optional().describe('New configuration content (for replace_content type)'),
|
|
142
141
|
pluginUpdates: z.any().optional().describe('Plugin configuration updates (for update_plugins type)'),
|
|
143
142
|
updateType: z.enum([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findGlobal: {\n description: 'Find a Payload global singleton configuration.',\n parameters: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Whether the document should be queried from the versions table/collection or not.',\n ),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n ),\n page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships in response (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code for the operation (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n updateGlobal: {\n description: 'Update a Payload global singleton configuration.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"siteName\\\": true}'\",\n ),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n generalConfig: z.any().optional().describe('General configuration updates'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n ),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\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 },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findGlobal","description","parameters","object","depth","number","int","min","max","optional","default","describe","fallbackLocale","string","locale","select","findResources","id","union","draft","boolean","limit","page","sort","where","createResource","data","updateResource","filePath","overrideLock","overwriteExistingFiles","deleteResource","updateGlobal","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","generalConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","unlock","createJob","inputSchema","record","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,YAAY;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C9E,EAAEwC,GAAG,IAAI7B,QAAQ,GAAGE,QAAQ,CAAC;YACpD2E,cAAcxF,EAAEuC,KAAK,CAACvC,EAAEwC,GAAG,IAAI7B,QAAQ,GAAGE,QAAQ,CAAC;YACnDsC,YAAYnD,EACToD,IAAI,CAAC;gBAAC;gBAAiB;gBAAgB;gBAAiB;aAAkB,EAC1EvC,QAAQ,CAAC;QACd;IACF;IAEA4E,QAAQ;QACNtF,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBqF,OAAO1F,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJE,QAAQ,GACRE,QAAQ,CAAC;YACZ8E,OAAO3F,EAAE8E,MAAM,CAAC9E,EAAEwC,GAAG,IAAI3B,QAAQ,CAAC;YAClCqE,SAASlF,EAAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7B+E,UAAU5F,EACPO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRE,QAAQ,CAAC;YACZgF,OAAO7F,EACJe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/tools/schemas.ts"],"sourcesContent":["import { z } from 'zod'\n\nexport const toolSchemas = {\n findGlobal: {\n description: 'Find a Payload global singleton configuration.',\n parameters: z.object({\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n findResources: {\n description: 'Find documents in a collection by ID or where clause using Find or FindByID.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe(\n 'Optional: specific document ID to retrieve. If not provided, returns all documents',\n ),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Whether the document should be queried from the versions table/collection or not.',\n ),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n limit: z\n .number()\n .int()\n .min(1, 'Limit must be at least 1')\n .max(100, 'Limit cannot exceed 100')\n .optional()\n .default(10)\n .describe('Maximum number of documents to return (default: 10, max: 100)'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to retrieve data in (e.g., \"en\", \"es\"). Use \"all\" to retrieve all locales for localized fields',\n ),\n page: z\n .number()\n .int()\n .min(1, 'Page must be at least 1')\n .optional()\n .default(1)\n .describe('Page number for pagination (default: 1)'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n sort: z\n .string()\n .optional()\n .describe('Field to sort by (e.g., \"createdAt\", \"-updatedAt\" for descending)'),\n where: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string for where clause filtering (e.g., \\'{\"title\": {\"contains\": \"test\"}}\\')',\n ),\n }),\n },\n\n createResource: {\n description: 'Create a document in a collection.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data for the new document'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('How many levels deep to populate relationships in response (default: 0)'),\n draft: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to create the document as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to create the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n }),\n },\n\n updateResource: {\n description: 'Update documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to update'),\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n filePath: z.string().optional().describe('Optional: absolute file path for file uploads'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update the document in (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n overrideLock: z\n .boolean()\n .optional()\n .default(true)\n .describe('Whether to override document locks'),\n overwriteExistingFiles: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to overwrite existing files'),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"title\\\": true}'\",\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to update multiple documents'),\n }),\n },\n\n deleteResource: {\n description: 'Delete documents in a collection by ID or where clause.',\n parameters: z.object({\n id: z\n .union([z.string(), z.number()])\n .optional()\n .describe('Optional: specific document ID to delete'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships in response'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code for the operation (e.g., \"en\", \"es\"). Defaults to the default locale',\n ),\n where: z\n .string()\n .optional()\n .describe('Optional: JSON string for where clause to delete multiple documents'),\n }),\n },\n\n updateGlobal: {\n description: 'Update a Payload global singleton configuration.',\n parameters: z.object({\n data: z.string().describe('JSON string containing the data to update'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n draft: z.boolean().optional().default(false).describe('Whether to update as a draft'),\n fallbackLocale: z\n .string()\n .optional()\n .describe('Optional: fallback locale code to use when requested locale is not available'),\n locale: z\n .string()\n .optional()\n .describe(\n 'Optional: locale code to update data in (e.g., \"en\", \"es\"). Use \"all\" to update all locales for localized fields',\n ),\n select: z\n .string()\n .optional()\n .describe(\n \"Optional: define exactly which fields you'd like to return in the response (JSON), e.g., '{\\\"siteName\\\": true}'\",\n ),\n }),\n },\n\n // Experimental Below This Line\n createCollection: {\n description: 'Creates a new collection with specified fields and configuration.',\n parameters: z.object({\n collectionDescription: z\n .string()\n .optional()\n .describe('Optional description for the collection'),\n collectionName: z.string().describe('The name of the collection to create'),\n fields: z.array(z.any()).describe('Array of field definitions for the collection'),\n hasUpload: z\n .boolean()\n .optional()\n .describe('Whether the collection should have upload capabilities'),\n }),\n },\n\n findCollections: {\n description: 'Finds and lists collections with optional content and document counts.',\n parameters: z.object({\n collectionName: z\n .string()\n .optional()\n .describe('Optional: specific collection name to retrieve'),\n includeContent: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include collection file content'),\n includeCount: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include document counts for each collection'),\n }),\n },\n\n updateCollection: {\n description:\n 'Updates an existing collection with new fields, modifications, or configuration changes.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to update'),\n configUpdates: z.any().optional().describe('Configuration updates (for update_config type)'),\n fieldModifications: z\n .array(z.any())\n .optional()\n .describe('Field modifications (for modify_field type)'),\n fieldNamesToRemove: z\n .array(z.string())\n .optional()\n .describe('Field names to remove (for remove_field type)'),\n newContent: z\n .string()\n .optional()\n .describe('New content to replace entire collection (for replace_content type)'),\n newFields: z.array(z.any()).optional().describe('New fields to add (for add_field type)'),\n updateType: z\n .enum(['add_field', 'remove_field', 'modify_field', 'update_config', 'replace_content'])\n .describe('Type of update to perform'),\n }),\n },\n\n deleteCollection: {\n description: 'Deletes a collection and optionally updates the configuration.',\n parameters: z.object({\n collectionName: z.string().describe('The name of the collection to delete'),\n confirmDeletion: z.boolean().describe('Confirmation flag to prevent accidental deletion'),\n updateConfig: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to update payload.config.ts to remove collection reference'),\n }),\n },\n\n findConfig: {\n description: 'Reads and displays the current configuration file.',\n parameters: z.object({\n includeMetadata: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to include file metadata (size, modified date, etc.)'),\n }),\n },\n\n updateConfig: {\n description: 'Updates the configuration file with various modifications.',\n parameters: z.object({\n adminConfig: z\n .any()\n .optional()\n .describe('Admin configuration updates (for update_admin type)'),\n collectionName: z\n .string()\n .optional()\n .describe('Collection name (required for add_collection and remove_collection)'),\n databaseConfig: z\n .any()\n .optional()\n .describe('Database configuration updates (for update_database type)'),\n newContent: z\n .string()\n .optional()\n .describe('New configuration content (for replace_content type)'),\n pluginUpdates: z\n .any()\n .optional()\n .describe('Plugin configuration updates (for update_plugins type)'),\n updateType: z\n .enum([\n 'add_collection',\n 'remove_collection',\n 'update_admin',\n 'update_database',\n 'update_plugins',\n 'replace_content',\n ])\n .describe('Type of configuration update to perform'),\n }),\n },\n\n auth: {\n description: 'Checks authentication status for the current user.',\n parameters: z.object({\n headers: z\n .string()\n .optional()\n .describe(\n 'Optional JSON string containing custom headers to send with the authentication request',\n ),\n }),\n },\n\n login: {\n description: 'Authenticates a user with email and password.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n depth: z\n .number()\n .int()\n .min(0)\n .max(10)\n .optional()\n .default(0)\n .describe('Depth of population for relationships'),\n email: z.string().email().describe('The user email address'),\n overrideAccess: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to override access controls'),\n password: z.string().describe('The user password'),\n showHiddenFields: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to show hidden fields in the response'),\n }),\n },\n\n verify: {\n description: 'Verifies a user email with a verification token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n token: z.string().describe('The verification token sent to the user email'),\n }),\n },\n\n resetPassword: {\n description: 'Resets a user password with a reset token.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\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 },\n\n forgotPassword: {\n description: 'Sends a password reset email to a user.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n disableEmail: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to disable sending the email (for testing)'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n unlock: {\n description: 'Unlocks a user account that has been locked due to failed login attempts.',\n parameters: z.object({\n collection: z.string().describe('The collection containing the user (e.g., \"users\")'),\n email: z.string().email().describe('The user email address'),\n }),\n },\n\n createJob: {\n description: 'Creates a new job (task or workflow) with specified configuration.',\n parameters: z.object({\n description: z.string().describe('Description of what the job does'),\n inputSchema: z.record(z.any()).optional().default({}).describe('Input schema for the job'),\n jobData: z\n .record(z.any())\n .optional()\n .default({})\n .describe('Additional job configuration data'),\n jobName: z\n .string()\n .min(1, 'Job name cannot be empty')\n .regex(/^[a-z][\\w-]*$/i, 'Job name must be alphanumeric and can contain underscores/dashes')\n .describe('The name of the job to create'),\n jobSlug: z\n .string()\n .min(1, 'Job slug cannot be empty')\n .regex(/^[a-z][a-z0-9-]*$/, 'Job slug must be kebab-case')\n .describe('The slug for the job (kebab-case format)'),\n jobType: z\n .enum(['task', 'workflow'])\n .describe('Whether to create a task (individual unit) or workflow (orchestrates tasks)'),\n outputSchema: z.record(z.any()).optional().default({}).describe('Output schema for the job'),\n }),\n },\n\n updateJob: {\n description: 'Updates an existing job with new configuration, schema, or handler code.',\n parameters: z.object({\n configUpdate: z.record(z.any()).optional().describe('New configuration for the job'),\n handlerCode: z\n .string()\n .optional()\n .describe('New handler code to replace the existing handler'),\n inputSchema: z.record(z.any()).optional().describe('New input schema for the job'),\n jobSlug: z.string().describe('The slug of the job to update'),\n outputSchema: z.record(z.any()).optional().describe('New output schema for the job'),\n taskSequence: z.array(z.any()).optional().describe('New task sequence for workflows'),\n updateType: z\n .enum(['modify_schema', 'update_tasks', 'change_config', 'replace_handler'])\n .describe('Type of update to perform on the job'),\n }),\n },\n\n runJob: {\n description: 'Runs a job with specified input data and queue options.',\n parameters: z.object({\n delay: z\n .number()\n .int()\n .min(0)\n .optional()\n .describe('Delay in milliseconds before job execution'),\n input: z.record(z.any()).describe('Input data for the job execution'),\n jobSlug: z.string().describe('The slug of the job to run'),\n priority: z\n .number()\n .int()\n .min(1)\n .max(10)\n .optional()\n .describe('Job priority (1-10, higher is more important)'),\n queue: z\n .string()\n .optional()\n .describe('Queue name to use for job execution (default: \"default\")'),\n }),\n },\n}\n"],"names":["z","toolSchemas","findGlobal","description","parameters","object","depth","number","int","min","max","optional","default","describe","fallbackLocale","string","locale","select","findResources","id","union","draft","boolean","limit","page","sort","where","createResource","data","updateResource","filePath","overrideLock","overwriteExistingFiles","deleteResource","updateGlobal","createCollection","collectionDescription","collectionName","fields","array","any","hasUpload","findCollections","includeContent","includeCount","updateCollection","configUpdates","fieldModifications","fieldNamesToRemove","newContent","newFields","updateType","enum","deleteCollection","confirmDeletion","updateConfig","findConfig","includeMetadata","adminConfig","databaseConfig","pluginUpdates","auth","headers","login","collection","email","overrideAccess","password","showHiddenFields","verify","token","resetPassword","forgotPassword","disableEmail","unlock","createJob","inputSchema","record","jobData","jobName","regex","jobSlug","jobType","outputSchema","updateJob","configUpdate","handlerCode","taskSequence","runJob","delay","input","priority","queue"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAK;AAEvB,OAAO,MAAMC,cAAc;IACzBC,YAAY;QACVC,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBC,OAAON,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC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,IAAI,CAAC;gBAAC;gBAAiB;gBAAgB;gBAAiB;aAAkB,EAC1EvC,QAAQ,CAAC;QACd;IACF;IAEA2E,QAAQ;QACNrF,aAAa;QACbC,YAAYJ,EAAEK,MAAM,CAAC;YACnBoF,OAAOzF,EACJO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJE,QAAQ,GACRE,QAAQ,CAAC;YACZ6E,OAAO1F,EAAE6E,MAAM,CAAC7E,EAAEwC,GAAG,IAAI3B,QAAQ,CAAC;YAClCoE,SAASjF,EAAEe,MAAM,GAAGF,QAAQ,CAAC;YAC7B8E,UAAU3F,EACPO,MAAM,GACNC,GAAG,GACHC,GAAG,CAAC,GACJC,GAAG,CAAC,IACJC,QAAQ,GACRE,QAAQ,CAAC;YACZ+E,OAAO5F,EACJe,MAAM,GACNJ,QAAQ,GACRE,QAAQ,CAAC;QACd;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertCollectionSchemaToZod.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAU9C,eAAO,MAAM,4BAA4B,WAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"convertCollectionSchemaToZod.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAU9C,eAAO,MAAM,4BAA4B,WAAY,WAAW,QA4B/D,CAAA"}
|
|
@@ -9,8 +9,7 @@ export const convertCollectionSchemaToZod = (schema)=>{
|
|
|
9
9
|
const schemaClone = JSON.parse(JSON.stringify(schema));
|
|
10
10
|
const sanitized = sanitizeJsonSchema(schemaClone);
|
|
11
11
|
const pointTransformed = transformPointFieldsForMCP(sanitized);
|
|
12
|
-
const
|
|
13
|
-
const zodSchemaAsString = jsonSchemaToZod(simplifiedSchema);
|
|
12
|
+
const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed));
|
|
14
13
|
// Transpile TypeScript to JavaScript
|
|
15
14
|
const transpileResult = ts.transpileModule(zodSchemaAsString, {
|
|
16
15
|
compilerOptions: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { jsonSchemaToZod } from 'json-schema-to-zod'\nimport * as ts from 'typescript'\nimport { z } from 'zod'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\nexport const convertCollectionSchemaToZod = (schema: JSONSchema4) => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/convertCollectionSchemaToZod.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { jsonSchemaToZod } from 'json-schema-to-zod'\nimport * as ts from 'typescript'\nimport { z } from 'zod'\n\nimport { sanitizeJsonSchema } from './sanitizeJsonSchema.js'\nimport { simplifyRelationshipFields } from './simplifyRelationshipFields.js'\nimport { transformPointFieldsForMCP } from './transformPointFields.js'\n\nexport const convertCollectionSchemaToZod = (schema: JSONSchema4) => {\n // Clone to avoid mutating the original schema (used elsewhere for tool listing)\n const schemaClone = JSON.parse(JSON.stringify(schema)) as JSONSchema4\n\n const sanitized = sanitizeJsonSchema(schemaClone)\n const pointTransformed = transformPointFieldsForMCP(sanitized)\n const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))\n\n // Transpile TypeScript to JavaScript\n const transpileResult = ts.transpileModule(zodSchemaAsString, {\n compilerOptions: {\n module: ts.ModuleKind.CommonJS,\n removeComments: true,\n strict: false,\n target: ts.ScriptTarget.ES2018,\n },\n })\n\n /**\n * This Function evaluation is safe because:\n * 1. The input schema comes from Payload's collection configuration, which is controlled by the application developer\n * 2. The jsonSchemaToZod library converts JSON Schema to Zod schema definitions, producing only type validation code\n * 3. The transpiled output contains only Zod schema definitions (z.string(), z.number(), etc.) - no executable logic\n * 4. The resulting Zod schema is used only for parameter validation in MCP tools, not for data processing\n * 5. No user input or external data is involved in the schema generation process\n */\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n return new Function('z', `return ${transpileResult.outputText}`)(z)\n}\n"],"names":["jsonSchemaToZod","ts","z","sanitizeJsonSchema","simplifyRelationshipFields","transformPointFieldsForMCP","convertCollectionSchemaToZod","schema","schemaClone","JSON","parse","stringify","sanitized","pointTransformed","zodSchemaAsString","transpileResult","transpileModule","compilerOptions","module","ModuleKind","CommonJS","removeComments","strict","target","ScriptTarget","ES2018","Function","outputText"],"mappings":"AAEA,SAASA,eAAe,QAAQ,qBAAoB;AACpD,YAAYC,QAAQ,aAAY;AAChC,SAASC,CAAC,QAAQ,MAAK;AAEvB,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,0BAA0B,QAAQ,kCAAiC;AAC5E,SAASC,0BAA0B,QAAQ,4BAA2B;AAEtE,OAAO,MAAMC,+BAA+B,CAACC;IAC3C,gFAAgF;IAChF,MAAMC,cAAcC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAE9C,MAAMK,YAAYT,mBAAmBK;IACrC,MAAMK,mBAAmBR,2BAA2BO;IACpD,MAAME,oBAAoBd,gBAAgBI,2BAA2BS;IAErE,qCAAqC;IACrC,MAAME,kBAAkBd,GAAGe,eAAe,CAACF,mBAAmB;QAC5DG,iBAAiB;YACfC,QAAQjB,GAAGkB,UAAU,CAACC,QAAQ;YAC9BC,gBAAgB;YAChBC,QAAQ;YACRC,QAAQtB,GAAGuB,YAAY,CAACC,MAAM;QAChC;IACF;IAEA;;;;;;;GAOC,GACD,8DAA8D;IAC9D,OAAO,IAAIC,SAAS,KAAK,CAAC,OAAO,EAAEX,gBAAgBY,UAAU,EAAE,EAAEzB;AACnE,EAAC"}
|
|
@@ -3,6 +3,11 @@ import type { JSONSchema4 } from 'json-schema';
|
|
|
3
3
|
* Removes internal Payload properties (id, createdAt, updatedAt) from a
|
|
4
4
|
* JSON Schema so they don't appear in the generated Zod validation schema.
|
|
5
5
|
* Also strips `id` from the `required` array when present.
|
|
6
|
+
*
|
|
7
|
+
* Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
|
|
8
|
+
* `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
|
|
9
|
+
* emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
|
|
10
|
+
* the concrete `type` from the output and breaking schema introspection.
|
|
6
11
|
*/
|
|
7
12
|
export declare function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4;
|
|
8
13
|
//# sourceMappingURL=sanitizeJsonSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C
|
|
1
|
+
{"version":3,"file":"sanitizeJsonSchema.d.ts","sourceRoot":"","sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA6BnE"}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Removes internal Payload properties (id, createdAt, updatedAt) from a
|
|
3
3
|
* JSON Schema so they don't appear in the generated Zod validation schema.
|
|
4
4
|
* Also strips `id` from the `required` array when present.
|
|
5
|
+
*
|
|
6
|
+
* Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
|
|
7
|
+
* `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
|
|
8
|
+
* emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
|
|
9
|
+
* the concrete `type` from the output and breaking schema introspection.
|
|
5
10
|
*/ export function sanitizeJsonSchema(schema) {
|
|
6
11
|
delete schema?.properties?.id;
|
|
7
12
|
delete schema?.properties?.createdAt;
|
|
@@ -12,7 +17,40 @@
|
|
|
12
17
|
delete schema.required;
|
|
13
18
|
}
|
|
14
19
|
}
|
|
20
|
+
if (schema.properties && typeof schema.properties === 'object') {
|
|
21
|
+
for (const key of Object.keys(schema.properties)){
|
|
22
|
+
const prop = schema.properties[key];
|
|
23
|
+
if (!prop || typeof prop !== 'object') {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
normalizeNullableType(prop);
|
|
27
|
+
if (prop.properties) {
|
|
28
|
+
sanitizeJsonSchema(prop);
|
|
29
|
+
}
|
|
30
|
+
if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
|
|
31
|
+
sanitizeJsonSchema(prop.items);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
15
35
|
return schema;
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Strips `'null'` from a `type` array only when the remaining type is a
|
|
39
|
+
* complex structural type (`array` or `object`).
|
|
40
|
+
*
|
|
41
|
+
* Simple scalar types (`string`, `number`, `boolean`) are intentionally
|
|
42
|
+
* preserved as `['string', 'null']` so that the MCP SDK serialises them as a
|
|
43
|
+
* compact inline `type` array. Complex types however cause `zodToJsonSchema`
|
|
44
|
+
* to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which
|
|
45
|
+
* has no top-level `type` property and breaks schema introspection by clients.
|
|
46
|
+
*/ function normalizeNullableType(schema) {
|
|
47
|
+
if (!Array.isArray(schema.type)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const nonNullTypes = schema.type.filter((t)=>t !== 'null');
|
|
51
|
+
if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {
|
|
52
|
+
schema.type = nonNullTypes[0];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
17
55
|
|
|
18
56
|
//# sourceMappingURL=sanitizeJsonSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n */\nexport function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4 {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n return schema\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length"],"mappings":"AAEA
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeJsonSchema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/**\n * Removes internal Payload properties (id, createdAt, updatedAt) from a\n * JSON Schema so they don't appear in the generated Zod validation schema.\n * Also strips `id` from the `required` array when present.\n *\n * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →\n * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`\n * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping\n * the concrete `type` from the output and breaking schema introspection.\n */\nexport function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4 {\n delete schema?.properties?.id\n delete schema?.properties?.createdAt\n delete schema?.properties?.updatedAt\n\n if (Array.isArray(schema.required)) {\n schema.required = schema.required.filter((field) => field !== 'id')\n if (schema.required.length === 0) {\n delete schema.required\n }\n }\n\n if (schema.properties && typeof schema.properties === 'object') {\n for (const key of Object.keys(schema.properties)) {\n const prop = schema.properties[key] as JSONSchema4\n if (!prop || typeof prop !== 'object') {\n continue\n }\n normalizeNullableType(prop)\n if (prop.properties) {\n sanitizeJsonSchema(prop)\n }\n if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {\n sanitizeJsonSchema(prop.items)\n }\n }\n }\n\n return schema\n}\n\n/**\n * Strips `'null'` from a `type` array only when the remaining type is a\n * complex structural type (`array` or `object`).\n *\n * Simple scalar types (`string`, `number`, `boolean`) are intentionally\n * preserved as `['string', 'null']` so that the MCP SDK serialises them as a\n * compact inline `type` array. Complex types however cause `zodToJsonSchema`\n * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which\n * has no top-level `type` property and breaks schema introspection by clients.\n */\nfunction normalizeNullableType(schema: JSONSchema4): void {\n if (!Array.isArray(schema.type)) {\n return\n }\n const nonNullTypes = schema.type.filter((t) => t !== 'null')\n if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {\n schema.type = nonNullTypes[0]\n }\n}\n"],"names":["sanitizeJsonSchema","schema","properties","id","createdAt","updatedAt","Array","isArray","required","filter","field","length","key","Object","keys","prop","normalizeNullableType","items","type","nonNullTypes","t"],"mappings":"AAEA;;;;;;;;;CASC,GACD,OAAO,SAASA,mBAAmBC,MAAmB;IACpD,OAAOA,QAAQC,YAAYC;IAC3B,OAAOF,QAAQC,YAAYE;IAC3B,OAAOH,QAAQC,YAAYG;IAE3B,IAAIC,MAAMC,OAAO,CAACN,OAAOO,QAAQ,GAAG;QAClCP,OAAOO,QAAQ,GAAGP,OAAOO,QAAQ,CAACC,MAAM,CAAC,CAACC,QAAUA,UAAU;QAC9D,IAAIT,OAAOO,QAAQ,CAACG,MAAM,KAAK,GAAG;YAChC,OAAOV,OAAOO,QAAQ;QACxB;IACF;IAEA,IAAIP,OAAOC,UAAU,IAAI,OAAOD,OAAOC,UAAU,KAAK,UAAU;QAC9D,KAAK,MAAMU,OAAOC,OAAOC,IAAI,CAACb,OAAOC,UAAU,EAAG;YAChD,MAAMa,OAAOd,OAAOC,UAAU,CAACU,IAAI;YACnC,IAAI,CAACG,QAAQ,OAAOA,SAAS,UAAU;gBACrC;YACF;YACAC,sBAAsBD;YACtB,IAAIA,KAAKb,UAAU,EAAE;gBACnBF,mBAAmBe;YACrB;YACA,IAAIA,KAAKE,KAAK,IAAI,OAAOF,KAAKE,KAAK,KAAK,YAAY,CAACX,MAAMC,OAAO,CAACQ,KAAKE,KAAK,GAAG;gBAC9EjB,mBAAmBe,KAAKE,KAAK;YAC/B;QACF;IACF;IAEA,OAAOhB;AACT;AAEA;;;;;;;;;CASC,GACD,SAASe,sBAAsBf,MAAmB;IAChD,IAAI,CAACK,MAAMC,OAAO,CAACN,OAAOiB,IAAI,GAAG;QAC/B;IACF;IACA,MAAMC,eAAelB,OAAOiB,IAAI,CAACT,MAAM,CAAC,CAACW,IAAMA,MAAM;IACrD,IAAID,aAAaR,MAAM,KAAK,KAAMQ,CAAAA,YAAY,CAAC,EAAE,KAAK,WAAWA,YAAY,CAAC,EAAE,KAAK,QAAO,GAAI;QAC9FlB,OAAOiB,IAAI,GAAGC,YAAY,CAAC,EAAE;IAC/B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-mcp",
|
|
3
|
-
"version": "3.78.0-canary.
|
|
3
|
+
"version": "3.78.0-canary.3",
|
|
4
4
|
"description": "MCP (Model Context Protocol) capabilities with Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@payloadcms/eslint-config": "3.28.0",
|
|
48
|
-
"payload": "3.78.0-canary.
|
|
48
|
+
"payload": "3.78.0-canary.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"payload": "3.78.0-canary.
|
|
51
|
+
"payload": "3.78.0-canary.3"
|
|
52
52
|
},
|
|
53
53
|
"homepage:": "https://payloadcms.com",
|
|
54
54
|
"scripts": {
|