edit-message
Modify existing message content or topic in Zulip workspaces by providing the message ID and updated text or subject.
Instructions
Edit an existing message's content or topic.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_id | Yes | Unique ID of the message to edit | |
| content | No | New message content with Markdown formatting | |
| topic | No | New topic name (for stream messages only) |
Implementation Reference
- src/server.ts:497-513 (registration)MCP server.tool registration for 'edit-message' tool, including inline handler function that validates parameters and delegates to ZulipClientserver.tool( "edit-message", "Edit an existing message's content or topic.", EditMessageSchema.shape, async ({ message_id, content, topic }) => { try { const updateParams = filterUndefined({ content, topic }); if (Object.keys(updateParams).length === 0) { return createErrorResponse('At least one of content or topic must be provided for message update'); } await zulipClient.updateMessage(message_id, updateParams); return createSuccessResponse(`Message ${message_id} updated successfully!`); } catch (error) { return createErrorResponse(`Error updating message: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
- src/types.ts:134-138 (schema)Zod schema defining the input parameters (message_id, optional content, optional topic) for the edit-message toolexport const EditMessageSchema = z.object({ message_id: z.number().describe("Unique ID of the message to edit"), content: z.string().optional().describe("New message content with Markdown formatting"), topic: z.string().optional().describe("New topic name (for stream messages only)") });
- src/zulip/client.ts:184-193 (helper)ZulipClient helper method that performs the actual HTTP PATCH request to Zulip's /messages/{id} endpoint to update message content or topicasync updateMessage(messageId: number, params: { content?: string; topic?: string; }): Promise<void> { // Filter out undefined values const filteredParams = Object.fromEntries( Object.entries(params).filter(([, value]) => value !== undefined) ); await this.client.patch(`/messages/${messageId}`, filteredParams); }
- src/server.ts:104-108 (helper)Utility helper function to remove undefined properties from parameter objects before API calls, used in edit-message handlerfunction filterUndefined<T extends Record<string, any>>(obj: T): Partial<T> { return Object.fromEntries( Object.entries(obj).filter(([_, value]) => value !== undefined) ) as Partial<T>; }