edit-draft
Update an existing message draft by specifying its ID and providing new type, recipients, topic, and content.
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
| Name | Required | Description | Default |
|---|---|---|---|
| draft_id | Yes | Unique draft ID to edit | |
| type | Yes | Draft message type | |
| to | Yes | Array of user IDs or channel ID | |
| topic | Yes | Topic for the draft | |
| content | Yes | Draft content | |
| timestamp | No | Updated timestamp |
Implementation Reference
- src/server.ts:740-753 (handler)The async handler function for the 'edit-draft' tool. It accepts draft_id, type, to, topic, content, timestamp, calls zulipClient.editDraft, and returns a success/error response.
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 schema (EditDraftSchema) defining the input shape for 'edit-draft': draft_id (number), type (enum 'stream'|'direct'), to (array of numbers), topic (string), content (string), timestamp (optional number).
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/server.ts:736-754 (registration)Server registration of the 'edit-draft' tool via server.tool() with name, description, schema, and handler.
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/zulip/client.ts:321-329 (helper)ZulipClient.editDraft helper method that sends a PATCH request to /drafts/{draftId} with the draft parameters.
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); }