Substack-OPS
substack-ops
Standalone Substack CLI + 26-tool MCP server. Your IDE drafts the replies. Zero AI API keys.
Site → substack-ops.chavan.in · Source → 06ketan/substack-ops · Glama → mcp/servers/06ketan/substack-ops
Posts, notes, comments, replies, reactions, restacks, recommendations, search, profiles, feeds, automations, MCP server, Textual TUI. One Python install, one binary, MIT licensed.
TL;DR — MCP-native (no API key, one command)
uvx substack-ops mcp install cursor # or claude-desktop, claude-code, print
# Restart your host. Then in chat:
# "list unanswered comments on post 193866852"
# "draft a warm reply to comment 12345"
# "post that draft"Your host's LLM (Cursor's, Claude's) does the drafting via the
propose_reply / confirm_reply tools. No ANTHROPIC_API_KEY /
OPENAI_API_KEY needed.
Related MCP server: medium-ops
Setup (dev / from source)
git clone https://github.com/06ketan/substack-ops && cd substack-ops
uv sync
uv sync --extra mcp # mcp SDK for the MCP server (recommended)
uv sync --extra tui # textual for the TUI
uv sync --extra chrome # pycryptodome + keyring for Chrome cookie auto-grabAuth defaults to ~/.cursor/mcp.json's mcpServers.substack-api.env. Override
with env or .env. Or use one of the auth flows in auth login / auth setup.
uv run substack-ops auth verify
uv run substack-ops quickstart # 20-step tourCommand surface
Grouped by intent. Every write defaults to --dry-run; flip with
--no-dry-run (and --yes-i-mean-it for the irreversible ones). All writes
land in .cache/audit.jsonl and are dedup-checked against .cache/actions.db.
Auth (4)
Command | What it does |
| Confirm the cookie works; print authed user/pub. |
| Same as verify, exit non-zero on failure (CI-friendly). |
| Auto-grab cookie from local Chromium browser via macOS Keychain. |
| Email magic-link → paste-the-link interactive flow. |
| Interactive paste of |
Read — Posts (8)
Command | What it does |
| List posts from a publication (yours by default). |
| Post metadata (title, dates, reactions, comment count). |
| Same as |
| HTML body (auth-aware for paywalled). |
| Engagement counts — reactions, comments. |
| Substack-side full-text search. |
| Boolean: is this post paywalled? |
| Add (or remove with |
| Restack a post (Substack does not support unrestack). |
Read — Notes (5)
Command | What it does |
| Your published Notes. |
| One note + its reply tree. |
| Publish a top-level Note. |
| React on any Note. |
| Restack a Note. |
Read + Write — Comments (5)
Command | What it does |
| Full nested comment tree as table. |
| Same tree as JSON. |
| New top-level comment. |
| React on a comment. |
| Destructive — your own comments only. |
Reply engine (6)
Command | What it does |
| Rule-based replies (no LLM). |
| LLM drafts each, you |
| Draft every comment to a file. Edit, set |
| Same for replies under a Note. |
| Posts only |
| Draft + post immediately. 30s rate limit. |
Read — Discovery (8)
Command | What it does |
| Reader feed (the Substack app feed). |
| Profile. |
| Public user info + their subs. |
| Audio posts. |
| Pub's recommended publications. |
| Pub's contributor list. |
| Substack's category taxonomy. |
Automations (3)
Command | What it does |
| List built-in YAML rules. |
| One-shot run a preset. |
| Loop forever; logs to audit. |
Operations + safety (3)
Command | What it does |
| Query the JSONL audit log. |
| Counts in the dedup SQLite DB. |
| 20-step interactive tour. |
MCP server (3)
Command | What it does |
| Auto-merge config into your host. |
| stdio MCP server (26 tools). |
| Print the tool registry. |
Other (1)
Command | What it does |
| Textual TUI — 6 tabs (Notes, Posts, Comments, Feed, Auto, Profile). |
Multi-publication
Every read command accepts --pub <subdomain|domain>. Defaults to your own
publication.
substack-ops posts list --pub stratechery --limit 5
substack-ops posts search "ai" --pub stratechery
substack-ops recommendations list --pub stratecheryReply modes
Mode | What it does | Safety |
| YAML keyword/regex rules under | dry-run default |
| LLM drafts each reply, you | dry-run default + manual gate per comment |
| LLM drafts every comment to | offline review, dedup-checked on send |
| Posts only items with | dry-run default; dedup DB prevents the M2 31-dup-replies regression |
| LLM drafts and posts immediately | requires |
After every live note-reply the engine re-fetches the new comment and asserts
ancestor_path is non-empty. If empty, the audit row's result_status is
flipped to "orphaned" (the M2 bug where parent_comment_id was silently
dropped — now caught).
Automations
Built-in presets (auto presets):
like-back — when someone reacts to your note, react to their latest note.
auto-reply — same trigger, but post a templated thank-you.
auto-restack — when a watchlist handle posts a new note, restack it.
follow-back — when someone follows you, follow them back.
Custom YAML rules under ~/.config/substack-ops/auto/*.yaml. Loop with
auto daemon <name> --interval 60.
MCP server
substack-ops mcp install cursor # auto-add to ~/.cursor/mcp.json
substack-ops mcp install claude-desktop # auto-add to claude_desktop_config.json
substack-ops mcp install claude-code # uses `claude mcp add` under the hood
substack-ops mcp install print # print the snippet only
substack-ops mcp install cursor --dry-run # preview without writing
substack-ops mcp serve # stdio server
substack-ops mcp list-tools # 26 toolsManual config snippet (if you prefer):
{
"mcpServers": {
"substack-ops": {
"command": "substack-ops",
"args": ["mcp", "serve"]
}
}
}If the mcp SDK is not installed, the server falls back to a minimal
stdin/stdout JSON-line dispatcher that's still useful for scripting:
echo '{"tool":"list_posts","args":{"limit":3}}' | substack-ops mcp serveMCP-native draft loop (no API key)
3 tools designed to let your host LLM draft for you:
Tool | What it does |
| Returns the worklist: comments where you have not yet replied (any depth). |
| Dry-run only. Returns a |
| Posts a previously-proposed reply by token. Idempotent via dedup DB. Token TTL 5 min. |
Differentiator tools (the safety + drafting stack that makes the unattended
mode safe): bulk_draft_replies, send_approved_drafts, audit_search,
dedup_status, get_unanswered_comments, propose_reply, confirm_reply.
LLM strategy
Two layers, both free:
MCP-native (default). Host LLM drafts via
propose_reply/confirm_reply. No env vars, no API key. Use this for interactive replies.Subprocess CLI (daemon path). For
reply auto/auto daemonwhen no human is in the loop. Auto-detectsclaude(Claude Code),cursor-agent, orcodexon PATH. Override withSUBSTACK_OPS_LLM_CMD.
There is no paid-API-key path. If you want one, vendor the old _anthropic /
_openai methods from substack-ops v0.2.0 yourself.
Textual TUI
substack-ops tui6 tabs: Notes / Posts / Comments / Feed / Auto / Profile. Sub-tabs: 1=mine, 2=following, 3=general. Keys: tab, 1-3, ↑/↓, enter, r, l, s, o, q/esc.
Auth methods
substack-ops auth verify # uses mcp.json or env
substack-ops auth login # auto-grab cookies from Chrome (macOS Keychain)
substack-ops auth login --browser brave
substack-ops auth login --email me@x.com # email magic-link, paste-the-link mode
substack-ops auth setup # interactive paste cookiesArchitecture
mcp.json | env | Chrome | OTP → auth.py / auth_chrome.py / auth_otp.py
│
.cache/cookies.json
│
SubstackClient (httpx)
│
┌──────┬──────┬───────┬───────┬───────┬──────┬──────┬─────┬──────┐
▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
posts notes comments feed profile users recs cats ... reply_engine
│
┌───────────────┼────────────┐
▼ ▼ ▼
template ai_review ai_bulk + ai_auto
└───────────────┬────────────┘
▼
base.post_reply / post_note_reply
│
┌────────┼────────┐
▼ ▼ ▼
dedup audit ancestor_path
(SQLite) (jsonl) guardrail
auto/engine.py ────────────────┐
mcp/server.py ──── 23 tools ──┼─── all share SubstackClient
tui/app.py ──── 6 tabs ──┘Endpoints used
Action | Method + URL |
Auth check |
|
List posts |
|
Post by id |
|
Post by slug |
|
Post content | same as above; |
Post search |
|
Comments |
|
Reply to comment |
|
Add top-level comment | same with |
React to post |
|
Restack post |
|
Restack note |
|
Delete post-comment |
|
Delete note |
|
My notes |
|
Note thread |
|
Note replies |
|
Publish note |
|
Reply to note | same with |
React to comment |
|
Recommendations |
|
Authors |
|
Categories |
|
User profile |
|
Reader feed |
|
Tests
uv run pytest -q # 43 tests, ~0.6s, no live networkCoverage today: auth, client (read+write+engagement+delete), reply engine,
dedup DB, audit log search, MCP tool registry & dispatcher, automation engine
preset loader, the M2 parent_id regression test, the M2 host-mismatch
regression test.
GSD workflow
.planning/ scaffold for Get Shit Done
under ~/.claude/skills/gsd-*. Roadmap at .planning/ROADMAP.md,
per-phase plans at .planning/phases/M*/PHASE.md.
Known gaps
Full email stats (opens/clicks/views) — needs dashboard CSRF flow. Fallback: Playwright MCP scrape.
Reactions endpoint shape on POST/DELETE not yet probed live; current shape is a best-guess from upstream tool catalogs.
Auto-engine
new_follower/new_note_fromtriggers are stubbed (returnnote: "trigger not yet implemented").TUI sub-tabs (1/2/3) and reply/like/restack key bindings are scaffolded but not wired to the client yet.
Chrome cookie auto-grab tested only for macOS Chrome; Brave path included; Linux/Windows not supported.
License
MIT. See LICENSE.
The vendored httpx-port helpers under src/substack_ops/_substack/ are derived
from the MIT-licensed NHagar/substack_api package — kept here so this repo
ships zero runtime dependencies on third-party Substack libraries. Attribution
preserved in each file's module docstring.
Available Tools
26 toolsaudit_searchA
Read-only. Query the local audit.jsonl log of every write this server has performed (or attempted). Filters compose with AND. Use to debug 'did I post that?' or to pull rate-limit history. For a quick count summary use dedup_status.
Inputs: kind, target, status, since, +1 more.
bulk_draft_repliesA
WRITE TO LOCAL FILE (no Substack call). Generate reply drafts for every comment on a post (kind='post') or every reply on a note (kind='note') using the daemon-path LLM (host CLI: claude / cursor-agent / codex on PATH, or SUBSTACK_OPS_LLM_CMD). Output is a JSONL drafts file with action='proposed' per row; review, edit action to 'approved' or 'rejected', then send via send_approved_drafts.
Inputs: id (required), kind, out, model.
comment_on_postA
WRITE. Add a NEW top-level comment under a post (not a reply to an existing comment). Defaults to dry_run=true. For replies to existing comments use propose_reply -> confirm_reply. Dedup-protected by (post_id, body) hash.
Inputs: post_id (required), body (required), pub, dry_run.
confirm_replyA
EXECUTE the staged write. Look up the token from propose_reply, post to Substack, log to audit.jsonl, persist dedup row. Idempotent: if the same content was already sent, returns {deduped: true} without re-posting. Use force=true to bypass dedup (rare). Tokens are single-use and expire 5 min after propose_reply.
Inputs: token (required), force.
dedup_statusA
Read-only. Return counts from the local dedup SQLite DB (one row per successful write, keyed by content hash). Quick health check; for filtered details use audit_search. No args.
Inputs: no named parameters.
delete_commentA
DESTRUCTIVE WRITE. Delete one of YOUR own comments (or one on your publication if you're the owner). Cannot be undone. Set kind='post' to delete a post comment (uses pub host) or kind='note' for a note reply. Defaults to dry_run=true — you must explicitly set false.
Inputs: comment_id (required), kind, pub, dry_run.
get_feedA
Read-only. Pull items from the reader feed you'd see in the Substack app/home. Pass tab='for-you' (personalized recommendations, default), 'subscribed' (only publications you've subscribed to), or 'category-{slug}' for a topic feed (e.g. 'category-tech', 'category-finance', 'category-politics'). Returns a list of {post_id, title, pub, byline, snippet, published_at}. For a single publication's chronological list use list_posts; for keyword search use search_posts.
Inputs: tab, limit.
get_own_profileA
Read-only. Return the authenticated user's full profile as a dict with keys: id, handle, name, bio, photo_url, subscriber_count, primary_publication. Use this for 'who am I'-style calls and for preflight checks before WRITE tools (the auth handle is needed to build the publish URL). For another user's profile by handle, call get_profile instead. No args.
Inputs: no named parameters.
get_postA
Read-only. Return one post's metadata (title, slug, dates, reactions, comment count) by numeric id OR slug. For HTML body use get_post_content. For id-only callers prefer get_post_by_id.
Inputs: post_id (required), pub.
get_post_by_idA
Read-only. Strict-typed variant of get_post that ONLY accepts a numeric post id (e.g. 193866852) — no slug fallback. Use this when your caller already has an integer id (e.g. from list_posts response) and you want type safety + fewer round-trips. Returns the same shape as get_post (title, slug, dates, reactions, comment_count). For a slug-or-id input use get_post; for the post body use get_post_content.
Inputs: post_id (required).
get_post_contentA
Read-only. Return a post's body. Auth-aware: returns full text for paywalled posts you have access to, otherwise only the free preview. Set as_markdown=true to convert HTML to Markdown for LLM context.
Inputs: post_id (required), pub, as_markdown.
get_profileA
Read-only. Return any Substack user's public profile by their handle (the @-name from their URL, e.g. 'paulgraham' for paulgraham.substack.com). Returns id, handle, name, bio, photo_url, subscriber_count, and primary_publication. For YOUR own profile, prefer get_own_profile (faster, no handle needed, includes private fields). To list a user's posts after this, use list_posts with their pub url.
Inputs: handle (required).
get_unanswered_commentsA
Read-only. Return comments on a post where the authenticated user has NOT yet replied (filters out the entire branch if you've replied anywhere in the ancestry). This is the canonical worklist tool: read each, draft a reply in your own context, then propose_reply -> confirm_reply per item. For the full unfiltered tree use list_comments.
Inputs: post_id (required), pub, limit.
list_commentsA
Read-only. Return the full nested comment tree for a post (parent + replies, with author handle, body, date, reaction count). To find only the threads YOU haven't replied to yet, use get_unanswered_comments.
Inputs: post_id (required), pub.
list_notesA
Read-only. List the authenticated user's own published Notes (short-form, Twitter-like). For a comment thread on a post use list_comments. For replies under one note, fetch via the note id.
Inputs: limit.
list_postsA
Read-only. List posts from a publication (yours by default). For a single post by id/slug use get_post; for full HTML body use get_post_content; to find by keyword use search_posts.
Inputs: limit, pub, sort.
propose_replyA
STAGE A WRITE (no Substack call yet). Validate a reply, compute its dedup hash, build the exact payload, store it under a token, return the token + preview. Show the preview to the user. On approval, call confirm_reply with the same token. Tokens expire in 5 minutes. kind='post' requires post_id + parent_comment_id (for replies under a comment); kind='note' requires note_id. For new top-level post comments use comment_on_post.
Inputs: body (required), kind, post_id, note_id, +2 more.
publish_noteA
WRITE. Publish a new top-level Note (short-form post). Defaults to dry_run=true (no network write); set dry_run=false to actually post. Idempotent via dedup hash on body. For a reply to an existing note use reply_to_note. For long-form posts, use Substack's editor (not exposed).
Inputs: body (required), dry_run.
react_to_commentB
WRITE. React on a comment (default ❤). Set kind='post' for comments under a post (uses the publication host) or kind='note' for replies on a Note (uses substack.com). Defaults to dry_run=true.
Inputs: comment_id (required), kind, reaction, on, +2 more.
react_to_postA
WRITE. Add (on=true, default) or remove (on=false) a reaction on a post. Defaults to ❤ and dry_run=true. For comment-level reactions use react_to_comment. Reactions are not deduped (Substack itself idempotent).
Inputs: post_id (required), reaction, on, pub, +1 more.
reply_to_noteA
WRITE. Reply to an existing Note (any author's). Defaults to dry_run=true. Dedup-protected: replays of the same body to the same note are no-ops. For replies to a post comment, use propose_reply -> confirm_reply (which run through the same safety stack).
Inputs: note_id (required), body (required), dry_run.
restack_noteA
WRITE. Restack a Note (Substack's reshare for short-form Notes), broadcasting it to your subscribers' feeds. Example: restack_note(note_id='123456789', dry_run=false). Defaults to dry_run=true so the first call is a no-op preview — set dry_run=false to actually publish. Like restack_post, Substack does not support un-restacking via the public API (on=false is a no-op). For long-form posts, use restack_post instead.
Inputs: note_id (required), on, dry_run.
restack_postA
WRITE. Restack a post (Substack's reshare). Defaults to dry_run=true. Substack does NOT support unrestacking via the public API — once on, stays on. To restack a Note instead, use restack_note.
Inputs: post_id (required), on, dry_run.
search_postsA
Read-only. Full-text search posts in a publication. Use for keyword discovery; for chronological browsing use list_posts. Returns titles + ids only (call get_post / get_post_content for details).
Inputs: query (required), limit, pub.
send_approved_draftsA
WRITE. Sequentially post every entry in a drafts.json file where action=='approved'. Skips proposed/rejected/already-deduped rows. Honors rate_seconds throttle. Defaults dry_run=true; set false to actually post. Use force=true to bypass dedup (rare; reposts a previously-sent reply).
Inputs: drafts_path (required), dry_run, rate_seconds, force.
test_connectionA
Read-only. Verify the Substack session cookie works and return the authenticated user's id, handle, and primary publication. Call this first if other tools 401 or to confirm setup. No args.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 26 tools
Each tool has a clearly distinct purpose. Related tools like get_post, get_post_by_id, and get_post_content are differentiated by input type and output. The staged write process (propose_reply/confirm_reply) is well-separated from direct writes (comment_on_post, delete_comment). Debugging tools (audit_search, dedup_status) are distinct from operational ones.
All tool names follow a consistent verb_noun snake_case pattern. Verbs are descriptive (get_, list_, create_, publish_, propose_confirm_, etc.) and nouns match the resource (post, comment, note, profile, draft). There is no mixing of conventions or vague verbs.
With 26 tools, the set is comprehensive but slightly above the ideal range. However, each tool addresses a specific operation or workflow (e.g., staging replies, batch drafts, debugging), and no tools feel redundant. The count is justified by the breadth of Substack's features covered.
The tool set covers reading and writing for comments, notes, reactions, restacks, and basic post metadata. However, there is no tool for creating or editing long-form posts, which is a notable omission for a Substack management server. The server seems focused on community engagement rather than full publishing.
Maintenance
Related MCP Connectors
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server for Substack that lets Claude Code create drafts, upload images, set cover thumbnails, schedule, and publish posts on your Substack publication.1116MIT
- AlicenseAqualityDmaintenanceMedium CLI + 23-tool MCP server. Hybrid official API + dashboard GraphQL. Your IDE drafts the responses — no AI API keys.23MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for Substack that enables reading articles, comments, feed, and subscriptions from AI clients like Cursor and Claude, with optional authentication for paid content.64 npm5MIT
- AlicenseAqualityBmaintenanceA local MCP server for managing saved Substack posts. Enables offline reading, searching, bookmarking, and unbookmarking of Substack content via CLI or MCP clients.18MIT