agent-notion
Notion CLI for humans and LLMs
- Language
- Go
- Version
- 0.10.2
- License
- PolyForm Perimeter 1.0.0
- Category
- CLI Tool
A Notion CLI covering search, databases, pages, blocks, comments, users, export, activity and Notion AI. Two backends serve one command surface — the official REST API for tokens and OAuth, and the v3 desktop session for everything the REST API cannot reach, including export, backlinks, version history, real archiving, block moves, inline comments and AI chat.
Features
Two backends, one surface — the official REST API and the v3 desktop session; --backend auto prefers a stored v3 session and falls back to the official credential
Full CRUD — search, read, create, update, trash, restore and archive pages, databases and blocks
Markdown in and out — page content renders as markdown with GitHub-flavored pipe tables, and content is appended or replaced from markdown
Notion AI — list models and threads, send messages against a page, stream responses, mark threads read
Export — a page (optionally recursive) or the whole workspace, as markdown or HTML, with task polling
Inline comments anchored to text — target a phrase by content and occurrence, not by offset
Backlinks, version history and the activity log — the questions the REST API cannot answer
Warns where Notion will mislead you — database query returns the view's own order, often manual, so --limit can silently omit a freshly-added row; the docs tell you to sort on a timestamp and watch the @pagination trailer
Tokens stay off argv — auth import reads from stdin, validates against the API before storing, and derives the alias from the workspace name
Explicit guidance for agent-driven setup — an agent should tell the user to run the import themselves rather than accept a pasted token on --token
Destructive commands refuse without --yes — trash, archive, block delete, block replace, logout
Multi-workspace — named aliases, switch and set-default, keychain-first with a warning field when it falls back to plaintext
Zero runtime dependencies — a single static Go binary
Install
Homebrew
$ brew install shhac/tap/agent-notion AI Agent Skill
$ npx skills add shhac/agent-skills --skill agent-notion --global GitHub Release (macOS)
$ curl -L https://github.com/shhac/agent-notion/releases/latest/download/agent-notion-darwin-arm64.tar.gz | tar xz Go Install
$ go install github.com/shhac/agent-notion/cmd/agent-notion@latest Build from Source
$ git clone https://github.com/shhac/agent-notion.git && cd agent-notion && make build Getting Started
OAuth gives the fullest access to any workspace the user authorizes; an integration token is simpler for CI. A desktop session unlocks the v3-only commands — export, backlinks, history, activity, block move, inline comments and AI.
01 · Option A — OAuth, for full access
$ agent-notion auth login Run auth setup-oauth --client-id <id> --client-secret <secret> first, against a Notion integration with OAuth enabled. Add --alias to keep several workspaces.
02 · Option B — an integration token, off argv
$ printf '%s' "$NOTION_TOKEN" | agent-notion auth import Read from stdin so the secret never reaches shell history or a transcript. It is validated before storing. If an agent is driving, have it ask you to run this yourself.
03 · Add a desktop session for the v3 commands
$ agent-notion auth import-desktop Reads the session from the Notion desktop app (auth import-browser also works). This is what powers export, backlinks, history, activity log, block move, inline comments and ai.
04 · Verify
$ agent-notion auth status Then agent-notion usage for the overview, or agent-notion page usage for detail on one group.
Usage
$ agent-notion search query "Meeting Notes" $ agent-notion page get PAGE_ID --content $ agent-notion database query DB_ID --sort '[{"timestamp":"last_edited_time","direction":"descending"}]' $ agent-notion database schema DB_ID $ agent-notion block append PAGE_ID --content "## New Section" $ agent-notion comment inline BLOCK_ID "needs a source" --text "revenue doubled" $ agent-notion page backlinks PAGE_ID $ agent-notion export page PAGE_ID --recursive --wait $ agent-notion ai chat send "Summarize my recent notes"