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

01

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

02

Full CRUD — search, read, create, update, trash, restore and archive pages, databases and blocks

03

Markdown in and out — page content renders as markdown with GitHub-flavored pipe tables, and content is appended or replaced from markdown

04

Notion AI — list models and threads, send messages against a page, stream responses, mark threads read

05

Export — a page (optionally recursive) or the whole workspace, as markdown or HTML, with task polling

06

Inline comments anchored to text — target a phrase by content and occurrence, not by offset

07

Backlinks, version history and the activity log — the questions the REST API cannot answer

08

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

09

Tokens stay off argv — auth import reads from stdin, validates against the API before storing, and derives the alias from the workspace name

10

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

11

Destructive commands refuse without --yes — trash, archive, block delete, block replace, logout

12

Multi-workspace — named aliases, switch and set-default, keychain-first with a warning field when it falls back to plaintext

13

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

>_ Search pages by title
$ agent-notion search query "Meeting Notes"
>_ Read a page as markdown
$ agent-notion page get PAGE_ID --content
>_ Query a database, newest first
$ agent-notion database query DB_ID --sort '[{"timestamp":"last_edited_time","direction":"descending"}]'
>_ Inspect a database's schema
$ agent-notion database schema DB_ID
>_ Append markdown to a page
$ agent-notion block append PAGE_ID --content "## New Section"
>_ Comment on a specific phrase
$ agent-notion comment inline BLOCK_ID "needs a source" --text "revenue doubled"
>_ What links here, and what changed
$ agent-notion page backlinks PAGE_ID
>_ Export a page tree as markdown
$ agent-notion export page PAGE_ID --recursive --wait
>_ Ask Notion AI
$ agent-notion ai chat send "Summarize my recent notes"