LN

lox/notion-cli

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

37 stars 16 forks 质量 68 趋势 20MIT

Notion 使用模型上下文协议(MCP)的 CLI

概览

Notion的命令行界面,使用远程MCP(模型上下文协议)。 灵感来自linear-cli——在管理Notion工作空间时,保持在终端中。 ——包含一项技能,允许代理在代码旁搜索、创建和管理你的Notion工作区。 该论证接受URL、ID或页面名称。 页面归档接受页面 URL 或页面 ID,并通过官方 API 将该页面移入垃圾桶。这需要通过认证 API 设置或NOTION_API_TOKEN配置官方 API 令牌。 页面视图默认显示页面层面的评论和内联块讨论。内嵌讨论会根据上下文渲染,锚文本以[[...]]包裹,讨论内容紧贴其下方。使用--no-comments抑制评论,--raw检查原始Notion标记,--json返回页面及评论数组。 参数接受URL、ID或名称。日期属性使用扩展键格式:date: :start, date: :end。

概述(AI 翻译)

Notion的命令行界面,使用远程MCP(模型上下文协议)。

灵感来自linear-cli——在管理Notion工作空间时,保持在终端中。

与AI代理配合良好——包含一项技能,让代理能在你的代码旁搜索、创建和管理你的Notion工作区。

安装

来自源头

本地建造

快速启动

命令

认证

页面

参数接受 URL、ID 或页面名。

page archive 接受页面 URL 或页面 ID,并通过官方 API 将该页面移入垃圾桶。这需要通过 auth api setup 或 NOTION_API_TOKEN 配置的官方 API 令牌。

page view 默认显示页面层面的开放评论和内联讨论。内联讨论会根据上下文渲染,锚文本被 [[...]] 包裹,讨论内容紧贴其下方。使用 --no-comments 抑制评论,--raw 检查原始 Notion 标记,--json 返回页面及 Comments 数组。

[page upload 和 page sync 支持本地本地上传,用于像 这样的独立 Markdown 图片行。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

notion-cli

A command-line interface for Notion using the remote MCP (Model Context Protocol).

Inspired by linear-cli - stay in the terminal while managing your Notion workspace.

Works great with AI agents — includes a skill that lets agents search, create, and manage your Notion workspace alongside your code.

Installation

From Source

go install github.com/lox/notion-cli@latest

Build Locally

git clone https://github.com/lox/notion-cli
cd notion-cli
mise run build

Quick Start

# Authenticate with Notion (opens browser for OAuth)
notion-cli auth login

# Search your workspace
notion-cli search "meeting notes"

# View a page with open comments inline by default
notion-cli page view "https://notion.so/My-Page-abc123"

# Hide page and block comments when you only want the body
notion-cli page view "Meeting Notes" --no-comments

# List your pages
notion-cli page list

# Create a page
notion-cli page create --title "New Page" --content "# Hello World"

Commands

Authentication

notion-cli auth login      # Authenticate with Notion via OAuth
notion-cli auth refresh    # Refresh the access token
notion-cli auth status     # Show authentication status
notion-cli auth logout     # Clear stored credentials

# Official API fallback auth for features MCP cannot handle directly
notion-cli auth api setup     # Opens the internal integrations page, prompts for token, warns if format looks wrong
notion-cli auth api status
notion-cli auth api verify
notion-cli auth api unset

Pages

notion-cli page list                           # List pages
notion-cli page list --limit 50                # Limit results
notion-cli page list --json                    # Output as JSON

notion-cli page view                     # View page content with comments
notion-cli page view  --no-comments      # Hide page and block comments
notion-cli page view  --raw              # View raw Notion markup
notion-cli page view  --json             # Output as JSON

notion-cli page create --title "Title"         # Create a page
notion-cli page create --title "T" --content "Body text"
notion-cli page create --title "T" --parent 
notion-cli page archive        # Archive a page via the official API

# Upload a markdown file as a new page
notion-cli page upload ./document.md                        # Title from # heading or filename
notion-cli page upload ./document.md --title "Custom Title" # Explicit title
notion-cli page upload ./document.md --parent "Engineering" # Parent by name or ID
notion-cli page upload ./document.md --parent-db     # Upload as database entry
notion-cli page upload ./document.md --icon "📄"             # Set emoji icon
在 GitHub 查看完整 README

安装

npx skills add lox/notion-cli
新手?先看 mcpskill.org 教程 →