substack-mcp
Provides tools for interacting with a Substack publication via its undocumented API: listing published posts and drafts, fetching and previewing drafts, retrieving subscriber counts and sections, and, when write mode is enabled, creating, updating, deleting, publishing, and scheduling drafts, plus uploading images.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
substack-mcp
MCP server for Substack publishing. Read and write to your Substack publication via the Model Context Protocol, using Substack's undocumented API.
Safety model
The server has a two-tier design that controls which tools are available:
Read-only (default) -- Six tools for listing posts, fetching drafts, checking subscriber counts, and previewing content. No state changes are possible.
Write mode (opt-in via
SUBSTACK_ENABLE_WRITE=true) -- Six additional tools for creating, updating, deleting, publishing, scheduling drafts, and uploading images.
Safety works through omission, not permission: write tools are never registered with the MCP server unless explicitly enabled. In read-only mode, the tools simply do not exist in the tool list -- there is nothing for the LLM to call.
Destructive operations (delete_draft, publish_draft) have an additional confirmation gate. The first call returns a preview of the affected draft. The caller must repeat the call with an explicit confirmation flag (confirm_delete=true or confirm_publish=true) to execute the action.
Related MCP server: Substack MCP
Quick start
Clone and build:
git clone https://github.com/mark-liu/substack-mcp.git
cd substack-mcp
npm install && npm run buildAdd to Claude Code:
claude mcp add substack-mcp -s user -e SUBSTACK_PUBLICATION_URL=https://yourpub.substack.com -e SUBSTACK_SESSION_TOKEN=your-session-token -e SUBSTACK_ENABLE_WRITE=true -- node /path/to/substack-mcp/dist/index.jsConfiguration
Variable | Required | Default | Description |
| Yes | -- | Full URL of your publication (e.g. |
| Yes | -- | Session cookie value (see Auth setup) |
| No |
| Set to |
| No |
| Max API requests per second |
| No |
| Retry count for 429/5xx errors (exponential backoff) |
Auth setup
Substack does not provide a public API or OAuth flow. Authentication uses a session cookie extracted from your browser.
Extracting the session token
Log in to substack.com in Chrome
Open DevTools (
F12orCmd+Opt+I)Navigate to Application > Cookies >
https://substack.comFind
substack.sid(orconnect.sidon older sessions)Copy the cookie Value -- this is your session token
Set it as
SUBSTACK_SESSION_TOKEN
Token storage
When the server starts, it can persist the session token to ~/.config/substack-mcp/auth.json, encrypted with AES-256-GCM. A randomly generated encryption key is stored alongside at ~/.config/substack-mcp/.key. Both files are created with mode 0600.
On subsequent launches, the server checks for a stored token before falling back to the environment variable.
Token lifetime
Session tokens typically last weeks but will expire if you log out of Substack in your browser, clear cookies, or if Substack rotates sessions server-side.
Tool reference
Read tools (always available)
Tool | Description | Parameters |
| List published posts, newest first |
|
| List draft posts for the authenticated user |
|
| Fetch a single draft by ID, including full body |
|
| Current subscriber count for the publication | -- |
| List all publication sections/categories | -- |
| Human-readable preview of a draft (title, subtitle, truncated body) |
|
Write tools (requires SUBSTACK_ENABLE_WRITE=true)
Tool | Description | Parameters |
| Create a new draft from markdown content |
|
| Update draft metadata |
|
| Delete a draft (confirmation gate) |
|
| Publish a draft immediately (confirmation gate) |
|
| Schedule a draft for future publication |
|
| Upload an image to Substack's CDN |
|
Image upload accepts .jpg, .jpeg, .png, .gif, and .webp files up to 10 MB. Local files are converted to base64 data URIs; URLs are passed to Substack for server-side fetch.
Claude Code integration
claude mcp add substack -s user -- npx -y @mark-liu/substack-mcpOr add directly to ~/.claude.json:
{
"mcpServers": {
"substack": {
"command": "npx",
"args": ["-y", "@mark-liu/substack-mcp"],
"env": {
"SUBSTACK_PUBLICATION_URL": "https://yourpub.substack.com",
"SUBSTACK_SESSION_TOKEN": "your-session-token",
"SUBSTACK_ENABLE_WRITE": "true"
}
}
}
}Architecture
src/
index.ts -- Entrypoint: env var parsing, config, stdio transport
server.ts -- MCP tool registration (12 tools, conditional on config)
types.ts -- TypeScript interfaces (drafts, posts, ProseMirror nodes)
errors.ts -- Error hierarchy: SubstackError > AuthError, APIError, RateLimitError
client/
http.ts -- Base HTTP client: cookie auth, token-bucket rate limiter, retry with backoff
auth.ts -- Session token encrypt/decrypt/validate (AES-256-GCM)
reader.ts -- Read-only API operations with lazy-fetch caching
writer.ts -- Write API operations with input validation
converters/
markdown.ts -- Markdown -> ProseMirror via unified/remark AST walk
prosemirror.ts -- ProseMirror node type factories (Substack's editor schema)Substack stores post bodies as ProseMirror JSON documents. The converters/ module translates between Markdown (what the LLM writes) and ProseMirror (what Substack's API expects). Supported node types: paragraphs, headings (h1-h6), code blocks, blockquotes, bullet lists, ordered lists, images (captionedImage wrapper), horizontal rules, and paywall dividers (<!-- PAYWALL -->). Inline marks: bold, italic, strikethrough, code, and links.
The HTTP client applies rate limiting via a token-bucket algorithm (default 1 req/s) and retries transient failures (429, 5xx) with exponential backoff up to a configurable retry count.
Reader methods for subscriber count, sections, tags, and users use lazy-fetch caching -- results are cached in memory after the first call and returned on subsequent requests without hitting the API. Pass force_refresh: true to bypass the cache.
Development
git clone https://github.com/mark-liu/substack-mcp.git
cd substack-mcp
npm install
npm run dev # Run with tsx (hot reload)
npm run build # Compile TypeScript
npm run typecheck # Type checking only
npm test # Run vitestRequires Node.js >= 20. CI runs typecheck, lint, and test against Node 20 and 22.
Prior art
This project builds on research and patterns from five existing Substack integration projects:
python-substack by ma2za -- API endpoint mapping and ProseMirror document format reference. The definitive source for understanding Substack's undocumented API surface.
substack-mcp-plus by ty13r -- Confirmation gate pattern for destructive operations and encrypted token storage at
~/.config/.substack-mcp by marcomoauro -- ProseMirror node type registry. Informed the
converters/prosemirror.tsfactory design.substack-mcp by conorbronsdon -- Safety-through-omission pattern: conditionally registering write tools rather than gating at call time.
substack_api by NHagar -- Lazy-fetch caching pattern and publication ID resolution strategy.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Draft & schedule Substack Notes, manage articles, and read stats via WriteStack.
Substack MCP server for ChatGPT, Claude and any AI agent: create post, schedule post, publish Note, reply to Notes, send direct message, moderate comments, list subscribers and get post stats in your own Substack account. Cotlet works in the account through your Cloud Browser, a real Chrome where you sign in to Substack yourself; Cotlet does not store your password and you need no Substack API key. About the official Substack API: Substack has only a limited API (checked 11 Oct 2026). Its Developer API looks up public creator profiles after approval, and there is no public API to write posts or Notes, manage subscribers or send email. Setup and FAQ: https://cotlet.dev/integrations/substack-api-mcp-server
Draft, schedule, and analyze content for Substack, Medium, LinkedIn, X, Bluesky, and Threads.
Read Buttondown subscribers, emails, analytics and automations; add subscribers; write email drafts.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables LLM clients to interact with Substack's API for automations like creating posts and managing drafts.27177 npm95MIT
- AlicenseNot gradedqualityDmaintenanceEnables managing Substack publications: publish Notes and posts, manage drafts, pull analytics, and read any publication's public feed via MCP.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to search and read Substack newsletter feeds, stage and publish drafts, interact with community comments, and track subscriber and post analytics through local tools and a web dashboard.1MIT
- FlicenseNot gradedqualityBmaintenanceEnables managing Substack publications through 27 tools for drafting, publishing, subscriber analytics, comments, Notes, and reader feed via Streamable HTTP.1-