Skip to content

Repository files navigation

postcli substack

@postcli/substack

Your entire Substack, from the terminal.

Read posts. Publish notes. Automate engagement. Power AI agents.

npm versiondownloadsCIlicensenodeMCPissues


Getting StartedCLITUIMCP ServerAutomationsAPIContributing


CLI Demo


Why PostCLI?

Substack has no public API. PostCLI fills that gap with a fast, local-first toolkit that puts your entire Substack workflow in the terminal, in a TUI, or behind an AI agent.

CLI

Full command suite for posts, notes, comments, profiles, and engagement. Pipe-friendly --json output.

TUI

Interactive terminal UI with 6 tabs, sub-views, keyboard shortcuts, mouse scroll, and thread navigation.

MCP Server

16 tools for Claude, GPT, and any MCP-compatible AI agent. Read, write, and engage, all through natural language.

Automations

Like-back, auto-reply, auto-restack with SQLite-backed dedup engine. No cloud required.

Getting Started

Prerequisites

  • Node.js 18+ (LTS recommended)
  • Chrome/Chromium with an active Substack session (for auto cookie grab)
  • macOS or Linux (Windows support tracked here)

Install

npm install -g @postcli/substack

Authenticate

PostCLI grabs session cookies directly from Chrome. Just be logged into Substack in your browser:

postcli-substack auth login

Alternative methods: email OTP or manual cookie paste. See the auth guide.

Verify

postcli-substack auth test# Connection successful. Logged in as @yourhandle

First commands

postcli-substack posts list # see your posts
postcli-substack notes publish "Hello!"# publish a note
postcli-substack tui # launch the TUI

CLI

Read

postcli-substack posts list # your posts (all publications)
postcli-substack posts list --subdomain techblog # specific publication
postcli-substack posts get --slug my-latest-post # full post in markdown
postcli-substack notes list --limit 20 # recent notes
postcli-substack comments list 12345 # comments on a post
postcli-substack feed list --tab for-you # reader feed
postcli-substack profile me # your profile
postcli-substack profile get nicolascole77 # someone else's profile

Write

postcli-substack notes publish "Hello world"# publish a note
postcli-substack notes publish "Something **bold**"# markdown support
postcli-substack notes reply 12345 "Great point"# reply to a note
postcli-substack comments add 12345 "Nice post!"# comment on a post

Engage

postcli-substack posts react 12345 # heart a post
postcli-substack notes react 67890 # heart a note
postcli-substack comments react 11111 # heart a comment
postcli-substack posts restack 12345 # restack a post
postcli-substack notes restack 67890 # restack a note

JSON output

Every command supports --json for piping and scripting:

postcli-substack posts list --json | jq '.[0].title'
postcli-substack notes list --json --limit 5 | jq '.[] | .id'

Full CLI reference →

Interactive TUI

postcli-substack tui

TUI Preview

Tabs

TabWhat it shows
NotesYour notes, following, and general feed with sub-tabs
PostsPosts from your publications with mine/following/general
CommentsThread view with parent and child context
FeedReader feed (for-you, subscribed, categories)
AutoAutomation rules and execution logs
ProfileYour profile and publication list

Keybindings

KeyAction
tabSwitch between tabs
1-3Switch sub-tabs (mine / following / general)
up/downNavigate items
enterOpen thread / detail view
rReply to note
lLike / heart
sRestack
oOpen in browser
q / escBack / quit

Mouse scroll is supported for navigation.

TUI guide →

MCP Server

Connect your Substack to Claude, GPT, or any AI agent via the Model Context Protocol.

MCP Demo

Start the server

postcli-substack --mcp

Claude Code

Add to .claude/settings.json:

{
"mcpServers": {
"substack": {
"command": "postcli-substack",
"args": ["--mcp"]
}
}
}

Claude Desktop

Add to claude_desktop_config.json:

{
"mcpServers": {
"substack": {
"command": "postcli-substack",
"args": ["--mcp"]
}
}
}

Available tools (16)

ToolDescription
test_connectionTest authentication
get_own_profileYour profile and publications
get_profileProfile by subdomain
list_postsList posts (all pubs or specific)
get_postFull post by slug
get_post_by_idFull post by numeric ID
list_notesNotes from feed
list_commentsComments on a post
get_feedReader feed
publish_notePublish a new note
reply_to_noteReply to a note
comment_on_postComment on a post
react_to_postHeart a post
react_to_commentHeart a comment/note
restack_postRestack a post
restack_noteRestack a note

Full MCP reference →

Automations

Local, SQLite-backed automation engine with deduplication. Runs on your machine, no cloud needed.

# See available presets
postcli-substack auto presets
# Create from preset
postcli-substack auto create "like-back" --preset 1
# Run once
postcli-substack auto run 1
# Manage
postcli-substack auto list
postcli-substack auto toggle 1 # enable/disable
postcli-substack auto remove 1 # delete

Built-in presets

#PresetTriggerAction
1Like backSomeone likes your noteLike their latest note
2Auto-reply to likesSomeone likes your noteReply with thank you
3Auto-restackNew note from a handleRestack it
4Follow backNew followerFollow them back

Custom automations can combine any trigger + action. See the automations guide.

Programmatic API

Use the client in your own Node.js projects:

import{SubstackClient}from'@postcli/substack/client';constclient=newSubstackClient({token: process.env.SUBSTACK_TOKEN,publicationUrl: 'https://yourpub.substack.com',});// Readconstposts=awaitclient.listPosts({limit: 5});constnotes=awaitclient.listNotes({limit: 10});constprofile=awaitclient.ownProfile();// Writeawaitclient.publishNote('Published via API');awaitclient.replyToNote(12345,'Great note!');awaitclient.commentOnPost(67890,'Nice post');// Engageawaitclient.reactToPost(12345);awaitclient.reactToComment(67890);awaitclient.restackPost(12345);

API reference →

Project Structure

src/
cli/
commands/ # auth, posts, notes, comments, profile, social, auto
tui/ # Interactive terminal UI (React + Ink)
automations/ # SQLite-backed automation engine
formatters.ts # Output formatting (markdown, tables, colors)
chrome-cookies.ts # Chrome cookie extraction
lib/
substack.ts # SubstackClient (core API wrapper)
http.ts # HTTP client with throttling
models.ts # Domain models (Post, Note, Comment, Profile)
types.ts # Substack API response types
mcp/
index.ts # MCP stdio server
tools.ts # 16 tool definitions + handlers
client.ts # Client initialization & config
plugin.ts # Plugin registration for PostCLI ecosystem

Roadmap

Track progress and vote on features via GitHub Issues.

Contributing

Contributions are welcome. Here's how to get started:

Setup

git clone https://github.com/postcli/substack.git
cd substack
npm install
npm run build
npm test

Development

# Run CLI in dev mode
npm run cli -- notes list
# Run MCP with inspector
npm run dev:mcp
# Run tests
npm test

Guidelines

  1. Open an issue first to discuss the change you'd like to make
  2. Fork the repo and create a branch from main
  3. Write tests for new functionality
  4. Run npm test and npm run build before submitting
  5. Keep PRs focused on a single change

Good first issues

Looking for something to work on? Check issues labeled good first issue or help wanted.

Authentication

PostCLI auto-grabs session cookies from Chrome. You must be logged into Substack in your browser.

postcli-substack auth login

Three auth methods:

MethodCommandHow it works
Chrome grab (default)auth loginReads cookies directly from Chrome's SQLite DB
Email OTPauth login --subdomain yourpubSends a magic link to your email
Manual pasteauth setupPaste cookies from Chrome DevTools

Credentials are stored at ~/.config/postcli/.env with 0600 permissions (owner-only read/write).

Auth setup guide →

Disclaimer

This is an unofficial tool, not affiliated with or endorsed by Substack. It interacts with undocumented APIs that may change without notice. Use at your own risk.

License

AGPL-3.0

About

Substack CLI and MCP Server

Resources

Stars

13 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages