Substack API and MCP server: connect Substack to ChatGPT and Claude
Yes, ChatGPT, Claude and other AI agents can work in your Substack account. That includes Cursor, Codex, OpenClaw and any MCP client, plus automations in n8n, Make and Zapier. Ask in plain words, and the AI drafts posts from your notes, schedules them, posts Notes, answers comments and reports your subscriber and post stats. It shows you what it will do first and sends nothing to other people until you say so.
As of November 2026, this repo is the missing piece: 50 Substack tools for AI assistants and scripts.
What you can ask
Turn essay.md into a draft for everyone and schedule it for Tuesday 8:00 New York time. Once it is out, post a Note with a link card to it.
Find comments on my last three posts that I have not answered and draft a short reply to each.
Last week's numbers: new and paid subscribers, cancellations, revenue, and opens for each post.
Where did my readers come from in the last 30 days?
Two ways to get it
Cotlet is best for writers and publishers who want ChatGPT, Claude or another AI agent to work in Substack for them, with nothing to install.
Start free at cotlet.dev →
Run it yourself
A Substack API and a Substack MCP server you run on your own computer, in Python, on the session of your own Google Chrome. All 50 Substack tools we run in production at Cotlet: posts and drafts from Markdown, publishing and scheduling, Notes, comments, subscribers, stats, recommendations and direct messages.
Substack has no public API to write posts, publish Notes or manage subscribers, and no official MCP server. This repo gives you both:
- MCP server for Claude Code, Claude Desktop, Cursor, Codex and any MCP client, over stdio or HTTP. Setup
- REST API on
http://127.0.0.1:8787/api/v1/substack, with OpenAPI docs at /docs. Setup
- Python:
call("list_posts", status="draft"), plus 14 ready scripts in examples/.
Free for your own use, your own business included (license).
[Substack MCP server]
[Python 3.11+]
[License: Elastic 2.0]
[MCP Badge]
Contents
Questions from Substack users
Does Substack have an API?
Only a limited one (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. RSS reads public posts only. This repo and Cotlet give you 50 Substack tools as a REST API and an MCP server.
Can I get a Substack API key?
Not from Substack for your own account. With Cotlet you get your own API key that works with your Substack account, for scripts, n8n, Make, Zapier or any HTTP client. This repo needs no key: it runs on your computer, on your own Substack session.
Is there an official ChatGPT integration for Substack?
Partly. Substack has an official Claude connector that reads your publication's data, such as subscribers, revenue and post stats. It cannot write. Cotlet adds the writing side: drafts, publishing and scheduling, Notes, comments and messages, in ChatGPT, Claude and other AI agents.
How do I connect Substack to ChatGPT?
Sign up at cotlet.dev, sign in to Substack once in your Cloud Browser there, and add Cotlet to ChatGPT, following the steps in your account. Then ask ChatGPT about your Substack like you would ask an assistant. ChatGPT needs a server on the internet, so this repo alone, running on your computer, does not connect to ChatGPT.
Can ChatGPT write and schedule my Substack posts?
Yes, with Cotlet. It turns your notes or a Markdown file into a Substack draft, shows it to you and publishes or schedules it after your OK. It can post a Note about it once it is out.
Can ChatGPT read my Substack stats?
Yes, with Cotlet: new and paid subscribers, cancellations, revenue, opens per post and where your readers came from, in plain words.
Can I automate Substack with Zapier, Make or n8n?
Substack has no official way to write posts from Zapier, Make or n8n. With Cotlet they can create drafts, publish posts and post Notes, for example from a Google Doc or an RSS feed.
Can I use it from my phone?
Yes, with Cotlet: once it is set up, the ChatGPT and Claude apps on your phone can use Substack for you.
Do I need to be technical?
For Cotlet, no: you sign in to Substack and add Cotlet to ChatGPT or Claude, with step-by-step instructions in your account. This repo is for people who are fine with Python and a terminal.
Is my Substack account safe?
Yes. Neither Cotlet nor this repo sees or stores your Substack password. You sign in yourself, the way you always do, and the AI works on that signed-in session. Anything that reaches other people asks for your OK first: in Cotlet by default, here through your MCP client.
Is it free?
This repo is free, also in your own business. Cotlet is free for 7 days with no card, then one-time credit packs from $29, no subscription. Pricing.
I manage Substack for several accounts or clients. Does that work?
Yes, with Cotlet. Each Substack login gets its own connection. Write to [email protected] and tell us how many accounts you manage.
How it works
- You sign in to Substack in your own Chrome, the way you always do.
substack-mcp connect attaches to that Chrome through the Chrome DevTools Protocol, reads the substack.com cookies and saves them to ~/.config/substack-api-mcp/session.json, readable by your user only. Substack signs in by an emailed code or link, so there is no password to see or store.
- Every tool call is a request to Substack's own web app endpoints (
substack.com/api/v1 for the reader side, yourname.substack.com/api/v1 for your publication's dashboard) with those cookies, sent with curl_cffi, which copies Chrome's TLS fingerprint. No headless browser runs.
Substack's session cookie (substack.sid) lasts about three months. When Substack signs you out, the server reads the cookies from Chrome again, if Chrome is open with remote debugging on.
Requirements
- Python 3.11 or newer.
- Google Chrome 144 or newer, signed in to Substack. Any Chrome or Chromium works with a debugging port.
- macOS, Linux or Windows.
- A Substack account. Publisher tools (posts, subscribers, stats, comments) work on the first publication your account runs as admin, owner, editor or contributor. Reader tools (feed, search, Notes, messages) work on any account.
Install
From PyPI:
MCP clients can also run it with no install: uvx substack-api-mcp mcp.
From source:
With uv: uv venv && uv pip install -e ., then uv run substack-mcp ....
Setting it up with an AI agent (Claude Code, Codex, Cursor)? Open it in this folder and ask it to set up the repo: AGENTS.md tells it every step, and it asks you only for the steps in Chrome.
To update: uv tool upgrade substack-api-mcp (or pip install -U substack-api-mcp), from source git pull && pip install -e .. We copy every change of the hosted Substack tools into this repo.
Connect your Chrome
Option A: your everyday Chrome (recommended)
-
Open chrome://inspect/#remote-debugging in Chrome and switch remote debugging on. Chrome then accepts DevTools connections from programs on this computer, and asks you before each one.
-
Make sure you are signed in at substack.com.
-
Run:
-
Chrome asks whether to allow the connection. Click Allow.
You can switch remote debugging off again afterwards. Leave it on if you want the server to pick up a new session by itself after Substack signs you out.
connect looks for Chrome's DevToolsActivePort file in the default profile folder. For Chrome Beta, Canary or a custom profile folder, pass --profile-dir "<folder>".
Option B: a Chrome with a debugging port
Chrome does not open a debugging port on your default profile, so start a separate one, sign in to Substack there once, and connect to it:
--cdp also takes a ws:// DevTools URL, for example of a Chrome on another machine reached over an SSH tunnel.
Option C: paste the cookie by hand
For a server with no Chrome: in Chrome open DevTools on substack.com, Application > Cookies > https://substack.com, copy the value of substack.sid, then:
A pasted token is not refreshed on its own. Paste a new one when Substack signs you out.
Check the session at any time:
MCP server
The MCP server lists every tool with its input schema, a description written for agents, and hints: read tools are marked read-only, and tools that publish, message or delete are marked so your client asks before running them.
Claude Code
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Cursor
~/.cursor/mcp.json, the same block as Claude Desktop. A ready copy is in mcp.json.
Codex
~/.codex/config.toml:
Over HTTP
substack-mcp serve also serves MCP over streamable HTTP at http://127.0.0.1:8787/mcp, for clients that take a URL:
Then ask your agent things like:
Turn essay.md into a draft for everyone and schedule it for Tuesday 8:00 New York time. Once it is out, post a Note with a link card to it.
Find comments on my last three posts that I have not answered and draft a short reply to each.
Last week's numbers: new and paid subscribers, cancellations, revenue, and opens for each post.
Where did my readers come from in the last 30 days?
REST API
Each tool has its own route under /api/v1/substack, the same paths as the hosted API at cotlet.dev, so code written against one works with the other. Path parts and the query string are arguments, and a JSON body adds the rest.
Any tool by name, body as its arguments:
GET /api/v1/substack/tools: every tool with its route, input schema and an example answer.
GET /docs: interactive OpenAPI docs, GET /openapi.json the schema, for n8n, Postman or a generated client.
- Answers are JSON. Lists return
next_cursor; pass it back as cursor for the next page.
The server listens on 127.0.0.1 only. To reach it from another device of yours, set a token, and every request then needs Authorization: Bearer <token>:
Python and the example scripts
Straight from Python, no server needed:
Or one tool from the shell: substack-mcp call get_post_stats post_id=148213977, or with a JSON object.
Ready scripts in examples/. Each prints JSON, takes --out file.csv or --out file.json where it makes sense, and --help:
On a schedule, cron on your own computer works while it is on: 0 8 * * 1 cd ~/substack-api-mcp-server && .venv/bin/python examples/weekly_report.py.
All 50 tools
post_id comes from list_posts, comment_id from list_comments. substack-mcp tools prints this list, substack-mcp tools --json adds the input schemas.
Posts and drafts
Publishing
Sections and post tags
Comments
Notes
Subscribers
Stats
Recommendations
Reader, feed and messages
Never built, on purpose: your Substack sign-in, email, profile and account settings, your publication's address or ownership, and anything that moves money (paid plans, payouts, comps). Every request passes a guard that refuses writes to those Substack paths.
Configuration
Security and your Substack account
- No password anywhere. Substack signs in by an emailed code. Only cookies are read, and only those of substack.com.
- The session file is yours.
session.json is created with mode 0600. Anyone who has it can act as you on Substack, so keep it out of git and shared folders.
- Local by default.
serve binds to 127.0.0.1 and refuses another address without SUBSTACK_MCP_TOKEN.
- substack.com only. Requests and redirects outside substack.com and its subdomains are refused.
- Read-only mode.
--read-only or SUBSTACK_MCP_READ_ONLY=1 exposes the 25 read tools only.
- Actions reach real people. Published and scheduled posts are emailed to your subscribers, and Notes, comments, replies and DMs go out under your name. MCP clients ask before running them; a script does not, so try it on a test publication first.
- Add only people who asked.
add_subscriber sends Substack's welcome email. Importing people who did not sign up breaks Substack's rules.
Errors
The REST API answers {"error": "<code>", "message": "..."}. The MCP server returns the same code and message as a tool error.
Self-hosted or hosted
On the hosted version a successful call uses 10 credits for most tools, failed calls are free, and the Cloud Browser uses 50 credits a day while it has an app enabled for agents. Full pricing.
FAQ
Is there a Substack MCP server for Claude, ChatGPT or Cursor?
Yes, this one runs on your machine: substack-mcp mcp for Claude Code, Claude Desktop, Cursor and Codex. ChatGPT and Claude.ai connectors need a public HTTPS URL, which the hosted Substack MCP server gives you.
Can I schedule Substack posts from Markdown?
Yes: python examples/draft_from_markdown.py essay.md --publish-at 2026-11-03T08:00:00-05:00. The Substack editor does not import Markdown. The script sends the file as a draft with its headings, bold text, links, lists and code blocks, then schedules it. Images have to be public URLs.
Can it schedule Notes as well as posts?
Yes. publish_note takes a publish_at time and the Note waits in your scheduled Notes until then. A link card needs a published post.
Can I export my Substack subscribers to CSV?
Yes: python examples/export_subscribers.py --out subscribers.csv gives the same CSV as Export in the subscriber dashboard. list_subscribers.py --plan paid or --since 2026-10-01 gives a filtered list with plan, join date and activity rating.
Can I export my posts as Markdown?
Yes, one at a time with examples/get_post.py --post-id <id> --out post.md, including the paywalled part and drafts of your own publication. list_posts.py gives the IDs.
Is this a Substack scraper?
It does what people want a scraper for (export posts, subscribers and stats) but does not parse HTML in a headless browser. It calls the same JSON endpoints the Substack web app calls, in your own account and publication.
Why does it need my Chrome?
To read your Substack session. Substack signs in by an emailed code, so there is no password to give it anyway. Chrome is used once per sign-in, not for each call.
What happens when Substack signs me out?
Calls fail with auth_expired. With Chrome remote debugging on, the server reads the new cookies on the next call (click Allow when Chrome asks); otherwise run substack-mcp connect again. Subscriber lists sometimes ask for a fresh sign-in even with a valid session: sign out and in again at substack.com, then connect.
Does it need a paid Substack plan?
No. Revenue, paid subscribers and cancellations exist only for publications with paid subscriptions.
Can it email all my subscribers?
Only by publishing or scheduling a post, the way the editor sends it. Substack emails a post once; edits after the send show on the web and in the app.
Can it run on a VPS or in Docker?
Technically yes, with SUBSTACK_AUTH_TOKEN. Substack then sees your session from a datacenter IP, which looks less like you. For an always-on setup the hosted version keeps your session in your own Cloud Browser on a fixed IP.
Will my Substack account get banned?
Requests carry Chrome's fingerprint and go out one at a time, as you would click. Nobody can promise a platform never acts. Keep to your normal use and do not add or message people in bulk.
Can I use it at work or for my clients?
At work and in your own business, yes, free. You may not offer it to others as a hosted or managed service. For client work, use Cotlet or write to [email protected].
Is it open source?
The source is public under the Elastic License 2.0: free to use and change, also in your own business, but not to resell as a hosted service.
A tool broke or I need another one.
Open an issue with the tool name and the error message.
License
Elastic License 2.0. In short:
- Allowed: using it for yourself and in your own business, free. Changing the code and sharing it under the same license.
- Not allowed: offering it to others as a hosted or managed service, removing the license notices, getting around its limits.
Earlier versions of this repo (the scripts for the hosted API, up to commit 4399e88) stay MIT.
[Cotlet]
Maintained by Cotlet (@cotletdev). Substack is a trademark of its owner. This project is unofficial and not affiliated with, endorsed or sponsored by Substack.