Skip to main content
Glama

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
NameRequiredDescriptionDefault
draft_idYesThe draft ID to retrieve

Implementation Reference

  • 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,
              ),
            },
          ],
        };
      },
    );
  • 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}`,
      );
    }
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/conorbronsdon/substack-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server