A comprehensive Model Context Protocol (MCP) server for Notion integration with enhanced functionality, robust error handling, production-ready features, and bulletproof validation. - โ Search: Find pages and databases with advanced filtering - โ Page Operations: Create, read, update pages with full content support - โ Content Management: Add paragraphs, headings, bullet points, todos, links, and
Add this skill
npx mdskills install ankitmalik84/agentic-longterm-memoryComprehensive MCP server with extensive Notion integration, analytics, and production-ready features
A comprehensive Model Context Protocol (MCP) server for Notion integration with enhanced functionality, robust error handling, production-ready features, and bulletproof validation.
notion_mcp_server/
โโโ ๐ __init__.py # Package initialization
โโโ ๐ง config.py # Configuration management
โโโ ๐ api_serverV2.py # FastAPI REST API server (49KB)
โโโ ๐ป serverV2.py # Interactive CLI server
โโโ โ๏ธ core_operations.py # Basic CRUD operations
โโโ ๐ analytics_operations.py # Analytics and metrics
โโโ ๐ bulk_operations.py # Bulk processing
โโโ โ๏ธ update_operations.py # Content updates (35KB)
โโโ ๐ ๏ธ notion_utils.py # Utility functions
โโโ ๐งช test_server.py # Comprehensive test suite (48KB)
โโโ ๐ README.md # This file
pip install notion-client fastapi uvicorn python-dotenv pydantic requests
.env file in your project root:# Required
NOTION_TOKEN=ntn_your_integration_token_here
# Optional Server Settings
HOST=0.0.0.0
PORT=8081
DEBUG=false
# Optional Feature Settings
MAX_PAGE_SIZE=100
DEFAULT_PAGE_SIZE=20
MAX_CONTENT_LENGTH=2000
ENABLE_ANALYTICS=true
ENABLE_BULK_OPERATIONS=true
# Optional Logging
LOG_LEVEL=INFO
ntn_)Start the server:
python -m notion_mcp_server.api_serverV2
Server will be available at:
http://localhost:8081http://localhost:8081/docshttp://localhost:8081/healthpython -m notion_mcp_server.serverV2
from notion_mcp_server import ComprehensiveNotionServer
import asyncio
async def example():
server = ComprehensiveNotionServer("your_notion_token")
await server.core_ops.search_content("search term")
asyncio.run(example())
POST /api/search
Content-Type: application/json
{
"query": "search term",
"page_size": 10
}
POST /api/page/create
Content-Type: application/json
{
"title": "My New Page",
"content": "Initial content",
"parent_id": "optional-parent-page-id"
}
POST /api/page/read
Content-Type: application/json
{
"identifier": "page-id-or-title"
}
POST /api/page/add-content
Content-Type: application/json
{
"page_id": "page-id",
"content_type": "paragraph",
"content": "New paragraph content"
}
Supported content types:
paragraph - Regular textheading_1 - Large headingheading_2 - Medium headingheading_3 - Small headingbulleted_list_item - Bullet pointto_do - Checkbox itembookmark - External website link (NEW)link_to_page - Internal page link (NEW)Add Bookmark (External Link):
POST /api/page/add-content
Content-Type: application/json
{
"page_id": "page-id",
"content_type": "bookmark",
"content": "OpenAI Website",
"url": "https://www.openai.com"
}
Add Link to Page (Internal Link):
POST /api/page/add-content
Content-Type: application/json
{
"page_id": "page-id",
"content_type": "link_to_page",
"content": "Link to related page",
"page_reference": "target-page-id-or-title"
}
POST /api/page/bulk-add-content
Content-Type: application/json
{
"page_id": "page-id",
"items": [
{
"content_type": "heading_2",
"content": "Section Title"
},
{
"content_type": "paragraph",
"content": "Paragraph content"
},
{
"content_type": "bookmark",
"url": "https://example.com",
"content": "External Link"
},
{
"content_type": "link_to_page",
"page_reference": "other-page-id",
"content": "Internal Link"
},
{
"content_type": "to_do",
"content": "Task item",
"checked": false
}
]
}
POST /api/analytics
Content-Type: application/json
{
"type": "workspace"
}
Analytics types: workspace, content, activity, database
POST /api/bulk
Content-Type: application/json
{
"operation": "list",
"query": "{\"limit\": 10, \"include_block_counts\": false}"
}
Optimization options:
limit: Number of pages to process (1-50)include_block_counts: Whether to calculate block counts (slower)Operations: list, analyze, create
POST /api/agent/query
Content-Type: application/json
{
"action": "search",
"parameters": {
"query": "search term",
"page_size": 10
}
}
Available actions: search, read_page, create_page, add_content, bulk_add_content, analytics, bulk_operations
Run the comprehensive test suite:
# Start the server first
python -m notion_mcp_server.api_serverV2
# In another terminal, run tests
cd src/notion_mcp_server
python test_server.py
Test Coverage (1,158 lines, 13+ categories):
Test Features:
| Variable | Default | Description |
|---|---|---|
NOTION_TOKEN | (required) | Your Notion integration token |
HOST | 0.0.0.0 | Server host address |
PORT | 8081 | Server port |
DEBUG | false | Enable debug mode |
MAX_PAGE_SIZE | 100 | Maximum results per page |
DEFAULT_PAGE_SIZE | 20 | Default results per page |
MAX_CONTENT_LENGTH | 2000 | Maximum content block length |
ENABLE_ANALYTICS | true | Enable analytics endpoints |
ENABLE_BULK_OPERATIONS | true | Enable bulk operations |
LOG_LEVEL | INFO | Logging level |
The server automatically validates all configuration on startup and provides clear error messages for invalid settings.
import requests
# Search for content
response = requests.post("http://localhost:8081/api/agent/query", json={
"action": "search",
"parameters": {"query": "project notes"}
})
# Create a new page with links
response = requests.post("http://localhost:8081/api/agent/query", json={
"action": "create_page",
"parameters": {
"title": "AI Generated Page",
"content": "This page was created by an AI agent"
}
})
# Add bookmark to page
response = requests.post("http://localhost:8081/api/agent/query", json={
"action": "add_content",
"parameters": {
"page_id": "page-id",
"content_type": "bookmark",
"content": "Useful Resource",
"url": "https://example.com"
}
})
# Already integrated in your chatbot_agentic_v3.py!
# Enhanced with ALL new functions:
# Core functions
server.notion_search_content()
server.notion_read_page()
server.notion_create_page()
# Content addition with links
server.notion_add_paragraph()
server.notion_add_heading()
server.notion_add_bullet_point()
server.notion_add_todo()
# Smart content helpers
server.notion_add_structured_content() # Multi-section content
server.notion_add_smart_content() # AI-friendly content parsing
# Bulk operations
server.notion_bulk_create_pages()
server.notion_bulk_list_pages()
server.notion_bulk_analyze_pages()
# Analytics
server.notion_workspace_analytics()
server.notion_content_analytics()
server.notion_activity_analytics()
The server provides detailed error messages for all scenarios:
git checkout -b feature-namepython test_server.pyTesting Requirements:
If you encounter issues:
/health endpoint to verify server statuspython test_server.py to identify specific issuesCommon Issues:
For direct support or questions:
Feel free to reach out for:
This project is part of the Agentic Long-Term Memory system.
๐ Your Notion MCP Server V2.1 is bulletproof and production-ready!
โก New in V2.1:
๐ Quality Metrics:
Install via CLI
npx mdskills install ankitmalik84/agentic-longterm-memoryNotion MCP Server V2 ๐ is a free, open-source AI agent skill. A comprehensive Model Context Protocol (MCP) server for Notion integration with enhanced functionality, robust error handling, production-ready features, and bulletproof validation. - โ Search: Find pages and databases with advanced filtering - โ Page Operations: Create, read, update pages with full content support - โ Content Management: Add paragraphs, headings, bullet points, todos, links, and
Install Notion MCP Server V2 ๐ with a single command:
npx mdskills install ankitmalik84/agentic-longterm-memoryThis downloads the skill files into your project and your AI agent picks them up automatically.
Notion MCP Server V2 ๐ works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.