Cover image
Try Now
2025-01-14

一个基于Python的MCP,用于将概念功能暴露于LLM(Claude)

3 years

Works with Finder

1

Github Watches

9

Github Forks

22

Github Stars

Notion API MCP

A Model Context Protocol (MCP) server that provides advanced todo list management and content organization capabilities through Notion's API. MCP enables AI models to interact with external tools and services, allowing seamless integration with Notion's powerful features.

MCP Overview

Python-based MCP server that enables AI models to interact with Notion's API, providing:

  • Todo Management: Create, update, and track tasks with rich text, due dates, priorities, and nested subtasks
  • Database Operations: Create and manage Notion databases with custom properties, filters, and views
  • Content Organization: Structure and format content with Markdown support, hierarchical lists, and block operations
  • Real-time Integration: Direct interaction with Notion's workspace, pages, and databases through clean async implementation

Full feature list →

Quick Start

# Clone and setup
git clone https://github.com/yourusername/notion-api-mcp.git
cd notion-api-mcp
uv venv && source .venv/bin/activate

# Install and configure
uv pip install -e .
cp .env.integration.template .env

# Add your Notion credentials to .env:
# NOTION_API_KEY=ntn_your_integration_token_here
# NOTION_PARENT_PAGE_ID=your_page_id_here  # For new databases
# NOTION_DATABASE_ID=your_database_id_here  # For existing databases

# Run the server
python -m notion_api_mcp

Getting Started

1. Create a Notion Integration

  1. Go to https://www.notion.so/my-integrations
  2. Click "New integration"
  3. Name your integration (e.g., "My MCP Integration")
  4. Select the workspace where you'll use the integration
  5. Copy the "Internal Integration Token" - this will be your NOTION_API_KEY
    • Should start with "ntn_"

2. Set Up Notion Access

You'll need either a parent page (for creating new databases) or an existing database ID:

Option A: Parent Page for New Databases

  1. Open Notion in your browser
  2. Create a new page or open an existing one where you want to create databases
  3. Click the ••• menu in the top right
  4. Select "Add connections" and choose your integration
  5. Copy the page ID from the URL - it's the string after the last slash and before the question mark
    • Example: In https://notion.so/myworkspace/123456abcdef..., the ID is 123456abcdef...
    • This will be your NOTION_PARENT_PAGE_ID

Option B: Existing Database

  1. Open your existing Notion database
  2. Make sure it's connected to your integration (••• menu > Add connections)
  3. Copy the database ID from the URL
    • Example: In https://notion.so/myworkspace/123456abcdef...?v=..., the ID is 123456abcdef...
    • This will be your NOTION_DATABASE_ID

3. Install the MCP Server

  1. Create virtual environment:
cd notion-api-mcp
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
uv pip install -e .
  1. Configure environment:
cp .env.integration.template .env
  1. Edit .env with your Notion credentials:
NOTION_API_KEY=ntn_your_integration_token_here

# Choose one or both of these depending on your needs:
NOTION_PARENT_PAGE_ID=your_page_id_here  # For creating new databases
NOTION_DATABASE_ID=your_database_id_here  # For working with existing databases

4. Configure Claude Desktop

IMPORTANT: While the server supports both .env files and environment variables, Claude Desktop specifically requires configuration in its config file to use the MCP.

Add to Claude Desktop's config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "notion-api": {
      "command": "/path/to/your/.venv/bin/python",
      "args": ["-m", "notion_api_mcp"],
      "env": {
        "NOTION_API_KEY": "ntn_your_integration_token_here",
        
        // Choose one or both:
        "NOTION_PARENT_PAGE_ID": "your_page_id_here",
        "NOTION_DATABASE_ID": "your_database_id_here"
      }
    }
  }
}

Note: Even if you have a .env file configured, you must add these environment variables to the Claude Desktop config for Claude to use the MCP. The .env file is primarily for local development and testing.

Documentation

Development

The server uses modern Python async features throughout:

  • Type-safe configuration using Pydantic models
  • Async HTTP using httpx for better performance
  • Clean MCP integration for exposing Notion capabilities
  • Proper resource cleanup and error handling

Debugging

The server includes comprehensive logging:

  • Console output for development
  • File logging when running as a service
  • Detailed error messages
  • Request/response logging at debug level

Set PYTHONPATH to include the project root when running directly:

PYTHONPATH=/path/to/project python -m notion_api_mcp

Future Development

Planned enhancements:

  1. Performance Optimization

    • Add request caching
    • Optimize database queries
    • Implement connection pooling
  2. Advanced Features

    • Multi-workspace support
    • Batch operations
    • Real-time updates
    • Advanced search capabilities
  3. Developer Experience

    • Interactive API documentation
    • CLI tools for common operations
    • Additional code examples
    • Performance monitoring
  4. Testing Enhancements

    • Performance benchmarks
    • Load testing
    • Additional edge cases
    • Extended integration tests

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Lists Tailwind CSS classes in monospaced font

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

    Reviews

    2 (1)
    Avatar
    user_CDPcdoPr
    2025-04-17

    I have been using the notion-api-mcp by pbohannon, and it has completely transformed my workflow. This tool seamlessly integrates with Notion, allowing me to automate tasks and retrieve data effortlessly. The documentation is clear, and the support community is very helpful. Highly recommend it for anyone looking to boost their productivity! Check it out at: https://github.com/pbohannon/notion-api-mcp.