update_document_lifecycle
Update and manage document lifecycle states (e.g., draft, review, approved) in CastPlan MCP. Includes optional review scheduling and comments for improved workflow tracking.
Instructions
Update the lifecycle state of a document with optional review scheduling
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documentId | Yes | UUID of the document | |
| newState | Yes | New lifecycle state | |
| reviewComment | No | Optional review comment | |
| scheduledReview | No | ISO datetime for scheduled review |
Implementation Reference
- src/tools/enhanced/index.ts:408-435 (handler)The handler function that implements the core logic for updating a document's lifecycle state, including state transition and optional review scheduling via DocumentLifecycleService.tools.set('update_document_lifecycle', async (args: any) => { try { logger.info(`Updating document ${args.documentId} to state: ${args.newState}`); // Update document state await lifecycleService.updateDocumentState(args.documentId, args.newState); // Schedule review if provided if (args.scheduledReview) { await lifecycleService.scheduleReview(args.documentId, args.scheduledReview); } // Get updated document for confirmation const document = await lifecycleService.getDocumentById(args.documentId); return { success: true, document: document?.title || 'Unknown', newState: args.newState, reviewComment: args.reviewComment, scheduledReview: args.scheduledReview ? localizationService.formatDateTime(new Date(args.scheduledReview)) : null, updatedAt: localizationService.getCurrentDateTimeString() }; } catch (error) { logger.error('Failed to update document lifecycle:', error); throw error; } });
- src/types/enhanced.types.ts:124-129 (schema)Zod schema defining the input validation for the update_document_lifecycle tool parameters.export const UpdateDocumentLifecycleSchema = z.object({ documentId: z.string().uuid(), newState: z.nativeEnum(DocumentLifecycleState), reviewComment: z.string().optional(), scheduledReview: z.string().datetime().optional(), });
- src/tools/enhanced/index.ts:161-187 (registration)Tool registration definition including name, description, and input schema within the registerEnhancedTools function.{ name: 'update_document_lifecycle', description: 'Update the lifecycle state of a document with optional review scheduling', inputSchema: { type: 'object', properties: { documentId: { type: 'string', description: 'UUID of the document' }, newState: { type: 'string', enum: ['draft', 'review', 'approved', 'published', 'outdated', 'archived'], description: 'New lifecycle state' }, reviewComment: { type: 'string', description: 'Optional review comment' }, scheduledReview: { type: 'string', description: 'ISO datetime for scheduled review' } }, required: ['documentId', 'newState'] } },