notion-mcp-server

turtleYJ/notion-mcp-server

3.2

If you are the rightful owner of notion-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Model Context Protocol (MCP) server is a specialized server designed to facilitate communication and data exchange between different machine learning models and applications.

Notion MCP Server

Claude Desktopκ³Ό Notion을 μ—°κ²°ν•˜λŠ” MCP (Model Context Protocol) μ„œλ²„μž…λ‹ˆλ‹€.

🎯 κΈ°λŠ₯

  • read_page: Notion νŽ˜μ΄μ§€ λ‚΄μš© 읽기 (ν™•μž₯된 λ§ˆν¬λ‹€μš΄ 포맷 지원)
  • create_page: μƒˆ Notion νŽ˜μ΄μ§€ 생성 (λŒ€μš©λŸ‰ λ¬Έμ„œ & λ§ˆν¬λ‹€μš΄ μ„œμ‹ 지원)

πŸ“‹ μš”κ΅¬μ‚¬ν•­

  • Node.js 18+
  • Notion Integration Token
  • Claude Desktop

πŸš€ λΉ λ₯Έ μ‹œμž‘

1. μ €μž₯μ†Œ 클둠 및 μ˜μ‘΄μ„± μ„€μΉ˜

git clone https://github.com/your-username/notion-mcp-server.git
cd notion-mcp-server
npm install

2. Notion Integration μ„€μ •

  1. Notion Developer Console 접속
  2. "New integration" 클릭
  3. κΈ°λ³Έ 정보 μž…λ ₯:
    • Name: "Claude MCP Integration"
    • Associated workspace: 본인 μ›Œν¬μŠ€νŽ˜μ΄μŠ€
    • Type: Internal
  4. "Submit" 클릭 ν›„ Integration Token 볡사
  5. μ—°κ²°ν•  νŽ˜μ΄μ§€μ—μ„œ "..." β†’ "Add connections" β†’ Integration 선택

3. Claude Desktop μ„€μ •

Claude Desktop μ„€μ • νŒŒμΌμ„ νŽΈμ§‘ν•©λ‹ˆλ‹€:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "notion": {
      "command": "node",
      "args": ["/absolute/path/to/your/notion-mcp-server/server.js"],
      "env": {
        "NOTION_TOKEN": "YOUR_NOTION_TOKEN_HERE"
      }
    }
  }
}

λ˜λŠ” config/claude_desktop_config.example.json νŒŒμΌμ„ μ°Έκ³ ν•˜μ—¬ μ„€μ •ν•˜μ„Έμš”.

4. Claude Desktop μž¬μ‹œμž‘

Claude Desktop을 μ™„μ „νžˆ μ’…λ£Œν•˜κ³  λ‹€μ‹œ μ‹œμž‘ν•˜λ©΄ MCP 도ꡬ가 μ—°κ²°λ©λ‹ˆλ‹€.

πŸ”§ μ‚¬μš©λ²•

Claude Desktopμ—μ„œ λ‹€μŒκ³Ό 같이 μš”μ²­ν•  수 μžˆμŠ΅λ‹ˆλ‹€:

νŽ˜μ΄μ§€ 읽기

"νŽ˜μ΄μ§€ ID 12345의 λ‚΄μš©μ„ μ½μ–΄μ€˜"

νŽ˜μ΄μ§€ 생성

"λΆ€λͺ¨ νŽ˜μ΄μ§€ 12345에 'μƒˆ ν”„λ‘œμ νŠΈ κ³„νš'μ΄λΌλŠ” 제λͺ©μœΌλ‘œ νŽ˜μ΄μ§€λ₯Ό λ§Œλ“€μ–΄μ€˜"

πŸ“š μž‘λ™ 원리

MCP (Model Context Protocol)

MCPλŠ” AI λͺ¨λΈκ³Ό μ™ΈλΆ€ 도ꡬ κ°„μ˜ ν‘œμ€€ν™”λœ 톡신 ν”„λ‘œν† μ½œμž…λ‹ˆλ‹€.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    MCP Protocol    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Claude        β”‚ ◄─────────────────► β”‚   MCP Server    β”‚
β”‚   Desktop       β”‚     (JSON-RPC)     β”‚   (Notion)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                               β”‚
                                               β–Ό
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚   Notion API    β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

톡신 ν”Œλ‘œμš°

  1. Initialization: Claude Desktop이 MCP μ„œλ²„μ— μ—°κ²°
  2. Capability Exchange: μ„œλ²„κ°€ μ œκ³΅ν•˜λŠ” 도ꡬ λͺ©λ‘ κ΅ν™˜
  3. Tool Invocation: Claudeκ°€ 도ꡬ 호좜 μš”μ²­
  4. Response: μ„œλ²„κ°€ κ²°κ³Ό λ°˜ν™˜

ν”„λ‘œν† μ½œ λ©”μ‹œμ§€

도ꡬ λͺ©λ‘ μš”μ²­:

{
  "method": "tools/list",
  "params": {},
  "jsonrpc": "2.0",
  "id": 1
}

도ꡬ 호좜 μš”μ²­:

{
  "method": "tools/call",
  "params": {
    "name": "read_page",
    "arguments": {
      "page_id": "12345"
    }
  },
  "jsonrpc": "2.0",
  "id": 2
}

πŸ”§ νŠΈλŸ¬λΈ”μŠˆνŒ…

문제 1: MCP SDK ν˜Έν™˜μ„± 였λ₯˜

증상:

TypeError: Cannot read properties of undefined (reading 'method')

ν•΄κ²°μ±…:

  1. @modelcontextprotocol/sdk 버전을 0.4.0으둜 κ³ μ •
  2. CallToolRequestSchema, ListToolsRequestSchema import 확인
  3. μ˜μ‘΄μ„± μž¬μ„€μΉ˜: npm install

문제 2: μ„œλ²„ μ—°κ²° μ‹€νŒ¨

증상: "Server disconnected" 둜그 λ©”μ‹œμ§€

진단 λͺ…λ Ήμ–΄:

# μ„œλ²„ ν”„λ‘œμ„ΈμŠ€ 확인
ps aux | grep "notion-mcp-server"

# 둜그 확인 (macOS)
tail -f ~/Library/Logs/Claude/mcp-server-notion.log

ν•΄κ²°μ±…:

  1. Node.js 버전 확인 (v18+ ꢌμž₯)
  2. 파일 μ ˆλŒ€ 경둜 확인
  3. μ‹€ν–‰ κΆŒν•œ μ„€μ •: chmod +x server.js
  4. ν™˜κ²½ λ³€μˆ˜ μ„€μ • 확인

문제 3: Notion API 였λ₯˜

증상: "Error: API request failed"

ν•΄κ²°μ±…:

  1. NOTION_TOKEN μž¬ν™•μΈ
  2. Integration κΆŒν•œμ΄ νŽ˜μ΄μ§€μ— μ—°κ²°λ˜μ—ˆλŠ”μ§€ 확인
  3. νŽ˜μ΄μ§€ ID ν˜•μ‹ 확인 (32자리 영숫자)

문제 4: ν…μŠ€νŠΈ 길이 μ œν•œ (2000자)

증상:

Error: body failed validation: body.children[0].paragraph.rich_text[0].text.content.length should be ≀ `2000`, instead was `3094`

ν•΄κ²°μ±…: βœ… μžλ™ 해결됨

  • κΈ΄ ν…μŠ€νŠΈλ₯Ό 1900자 λ‹¨μœ„λ‘œ μžλ™ λΆ„ν• 
  • μ•ˆμ „ν•œ 뢄할점 μžλ™ 탐지 (μ€„λ°”κΏˆ, λ¬Έμž₯ 끝, 단어 경계)

문제 5: 블둝 수 μ œν•œ (100개)

증상:

Error: body failed validation: body.children.length should be ≀ `100`, instead was `109`

ν•΄κ²°μ±…: βœ… μžλ™ 해결됨

  • λŒ€μš©λŸ‰ λ¬Έμ„œλ₯Ό 95개 블둝씩 배치 처리
  • 첫 배치둜 νŽ˜μ΄μ§€ 생성 ν›„ λ‚˜λ¨Έμ§€ 블둝 μΆ”κ°€
  • 총 블둝 수 ν”Όλ“œλ°± 제곡

문제 6: λ§ˆν¬λ‹€μš΄ μ„œμ‹ 미적용

증상: **λ³Όλ“œ** ν…μŠ€νŠΈκ°€ κ·ΈλŒ€λ‘œ ν‘œμ‹œλ¨

ν•΄κ²°μ±…: βœ… μžλ™ 해결됨

  • λ³Όλ“œ λ§ˆν¬λ‹€μš΄(**text**)을 Notion μ„œμ‹μœΌλ‘œ μžλ™ λ³€ν™˜
  • Rich Text annotations 적용
  • λͺ¨λ“  블둝 νƒ€μž…μ—μ„œ μ„œμ‹ 지원

디버깅 팁

둜그 λͺ¨λ‹ˆν„°λ§:

# macOS
tail -f ~/Library/Logs/Claude/mcp-server-notion.log ~/Library/Logs/Claude/mcp.log

직접 μ„œλ²„ ν…ŒμŠ€νŠΈ:

# μ„œλ²„ 직접 μ‹€ν–‰
NOTION_TOKEN=your_token node server.js

# ν™˜κ²½ λ³€μˆ˜ 확인
echo $NOTION_TOKEN

μ„±λŠ₯ μ΅œμ ν™”:

  • λŒ€μš©λŸ‰ λ¬Έμ„œλŠ” 배치 처리둜 인해 μΆ”κ°€ μ‹œκ°„ μ†Œμš” (λ°°μΉ˜λ‹Ή 1-2초)
  • 맀우 큰 λ¬Έμ„œλŠ” μ—¬λŸ¬ νŽ˜μ΄μ§€λ‘œ λΆ„ν•  ꢌμž₯

πŸ”’ λ³΄μ•ˆ 고렀사항

토큰 관리

  • μ ˆλŒ€ Git에 토큰 컀밋 κΈˆμ§€: .env νŒŒμΌμ€ .gitignore에 포함
  • ν™˜κ²½ λ³€μˆ˜ μ‚¬μš©: Claude Desktop μ„€μ •μ—μ„œ 토큰을 ν™˜κ²½ λ³€μˆ˜λ‘œ μ„€μ •
  • 토큰 주기적 κ°±μ‹ : λ³΄μ•ˆμ„ μœ„ν•΄ μ •κΈ°μ μœΌλ‘œ 토큰 μž¬μƒμ„±
  • .env.example ν™œμš©: μ‹€μ œ 토큰 없이 μ„€μ • ν…œν”Œλ¦Ώ 제곡

κΆŒν•œ μ œμ–΄

  • μ΅œμ†Œ κΆŒν•œ 원칙: Notion Integration에 ν•„μš”ν•œ μ΅œμ†Œν•œμ˜ κΆŒν•œλ§Œ λΆ€μ—¬
  • νŽ˜μ΄μ§€λ³„ κΆŒν•œ: ν•„μš”ν•œ νŽ˜μ΄μ§€μ—λ§Œ Integration μ—°κ²°
  • 정기적 κΆŒν•œ κ²€ν† : μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” Integration 정리

개발 ν™˜κ²½ λ³΄μ•ˆ

# 둜컬 개발 μ‹œ .env 파일 μ‚¬μš©
cp .env.example .env
# .env νŒŒμΌμ— μ‹€μ œ 토큰 μž…λ ₯ (Git에 μΆ”κ°€λ˜μ§€ μ•ŠμŒ)

μ—λŸ¬ 처리

  • 민감 정보 λ‘œκΉ… λ°©μ§€: ν† ν°μ΄λ‚˜ κ°œμΈμ •λ³΄κ°€ λ‘œκ·Έμ— λ…ΈμΆœλ˜μ§€ μ•Šλ„λ‘ 처리
  • μ μ ˆν•œ λ‘œκΉ… μˆ˜μ€€: 디버깅 정보와 λ³΄μ•ˆ 정보 ꡬ뢄
  • μ‚¬μš©μž μΉœν™”μ  였λ₯˜ λ©”μ‹œμ§€: λ‚΄λΆ€ κ΅¬ν˜„ 세뢀사항 λ…ΈμΆœ λ°©μ§€

πŸ”§ 개발

ν”„λ‘œμ νŠΈ ꡬ쑰

notion-mcp-server/
β”œβ”€β”€ server.js           # MCP μ„œλ²„ 메인 파일
β”œβ”€β”€ package.json        # ν”„λ‘œμ νŠΈ μ„€μ • 및 μ˜μ‘΄μ„±
β”œβ”€β”€ package-lock.json   # μ˜μ‘΄μ„± 잠금 파일
└── README.md          # ν”„λ‘œμ νŠΈ λ¬Έμ„œ

μ½”λ“œ ꡬ쑰

server.js의 μ£Όμš” ꡬ성 μš”μ†Œ:

  1. Import 및 μ΄ˆκΈ°ν™”

    import { Server } from "@modelcontextprotocol/sdk/server/index.js";
    import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
    import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
    import { Client } from "@notionhq/client";
    
  2. 핡심 μœ ν‹Έλ¦¬ν‹° ν•¨μˆ˜λ“€

    function splitTextIntoBlocks(content, maxLength = 1900)  // ν…μŠ€νŠΈ λΆ„ν• 
    function parseRichText(text)                             // λ§ˆν¬λ‹€μš΄ β†’ Rich Text λ³€ν™˜
    function parseMarkdownToBlocks(content)                  // λ§ˆν¬λ‹€μš΄ β†’ Notion 블둝 λ³€ν™˜
    function richTextToMarkdown(richTextArray)              // Rich Text β†’ λ§ˆν¬λ‹€μš΄ λ³€ν™˜
    function blockToText(block)                              // Notion 블둝 β†’ ν…μŠ€νŠΈ λ³€ν™˜
    
  3. Notion Client μ„€μ •

    const notion = new Client({
      auth: process.env.NOTION_TOKEN,
    });
    
  4. MCP Server μ΄ˆκΈ°ν™”

    const server = new Server({
      name: "notion-mcp-server",
      version: "1.0.0",
    }, {
      capabilities: { tools: {} },
    });
    
  5. 도ꡬ λͺ©λ‘ ν•Έλ“€λŸ¬

    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools: [/* 도ꡬ μ •μ˜ */] };
    });
    
  6. 도ꡬ 호좜 ν•Έλ“€λŸ¬ (배치 처리 지원)

    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      // read_page: ν™•μž₯된 블둝 νƒ€μž… 지원
      // create_page: λŒ€μš©λŸ‰ λ¬Έμ„œ 배치 처리
    });
    
  7. STDIO 톡신 μ„€μ •

    async function run() {
      const transport = new StdioServerTransport();
      await server.connect(transport);
    }
    

μ§€μ›ν•˜λŠ” Notion 블둝 νƒ€μž…

ν˜„μž¬ λ‹€μŒ 블둝 νƒ€μž…μ„ μ§€μ›ν•©λ‹ˆλ‹€:

읽기 지원 (read_page)
  • paragraph: 일반 ν…μŠ€νŠΈ (λ³Όλ“œ, 이타릭, μ½”λ“œ, μ·¨μ†Œμ„ , 밑쀄, 링크 μ„œμ‹ 포함)
  • heading_1/2/3: 제λͺ© (# ## ### ν˜•νƒœλ‘œ λ³€ν™˜)
  • bulleted_list_item: 뢈릿 리슀트 (β€’ ν˜•νƒœ, 쀑첩 지원)
  • numbered_list_item: 번호 리슀트 (1. ν˜•νƒœ, 쀑첩 지원)
  • code: μ½”λ“œ 블둝 (언어별 ꡬ문 κ°•μ‘°)
  • quote: 인용ꡬ (> ν˜•νƒœ)
  • divider: ꡬ뢄선 (---)
  • callout: μ½œμ•„μ›ƒ (이λͺ¨μ§€ + κ°•μ‘° ν…μŠ€νŠΈ)
  • toggle: μ ‘κΈ°/펼치기 μ„Ήμ…˜
  • to_do: μ²΄ν¬λ°•μŠ€ ν•­λͺ©
생성 지원 (create_page)
  • λ§ˆν¬λ‹€μš΄ νŒŒμ‹±: # ## ### (제λͺ©), - * (뢈릿 리슀트), --- (ꡬ뢄선)
  • ν…μŠ€νŠΈ μ„œμ‹: **λ³Όλ“œ** μžλ™ λ³€ν™˜
  • λŒ€μš©λŸ‰ λ¬Έμ„œ: 100개 이상 블둝 μžλ™ 배치 처리
  • κΈ΄ ν…μŠ€νŠΈ: 2000자 이상 μžλ™ λΆ„ν•  처리

πŸš€ ν™•μž₯ κ°€λŠ₯μ„±

MCP ν”„λ‘œν† μ½œμ„ 톡해 λ‹€μ–‘ν•œ μ„œλΉ„μŠ€μ™€ 연동할 수 μžˆμŠ΅λ‹ˆλ‹€:

λ°μ΄ν„°λ² μ΄μŠ€

  • PostgreSQL, MongoDB
  • Redis, Elasticsearch

ν΄λΌμš°λ“œ μ„œλΉ„μŠ€

  • AWS (S3, Lambda, DynamoDB)
  • GCP (BigQuery, Cloud Storage)
  • Azure (Cosmos DB, Functions)

개발 도ꡬ

  • GitHub (이슈, PR 관리)
  • GitLab (CI/CD νŒŒμ΄ν”„λΌμΈ)
  • Jira (ν‹°μΌ“ 관리)

생산성 도ꡬ

  • Slack (λ©”μ‹œμ§€, 채널 관리)
  • Trello (λ³΄λ“œ, μΉ΄λ“œ 관리)
  • Google Workspace (Drive, Calendar)

πŸ“„ λΌμ΄μ„ μŠ€

MIT License

🀝 κΈ°μ—¬

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ž 지원

λ¬Έμ œκ°€ λ°œμƒν•˜κ±°λ‚˜ 질문이 μžˆμœΌμ‹œλ©΄:

  1. Issues에 등둝
  2. 둜그 파일과 ν•¨κ»˜ μƒμ„Έν•œ 증상 μ„€λͺ…
  3. 운영체제, Node.js 버전 정보 포함

πŸ”— κ΄€λ ¨ 링크


Note: 이 ν”„λ‘œμ νŠΈλŠ” Anthropic의 MCP ν”„λ‘œν† μ½œμ„ μ‚¬μš©ν•˜μ—¬ Claude Desktopκ³Ό Notion을 μ—°κ²°ν•©λ‹ˆλ‹€. 곡식 지원이 μ•„λ‹ˆλ©°, 개인 ν”„λ‘œμ νŠΈλ‘œ κ°œλ°œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.