get_draft
Retrieve a draft post's full content, including title, body, and metadata, using its unique ID from the Substack platform.
Instructions
Get the full content of a draft post by ID. Returns title, body, metadata.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draft_id | Yes | The draft ID to retrieve |
Implementation Reference
- src/server.ts:110-140 (handler)The 'get_draft' tool registration with its handler function. Uses Zod schema to validate draft_id parameter, calls client.getDraft(), and returns the draft data (id, title, subtitle, body, audience, word_count, created_at, updated_at) as JSON.
server.tool( "get_draft", "Get the full content of a draft post by ID. Returns title, body, metadata.", { draft_id: z.number().describe("The draft ID to retrieve"), }, async ({ draft_id }) => { const draft = await client.getDraft(draft_id); return { content: [ { type: "text", text: JSON.stringify( { id: draft.id, title: draft.draft_title, subtitle: draft.draft_subtitle, body: draft.draft_body, audience: draft.audience, word_count: draft.word_count, created_at: draft.draft_created_at, updated_at: draft.draft_updated_at, }, null, 2, ), }, ], }; }, ); - src/api/client.ts:111-115 (helper)The getDraft method in SubstackClient that makes the actual HTTP GET request to the Substack API endpoint /api/v1/drafts/{id} to fetch a single draft by ID.
async getDraft(id: number): Promise<SubstackDraft> { return this.request<SubstackDraft>( `${this.publicationUrl}/api/v1/drafts/${id}`, ); } - src/api/types.ts:38-51 (schema)The SubstackDraft interface defining the structure of draft data returned by the get_draft tool, including id, draft_title, draft_subtitle, draft_body, audience, word_count, and timestamps.
export interface SubstackDraft { id: number; draft_title: string; draft_subtitle: string | null; draft_body: string | null; draft_bylines: Array<{ id: number; is_guest: boolean }>; audience: string; type: string; word_count: number; cover_image: string | null; section_id: number | null; draft_created_at: string; draft_updated_at: string; }