Notion-MCP-Server

Kumala3/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 dayong@mcphub.com.

The Notion MCP Server for ChatGPT is a Model Context Protocol server that integrates Notion with ChatGPT, providing controlled access to specific Notion pages.

Tools
2
Resources
0
Prompts
0

Notion MCP Server for ChatGPT

A Model Context Protocol (MCP) server that connects your Notion account with ChatGPT, allowing controlled access to specific Notion pages.

Features

  • 🔒 Page-specific access control - Only grant access to specific Notion pages
  • 🔍 Search functionality - Search across your authorized Notion pages
  • 📄 Fetch full content - Retrieve complete page content including blocks
  • 🔐 OAuth support - Secure authentication with Notion
  • 🚀 FastMCP powered - Built with FastMCP for easy deployment

Architecture

This MCP server implements two required tools:

  1. search - Search across authorized Notion pages

    • Returns: {results: [{id, title, url}]}
  2. fetch - Retrieve full content of a specific page

    • Returns: {id, title, text, url, metadata}

Setup

Prerequisites

  • Python 3.8+
  • Notion account
  • Notion Integration (API key)

Installation

  1. Clone this repository:
git clone <your-repo-url>
cd ChatGPT\ Notion\ MCP\ Server
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file with your configuration:
NOTION_API_KEY=your_notion_api_key
ALLOWED_PAGE_IDS=page_id_1,page_id_2,page_id_3
PORT=8000

Getting Your Notion API Key

  1. Go to https://www.notion.so/my-integrations
  2. Click "New integration"
  3. Give it a name (e.g., "ChatGPT MCP Server")
  4. Copy the "Internal Integration Token"
  5. Share specific pages with your integration:
    • Open each page you want to grant access to
    • Click "Share" → "Invite" → Select your integration

Getting Page IDs

  1. Open a Notion page in your browser
  2. The URL will look like: https://www.notion.so/Page-Title-32charPageID
  3. Copy the 32-character ID at the end
  4. Add multiple page IDs to ALLOWED_PAGE_IDS (comma-separated)

Running the Server

Local Development

python server.py

The server will start on http://localhost:8000

Deploy to Replit

  1. Import this repository to Replit
  2. Add environment variables in Replit Secrets
  3. Run the project

Connecting to ChatGPT

Via ChatGPT Settings

  1. Open ChatGPT Settings → Connectors
  2. Add a new MCP server
  3. Enter your server URL (e.g., https://your-server.repl.co/sse/)
  4. Add the search and fetch tools

Via API (Deep Research)

curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "o4-mini-deep-research",
    "input": [...],
    "tools": [
      {
        "type": "mcp",
        "server_label": "notion",
        "server_url": "https://your-server.com/sse/",
        "allowed_tools": ["search", "fetch"],
        "require_approval": "never"
      }
    ]
  }'

Security Considerations

  • ⚠️ Only add page IDs for pages you want ChatGPT to access
  • 🔒 Keep your NOTION_API_KEY secret
  • 🛡️ Review the OpenAI MCP Security Guidelines
  • ✅ Use HTTPS in production
  • 🔐 Consider implementing OAuth for multi-user scenarios

Testing

Test your server locally:

# Search test
curl http://localhost:8000/test-search?query=test

# Fetch test
curl http://localhost:8000/test-fetch?page_id=YOUR_PAGE_ID

Troubleshooting

"Page not found" error

  • Ensure the page is shared with your integration
  • Verify the page ID is in ALLOWED_PAGE_IDS

"Unauthorized" error

  • Check your NOTION_API_KEY is correct
  • Verify the integration has access to the pages

Connection issues

  • Ensure your server is publicly accessible
  • Check firewall settings
  • Verify HTTPS is enabled (required for production)