schedule_draft
Schedule an existing email draft for automated sending at a specified time using the Buttondown newsletter service.
Instructions
Schedule an existing email draft to be sent at a specific time. This tool requires explicit user confirmation before proceeding as it will modify the draft's status and schedule.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draftId | Yes | The ID of the email draft to schedule | |
| scheduledTime | Yes | When to send the email (ISO 8601 datetime format) | |
| confirmed | Yes | Must be true to confirm the scheduling |
Implementation Reference
- src/mcp/index.ts:192-239 (registration)Registration of the MCP 'schedule_draft' tool using this.server.tool(). Includes tool description, Zod input schema (draftId: string, scheduledTime: string, confirmed: boolean), and inline handler function that checks confirmation, ensures API key, calls api.scheduleDraft(draftId, scheduledTime), and returns JSON response.this.server.tool( "schedule_draft", "Schedule an existing email draft to be sent at a specific time. This tool requires explicit user confirmation before proceeding as it will modify the draft's status and schedule.", { draftId: z.string().describe("The ID of the email draft to schedule"), scheduledTime: z .string() .describe("When to send the email (ISO 8601 datetime format)"), confirmed: z .boolean() .describe("Must be true to confirm the scheduling"), }, async ({ draftId, scheduledTime, confirmed }) => { if (!confirmed) { return { content: [ { type: "text", text: JSON.stringify( { error: "User confirmation required", message: "Please ask the user if they want to schedule this draft and set confirmed=true if they agree", preview: { draftId, scheduledTime, localTime: new Date(scheduledTime).toLocaleString(), }, }, null, 2 ), }, ], }; } await this.ensureApiKey(); const response = await this.api.scheduleDraft(draftId, scheduledTime); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } );
- src/api/client.ts:91-103 (handler)Core handler logic for scheduling a draft via Buttondown API: PATCH /emails/{draftId} with body {scheduled_for, publish_date: scheduledTime, status: 'scheduled'}.async scheduleDraft( draftId: string, scheduledTime: string ): Promise<ButtondownEmail> { return this.request<ButtondownEmail>(`/emails/${draftId}`, { method: "PATCH", body: JSON.stringify({ scheduled_for: scheduledTime, publish_date: scheduledTime, status: "scheduled", }), }); }
- src/api/client.ts:19-22 (schema)TypeScript interface IButtondownAPI defining scheduleDraft(draftId: string, scheduledTime: string): Promise<ButtondownEmail>.scheduleDraft( draftId: string, scheduledTime: string ): Promise<ButtondownEmail>;