Skip to main content

LangChain Notion Tools

PyPI Build Coverage License Docs

LangChain Notion Tools is an external integration package that gives LangChain agents read and write access to Notion via the official Notion API. Built for the LangChain documentation ecosystem, it ships a polished developer experience:

  • 🔍 NotionSearchTool for locating pages and databases with LLM-friendly output.
  • ✍️ NotionWriteTool for creating and updating pages with rich blocks, property updates, and dry-run previews.
  • 🧱 Block helper utilities and a Markdown-to-Notion converter (from_text) to keep prompts terse.
  • 🛠️ A tiny CLI (notion-search, notion-write) to debug flows without leaving the terminal.
  • 📚 MkDocs-based documentation with doctested examples and JSON schemas ready for tool-calling LLMs.

Status: Actively developed. Contributions and feedback are welcome!


Installation

pip install langchain-notion-tools

Developers can install with extras for linting, typing, and doctests:

pip install -e .[dev]

Supported block helpers

Helper Block type Description
paragraph(text) paragraph Standard rich-text paragraph
heading_1/2/3(text) heading_1/2/3 Headings with descending emphasis
bulleted_list_item(text) bulleted_list_item Bulleted list entries
numbered_list_item(text) numbered_list_item Ordered list entries
to_do(text, checked=False) to_do Task items with optional checkbox
toggle(text, children=None) toggle Collapsible toggles with nested blocks
callout(text, icon=None) callout Callouts with optional icon metadata
quote(text) quote Quoted text blocks
code(text, language="plain text") code Code fences with link stripping

Use sanitize_blocks to enforce allowlists and size limits before sending content to Notion. The from_text helper converts a Markdown-like syntax (#, -, 1., ``` fences) into a safe block payload.


Quickstart

from langchain_notion_tools import NotionSearchTool, NotionWriteTool, from_text

search = NotionSearchTool()
write = NotionWriteTool()

results = search.run(query="product roadmap")
print(results[0]["title"], results[0]["url"])

summary_blocks = from_text("### Summary\n- Release is on track\n- Risks reviewed")
response = write.run(
    update={"page_id": results[0]["id"], "mode": "append"},
    blocks=summary_blocks,
)
print(response["summary"])

Credentials are read from NOTION_API_TOKEN (and optionally NOTION_DEFAULT_PARENT_PAGE_ID). See docs/quickstart.md for full setup instructions, including CLI usage.


Toolkit helper

When you need both tools side by side, use the NotionToolkit factory. It shares a single Notion client across the search and write tools so rate limits and retries are coordinated.

from langchain_notion_tools import create_toolkit

notion = create_toolkit()
for tool in notion.tools:
    print(tool.name)

# Plug into an agent
from langchain_core.runnables import RunnableParallel
workflow = RunnableParallel({"search": notion.search, "write": notion.write})

Call create_toolkit(api_token="...") to override credentials or pass an existing NotionClientSettings instance.


CLI

Debug workflows without writing a script:

# Search for specs
notion-search --query "api spec" --limit 5

# Append Markdown-converted blocks to a page
notion-write --update-page "abcd1234" --blocks-from-text "### Decisions\n- Adopt OAuth2"

# Create a page in the default parent and dry-run the payload
notion-write --title "Weekly Review" --blocks-from-text "# Intro" --dry-run

The CLI respects the same environment variables as the Python API and prints JSON responses that can be piped into jq for terminal-friendly inspection.


Documentation

The full documentation (Quickstart, Configuration, Examples, JSON Schema) lives under docs/ and is built with MkDocs Material:

pip install -e .[dev] mkdocs-material
mkdocs serve

Open http://127.0.0.1:8000 to browse the live docs with hot reload.


Examples

The examples/ directory contains runnable scripts and notebooks. They load .env files for convenience and show how to orchestrate read/write cycles, LangChain agents, and CLI automation.


Contributing

We follow Conventional Commits, run ruff, mypy, and pytest in CI, and welcome issues or pull requests. See CONTRIBUTING.md for the full guide.


License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for langchain-notion-tools 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-notion-tools 0.1.0
File Size Uploaded
langchain_notion_tools-0.1.0.tar.gz 26.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-notion-tools 0.1.0
File Interpreter ABI Platform
langchain_notion_tools-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.6 kB

Release files / langchain_notion_tools-0.1.0.tar.gz

Download URL langchain_notion_tools-0.1.0.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c05bde036c9cde4eef83bcc2351a56b6be57026d4158002b7fc34979e3244e34
BLAKE2b-256 checksum
How to use checksums
3642ebc31be9bef7c62cef149ab9ec67fb237344029caec0dea1d42082a0b68f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / langchain_notion_tools-0.1.0-py3-none-any.whl

Download URL langchain_notion_tools-0.1.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
478db122959fa9a9fc248801fcd21761631f75a20fc62479094c13d92eb3654a
BLAKE2b-256 checksum
How to use checksums
8568052e45b632092df623817f6c289d6b29e1bb3a86c85bc784f3f3297130a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page