@payloadcms/plugin-mcp 0.0.1-alpha.0

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.
Files changed (173) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +7 -0
  3. package/dist/collections/createApiKeysCollection.d.ts +7 -0
  4. package/dist/collections/createApiKeysCollection.d.ts.map +1 -0
  5. package/dist/collections/createApiKeysCollection.js +315 -0
  6. package/dist/collections/createApiKeysCollection.js.map +1 -0
  7. package/dist/endpoints/mcp.d.ts +4 -0
  8. package/dist/endpoints/mcp.d.ts.map +1 -0
  9. package/dist/endpoints/mcp.js +44 -0
  10. package/dist/endpoints/mcp.js.map +1 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +67 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/mcp/createRequest.d.ts +3 -0
  16. package/dist/mcp/createRequest.d.ts.map +1 -0
  17. package/dist/mcp/createRequest.js +14 -0
  18. package/dist/mcp/createRequest.js.map +1 -0
  19. package/dist/mcp/getMcpHandler.d.ts +4 -0
  20. package/dist/mcp/getMcpHandler.d.ts.map +1 -0
  21. package/dist/mcp/getMcpHandler.js +179 -0
  22. package/dist/mcp/getMcpHandler.js.map +1 -0
  23. package/dist/mcp/helpers/config.d.ts +30 -0
  24. package/dist/mcp/helpers/config.d.ts.map +1 -0
  25. package/dist/mcp/helpers/config.js +217 -0
  26. package/dist/mcp/helpers/config.js.map +1 -0
  27. package/dist/mcp/helpers/conversion.d.ts +2 -0
  28. package/dist/mcp/helpers/conversion.d.ts.map +1 -0
  29. package/dist/mcp/helpers/conversion.js +5 -0
  30. package/dist/mcp/helpers/conversion.js.map +1 -0
  31. package/dist/mcp/helpers/fields.d.ts +38 -0
  32. package/dist/mcp/helpers/fields.d.ts.map +1 -0
  33. package/dist/mcp/helpers/fields.js +96 -0
  34. package/dist/mcp/helpers/fields.js.map +1 -0
  35. package/dist/mcp/helpers/fileValidation.d.ts +69 -0
  36. package/dist/mcp/helpers/fileValidation.d.ts.map +1 -0
  37. package/dist/mcp/helpers/fileValidation.js +305 -0
  38. package/dist/mcp/helpers/fileValidation.js.map +1 -0
  39. package/dist/mcp/helpers/validation.d.ts +9 -0
  40. package/dist/mcp/helpers/validation.d.ts.map +1 -0
  41. package/dist/mcp/helpers/validation.js +22 -0
  42. package/dist/mcp/helpers/validation.js.map +1 -0
  43. package/dist/mcp/registerTool.d.ts +6 -0
  44. package/dist/mcp/registerTool.d.ts.map +1 -0
  45. package/dist/mcp/registerTool.js +18 -0
  46. package/dist/mcp/registerTool.js.map +1 -0
  47. package/dist/mcp/tools/auth/auth.d.ts +4 -0
  48. package/dist/mcp/tools/auth/auth.d.ts.map +1 -0
  49. package/dist/mcp/tools/auth/auth.js +54 -0
  50. package/dist/mcp/tools/auth/auth.js.map +1 -0
  51. package/dist/mcp/tools/auth/forgotPassword.d.ts +4 -0
  52. package/dist/mcp/tools/auth/forgotPassword.d.ts.map +1 -0
  53. package/dist/mcp/tools/auth/forgotPassword.js +45 -0
  54. package/dist/mcp/tools/auth/forgotPassword.js.map +1 -0
  55. package/dist/mcp/tools/auth/login.d.ts +4 -0
  56. package/dist/mcp/tools/auth/login.d.ts.map +1 -0
  57. package/dist/mcp/tools/auth/login.js +48 -0
  58. package/dist/mcp/tools/auth/login.js.map +1 -0
  59. package/dist/mcp/tools/auth/resetPassword.d.ts +4 -0
  60. package/dist/mcp/tools/auth/resetPassword.d.ts.map +1 -0
  61. package/dist/mcp/tools/auth/resetPassword.js +46 -0
  62. package/dist/mcp/tools/auth/resetPassword.js.map +1 -0
  63. package/dist/mcp/tools/auth/unlock.d.ts +4 -0
  64. package/dist/mcp/tools/auth/unlock.d.ts.map +1 -0
  65. package/dist/mcp/tools/auth/unlock.js +45 -0
  66. package/dist/mcp/tools/auth/unlock.js.map +1 -0
  67. package/dist/mcp/tools/auth/verify.d.ts +4 -0
  68. package/dist/mcp/tools/auth/verify.d.ts.map +1 -0
  69. package/dist/mcp/tools/auth/verify.js +42 -0
  70. package/dist/mcp/tools/auth/verify.js.map +1 -0
  71. package/dist/mcp/tools/collection/create.d.ts +10 -0
  72. package/dist/mcp/tools/collection/create.d.ts.map +1 -0
  73. package/dist/mcp/tools/collection/create.js +159 -0
  74. package/dist/mcp/tools/collection/create.js.map +1 -0
  75. package/dist/mcp/tools/collection/delete.d.ts +10 -0
  76. package/dist/mcp/tools/collection/delete.d.ts.map +1 -0
  77. package/dist/mcp/tools/collection/delete.js +162 -0
  78. package/dist/mcp/tools/collection/delete.js.map +1 -0
  79. package/dist/mcp/tools/collection/find.d.ts +10 -0
  80. package/dist/mcp/tools/collection/find.d.ts.map +1 -0
  81. package/dist/mcp/tools/collection/find.js +162 -0
  82. package/dist/mcp/tools/collection/find.js.map +1 -0
  83. package/dist/mcp/tools/collection/update.d.ts +10 -0
  84. package/dist/mcp/tools/collection/update.d.ts.map +1 -0
  85. package/dist/mcp/tools/collection/update.js +206 -0
  86. package/dist/mcp/tools/collection/update.js.map +1 -0
  87. package/dist/mcp/tools/config/find.d.ts +10 -0
  88. package/dist/mcp/tools/config/find.d.ts.map +1 -0
  89. package/dist/mcp/tools/config/find.js +94 -0
  90. package/dist/mcp/tools/config/find.js.map +1 -0
  91. package/dist/mcp/tools/config/update.d.ts +10 -0
  92. package/dist/mcp/tools/config/update.d.ts.map +1 -0
  93. package/dist/mcp/tools/config/update.js +212 -0
  94. package/dist/mcp/tools/config/update.js.map +1 -0
  95. package/dist/mcp/tools/job/create.d.ts +10 -0
  96. package/dist/mcp/tools/job/create.d.ts.map +1 -0
  97. package/dist/mcp/tools/job/create.js +293 -0
  98. package/dist/mcp/tools/job/create.js.map +1 -0
  99. package/dist/mcp/tools/job/run.d.ts +10 -0
  100. package/dist/mcp/tools/job/run.d.ts.map +1 -0
  101. package/dist/mcp/tools/job/run.js +147 -0
  102. package/dist/mcp/tools/job/run.js.map +1 -0
  103. package/dist/mcp/tools/job/update.d.ts +11 -0
  104. package/dist/mcp/tools/job/update.d.ts.map +1 -0
  105. package/dist/mcp/tools/job/update.js +211 -0
  106. package/dist/mcp/tools/job/update.js.map +1 -0
  107. package/dist/mcp/tools/resource/create.d.ts +6 -0
  108. package/dist/mcp/tools/resource/create.d.ts.map +1 -0
  109. package/dist/mcp/tools/resource/create.js +75 -0
  110. package/dist/mcp/tools/resource/create.js.map +1 -0
  111. package/dist/mcp/tools/resource/delete.d.ts +5 -0
  112. package/dist/mcp/tools/resource/delete.d.ts.map +1 -0
  113. package/dist/mcp/tools/resource/delete.js +140 -0
  114. package/dist/mcp/tools/resource/delete.js.map +1 -0
  115. package/dist/mcp/tools/resource/find.d.ts +5 -0
  116. package/dist/mcp/tools/resource/find.d.ts.map +1 -0
  117. package/dist/mcp/tools/resource/find.js +119 -0
  118. package/dist/mcp/tools/resource/find.js.map +1 -0
  119. package/dist/mcp/tools/resource/update.d.ts +6 -0
  120. package/dist/mcp/tools/resource/update.d.ts.map +1 -0
  121. package/dist/mcp/tools/resource/update.js +201 -0
  122. package/dist/mcp/tools/resource/update.js.map +1 -0
  123. package/dist/mcp/tools/schemas.d.ts +374 -0
  124. package/dist/mcp/tools/schemas.d.ts.map +1 -0
  125. package/dist/mcp/tools/schemas.js +201 -0
  126. package/dist/mcp/tools/schemas.js.map +1 -0
  127. package/dist/types.d.ts +379 -0
  128. package/dist/types.d.ts.map +1 -0
  129. package/dist/types.js +3 -0
  130. package/dist/types.js.map +1 -0
  131. package/dist/utils/camelCase.d.ts +9 -0
  132. package/dist/utils/camelCase.d.ts.map +1 -0
  133. package/dist/utils/camelCase.js +11 -0
  134. package/dist/utils/camelCase.js.map +1 -0
  135. package/dist/utils/convertCollectionSchemaToZod.d.ts +3 -0
  136. package/dist/utils/convertCollectionSchemaToZod.d.ts.map +1 -0
  137. package/dist/utils/convertCollectionSchemaToZod.js +30 -0
  138. package/dist/utils/convertCollectionSchemaToZod.js.map +1 -0
  139. package/package.json +64 -0
  140. package/src/collections/createApiKeysCollection.ts +393 -0
  141. package/src/endpoints/mcp.ts +60 -0
  142. package/src/index.ts +86 -0
  143. package/src/mcp/createRequest.ts +13 -0
  144. package/src/mcp/getMcpHandler.ts +433 -0
  145. package/src/mcp/helpers/config.ts +326 -0
  146. package/src/mcp/helpers/conversion.ts +3 -0
  147. package/src/mcp/helpers/fields.ts +158 -0
  148. package/src/mcp/helpers/fileValidation.ts +417 -0
  149. package/src/mcp/helpers/validation.ts +32 -0
  150. package/src/mcp/registerTool.ts +22 -0
  151. package/src/mcp/tools/auth/auth.ts +69 -0
  152. package/src/mcp/tools/auth/forgotPassword.ts +68 -0
  153. package/src/mcp/tools/auth/login.ts +70 -0
  154. package/src/mcp/tools/auth/resetPassword.ts +59 -0
  155. package/src/mcp/tools/auth/unlock.ts +62 -0
  156. package/src/mcp/tools/auth/verify.ts +55 -0
  157. package/src/mcp/tools/collection/create.ts +236 -0
  158. package/src/mcp/tools/collection/delete.ts +227 -0
  159. package/src/mcp/tools/collection/find.ts +222 -0
  160. package/src/mcp/tools/collection/update.ts +288 -0
  161. package/src/mcp/tools/config/find.ts +126 -0
  162. package/src/mcp/tools/config/update.ts +282 -0
  163. package/src/mcp/tools/job/create.ts +420 -0
  164. package/src/mcp/tools/job/run.ts +189 -0
  165. package/src/mcp/tools/job/update.ts +319 -0
  166. package/src/mcp/tools/resource/create.ts +121 -0
  167. package/src/mcp/tools/resource/delete.ts +210 -0
  168. package/src/mcp/tools/resource/find.ts +194 -0
  169. package/src/mcp/tools/resource/update.ts +314 -0
  170. package/src/mcp/tools/schemas.ts +373 -0
  171. package/src/types.ts +405 -0
  172. package/src/utils/camelCase.ts +12 -0
  173. package/src/utils/convertCollectionSchemaToZod.ts +35 -0
@@ -0,0 +1,293 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { validatePayloadFile } from '../../helpers/fileValidation.js';
4
+ import { toolSchemas } from '../schemas.js';
5
+ const createOrUpdateJobFile = (req, verboseLogs, jobsDir, jobName, jobType, jobSlug, camelCaseJobSlug)=>{
6
+ const payload = req.payload;
7
+ const jobFilePath = join(jobsDir, `${jobName}.ts`);
8
+ const importName = `${camelCaseJobSlug}${jobType === 'task' ? 'Task' : 'Workflow'}`;
9
+ const importPath = `./${jobType === 'task' ? 'tasks' : 'workflows'}/${camelCaseJobSlug}`;
10
+ if (verboseLogs) {
11
+ payload.logger.info(`[payload-mcp] Processing job file: ${jobFilePath}`);
12
+ }
13
+ if (existsSync(jobFilePath)) {
14
+ if (verboseLogs) {
15
+ payload.logger.info(`[payload-mcp] Updating existing job file: ${jobFilePath}`);
16
+ }
17
+ // Update existing job file
18
+ let content = readFileSync(jobFilePath, 'utf8');
19
+ // Add import if not already present
20
+ const importStatement = `import { ${importName} } from '${importPath}'`;
21
+ if (!content.includes(importStatement)) {
22
+ if (verboseLogs) {
23
+ payload.logger.info(`[payload-mcp] Adding import: ${importStatement}`);
24
+ }
25
+ // Find the last import statement and add after it
26
+ const importRegex = /import\s+(?:\S.*)?from\s+['"].*['"];?\s*\n/g;
27
+ let lastImportMatch;
28
+ let match;
29
+ while((match = importRegex.exec(content)) !== null){
30
+ lastImportMatch = match;
31
+ }
32
+ if (lastImportMatch) {
33
+ const insertIndex = lastImportMatch.index + lastImportMatch[0].length;
34
+ content = content.slice(0, insertIndex) + importStatement + '\n' + content.slice(insertIndex);
35
+ } else {
36
+ // No imports found, add at the beginning
37
+ content = importStatement + '\n\n' + content;
38
+ }
39
+ }
40
+ // Add to the appropriate array
41
+ const arrayName = jobType === 'task' ? 'tasks' : 'workflows';
42
+ const arrayRegex = new RegExp(`(${arrayName}:\\s*\\[)([^\\]]*)(\\])`, 's');
43
+ const arrayMatch = content.match(arrayRegex);
44
+ if (arrayMatch && arrayMatch[2]) {
45
+ const existingItems = arrayMatch[2].trim();
46
+ const newItem = existingItems ? `${existingItems},\n ${importName}` : `\n ${importName}`;
47
+ content = content.replace(arrayRegex, `$1${newItem}\n $3`);
48
+ if (verboseLogs) {
49
+ payload.logger.info(`[payload-mcp] Added ${importName} to ${arrayName} array`);
50
+ }
51
+ } else {
52
+ // Array doesn't exist, add it
53
+ const jobsConfigRegex = /(export\s+const\s.*JobsConfig\s*=\s*\{)([^}]*)(\})/s;
54
+ const jobsConfigMatch = content.match(jobsConfigRegex);
55
+ if (jobsConfigMatch && jobsConfigMatch[2]) {
56
+ const existingConfig = jobsConfigMatch[2].trim();
57
+ const newConfig = existingConfig ? `${existingConfig},\n ${arrayName}: [\n ${importName}\n ]` : `\n ${arrayName}: [\n ${importName}\n ]`;
58
+ content = content.replace(jobsConfigRegex, `$1${newConfig}\n$3`);
59
+ if (verboseLogs) {
60
+ payload.logger.info(`[payload-mcp] Created new ${arrayName} array with ${importName}`);
61
+ }
62
+ }
63
+ }
64
+ writeFileSync(jobFilePath, content);
65
+ if (verboseLogs) {
66
+ payload.logger.info(`[payload-mcp] Successfully updated job file: ${jobFilePath}`);
67
+ }
68
+ } else {
69
+ if (verboseLogs) {
70
+ payload.logger.info(`[payload-mcp] Creating new job file: ${jobFilePath}`);
71
+ }
72
+ // Create new job file
73
+ const camelCaseJobName = toCamelCase(jobName);
74
+ const jobFileContent = `import type { JobsConfig } from 'payload'
75
+ import { ${importName} } from '${importPath}'
76
+
77
+ export const ${camelCaseJobName}JobsConfig: JobsConfig = {
78
+ ${jobType === 'task' ? 'tasks' : 'workflows'}: [
79
+ ${importName}
80
+ ]
81
+ }
82
+ `;
83
+ writeFileSync(jobFilePath, jobFileContent);
84
+ if (verboseLogs) {
85
+ payload.logger.info(`[payload-mcp] Successfully created new job file: ${jobFilePath}`);
86
+ }
87
+ }
88
+ };
89
+ // Reusable function for creating jobs
90
+ export const createJob = async (req, verboseLogs, jobsDir, jobName, jobType, jobSlug, description, inputSchema, outputSchema, jobData)=>{
91
+ const payload = req.payload;
92
+ if (verboseLogs) {
93
+ payload.logger.info(`[payload-mcp] Creating ${jobType}: ${jobName}`);
94
+ }
95
+ try {
96
+ // Ensure jobs directory exists
97
+ if (!existsSync(jobsDir)) {
98
+ if (verboseLogs) {
99
+ payload.logger.info(`[payload-mcp] Creating jobs directory: ${jobsDir}`);
100
+ }
101
+ mkdirSync(jobsDir, {
102
+ recursive: true
103
+ });
104
+ }
105
+ // Ensure subdirectories exist
106
+ const tasksDir = join(jobsDir, 'tasks');
107
+ const workflowsDir = join(jobsDir, 'workflows');
108
+ if (!existsSync(tasksDir)) {
109
+ mkdirSync(tasksDir, {
110
+ recursive: true
111
+ });
112
+ }
113
+ if (!existsSync(workflowsDir)) {
114
+ mkdirSync(workflowsDir, {
115
+ recursive: true
116
+ });
117
+ }
118
+ const camelCaseJobSlug = toCamelCase(jobSlug);
119
+ const targetDir = jobType === 'task' ? tasksDir : workflowsDir;
120
+ const fileName = `${camelCaseJobSlug}.ts`;
121
+ const filePath = join(targetDir, fileName);
122
+ if (verboseLogs) {
123
+ payload.logger.info(`[payload-mcp] Target file path: ${filePath}`);
124
+ }
125
+ // Security check: ensure we're working with the jobs directory
126
+ if (!filePath.startsWith(jobsDir)) {
127
+ payload.logger.error(`[payload-mcp] Invalid job path attempted: ${filePath}`);
128
+ return {
129
+ content: [
130
+ {
131
+ type: 'text',
132
+ text: '❌ **Error**: Invalid job path'
133
+ }
134
+ ]
135
+ };
136
+ }
137
+ // Check if file already exists
138
+ if (existsSync(filePath)) {
139
+ if (verboseLogs) {
140
+ payload.logger.info(`[payload-mcp] Job file already exists: ${fileName}`);
141
+ }
142
+ return {
143
+ content: [
144
+ {
145
+ type: 'text',
146
+ text: `❌ **Error**: Job file already exists: ${fileName}`
147
+ }
148
+ ]
149
+ };
150
+ }
151
+ // Generate job content based on type
152
+ let jobContent;
153
+ if (jobType === 'task') {
154
+ jobContent = generateTaskContent(jobName, jobSlug, description, inputSchema, outputSchema, jobData);
155
+ } else {
156
+ jobContent = generateWorkflowContent(jobName, jobSlug, description, inputSchema, outputSchema, jobData);
157
+ }
158
+ // Write the job file
159
+ writeFileSync(filePath, jobContent, 'utf8');
160
+ if (verboseLogs) {
161
+ payload.logger.info(`[payload-mcp] Successfully created job file: ${filePath}`);
162
+ }
163
+ // Update the main job file
164
+ createOrUpdateJobFile(req, verboseLogs, jobsDir, jobName, jobType, jobSlug, camelCaseJobSlug);
165
+ // Validate the generated file
166
+ const validationResult = await validatePayloadFile(fileName, jobType);
167
+ if (validationResult.error) {
168
+ return {
169
+ content: [
170
+ {
171
+ type: 'text',
172
+ text: `❌ **Error**: Generated job has validation issues:\n\n${validationResult.error}`
173
+ }
174
+ ]
175
+ };
176
+ }
177
+ return {
178
+ content: [
179
+ {
180
+ type: 'text',
181
+ text: `✅ **Job created successfully!**
182
+
183
+ **File**: \`${fileName}\`
184
+ **Type**: \`${jobType}\`
185
+ **Slug**: \`${jobSlug}\`
186
+ **Description**: ${description}
187
+
188
+ **Generated Job Code:**
189
+ \`\`\`typescript
190
+ ${jobContent}
191
+ \`\`\``
192
+ }
193
+ ]
194
+ };
195
+ } catch (error) {
196
+ const errorMessage = error.message;
197
+ payload.logger.error(`[payload-mcp] Error creating job: ${errorMessage}`);
198
+ return {
199
+ content: [
200
+ {
201
+ type: 'text',
202
+ text: `❌ **Error creating job**: ${errorMessage}`
203
+ }
204
+ ]
205
+ };
206
+ }
207
+ };
208
+ // Helper function to generate task content
209
+ function generateTaskContent(jobName, jobSlug, description, inputSchema, outputSchema, jobData) {
210
+ const camelCaseJobSlug = toCamelCase(jobSlug);
211
+ return `import type { Task } from 'payload'
212
+
213
+ export const ${camelCaseJobSlug}Task: Task = {
214
+ slug: '${jobSlug}',
215
+ description: '${description}',
216
+ inputSchema: ${JSON.stringify(inputSchema, null, 2)},
217
+ outputSchema: ${JSON.stringify(outputSchema, null, 2)},
218
+ handler: async (input, context) => {
219
+ // TODO: Implement your task logic here
220
+ // Access input data: input.fieldName
221
+ // Access context: context.payload, context.req, etc.
222
+
223
+ // Example implementation:
224
+ const result = {
225
+ message: 'Task executed successfully',
226
+ input,
227
+ timestamp: new Date().toISOString(),
228
+ }
229
+
230
+ return result
231
+ },
232
+ }
233
+ `;
234
+ }
235
+ // Helper function to generate workflow content
236
+ function generateWorkflowContent(jobName, jobSlug, description, inputSchema, outputSchema, jobData) {
237
+ const camelCaseJobSlug = toCamelCase(jobSlug);
238
+ return `import type { Workflow } from 'payload'
239
+
240
+ export const ${camelCaseJobSlug}Workflow: Workflow = {
241
+ slug: '${jobSlug}',
242
+ description: '${description}',
243
+ inputSchema: ${JSON.stringify(inputSchema, null, 2)},
244
+ outputSchema: ${JSON.stringify(outputSchema, null, 2)},
245
+ steps: [
246
+ // TODO: Define your workflow steps here
247
+ // Each step should be a function that returns a result
248
+ // Example:
249
+ // {
250
+ // name: 'step1',
251
+ // handler: async (input, context) => {
252
+ // // Step logic here
253
+ // return { result: 'step1 completed' }
254
+ // }
255
+ // }
256
+ ],
257
+ }
258
+ `;
259
+ }
260
+ // Helper function to convert to camel case
261
+ function toCamelCase(str) {
262
+ return str.replace(/[-_\s]+(.)?/g, (_, chr)=>chr ? chr.toUpperCase() : '').replace(/^(.)/, (_, chr)=>chr.toLowerCase());
263
+ }
264
+ export const createJobTool = (server, req, verboseLogs, jobsDir)=>{
265
+ const tool = async (jobName, jobType, jobSlug, description, inputSchema = {}, outputSchema = {}, jobData = {})=>{
266
+ if (verboseLogs) {
267
+ req.payload.logger.info(`[payload-mcp] Create Job Tool called with: ${jobName}, ${jobType}, ${jobSlug}`);
268
+ }
269
+ try {
270
+ const result = await createJob(req, verboseLogs, jobsDir, jobName, jobType, jobSlug, description, inputSchema, outputSchema, jobData);
271
+ if (verboseLogs) {
272
+ req.payload.logger.info(`[payload-mcp] Create Job Tool completed successfully`);
273
+ }
274
+ return result;
275
+ } catch (error) {
276
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
277
+ req.payload.logger.error(`[payload-mcp] Error in Create Job Tool: ${errorMessage}`);
278
+ return {
279
+ content: [
280
+ {
281
+ type: 'text',
282
+ text: `❌ **Error in Create Job Tool**: ${errorMessage}`
283
+ }
284
+ ]
285
+ };
286
+ }
287
+ };
288
+ server.tool('createJob', 'Creates a new Payload job (task or workflow) with specified configuration', toolSchemas.createJob.parameters.shape, async (args)=>{
289
+ return tool(args.jobName, args.jobType, args.jobSlug, args.description, args.inputSchema, args.outputSchema, args.jobData);
290
+ });
291
+ };
292
+
293
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/mcp/tools/job/create.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport type { PayloadRequest } from 'payload'\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'\nimport { join } from 'path'\n\nimport { validatePayloadFile } from '../../helpers/fileValidation.js'\nimport { toolSchemas } from '../schemas.js'\n\nconst createOrUpdateJobFile = (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n jobName: string,\n jobType: 'task' | 'workflow',\n jobSlug: string,\n camelCaseJobSlug: string,\n) => {\n const payload = req.payload\n const jobFilePath = join(jobsDir, `${jobName}.ts`)\n const importName = `${camelCaseJobSlug}${jobType === 'task' ? 'Task' : 'Workflow'}`\n const importPath = `./${jobType === 'task' ? 'tasks' : 'workflows'}/${camelCaseJobSlug}`\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Processing job file: ${jobFilePath}`)\n }\n\n if (existsSync(jobFilePath)) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Updating existing job file: ${jobFilePath}`)\n }\n\n // Update existing job file\n let content = readFileSync(jobFilePath, 'utf8')\n\n // Add import if not already present\n const importStatement = `import { ${importName} } from '${importPath}'`\n if (!content.includes(importStatement)) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Adding import: ${importStatement}`)\n }\n\n // Find the last import statement and add after it\n const importRegex = /import\\s+(?:\\S.*)?from\\s+['\"].*['\"];?\\s*\\n/g\n let lastImportMatch\n let match\n while ((match = importRegex.exec(content)) !== null) {\n lastImportMatch = match\n }\n\n if (lastImportMatch) {\n const insertIndex = lastImportMatch.index + lastImportMatch[0].length\n content =\n content.slice(0, insertIndex) + importStatement + '\\n' + content.slice(insertIndex)\n } else {\n // No imports found, add at the beginning\n content = importStatement + '\\n\\n' + content\n }\n }\n\n // Add to the appropriate array\n const arrayName = jobType === 'task' ? 'tasks' : 'workflows'\n const arrayRegex = new RegExp(`(${arrayName}:\\\\s*\\\\[)([^\\\\]]*)(\\\\])`, 's')\n const arrayMatch = content.match(arrayRegex)\n\n if (arrayMatch && arrayMatch[2]) {\n const existingItems = arrayMatch[2].trim()\n const newItem = existingItems ? `${existingItems},\\n ${importName}` : `\\n ${importName}`\n content = content.replace(arrayRegex, `$1${newItem}\\n $3`)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Added ${importName} to ${arrayName} array`)\n }\n } else {\n // Array doesn't exist, add it\n const jobsConfigRegex = /(export\\s+const\\s.*JobsConfig\\s*=\\s*\\{)([^}]*)(\\})/s\n const jobsConfigMatch = content.match(jobsConfigRegex)\n\n if (jobsConfigMatch && jobsConfigMatch[2]) {\n const existingConfig = jobsConfigMatch[2].trim()\n const newConfig = existingConfig\n ? `${existingConfig},\\n ${arrayName}: [\\n ${importName}\\n ]`\n : `\\n ${arrayName}: [\\n ${importName}\\n ]`\n content = content.replace(jobsConfigRegex, `$1${newConfig}\\n$3`)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Created new ${arrayName} array with ${importName}`)\n }\n }\n }\n\n writeFileSync(jobFilePath, content)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully updated job file: ${jobFilePath}`)\n }\n } else {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Creating new job file: ${jobFilePath}`)\n }\n\n // Create new job file\n const camelCaseJobName = toCamelCase(jobName)\n const jobFileContent = `import type { JobsConfig } from 'payload'\nimport { ${importName} } from '${importPath}'\n\nexport const ${camelCaseJobName}JobsConfig: JobsConfig = {\n ${jobType === 'task' ? 'tasks' : 'workflows'}: [\n ${importName}\n ]\n}\n`\n writeFileSync(jobFilePath, jobFileContent)\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully created new job file: ${jobFilePath}`)\n }\n }\n}\n\n// Reusable function for creating jobs\nexport const createJob = async (\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n jobName: string,\n jobType: 'task' | 'workflow',\n jobSlug: string,\n description: string,\n inputSchema: any,\n outputSchema: any,\n jobData: Record<string, any>,\n) => {\n const payload = req.payload\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Creating ${jobType}: ${jobName}`)\n }\n\n try {\n // Ensure jobs directory exists\n if (!existsSync(jobsDir)) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Creating jobs directory: ${jobsDir}`)\n }\n mkdirSync(jobsDir, { recursive: true })\n }\n\n // Ensure subdirectories exist\n const tasksDir = join(jobsDir, 'tasks')\n const workflowsDir = join(jobsDir, 'workflows')\n\n if (!existsSync(tasksDir)) {\n mkdirSync(tasksDir, { recursive: true })\n }\n if (!existsSync(workflowsDir)) {\n mkdirSync(workflowsDir, { recursive: true })\n }\n\n const camelCaseJobSlug = toCamelCase(jobSlug)\n const targetDir = jobType === 'task' ? tasksDir : workflowsDir\n const fileName = `${camelCaseJobSlug}.ts`\n const filePath = join(targetDir, fileName)\n\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Target file path: ${filePath}`)\n }\n\n // Security check: ensure we're working with the jobs directory\n if (!filePath.startsWith(jobsDir)) {\n payload.logger.error(`[payload-mcp] Invalid job path attempted: ${filePath}`)\n return {\n content: [\n {\n type: 'text' as const,\n text: '❌ **Error**: Invalid job path',\n },\n ],\n }\n }\n\n // Check if file already exists\n if (existsSync(filePath)) {\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Job file already exists: ${fileName}`)\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Job file already exists: ${fileName}`,\n },\n ],\n }\n }\n\n // Generate job content based on type\n let jobContent: string\n if (jobType === 'task') {\n jobContent = generateTaskContent(\n jobName,\n jobSlug,\n description,\n inputSchema,\n outputSchema,\n jobData,\n )\n } else {\n jobContent = generateWorkflowContent(\n jobName,\n jobSlug,\n description,\n inputSchema,\n outputSchema,\n jobData,\n )\n }\n\n // Write the job file\n writeFileSync(filePath, jobContent, 'utf8')\n if (verboseLogs) {\n payload.logger.info(`[payload-mcp] Successfully created job file: ${filePath}`)\n }\n\n // Update the main job file\n createOrUpdateJobFile(req, verboseLogs, jobsDir, jobName, jobType, jobSlug, camelCaseJobSlug)\n\n // Validate the generated file\n const validationResult = await validatePayloadFile(fileName, jobType)\n if (validationResult.error) {\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error**: Generated job has validation issues:\\n\\n${validationResult.error}`,\n },\n ],\n }\n }\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `✅ **Job created successfully!**\n\n**File**: \\`${fileName}\\`\n**Type**: \\`${jobType}\\`\n**Slug**: \\`${jobSlug}\\`\n**Description**: ${description}\n\n**Generated Job Code:**\n\\`\\`\\`typescript\n${jobContent}\n\\`\\`\\``,\n },\n ],\n }\n } catch (error) {\n const errorMessage = (error as Error).message\n payload.logger.error(`[payload-mcp] Error creating job: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error creating job**: ${errorMessage}`,\n },\n ],\n }\n }\n}\n\n// Helper function to generate task content\nfunction generateTaskContent(\n jobName: string,\n jobSlug: string,\n description: string,\n inputSchema: any,\n outputSchema: any,\n jobData: Record<string, any>,\n): string {\n const camelCaseJobSlug = toCamelCase(jobSlug)\n\n return `import type { Task } from 'payload'\n\nexport const ${camelCaseJobSlug}Task: Task = {\n slug: '${jobSlug}',\n description: '${description}',\n inputSchema: ${JSON.stringify(inputSchema, null, 2)},\n outputSchema: ${JSON.stringify(outputSchema, null, 2)},\n handler: async (input, context) => {\n // TODO: Implement your task logic here\n // Access input data: input.fieldName\n // Access context: context.payload, context.req, etc.\n\n // Example implementation:\n const result = {\n message: 'Task executed successfully',\n input,\n timestamp: new Date().toISOString(),\n }\n\n return result\n },\n}\n`\n}\n\n// Helper function to generate workflow content\nfunction generateWorkflowContent(\n jobName: string,\n jobSlug: string,\n description: string,\n inputSchema: any,\n outputSchema: any,\n jobData: Record<string, any>,\n): string {\n const camelCaseJobSlug = toCamelCase(jobSlug)\n\n return `import type { Workflow } from 'payload'\n\nexport const ${camelCaseJobSlug}Workflow: Workflow = {\n slug: '${jobSlug}',\n description: '${description}',\n inputSchema: ${JSON.stringify(inputSchema, null, 2)},\n outputSchema: ${JSON.stringify(outputSchema, null, 2)},\n steps: [\n // TODO: Define your workflow steps here\n // Each step should be a function that returns a result\n // Example:\n // {\n // name: 'step1',\n // handler: async (input, context) => {\n // // Step logic here\n // return { result: 'step1 completed' }\n // }\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\nexport const createJobTool = (\n server: McpServer,\n req: PayloadRequest,\n verboseLogs: boolean,\n jobsDir: string,\n) => {\n const tool = async (\n jobName: string,\n jobType: 'task' | 'workflow',\n jobSlug: string,\n description: string,\n inputSchema: any = {},\n outputSchema: any = {},\n jobData: Record<string, any> = {},\n ) => {\n if (verboseLogs) {\n req.payload.logger.info(\n `[payload-mcp] Create Job Tool called with: ${jobName}, ${jobType}, ${jobSlug}`,\n )\n }\n\n try {\n const result = await createJob(\n req,\n verboseLogs,\n jobsDir,\n jobName,\n jobType,\n jobSlug,\n description,\n inputSchema,\n outputSchema,\n jobData,\n )\n\n if (verboseLogs) {\n req.payload.logger.info(`[payload-mcp] Create 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 Create Job Tool: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error in Create Job Tool**: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.tool(\n 'createJob',\n 'Creates a new Payload job (task or workflow) with specified configuration',\n toolSchemas.createJob.parameters.shape,\n async (args) => {\n return tool(\n args.jobName,\n args.jobType,\n args.jobSlug,\n args.description,\n args.inputSchema,\n args.outputSchema,\n args.jobData,\n )\n },\n )\n}\n"],"names":["existsSync","mkdirSync","readFileSync","writeFileSync","join","validatePayloadFile","toolSchemas","createOrUpdateJobFile","req","verboseLogs","jobsDir","jobName","jobType","jobSlug","camelCaseJobSlug","payload","jobFilePath","importName","importPath","logger","info","content","importStatement","includes","importRegex","lastImportMatch","match","exec","insertIndex","index","length","slice","arrayName","arrayRegex","RegExp","arrayMatch","existingItems","trim","newItem","replace","jobsConfigRegex","jobsConfigMatch","existingConfig","newConfig","camelCaseJobName","toCamelCase","jobFileContent","createJob","description","inputSchema","outputSchema","jobData","recursive","tasksDir","workflowsDir","targetDir","fileName","filePath","startsWith","error","type","text","jobContent","generateTaskContent","generateWorkflowContent","validationResult","errorMessage","message","JSON","stringify","str","_","chr","toUpperCase","toLowerCase","createJobTool","server","tool","result","Error","parameters","shape","args"],"mappings":"AAGA,SAASA,UAAU,EAAEC,SAAS,EAAEC,YAAY,EAAEC,aAAa,QAAQ,KAAI;AACvE,SAASC,IAAI,QAAQ,OAAM;AAE3B,SAASC,mBAAmB,QAAQ,kCAAiC;AACrE,SAASC,WAAW,QAAQ,gBAAe;AAE3C,MAAMC,wBAAwB,CAC5BC,KACAC,aACAC,SACAC,SACAC,SACAC,SACAC;IAEA,MAAMC,UAAUP,IAAIO,OAAO;IAC3B,MAAMC,cAAcZ,KAAKM,SAAS,GAAGC,QAAQ,GAAG,CAAC;IACjD,MAAMM,aAAa,GAAGH,mBAAmBF,YAAY,SAAS,SAAS,YAAY;IACnF,MAAMM,aAAa,CAAC,EAAE,EAAEN,YAAY,SAAS,UAAU,YAAY,CAAC,EAA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B,CAAC,CAAC,EACtBC,UAA+B,CAAC,CAAC;QAEjC,IAAI1C,aAAa;YACfD,IAAIO,OAAO,CAACI,MAAM,CAACC,IAAI,CACrB,CAAC,2CAA2C,EAAET,QAAQ,EAAE,EAAEC,QAAQ,EAAE,EAAEC,SAAS;QAEnF;QAEA,IAAI;YACF,MAAMiE,SAAS,MAAM/B,UACnBvC,KACAC,aACAC,SACAC,SACAC,SACAC,SACAmC,aACAC,aACAC,cACAC;YAGF,IAAI1C,aAAa;gBACfD,IAAIO,OAAO,CAACI,MAAM,CAACC,IAAI,CAAC,CAAC,oDAAoD,CAAC;YAChF;YAEA,OAAO0D;QACT,EAAE,OAAOnB,OAAO;YACd,MAAMO,eAAeP,iBAAiBoB,QAAQpB,MAAMQ,OAAO,GAAG;YAC9D3D,IAAIO,OAAO,CAACI,MAAM,CAACwC,KAAK,CAAC,CAAC,wCAAwC,EAAEO,cAAc;YAElF,OAAO;gBACL7C,SAAS;oBACP;wBACEuC,MAAM;wBACNC,MAAM,CAAC,gCAAgC,EAAEK,cAAc;oBACzD;iBACD;YACH;QACF;IACF;IAEAU,OAAOC,IAAI,CACT,aACA,6EACAvE,YAAYyC,SAAS,CAACiC,UAAU,CAACC,KAAK,EACtC,OAAOC;QACL,OAAOL,KACLK,KAAKvE,OAAO,EACZuE,KAAKtE,OAAO,EACZsE,KAAKrE,OAAO,EACZqE,KAAKlC,WAAW,EAChBkC,KAAKjC,WAAW,EAChBiC,KAAKhC,YAAY,EACjBgC,KAAK/B,OAAO;IAEhB;AAEJ,EAAC"}
@@ -0,0 +1,10 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { PayloadRequest } from 'payload';
3
+ export declare const runJob: (req: PayloadRequest, verboseLogs: boolean, jobSlug: string, input: Record<string, any>, queue?: string, priority?: number, delay?: number) => Promise<{
4
+ content: {
5
+ type: "text";
6
+ text: string;
7
+ }[];
8
+ }>;
9
+ export declare const runJobTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean) => void;
10
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/job/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK7C,eAAO,MAAM,MAAM,QACZ,cAAc,eACN,OAAO,WACX,MAAM,SACR,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAClB,MAAM,aACH,MAAM,UACT,MAAM;;;;;EAiIf,CAAA;AAED,eAAO,MAAM,UAAU,WAAY,SAAS,OAAO,cAAc,eAAe,OAAO,SA4CtF,CAAA"}
@@ -0,0 +1,147 @@
1
+ import { toolSchemas } from '../schemas.js';
2
+ // Reusable function for running jobs
3
+ export const runJob = async (req, verboseLogs, jobSlug, input, queue, priority, delay)=>{
4
+ const payload = req.payload;
5
+ if (verboseLogs) {
6
+ payload.logger.info(`[payload-mcp] Running job: ${jobSlug}`);
7
+ }
8
+ try {
9
+ // Actually run the job using Payload's job queue
10
+ const jobQueueOptions = {
11
+ input,
12
+ task: jobSlug
13
+ };
14
+ if (queue && queue !== 'default') {
15
+ jobQueueOptions.queue = queue;
16
+ if (verboseLogs) {
17
+ payload.logger.info(`[payload-mcp] Using custom queue: ${queue}`);
18
+ }
19
+ }
20
+ if (priority && priority > 0) {
21
+ jobQueueOptions.priority = priority;
22
+ if (verboseLogs) {
23
+ payload.logger.info(`[payload-mcp] Setting job priority: ${priority}`);
24
+ }
25
+ }
26
+ if (delay && delay > 0) {
27
+ jobQueueOptions.waitUntil = new Date(Date.now() + delay);
28
+ if (verboseLogs) {
29
+ payload.logger.info(`[payload-mcp] Setting job delay: ${delay}ms`);
30
+ }
31
+ }
32
+ if (verboseLogs) {
33
+ payload.logger.info(`[payload-mcp] Queuing job with options: ${JSON.stringify(jobQueueOptions)}`);
34
+ }
35
+ const job = await payload.jobs.queue(jobQueueOptions);
36
+ const jobId = job?.id || 'unknown';
37
+ if (verboseLogs) {
38
+ payload.logger.info(`[payload-mcp] Job created successfully: ${jobId}`);
39
+ }
40
+ return {
41
+ content: [
42
+ {
43
+ type: 'text',
44
+ text: `# Job Queued Successfully: ${jobSlug}
45
+
46
+ ## Job Details
47
+ - **Job ID**: ${jobId}
48
+ - **Job Slug**: ${jobSlug}
49
+ - **Queue**: ${queue || 'default'}
50
+ - **Priority**: ${priority || 'default'}
51
+ - **Delay**: ${delay ? `${delay}ms` : 'none'}
52
+ - **Status**: Queued and Running
53
+
54
+ ## Input Data
55
+ \`\`\`json
56
+ ${JSON.stringify(input, null, 2)}
57
+ \`\`\`
58
+
59
+ ## Job Status
60
+ The job has been successfully queued and will be processed according to the queue settings.
61
+
62
+ ## Monitoring the Job
63
+ You can monitor the job status using:
64
+
65
+ \`\`\`typescript
66
+ // Check job status
67
+ const jobStatus = await payload.jobs.status('${jobId}')
68
+ console.log('Job status:', jobStatus)
69
+
70
+ // Wait for completion
71
+ const result = await payload.jobs.wait('${jobId}')
72
+ console.log('Job result:', result)
73
+ \`\`\`
74
+
75
+ ✅ Job successfully queued with ID: ${jobId}`
76
+ }
77
+ ]
78
+ };
79
+ } catch (error) {
80
+ const errorMsg = error.message;
81
+ payload.logger.error(`[payload-mcp] Error running job "${jobSlug}": ${errorMsg}`);
82
+ return {
83
+ content: [
84
+ {
85
+ type: 'text',
86
+ text: `❌ Error running job "${jobSlug}": ${errorMsg}
87
+
88
+ ## Common Issues:
89
+ 1. **Job not found**: The job "${jobSlug}" may not be registered in your Payload configuration
90
+ 2. **Invalid input format**: Ensure the input matches the job's input schema
91
+ 3. **Queue not configured**: The queue "${queue || 'default'}" may not be properly set up
92
+ 4. **Permission issues**: Ensure proper access rights for job execution
93
+ 5. **Job handler error**: The job implementation may have errors
94
+
95
+ ## Input Data Provided:
96
+ \`\`\`json
97
+ ${JSON.stringify(input, null, 2)}
98
+ \`\`\`
99
+
100
+ ## Next Steps:
101
+ 1. **Verify job exists**: Check that the job "${jobSlug}" is properly registered
102
+ 2. **Check input format**: Ensure the input data matches the expected schema
103
+ 3. **Review job configuration**: Verify the job is properly configured in your Payload setup
104
+ 4. **Check permissions**: Ensure you have the necessary permissions to run jobs
105
+ 5. **Review error logs**: Check the server logs for more detailed error information
106
+
107
+ ## Troubleshooting:
108
+ - **Job not found**: Verify the job slug and check your jobs configuration
109
+ - **Schema mismatch**: Ensure input data matches the job's input schema
110
+ - **Queue issues**: Check that the specified queue is properly configured
111
+ - **Permission errors**: Verify user permissions for job execution`
112
+ }
113
+ ]
114
+ };
115
+ }
116
+ };
117
+ export const runJobTool = (server, req, verboseLogs)=>{
118
+ const tool = async (jobSlug, input, queue, priority, delay)=>{
119
+ if (verboseLogs) {
120
+ req.payload.logger.info(`[payload-mcp] Run Job Tool called with: ${jobSlug}`);
121
+ }
122
+ try {
123
+ const result = await runJob(req, verboseLogs, jobSlug, input, queue, priority, delay);
124
+ if (verboseLogs) {
125
+ req.payload.logger.info(`[payload-mcp] Run Job Tool completed successfully`);
126
+ }
127
+ return result;
128
+ } catch (error) {
129
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
130
+ req.payload.logger.error(`[payload-mcp] Error in Run Job Tool: ${errorMessage}`);
131
+ return {
132
+ content: [
133
+ {
134
+ type: 'text',
135
+ text: `❌ **Error in Run Job Tool**: ${errorMessage}`
136
+ }
137
+ ]
138
+ };
139
+ }
140
+ };
141
+ server.tool('runJob', 'Runs a Payload job with specified input data and queue options', toolSchemas.runJob.parameters.shape, async (args)=>{
142
+ const { delay, input, jobSlug, priority, queue } = args;
143
+ return await tool(jobSlug, input, queue, priority, delay);
144
+ });
145
+ };
146
+
147
+ //# sourceMappingURL=run.js.map
@@ -0,0 +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, any>,\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 const tool = async (\n jobSlug: string,\n input: Record<string, any>,\n queue?: string,\n priority?: number,\n delay?: number,\n ) => {\n if (verboseLogs) {\n req.payload.logger.info(`[payload-mcp] Run Job Tool called with: ${jobSlug}`)\n }\n\n try {\n const result = await runJob(req, verboseLogs, jobSlug, input, queue, priority, delay)\n\n if (verboseLogs) {\n req.payload.logger.info(`[payload-mcp] Run 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 Run Job Tool: ${errorMessage}`)\n\n return {\n content: [\n {\n type: 'text' as const,\n text: `❌ **Error in Run Job Tool**: ${errorMessage}`,\n },\n ],\n }\n }\n }\n\n server.tool(\n 'runJob',\n 'Runs a Payload job with specified input data and queue options',\n toolSchemas.runJob.parameters.shape,\n async (args) => {\n const { delay, input, jobSlug, priority, queue } = args\n return await tool(jobSlug, input, queue, priority, delay)\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","tool","result","errorMessage","Error","parameters","shape","args"],"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,IA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AQ;;;;;;;;;;kEAUU,CAAC;gBAC3D;aACD;QACH;IACF;AACF,EAAC;AAED,OAAO,MAAMyB,aAAa,CAACC,QAAmB5B,KAAqBC;IACjE,MAAM4B,OAAO,OACX3B,SACAC,OACAC,OACAC,UACAC;QAEA,IAAIL,aAAa;YACfD,IAAIO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,wCAAwC,EAAEP,SAAS;QAC9E;QAEA,IAAI;YACF,MAAM4B,SAAS,MAAM/B,OAAOC,KAAKC,aAAaC,SAASC,OAAOC,OAAOC,UAAUC;YAE/E,IAAIL,aAAa;gBACfD,IAAIO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,iDAAiD,CAAC;YAC7E;YAEA,OAAOqB;QACT,EAAE,OAAON,OAAO;YACd,MAAMO,eAAeP,iBAAiBQ,QAAQR,MAAME,OAAO,GAAG;YAC9D1B,IAAIO,OAAO,CAACC,MAAM,CAACgB,KAAK,CAAC,CAAC,qCAAqC,EAAEO,cAAc;YAE/E,OAAO;gBACLV,SAAS;oBACP;wBACEC,MAAM;wBACNC,MAAM,CAAC,6BAA6B,EAAEQ,cAAc;oBACtD;iBACD;YACH;QACF;IACF;IAEAH,OAAOC,IAAI,CACT,UACA,kEACA/B,YAAYC,MAAM,CAACkC,UAAU,CAACC,KAAK,EACnC,OAAOC;QACL,MAAM,EAAE7B,KAAK,EAAEH,KAAK,EAAED,OAAO,EAAEG,QAAQ,EAAED,KAAK,EAAE,GAAG+B;QACnD,OAAO,MAAMN,KAAK3B,SAASC,OAAOC,OAAOC,UAAUC;IACrD;AAEJ,EAAC"}
@@ -0,0 +1,11 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { PayloadRequest } from 'payload';
3
+ import type { JobConfigUpdate, SchemaField, TaskSequenceItem } from '../../../types.js';
4
+ export declare const updateJob: (req: PayloadRequest, verboseLogs: boolean, jobsDir: string, jobSlug: string, updateType: string, inputSchema?: SchemaField[], outputSchema?: SchemaField[], taskSequence?: TaskSequenceItem[], configUpdate?: JobConfigUpdate, handlerCode?: string) => Promise<{
5
+ content: {
6
+ type: "text";
7
+ text: string;
8
+ }[];
9
+ }>;
10
+ export declare const updateJobTool: (server: McpServer, req: PayloadRequest, verboseLogs: boolean, jobsDir: string) => void;
11
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +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;AAMvF,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;AAuCD,eAAO,MAAM,aAAa,WAChB,SAAS,OACZ,cAAc,eACN,OAAO,WACX,MAAM,SA4EhB,CAAA"}