edit-scheduled-message
Modify scheduled messages in Zulip before delivery by updating recipients, content, topic, or timing.
Instructions
Modify a scheduled message before it's sent. For direct messages, use comma-separated email addresses or get user info from the users-directory resource (zulip://users).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scheduled_message_id | Yes | Unique scheduled message ID to edit | |
| type | No | Message type | |
| to | No | Recipients (channel name or comma-separated emails) | |
| content | No | New message content | |
| topic | No | New topic for stream messages | |
| scheduled_delivery_timestamp | No | New delivery timestamp |
Implementation Reference
- src/server.ts:668-685 (handler)The inline async handler function for the 'edit-scheduled-message' tool. It destructures input params, filters undefined values using filterUndefined, validates at least one param, calls zulipClient.editScheduledMessage, and returns formatted success/error responses.async ({ scheduled_message_id, type, to, content, topic, scheduled_delivery_timestamp }) => { try { const updateParams = filterUndefined({ type, to, content, topic, scheduled_delivery_timestamp }); if (Object.keys(updateParams).length === 0) { return createErrorResponse('At least one parameter must be provided to update scheduled message'); } await zulipClient.editScheduledMessage(scheduled_message_id, updateParams); return createSuccessResponse(`Scheduled message ${scheduled_message_id} updated successfully!`); } catch (error) { return createErrorResponse(`Error editing scheduled message: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/types.ts:220-227 (schema)Zod schema defining and validating the input parameters for the edit-scheduled-message tool, including scheduled_message_id (required) and optional fields for type, to, content, topic, scheduled_delivery_timestamp.export const EditScheduledMessageSchema = z.object({ scheduled_message_id: z.number().describe("Unique scheduled message ID to edit"), type: z.enum(["stream", "direct"]).optional().describe("Message type"), to: z.string().optional().describe("Recipients (channel name or comma-separated emails)"), content: z.string().optional().describe("New message content"), topic: z.string().optional().describe("New topic for stream messages"), scheduled_delivery_timestamp: z.number().optional().describe("New delivery timestamp") });
- src/server.ts:664-686 (registration)Registration of the 'edit-scheduled-message' MCP tool via server.tool(), providing name, description, schema, and handler function.server.tool( "edit-scheduled-message", "Modify a scheduled message before it's sent. For direct messages, use comma-separated email addresses or get user info from the users-directory resource (zulip://users).", EditScheduledMessageSchema.shape, async ({ scheduled_message_id, type, to, content, topic, scheduled_delivery_timestamp }) => { try { const updateParams = filterUndefined({ type, to, content, topic, scheduled_delivery_timestamp }); if (Object.keys(updateParams).length === 0) { return createErrorResponse('At least one parameter must be provided to update scheduled message'); } await zulipClient.editScheduledMessage(scheduled_message_id, updateParams); return createSuccessResponse(`Scheduled message ${scheduled_message_id} updated successfully!`); } catch (error) { return createErrorResponse(`Error editing scheduled message: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
- src/zulip/client.ts:296-308 (helper)ZulipClient helper method that implements the core logic for editing a scheduled message by filtering undefined params and making a PATCH request to Zulip's /scheduled_messages/{id} API endpoint.async editScheduledMessage(scheduledMessageId: number, params: { type?: 'stream' | 'direct'; to?: string; content?: string; topic?: string; scheduled_delivery_timestamp?: number; }): Promise<void> { // Filter out undefined values const filteredParams = Object.fromEntries( Object.entries(params).filter(([, value]) => value !== undefined) ); await this.client.patch(`/scheduled_messages/${scheduledMessageId}`, filteredParams); }