Skip to main content
Glama

create_draft

Create a Substack draft from Markdown. Supply title and content, optionally subtitle and audience (everyone, paid, founding, or free). Returns the post ID and edit URL for further editing.

Instructions

Create a new Substack draft post from Markdown.

Args: title: Post title (max 280 chars). content_markdown: Body in Markdown. Supports headings, bold/italic, links, bullet lists, blockquotes, code blocks, and images (alt - local paths are auto-uploaded to Substack CDN). subtitle: Optional subtitle (max 280 chars). audience: Who can read it: 'everyone' (default), 'only_paid', 'founding', or 'only_free'.

Returns: Summary including post_id, title, edit_url.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
content_markdownYes
subtitleNo
audienceNoeveryone

Implementation Reference

  • MCP tool registration via @mcp.tool() decorator on create_draft function
    @mcp.tool()
    def create_draft(
  • MCP tool handler: validates inputs (title length, content non-empty), then delegates to client.create_draft()
    def create_draft(
        title: str,
        content_markdown: str,
        subtitle: str = "",
        audience: str = "everyone",
    ) -> dict:
        """Create a new Substack draft post from Markdown.
    
        Args:
            title: Post title (max 280 chars).
            content_markdown: Body in Markdown. Supports headings, bold/italic, links,
                bullet lists, blockquotes, code blocks, and images (![alt](url) - local
                paths are auto-uploaded to Substack CDN).
            subtitle: Optional subtitle (max 280 chars).
            audience: Who can read it: 'everyone' (default), 'only_paid', 'founding',
                or 'only_free'.
    
        Returns:
            Summary including post_id, title, edit_url.
        """
        if not title or not isinstance(title, str):
            raise ValueError("title must be a non-empty string")
        if len(title) > 280:
            raise ValueError("title must be 280 characters or less")
        if subtitle and len(subtitle) > 280:
            raise ValueError("subtitle must be 280 characters or less")
        if not content_markdown:
            raise ValueError("content_markdown must be non-empty")
        return _get_client().create_draft(
            title=title,
            content_markdown=content_markdown,
            subtitle=subtitle,
            audience=audience,
        )
  • Client implementation: constructs a Post object from Markdown, normalizes ProseMirror body, and posts the draft via the Substack API
    def create_draft(
        self,
        title: str,
        content_markdown: str,
        subtitle: str = "",
        audience: str = "everyone",
    ) -> dict:
        if audience not in VALID_AUDIENCES:
            raise ValueError(
                f"audience must be one of {sorted(VALID_AUDIENCES)}, got {audience!r}"
            )
        post = Post(
            title=title,
            subtitle=subtitle,
            user_id=self.user_id,
            audience=audience,
        )
        post.from_markdown(content_markdown, api=self._api)
        draft = post.get_draft()
        draft["draft_body"] = _normalize_prosemirror(draft["draft_body"])
        result = self._api.post_draft(draft)
        return self._summarize_draft(result)
  • VALID_AUDIENCES constant used for audience validation in create_draft
    VALID_AUDIENCES = {"everyone", "only_paid", "founding", "only_free"}
  • _normalize_prosemirror helper (and _fix_node) used to fix python-substack's ProseMirror JSON bugs before posting the draft
    def _normalize_prosemirror(body_json: str) -> str:
        """Fix issues in python-substack's generated ProseMirror JSON.
    
        Bug 1: bullet/ordered list items emit text nodes shaped like
            {"content": "...", "marks": [...]}
        when ProseMirror requires
            {"type": "text", "text": "...", "marks": [...]}
        This walks the tree and rewrites any such nodes in place.
        """
        body = json.loads(body_json)
        _fix_node(body)
        return json.dumps(body)
    
    
    def _fix_node(node: Any) -> None:
        if isinstance(node, list):
            for item in node:
                _fix_node(item)
            return
        if not isinstance(node, dict):
            return
    
        # Detect malformed text nodes: have "content" as string, no "type"
        if "type" not in node and isinstance(node.get("content"), str):
            text_value = node["content"]
            marks = node.get("marks")
            node.clear()
            node["type"] = "text"
            node["text"] = text_value
            if marks:
                node["marks"] = marks
            return
    
        # Recurse into children
        children = node.get("content")
        if children is not None:
            _fix_node(children)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses important behavior: auto-uploading local image paths to Substack CDN. However, it omits permissions, reversibility, or rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is structured with Args and Returns, and each sentence provides value. It is somewhat lengthy but not verbose; front-loaded purpose and parameter details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description covers purpose, parameters with constraints, and return summary. It lacks some behavioral details like authentication needs, but is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so description must compensate. It adds max char limits for 'title' and 'subtitle', allowed values for 'audience', and explains Markdown support and image handling for 'content_markdown'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'Create a new Substack draft post from Markdown,' making the verb and resource clear. It differentiates from sibling tools like 'delete_draft' and 'publish_draft' by focusing on creation from Markdown.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains what the tool does but does not explicitly say when to use it versus alternatives like 'update_draft' or 'schedule_draft.' It provides no exclusions or context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/nanameru/substack-mcp'

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