CN

ccabanillas/notion-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

111 stars 23 forks 质量 61 趋势 15MIT

ccabanillas/notion-mcp 是从 https://github.com/ccabanillas/notion-mcp. 导入的 MCP 服务器候选

概览

ccabanillas/notion-mcp 是从 https://github.com/ccabanillas/notion-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

模型上下文协议(MCP)服务器实现,用于与 Notion 集成,提供与 Notion API 交互的标准化接口。兼容 Claude Desktop 及其他 MCP 客户端。

特色

  • 列表和查询Notion数据库
  • 创建和更新页面
  • 跨 Notion 工作区搜索
  • 获取数据库详情并屏蔽子节点
  • httpx 的全异步/等待支持
  • 与Pydantic v2型号兼容类型安全
  • 正确的错误处理和详细记录
  • 兼容MCP 1.6.0

安装

通过Smithery安装

通过Smithery自动安装Claude Desktop的Notion集成服务器:

手动安装

  1. 克隆仓库:

  2. 创建虚拟环境并安装依赖关系(使用UV):

或者,使用标准venv:

  1. 在项目根创建 .env 文件:

用途

  1. 测试服务器(应无错误运行):

  2. 要与 Claude Desktop 一起使用,请调整你的 claude_desktop_config.json 文件(macOS 上的 ~/Library/Application Support/Claude/claude_desktop_config.json):

请务必用你的实际家庭目录路径替换/Users/username/。

发展

项目结构

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Notion MCP Server

A Model Context Protocol (MCP) server implementation for Notion integration, providing a standardized interface for interacting with Notion’s API. Compatible with Claude Desktop and other MCP clients.

Features

  • List and query Notion databases
  • Create and update pages
  • Search across Notion workspace
  • Get database details and block children
  • Full async/await support with httpx
  • Type-safe with Pydantic v2 models
  • Proper error handling with detailed logging
  • Compatibility with MCP 1.6.0

Installation

Installing via Smithery

To install Notion Integration Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @ccabanillas/notion-mcp --client claude

Manual Installation

  1. Clone the repository:
git clone https://github.com/ccabanillas/notion-mcp.git
cd notion-mcp
  1. Create a virtual environment and install dependencies (using uv):
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e .

Alternatively, using standard venv:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .
  1. Create a .env file in the project root:
NOTION_API_KEY=your_notion_integration_token

Usage

  1. Test the server (it should run without errors):
python -m notion_mcp
  1. To use it with Claude Desktop, adjust your claude_desktop_config.json file (located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
  "servers": {
    "notion-mcp": {
      "command": "/Users/username/Projects/notion-mcp/.venv/bin/python",
      "args": ["-m", "notion_mcp"],
      "cwd": "/Users/username/Projects/notion-mcp"
    }
  }
}

Be sure to replace /Users/username/ with your actual home directory path.

Development

Project Structure

notion-mcp/
├── src/
│   └── notion_mcp/
│       ├── models/
│       │   ├── __init__.py
│       │   └── notion.py      # Pydantic models for Notion objects
│       ├── __init__.py        
│       ├── __main__.py        # Entry point
│       ├── client.py          # Notion API client
│       └── server.py          # MCP server implementation
├── .env                       # Environment variables (add your Notion API key here)
├── .gitignore
├── pyproject.toml             # Project dependencies
└── README.md

Running Tests

pytest

Configuration

The server requires a Notion integration token. To set this up:

  1. Go to https://www.notion.so/my-integrations
  2. Create a new integration with appropriate capabilities (read/write as needed)
  3. Copy the integration token
  4. Add it to your .env file in the project root directory:
NOTION_API_KEY=your_notion_integration_token
在 GitHub 查看完整 README

安装

npx -y @smithery/cli install @ccabanillas/notion-mcp --client claude
新手?先看 mcpskill.org 教程 →