GitHub - ccabanillas/notion-mcp: A Model Context Protocol (MCP) server implementation for Notion integration, providing a standardized interface for interacting with Notion's API.
Service

GitHub - ccabanillas/notion-mcp: A Model Context Protocol (MCP) server implementation for Notion integration, providing a standardized interface for interacting with Notion's API.

ccabanillas
2025.04.14
·GitHub·by Anonymous
#Notion API#MCP#Python#Server

Key Points

  • 1The `notion-mcp` project provides a Model Context Protocol (MCP) server that acts as a standardized interface for interacting with Notion's API, primarily designed for clients like Claude Desktop.
  • 2This server enables users to list, query, and manage Notion databases, create and update pages, search across the Notion workspace, and retrieve database details and block children.
  • 3To use it, users must install the server, configure a `.env` file with a Notion API key, and ensure their Notion databases are shared with the integration.

The document describes notion-mcp, a server-side implementation of the Model Context Protocol (MCP) designed to integrate with Notion's API. Its primary purpose is to provide a standardized, MCP-compliant interface for interacting with Notion workspace data, making it compatible with MCP clients such as Claude Desktop.

The core methodology involves establishing a bridge between MCP requests from clients and the Notion API. The notion-mcp server acts as a middleware: it receives requests formulated according to the MCP 1.6.0 specification, translates these into corresponding Notion API calls, processes the Notion API responses, and then formats the data back into MCP-compliant payloads for the client.

Key functionalities provided by the server include:

  • Listing and querying Notion databases, allowing programmatic access to database contents.
  • Creating and updating Notion pages, enabling data manipulation within the workspace.
  • Performing searches across the entire Notion workspace, facilitating discovery of pages and databases.
  • Retrieving detailed information about Notion databases and their associated block children, providing granular access to content structure.

Technically, the server leverages several robust Python libraries and programming paradigms:

  • Notion API Interaction: It utilizes a dedicated client (src/notion_mcp/client.py) to communicate with Notion's API (specifically, version 2022-02-22). This client handles the HTTP requests and responses.
  • Asynchronous Operations: The implementation fully supports async/await patterns using the httpx library, ensuring non-blocking I/O for efficient handling of concurrent requests to the Notion API. This allows the server to remain responsive even during network latency or heavy load.
  • Type Safety and Data Validation: Pydantic v2 models (src/notion_mcp/models/notion.py) are extensively used to define the structure of Notion objects (e.g., pages, databases, blocks) and the incoming/outgoing MCP request/response payloads. This enforces strict type checking and data validation at runtime, contributing to robust and predictable data handling.
  • Server Implementation: The main MCP server logic resides in src/notion_mcp/server.py, which is responsible for routing MCP requests to the appropriate Notion API calls and formatting responses. The entry point for running the server is src/notion_mcp/__main__.py.
  • Error Handling: The server incorporates proper error handling mechanisms with detailed logging, aiding in debugging and maintaining reliability.

For operation, the server requires a Notion integration token, which must be created through the Notion developer console (notion.so/my-integrations) with appropriate read/write capabilities. This token is then configured as an environment variable (NOTION_API_KEY) within a .env file. Furthermore, for the server to access specific Notion databases, those databases must be explicitly shared with the created Notion integration.

Installation can be performed manually by cloning the repository and installing dependencies via uv or standard venv/pip, or automatically via the Smithery CLI (npx -y @smithery/cli install @ccabanillas/notion-mcp --client claude). Integration with Claude Desktop involves configuring the claude_desktop_config.json file to specify the server's command, arguments, and current working directory.

The project is licensed under the MIT License. Troubleshooting guidance focuses on verifying the Notion API key, ensuring correct database permissions, and confirming accurate Claude Desktop configuration and server operation.