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

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:
| Tool | Actions | Scope & Capabilities | Token Mode |
|---|
pages | create, 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 |
databases | create, 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 |
blocks | get, children, append, update, delete (5 actions) | Granular block operations; tree traversal and content manipulation. | Notion API |
workspace | info, search (2 actions) | Global fuzzy search and workspace metadata inspection. | Notion API |
users | list, get, me, from_workspace (4 actions) | Team members, collaborators, and bot user retrieval. | Notion API |
comments | list, get, create, update, delete (5 actions) | Comment discussion lifecycle on pages and blocks, with workarounds for upstream OAuth 404 quirks. | Notion API |
content_convert | markdown-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_uploads | create, send, complete, retrieve, list (5 actions) | Upload local files and attachments to Notion with chunked multi-part resumption. | Notion API |
help | Target tool_name | Core of Tiered Token Optimization: Dynamically retrieves complete schemas and examples for any composite tool. | Offline (Token-Free) |
config | status, 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.):
{
"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:
npm install -g @faize555/better-notion-mcp
Client configuration:
{
"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:
# 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
| Variable | Required | Default | Description |
|---|
NOTION_TOKEN | Yes (Stdio mode) | - | Internal Notion integration token (ntn_...) |
TRANSPORT_MODE / MCP_TRANSPORT | No | stdio | Transport mode. Set to http for remote multi-tenant service |
PORT | No | 8080 | Port for remote HTTP transport |
HOST | No | 0.0.0.0 | Bind address for remote HTTP server |
PUBLIC_URL | Yes (HTTP mode) | - | Public URL of the server for OAuth redirect resolution |
NOTION_OAUTH_CLIENT_ID | Yes (HTTP mode) | - | Notion Public Integration Client ID |
NOTION_OAUTH_CLIENT_SECRET | Yes (HTTP mode) | - | Notion Public Integration Client Secret |
CREDENTIAL_SECRET | No (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
- Visit Notion Developers and create an integration;
- Select type Public;
- Set Redirect URIs to:
https://<your-domain>/callback;
- Grant required read/write permissions and copy the Client ID and Client Secret.
2. Docker Compose Setup
Create docker-compose.yml: