
Notion MCP 通过 Markdown 将 AI 代理连接到 Notion |读写 Notion Markdown
概览
面向生产环境的MCP服务器,通过标准markdown而非原始API JSON将AI代理连接到Notion。 代理负责读写GFM markdown。服务器负责块转换、数据库模式映射、OAuth以及可选的Redis支持持久化,用于多实例部署。 - — 工具处理程序保持server.ts以保持稳定的公共MCP合同;支持模块处理跨领域问题。- — 缓存存储抽象允许内存内(默认)或Redis后端,而不更改Notion客户端逻辑。- — 如果Redis已配置但无法访问,服务器会记录警告并继续内存内/文件持久化。 - Node.js 20+ - 一个与 Notion 共享页面的集成 在从克隆的检查点运行时,将 .env.example 复制到 .env: 在无法创建符号链接的平台上(Windows无开发者模式常见),依赖符号链接的安全测试会自动跳过。 1. 分支仓库并从主节点创建一个功能分支 2.
概述(AI 翻译)
面向生产环境的MCP服务器,通过标准markdown而非原始API JSON将AI代理连接到Notion。
代理负责读写GFM markdown。服务器负责块转换、数据库模式映射、OAuth以及可选的Redis支持持久化,用于多实例部署。
特色亮点
| 能力 | 详情 |
|---|---|
| Markdown 优先输入输出 | 42 个 MCP 工具;代理从不构建 Notion 块 JSON |
| 往返保真度 | 24种块类型,包括开关、列、呼叫、表格、上传 |
| 数据库人体工学 | 写入{ "Status": "Done" } — 模式转换是自动的 |
| 双重传输 | Stdio(API令牌)和HTTP(OAuth或承载保护静态令牌) |
| 安全默认 | 内容通知前缀,URL净化,工作区根文件包含 |
| 可选Redis | 共享模式缓存和OAuth令牌持久性,支持优雅的备份 |
| CLI配置文件 | 通过easy-notion支持的低上下文Notion访问,支持可读/读写模式 |
建筑
请求工作流程(工具调用)
项目结构
设计决策
- 单一服务器模块 — 工具处理器仍保留在“服务器”中。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
easy-notion-mcp
Production-oriented MCP server that connects AI agents to Notion through standard markdown instead of raw API JSON.
Agents read and write GFM markdown. The server handles block conversion, database schema mapping, OAuth, and optional Redis-backed persistence for multi-instance deployments.
Feature highlights
| Capability | Details |
|---|---|
| Markdown-first I/O | 42 MCP tools; agents never construct Notion block JSON |
| Round-trip fidelity | 24 block types including toggles, columns, callouts, tables, uploads |
| Database ergonomics | Write { "Status": "Done" } — schema conversion is automatic |
| Dual transport | Stdio (API token) and HTTP (OAuth or bearer-protected static token) |
| Security defaults | Content-notice prefix, URL sanitization, workspace-root file containment |
| Optional Redis | Shared schema cache and OAuth token persistence with graceful fallback |
| CLI profiles | Low-context Notion access via easy-notion with readonly/readwrite modes |
Architecture
flowchart TB
subgraph clients [MCP Clients]
CC[Claude Code / Cursor]
HTTP[HTTP MCP clients]
end
subgraph transport [Transport Layer]
STDIO[index.ts — stdio]
HTTP_SRV[http.ts — Express]
end
subgraph core [Application Core]
SRV[server.ts — MCP tools & resources]
NC[notion-client.ts — Notion SDK wrapper]
MD[markdown converters]
end
subgraph persistence [Persistence — optional]
MEM[(In-memory cache)]
REDIS[(Redis)]
FS[(Encrypted token files)]
end
CC --> STDIO
HTTP --> HTTP_SRV
STDIO --> SRV
HTTP_SRV --> SRV
SRV --> NC
SRV --> MD
NC --> MEM
NC --> REDIS
HTTP_SRV --> FS
HTTP_SRV --> REDIS
Request workflow (tool call)
sequenceDiagram
participant Agent
participant MCP as MCP Server
participant Cache as Cache Store
participant Notion as Notion API
Agent->>MCP: tools/call (e.g. read_page)
MCP->>Notion: blocks.children.list (paginated)
Notion-->>MCP: block tree
MCP->>MCP: blocks → markdown
MCP-->>Agent: { markdown, warnings? }
Agent->>MCP: tools/call (add_database_entry)
MCP->>Cache: get schema:dbId
alt cache miss
Cache->>Notion: dataSources.retrieve
Notion-->>Cache: schema
Cache-->>MCP: schema
else cache hit
Cache-->>MCP: schema
end
MCP->>MCP: convert property values
MCP->>Notion: pages.create
Notion-->>MCP: page
MCP-->>Agent: { id, url }
Project structure
easy-notion-mcp/
├── src/
│ ├── index.ts # Stdio entry point
│ ├── http.ts # HTTP/OAuth entry point
│ ├── cli.ts # Profile-based CLI
│ ├── server.ts # MCP tool & resource handlers
│ ├── notion-client.ts # Notion SDK integration
│ ├── config/env.ts # Typed environment parsing
│ ├── logging/logger.ts # Structured logging
│ ├── persistence/ # Cache + Redis integration
安装
npx -y easy-notion-mcp配置
{
"mcpServers": {
"notion": {
"command": "npx",
"args": ["-y", "easy-notion-mcp"],
"env": {
"NOTION_TOKEN": "ntn_your_integration_token"
}
}
}
}