edit-message
Modify message content or topic in Zulip workspaces. Input the message ID and updated content or topic to edit existing messages directly through the MCP server API.
Instructions
Edit an existing message's content or topic.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | New message content with Markdown formatting | |
| message_id | Yes | Unique ID of the message to edit | |
| topic | No | New topic name (for stream messages only) |
Implementation Reference
- src/server.ts:501-512 (handler)MCP tool handler: destructures params, filters undefined fields, calls ZulipClient.updateMessage, handles errors and formats MCP response.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/server.ts:497-513 (registration)Tool registration with MCP server: registers 'edit-message' tool with description, input schema, and handler function.server.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 input schema for edit-message tool defining message_id (required), content and topic (optional).export 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: filters params and makes PATCH request to Zulip API /messages/{id} endpoint.async 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); }