Repository avatar
Databases
v0.4.2
active

onenote

io.github.BiteFoundry/onenote

Microsoft OneNote MCP server, CLI, and TUI in Rust with local SQLite FTS5 cache & block edits.

Documentation

@bitefoundry/onenote

Read and edit OneNote pages, search cached notebooks, and update checklists from the terminal.

npm version Platforms Built with Rust & Ratatui License: MIT

BiteFoundry · Latest release notes


Microsoft OneNote TUI Demo


Highlights

CapabilityDetails
Minimal-Chrome 3-Pane TUIPersonal and Teams/Group notebooks, colored section ribbon, nested subpages (level 0/1/2), bidirectional XHTML ↔ Markdown canvas, surgical data-id PATCH edits, optimistic to-do toggles, Link Extractor (u), File Picker with zoxide (Ctrl+F), and 6 themes.
High-Res Terminal ImagesInline thumbnails & fullscreen HD previews (v / Alt+v) with 80ms protocol probing for Kitty, iTerm2, Sixel (Floyd-Steinberg dithering), and 24-bit Unicode Half-Blocks + Ctrl+V clipboard PNG upload.
Local SQLite FTS5 + IPC DaemonWAL-mode SQLite cache with 4-reader pool, trigram full-text search (/), persistent DraftStore, and a shared background sync daemon (onenote daemon start).
4-in-1 Agent InterfaceInteractive TUI (onenote), scriptable --json CLI, local HTTP JSON API (onenote serve, port 8793), and stdio MCP Server (onenote mcp).

Quick Start

# 1. Install globally via npm (precompiled native binary for win32 / darwin / linux)
npm i -g @bitefoundry/onenote

# 2. Authenticate with Microsoft 365 (PKCE loopback, --device-code, or --token-file)
onenote login

# 3. Launch the interactive TUI
onenote
onenote read "Meeting notes" --json

Read a page with its key and notebook scope. Local search uses the identified account’s cache. If you use an opaque access token, run onenote whoami once online first. For full detail, add --full in the CLI or pass compact: false to get_page in MCP.

Build from source with cargo build --release. See installation and migration for updating scripts, MCP configurations, and local HTTP clients.

Company-managed Microsoft Entra sign-in

onenote login uses the public Microsoft Graph Command Line Tools client by default. To use a company-owned app, register it as a public client and configure the http://localhost redirect URI. Enable public client flows for headless --device-code sign-in. Company app registration guide

Add the Microsoft Graph delegated permissions your users need and have your Entra administrator grant consent where required.

FeatureDelegated scopes
Profile and session refreshUser.Read, offline_access
Read, create, and edit the user's OneNote contentNotes.Read, Notes.Create, Notes.ReadWrite
Discover joined Teams and read or edit organizational notebooks the user can accessTeam.ReadBasic.All, Notes.Read.All, Notes.ReadWrite.All

The default sign-in adds the organizational scopes when you specify your company's tenant ID. Set scopes in config.toml to request a narrower set that matches your workflow.

onenote login --client-id YOUR_APP_ID --tenant-id YOUR_TENANT_ID
onenote whoami --json

For persistent environment configuration, set ONENOTE_CLIENT_ID and ONENOTE_TENANT_ID.

When supplying a token without an embedded user ID (for example an opaque ONENOTE_ACCESS_TOKEN or ONENOTE_TOKEN_FILE), run onenote whoami once while online to record only the token fingerprint and user ID under identity-map/. Running local search (without --refresh) or --offline with an unrecorded token returns an Unknown identity error instead of falling back to an empty default cache. Running onenote search <query> --refresh also records the identity binding. Whenever the token rotates or changes, run onenote whoami once again for the new token.

Enterprise networks / custom CA

HTTPS connections trust the bundled Mozilla roots and the operating system's trust store. If your network inspects HTTPS with a private root CA that is not in either, export that root as PEM and point the CLI at it:

VariableBehaviour
ONENOTE_EXTRA_CA_PEMPEM file (one certificate or a bundle) added to the trusted roots. If it cannot be read or parsed, the command fails with an error naming the file.
SSL_CERT_FILEAlso loaded as extra roots. An unusable file is reported on stderr and skipped. When set, it replaces the OS trust store for the native-roots lookup; the bundled roots still apply.
NODE_EXTRA_CA_CERTSAlso loaded as extra roots, so an existing Node.js setup works unchanged. An unusable file is reported on stderr and skipped.
export ONENOTE_EXTRA_CA_PEM=/path/to/corporate-root.pem
onenote doctor --online

A certificate from an unknown issuer produces a TLS certificate was not trusted (unknown issuer) hint naming these variables. Certificate verification cannot be turned off. Warnings go to stderr only, so onenote mcp stdio output is unaffected.


Keybindings Cheat Sheet

KeyAction
Tab / Shift+TabCycle focus (Notebooks → Pages → Note Canvas)
j / k · ↑ / ↓Navigate notebooks, pages, subpages, or blocks
[ / ]Switch to previous / next section tab
nCreate a page (Markdown + Ctrl+V PNG)
a / eAppend Markdown block / surgically edit selected block
Space / xToggle selected To-Do checkbox (data-tag="to-do:completed")
B / S / DCreate notebook / create section / delete page
u / hOpen Link Extractor modal / toggle inline href URLs
v / o / yHD image preview / open in browser / copy page Markdown
Ctrl+FInteractive File Picker (z for zoxide directory jump)
/Instant full-text search across cached pages (SQLite FTS5)
Ctrl+P / Ctrl+KUnified Command Palette & Omni-Switcher
. / Right-clickContext Menu
Ctrl+, / Ctrl+B / ?Settings / Toggle sidebar / Keyboard shortcuts help

CLI, HTTP API & MCP

CLI

onenote notebooks --json
onenote pages "Acme Engineering/Architecture" --json
onenote rename-section 'me|SECTION_ID' --name 'Architecture Notes' --json
onenote rename-notebook --drive-id DRIVE_ID --item-id ITEM_ID --name 'Engineering Notes' --json
onenote read "Q4 Architecture RFC" --json
onenote read "Q4 Architecture RFC" --json --full
onenote copy-page 'me|PAGE_ID' --section 'me|SECTION_ID' --json
onenote create "Architecture" --title "Release Notes" '## Shipped
- [x] WAL pool' --json
onenote check "Migration Cutover" --block-id 'p:m3' --done --json
onenote search "canary" --json

onenote read PAGE --json returns compact Markdown and identifiers by default; pass --full for parsed blocks, raw XHTML, and resources. Passing an explicit --format <fmt> --json returns the full JSON page, and adding --compact selects the compact shape. Write commands (append, update, check) with --json return a compact summary (ok, page_key, title, last_modified_at, plus block_id / completed where applicable) by default; pass --full to include the full page object.

Page commands (read, append, update, check, delete) accept an optional --section (name, Notebook/Section, ID, or scoped key) to narrow title lookup to one section.

When a --json command fails at runtime, it exits 1 and writes a single JSON object ({"ok":false,"error":{"code","message"}}, plus top-level operation fields for non-completed copy-page) to stdout alongside the stderr error line. Successful read/list --json responses omit ok and signal success with exit 0; CLI argument/usage errors exit 2 on stderr without JSON.

onenote notebooks --json and onenote sections --json return 50 items by default (text output stays unbounded unless --limit is passed); pages defaults to 50 and search defaults to 30. All four JSON list responses include returned, has_more, and next_cursor, which can be passed back with --limit and --cursor to page through results. Full-text body search in onenote search covers pages that have been read or synced (cache.pages_with_body).

Use onenote read PAGE --format blocks to find a checkbox or text block's current element ID. Use --done or --undone to set a checkbox state. Omit both flags to toggle it.

onenote notebooks lists your personal notebooks, plus the notebooks of your joined Teams/Groups with --include-teams. SharePoint site notebooks are not auto-discovered; you can create one with onenote create-notebook NAME --site SITE_ID.

copy-page uses Microsoft Graph to create a new page in the destination section and preserves the original page and its links. If the copy is still pending, pass its operation_url with --operation to check the same copy. Copy a page

On Windows, desktop-set-page-level and desktop-rename-section work on existing objects in an open notebook. Use the OneNote app's Move command to move a page between sections. Hierarchy operations and permissions

Local HTTP API (onenote serve)

# Start local Axum JSON server (default 127.0.0.1:8793) with your own API key
onenote serve --token dev-secret

# Query pages & FTS5 search from scripts or agents
curl -H "Authorization: Bearer dev-secret" \
  "http://127.0.0.1:8793/v1/onenote/search?q=canary&limit=10"

The API key is required on every route except /health. Without --token (alias of --api-key) or ONENOTE_API_KEY, a loopback server generates a random key and prints it once on stderr; pass --allow-keyless to run a loopback server without one. A non-loopback --bind always needs a key. Browser pages cannot call the API unless their exact origin is listed with --cors-origin, and requests whose Host is not a loopback name, the bind address or an --allowed-host are refused. Authentication and access control

Full route reference & OpenAPI 3.1 spec: docs/API.md · docs/openapi.yaml.

Model Context Protocol (onenote mcp)

Add to Claude Desktop, Claude Code, Cursor, or Codex over stdio JSON-RPC 2.0.

{
  "mcpServers": {
    "onenote": {
      "command": "onenote",
      "args": ["mcp"]
    }
  }
}

Full tool catalog & schemas: docs/MCP.md.


@bitefoundry Enterprise Terminal Suite

PackageCommandsWorkspace Coverage
@bitefoundry/teamsteamsMicrosoft Teams chats, channels, threads & meetings
@bitefoundry/outlookoutlookMicrosoft Outlook mail, calendar & contacts
@bitefoundry/onenoteonenoteMicrosoft OneNote notebooks, sections, pages & XHTML/Markdown
@bitefoundry/sharepointsharepoint, bitefoundry-onedriveMicrosoft SharePoint sites, document libraries & OneDrive files
@bitefoundry/atlassianatlassian, confluence, confAtlassian Jira issues, boards, sprints & Confluence pages
@bitefoundry/notionnotionNotion pages, databases, blocks & Markdown sync

License & Disclaimer

Licensed under the MIT License.

Unofficial terminal client for Microsoft OneNote. Not affiliated with, endorsed by, or sponsored by Microsoft Corporation.