create_draft
Initiate email draft creation in Buttondown by specifying content and optional title. Requires user confirmation to proceed, ensuring controlled and deliberate email drafting.
Instructions
Create a new email draft in Buttondown with the specified content and optional title. This tool requires explicit user confirmation before proceeding as it will create a new draft in your Buttondown account.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| confirmed | Yes | Must be true to confirm the draft creation | |
| content | Yes | The main content/body of the email draft | |
| title | No | Optional title/subject for the email draft |
Implementation Reference
- src/mcp/index.ts:132-165 (handler)Executes the create_draft tool logic: validates confirmation, ensures API key, creates draft via API client, returns JSON response.async ({ content, title, confirmed }) => { if (!confirmed) { return { content: [ { type: "text", text: JSON.stringify( { error: "User confirmation required", message: "Please ask the user if they want to create this draft and set confirmed=true if they agree", preview: { title: title || "Untitled", content_length: content.length, }, }, null, 2 ), }, ], }; } await this.ensureApiKey(); const response = await this.api.createDraft(content, title); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; }
- src/mcp/index.ts:120-131 (schema)Input schema definition using Zod for the create_draft tool parameters.{ content: z .string() .describe("The main content/body of the email draft"), title: z .string() .optional() .describe("Optional title/subject for the email draft"), confirmed: z .boolean() .describe("Must be true to confirm the draft creation"), },
- src/mcp/index.ts:117-166 (registration)Registers the 'create_draft' tool on the MCP server, including description, schema, and handler function.this.server.tool( "create_draft", "Create a new email draft in Buttondown with the specified content and optional title. This tool requires explicit user confirmation before proceeding as it will create a new draft in your Buttondown account.", { content: z .string() .describe("The main content/body of the email draft"), title: z .string() .optional() .describe("Optional title/subject for the email draft"), confirmed: z .boolean() .describe("Must be true to confirm the draft creation"), }, async ({ content, title, confirmed }) => { if (!confirmed) { return { content: [ { type: "text", text: JSON.stringify( { error: "User confirmation required", message: "Please ask the user if they want to create this draft and set confirmed=true if they agree", preview: { title: title || "Untitled", content_length: content.length, }, }, null, 2 ), }, ], }; } await this.ensureApiKey(); const response = await this.api.createDraft(content, title); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } );
- src/api/client.ts:76-85 (helper)API client method that performs the HTTP POST request to Buttondown's /emails endpoint to create a new draft.async createDraft(content: string, title?: string): Promise<ButtondownEmail> { return this.request<ButtondownEmail>("/emails", { method: "POST", body: JSON.stringify({ body: content, subject: title || "Untitled Draft", status: "draft", }), }); }
- src/api/client.ts:17-17 (schema)TypeScript interface definition for the createDraft method in the ButtondownAPI.createDraft(content: string, title?: string): Promise<ButtondownEmail>;