edit-draft
Edit an existing message draft on the Zulip MCP Server by updating its type, recipients, topic, content, and timestamp using the draft ID.
Instructions
Update an existing message draft. For user IDs in the 'to' field, use the users-directory resource (zulip://users) or get-users tool to discover available users and their IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Draft content | |
| draft_id | Yes | Unique draft ID to edit | |
| timestamp | No | Updated timestamp | |
| to | Yes | Array of user IDs or channel ID | |
| topic | Yes | Topic for the draft | |
| type | Yes | Draft message type |
Implementation Reference
- src/server.ts:736-754 (handler)MCP tool registration and handler implementation for the 'edit-draft' tool. This function processes tool calls, invokes the ZulipClient.editDraft method, and formats MCP-compliant responses.server.tool( "edit-draft", "Update an existing message draft. For user IDs in the 'to' field, use the users-directory resource (zulip://users) or get-users tool to discover available users and their IDs.", EditDraftSchema.shape, async ({ draft_id, type, to, topic, content, timestamp }) => { try { await zulipClient.editDraft(draft_id, { type, to, topic, content, timestamp }); return createSuccessResponse(`Draft ${draft_id} updated successfully!`); } catch (error) { return createErrorResponse(`Error editing draft: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
- src/types.ts:229-236 (schema)Zod input schema definition for the 'edit-draft' tool, used for validation in the MCP server.tool registration.export const EditDraftSchema = z.object({ draft_id: z.number().describe("Unique draft ID to edit"), type: z.enum(["stream", "direct"]).describe("Draft message type"), to: z.array(z.number()).describe("Array of user IDs or channel ID"), topic: z.string().describe("Topic for the draft"), content: z.string().describe("Draft content"), timestamp: z.number().optional().describe("Updated timestamp") });
- src/zulip/client.ts:321-329 (helper)ZulipClient helper method that executes the actual HTTP PATCH request to the Zulip API endpoint `/drafts/{draftId}` to update a draft.async editDraft(draftId: number, params: { type: 'stream' | 'direct'; to: number[]; topic: string; content: string; timestamp?: number; }): Promise<void> { await this.client.patch(`/drafts/${draftId}`, params); }