delete_draft
Delete a saved draft permanently using its ID. This action is irreversible and removes the draft from Pipepost. Returns confirmation with deletion status and the draft ID.
Instructions
Permanently delete a saved draft by id. FREE. Operation is irreversible. Returns: { deleted: true, id }. Common errors: draft id not found (VALIDATION_ERROR).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Draft ID to delete |
Implementation Reference
- src/tools/draft-tools.ts:65-70 (handler)Handler function for the delete_draft tool. Validates required 'id' field, then delegates to the store's deleteDraft function.
export async function handleDeleteDraft(input: z.infer<typeof deleteDraftSchema>) { const idErr = validateRequired(input.id, "id"); if (idErr) return makeError("VALIDATION_ERROR", idErr); return deleteDraft(input.id); } - src/drafts/store.ts:116-126 (handler)Core deletion logic: ensures directory exists, checks if draft file exists, deletes the JSON file from disk, returns success/error.
export function deleteDraft(id: string) { ensureDir(); const filePath = path.join(getDraftsDir(), `${id}.json`); if (!fs.existsSync(filePath)) { return makeError("NOT_FOUND", `Draft "${id}" not found`); } fs.unlinkSync(filePath); return makeSuccess({ id, deleted: true }); } - src/tools/draft-tools.ts:59-62 (schema)Zod schema for delete_draft input validation. Expects a single required string field 'id'.
/** Zod schema for the `delete_draft` tool input. */ export const deleteDraftSchema = z.object({ id: z.string().describe("Draft ID to delete"), }); - src/index.ts:221-225 (registration)Registration of the 'delete_draft' tool on the MCP server with description, schema, and handler invocation.
server.tool("delete_draft", "Permanently delete a saved draft by id. FREE. Operation is irreversible. Returns: { deleted: true, id }. Common errors: draft id not found (VALIDATION_ERROR).", deleteDraftSchema.shape, async (input) => { const parsed = deleteDraftSchema.parse(input); const result = await handleDeleteDraft(parsed); return { content: [{ type: "text", text: formatToolResponse("delete_draft", result, formatDeleteDraft) }] }; }); - src/drafts/format.ts:108-118 (helper)Formats the deletion result for display, showing a success header and the deleted draft ID.
export function formatDeleteDraft(data: unknown): string { const d = data as { id: string; deleted: boolean }; return [ successHeader("Draft Deleted"), "", field("ID", `\`${d.id}\``), "", note("This action cannot be undone."), ].join("\n"); }