Better Notion MCP README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Better Notion MCP listing page.

Better Notion MCP

๐Ÿ‡บ๐Ÿ‡ธ English ยท ๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡

An independently maintained enhanced edition evolved from the outstanding open-source project n24q02m/better-notion-mcp (now n24q02m/notion), maintained by one2agi.
A high-fidelity Markdown pipeline and production-grade Notion MCP infrastructure deeply redesigned for modern AI Agents (Claude, Cursor, Antigravity, Gemini Spark, etc.).

๐ŸŒ Official Website ยท ๐Ÿงญ Knowledge Base ยท ๐Ÿ’ฌ Community ยท ๐Ÿ“ฆ GitHub Repo

Maintained by one2agi npm License: MIT TypeScript Node.js Notion


Table of Contents


Core Architecture Design

Better Notion MCP is engineered specifically for LLM context optimization and autonomous multi-step execution across 4 technical pillars:

1. Markdown-First Semantic Pipeline

Equipped with an in-house 1,700+ line bi-directional AST compiler. Elements like callouts, toggles, multi-column blocks, syntax-highlighted code, and complex tables render as clean, standard Markdown. Writing content automatically compiles into valid Notion Block trees, reducing static and interaction token consumption by 70% to 90%.

2. Composite Mega-Tools

Instead of exposing dozens of fragmented low-level endpoints, APIs are consolidated into 8 domain composite tools (53 atomic actions) + 2 infrastructure tools. A single pages action can atomically update body content, title, icon, and cover in one transaction, eliminating redundant network hops.

3. Agent Resilience & Self-Healing

Features built-in exponential backoff retries (retryWithBackoff) and machine-readable fix advice (suggestFixes). When encountering transient rate limits or validation errors, structured fix instructions allow the model to self-correct autonomously without aborting tasks.

4. Lightweight & Isomorphic Runtimes

Seamlessly bridges local developer workflows and enterprise infrastructure: zero-setup local Stdio with integration tokens, or production Docker deployments with OAuth 2.1 + PKCE multi-user session isolation.


Key Features

  • ๐Ÿ“„ Full Markdown Round-Trip: High-fidelity bi-directional AST conversion between Markdown and Notion blocks.
  • ๐Ÿ› ๏ธ Complete 10-Tool Matrix: 8 domain composite tools + 2 infrastructure tools covering 95%+ of Notion API capabilities.
  • โšก Atomic Multi-Field Updates: Modify body text, title, icon, and cover in a single replace_content call.
  • ๐Ÿ“š Tiered Token Optimization: Compact tool descriptions reduce static context by ~77%, with on-demand detailed manual retrieval via help.
  • ๐Ÿ”„ Kernel-Level Auto-Pagination: autoPaginate transparently handles cursor loops and recursive deep-child block fetching.
  • ๐Ÿ›ก๏ธ Production Security: Automatic token sanitization on error paths; full OAuth 2.1 PKCE support for HTTP mode.
  • ๐ŸŒ Dual Transport: Seamlessly switch between local Stdio and self-hosted remote HTTP services.

Tool Matrix (10 Tools)

The server registers 10 MCP tools comprising 8 Notion domain composite tools and 2 infrastructure tools:

ToolActionsScope & CapabilitiesToken Mode
pagescreate, get, get_property, update, move, archive, restore, duplicate, get_markdown, replace_content, insert_markdown, update_content, replace_content_range (13 actions)Full page lifecycle; native Markdown reading/writing, atomic metadata updates (icon, cover, title), server-side fast rendering.Notion API
databasescreate, get, query, create_page, update_page, delete_page, create_data_source, update_data_source, update_database, list_templates, aggregate, group_by, create_view, list_views, get_view, update_view, delete_view (17 actions)Database schema management, multi-view configurations, batch row CRUD, and aggregations (count/sum/avg/group).Notion API
blocksget, children, append, update, delete (5 actions)Granular block operations; tree traversal and content manipulation.Notion API
workspaceinfo, search (2 actions)Global fuzzy search and workspace metadata inspection.Notion API
userslist, get, me, from_workspace (4 actions)Team members, collaborators, and bot user retrieval.Notion API
commentslist, get, create, update, delete (5 actions)Comment discussion lifecycle on pages and blocks, with workarounds for upstream OAuth 404 quirks.Notion API
content_convertmarkdown-to-blocks, blocks-to-markdown (2 directions)Pure local offline AST converter. Transforms Markdown into Notion blocks and vice versa without network calls.Offline (Token-Free)
file_uploadscreate, send, complete, retrieve, list (5 actions)Upload local files and attachments to Notion with chunked multi-part resumption.Notion API
helpTarget tool_nameCore of Tiered Token Optimization: Dynamically retrieves complete schemas and examples for any composite tool.Offline (Token-Free)
configstatus, setup_start, setup_reset, setup_complete, set, cache_clear (6 actions)Runtime Autonomy: Inspects credential health and resets or reloads configuration without restarting the client.Offline (Token-Free)

Note on Complex Arguments: Parameters typed as objects or arrays (properties, filters, sorts, etc.) accept both raw structured JSON and JSON strings to maintain compatibility across different clients.


Quick Start & Installation

1. Zero-Install with npx (Recommended)

Requires Node.js (>= 24) and a Notion integration token from Notion Integrations (starts with ntn_):

Add to your MCP client configuration (Claude Desktop, Cursor, Antigravity, Windsurf, etc.):

JSON Config
{
  "mcpServers": {
    "better-notion-mcp": {
      "command": "npx",
      "args": ["-y", "@faize555/better-notion-mcp@latest"],
      "env": {
        "NOTION_TOKEN": "ntn_your_integration_token_here"
      }
    }
  }
}

2. Global Installation via npm

Install globally on your machine:

Terminal
npm install -g @faize555/better-notion-mcp

Client configuration:

JSON Config
{
  "mcpServers": {
    "better-notion-mcp": {
      "command": "better-notion-mcp",
      "env": {
        "NOTION_TOKEN": "ntn_your_integration_token_here"
      }
    }
  }
}

3. Docker Container (Stdio Mode)

Build and run in stdio mode via Docker:

bash
# Build the Docker image
docker build -t better-notion-mcp .

# Run container
docker run --rm -i -e NOTION_TOKEN=ntn_your_integration_token_here better-notion-mcp

Configuration Reference

VariableRequiredDefaultDescription
NOTION_TOKENYes (Stdio mode)-Internal Notion integration token (ntn_...)
TRANSPORT_MODE / MCP_TRANSPORTNostdioTransport mode. Set to http for remote multi-tenant service
PORTNo8080Port for remote HTTP transport
HOSTNo0.0.0.0Bind address for remote HTTP server
PUBLIC_URLYes (HTTP mode)-Public URL of the server for OAuth redirect resolution
NOTION_OAUTH_CLIENT_IDYes (HTTP mode)-Notion Public Integration Client ID
NOTION_OAUTH_CLIENT_SECRETYes (HTTP mode)-Notion Public Integration Client Secret
CREDENTIAL_SECRETNo (HTTP mode)-32-byte hex key for EdDSA signing across container restarts

Self-Hosted Deployment: Remote OAuth 2.1

Ideal for team-wide tokenless access. Users authenticate via standard OAuth 2.1 web authorization rather than copying and pasting private tokens.

1. Create a Notion Public Integration

  1. Visit Notion Developers and create an integration;
  2. Select type Public;
  3. Set Redirect URIs to: https://<your-domain>/callback;
  4. Grant required read/write permissions and copy the Client ID and Client Secret.

2. Docker Compose Setup

Create docker-compose.yml:

docker-compose.yml
services:
  better-notion-mcp:
    image: better-notion-mcp:latest
    container_name: better-notion-mcp
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:8080"
    environment:
      - TRANSPORT_MODE=http
      - MCP_TRANSPORT=http
      - PORT=8080
      - HOST=0.0.0.0
      - PUBLIC_URL=https://<your-domain>
      - NOTION_OAUTH_CLIENT_ID=<your-client-id>
      - NOTION_OAUTH_CLIENT_SECRET=<your-client-secret>
      - CREDENTIAL_SECRET=<32-byte-hex-secret>

Tip: Generate a secret with: openssl rand -hex 32.

3. Nginx Reverse Proxy

nginx.conf
server {
    listen 443 ssl http2;
    server_name <your-domain>;

    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 300s;
    }
}

Verify service status: curl https://<your-domain>/health should return {"status":"ok"}.


Security & Sandbox Architecture

  • Data Privacy: Stdio mode runs entirely within local OS process memory without external intermediaries. HTTP mode maintains in-memory tenant isolation.
  • Credential Sanitization: The kernel filters sensitive tokens and secrets before error logs reach the model context.
  • OAuth 2.1 + PKCE S256: Tamper-proof cryptographic authorization flows ensure secure remote credential exchange.

Build from Source & Verification

Built with Bun and TypeScript:

bash
# 1. Clone repository
git clone https://github.com/one2agi/better-notion-mcp.git
cd better-notion-mcp

# 2. Install dependencies
bun install

# 3. Local development server
bun run dev

# 4. Linting and full test suite (1500+ tests)
bun run check
bun run test

Origin & Attribution

  • Upstream Origin: Originally derived from the pioneering open-source project n24q02m/better-notion-mcp by @n24q02m (now renamed to notion). We honor the original author's foundational work on Notion AST parsing and composite tool architectures!

  • Independent Enhanced Edition: Currently maintained and evolved by one2agi. We streamlined the hosting surface, focused on robust cross-platform Node.js/Docker runtimes, and optimized the suite for production-grade autonomous Agent workflows.

  • Official Website: https://one2agi.com

  • Knowledge Base: https://way.one2agi.com

  • GitHub Organization: https://github.com/one2agi


License

Licensed under the MIT License.