Notion CLI for AI Agents

Framework Integration Gradient
Notion Logo
CLI Logo
divider

Introduction

CLIs are eating MCPs. The industry is converging on the very same idea. MCPs for all their merit can be token hungry, slow, and unreliable for complex tool chaining. However, coding agents have become incredibly good at working with CLIs, and in fact they are far more comfortable working with CLI tools than MCP.

With Composio's Universal CLI, your coding agents can talk to over 850+ SaaS applications. With Notion, agents can add meeting notes to project wiki page, create a new task database for q3, archive completed sprint summary pages, and more — all without worrying about authentication.

This guide walks you through Composio Universal CLI and explains how you can connect it with coding agents like Claude Code, Codex, OpenCode, etc, for end-to-end Notion automation.

Also integrate Notion with

What is Universal CLI and why use it?

The idea behind building the universal CLI is to give agents a single command interface to interact with all your external applications. Here's what you'll get with it:

  • Agent-friendly: Coding agents like Claude Code, Codex, and OpenCode can use CLI tools natively — no MCP setup required.
  • Authentication handled: Connect once via OAuth or API Key, and all CLI commands work with your credentials automatically.
  • Tool discovery: Search, inspect, and execute 20,000+ tools across 850+ apps from one interface.
  • Trigger support: Use triggers to listen for events across your apps, powered by real-time webhooks or polling under the hood.
  • Type generation: Generate typed schemas for autocomplete and type safety in your projects.

Prerequisites

Install the Composio CLI, authenticate, and initialize your project:

bash
# Install the Composio CLI
curl -fsSL https://composio.dev/install | bash

# Authenticate with Composio
composio login

During login you'll be redirected to sign in page, finish the complete flow and you're all set.

Composio CLI authentication flow

Connecting Notion to Coding Agents via Universal CLI

Once it is installed, it's essentially done. Claude Code, Codex, OpenCode, OpenClaw, or any other agent will be able to access the CLI. A few steps to give agents access to your apps.

  1. Launch your Coding Agent — Claude Code, Codex, OpenCode, anything you prefer.
  2. Prompt it to "Authenticate with Notion"
  3. Complete the authentication and authorization flow and your Notion integration is all set.
  4. Start asking anything you want.

Supported Tools & Triggers

Tools
Triggers
Add multiple content blocks (bulk, user-friendly)Efficiently adds multiple standard content blocks to a notion page in a single api call with automatic markdown parsing.
Append complex blocks (advanced, full control)Appends complex blocks with full notion block structure to a parent block or page.
Archive Notion PageArchives (moves to trash) or unarchives (restores from trash) a specified notion page.
Create commentAdds a comment to a notion page (via `parent page id`) or to an existing discussion thread (via `discussion id`); cannot create new discussion threads on specific blocks (inline comments).
Create Notion DatabaseCreates a new notion database as a subpage under a specified parent page with a defined properties schema; use this action exclusively for creating new databases.
Create Notion pageCreates a new empty page in a notion workspace.
Delete a blockArchives a notion block, page, or database using its id, which sets its 'archived' property to true (like moving to "trash" in the ui) and allows it to be restored later.
Duplicate pageDuplicates a notion page, including all its content, properties, and nested blocks, under a specified parent page or workspace.
Fetch Notion Block ChildrenRetrieves a paginated list of direct, first-level child block objects along with contents for a given parent notion block or page id; use block ids from the response for subsequent calls to access deeply nested content.
Fetch Notion block metadataFetches metadata for a notion block (or page, as pages are blocks) using its valid uuid; if the block has children, use fetch block contents to fetch their contents.
Fetch commentsFetches unresolved comments for a specified notion block or page id.
Fetch Notion DataFetches notion items (pages and/or databases) from the notion workspace, use this to get minimal data about the items in the workspace with a query or list all items in the workspace with minimal data
Fetch DatabaseFetches a notion database's structural metadata (properties, title, etc.
Fetch database rowRetrieves a notion database row's properties and metadata; use fetch block contents for page content blocks.
Get About MeRetrieves the user object for the bot associated with the current notion integration token, typically to obtain the bot's user id for other api operations.
Get about userRetrieves detailed information about a specific notion user, such as their name, avatar, and email, based on their unique user id.
Get page propertyCall this to get a specific property from a notion page when you have a valid `page id` and `property id`; handles pagination for properties returning multiple items.
Insert row databaseCreates a new page (row) in a specified notion database.
List usersRetrieves a paginated list of users (excluding guests) from the notion workspace; the number of users returned per page may be less than the requested `page size`.
Query databaseQueries a notion database for pages (rows), where rows are pages and columns are properties; ensure sort property names correspond to existing database properties.
Retrieve CommentTool to retrieve a specific comment by its id.
Retrieve Database PropertyTool to retrieve a specific property object of a notion database.
Search Notion pageSearches notion pages and databases by title; an empty query lists all accessible items, useful for discovering ids or as a fallback when a specific query yields no results.
Update blockUpdates an existing notion block's textual content or type-specific properties (e.
Update PageTool to update the properties, icon, cover, or archive status of a page.
Update row databaseUpdates or archives an existing notion database row (page) using its `row id`, allowing modification of its icon, cover, and/or properties; ensure the target page is accessible and property details (names/ids and values) align with the database schema and specified formats.
Update database schemaUpdates an existing notion database's title, description, and/or properties; at least one of these attributes must be provided to effect a change.

Universal CLI Commands for Notion

You can also manually execute CLI commands to interact with your Notion.

Connect your Notion account

Link your Notion account and verify the connection:

bash
# Connect your Notion account (opens OAuth flow)
composio connected-accounts link notion

# Verify the connection
composio connected-accounts list --toolkits notion

Discover Notion tools

Search and inspect available Notion tools:

bash
# List all available Notion tools
composio tools list --toolkit notion

# Search for Notion tools by action
composio tools search "notion"

# Inspect a tool's input schema
composio tools info NOTION_ADD_MULTIPLE_PAGE_CONTENT

Common Notion Actions

Add multiple content blocks (bulk, user-friendly)Efficiently adds multiple standard content blocks to a notion page in a single api call with automatic markdown parsing

bash
composio tools execute NOTION_ADD_MULTIPLE_PAGE_CONTENT \
  --content_blocks '[{"content_block":{"content":"# Project Status Report","block_property":"heading_1"}},{"content_block":{"content":"System is **running smoothly** with *excellent* performance. ~~Issues~~ resolved!","block_property":"paragraph"}},{"content_block":{"content":"Visit our [dashboard](https://example.com/dashboard) for details.","block_property":"paragraph"}},{"content_block":{"content":"Monitor system status with `kubectl get pods`","block_property":"paragraph"}}]' \
  --parent_block_id "4b5f6e87-123a-456b-789c-9de8f7a9e4c1"

Append complex blocks (advanced, full control)Appends complex blocks with full notion block structure to a parent block or page

bash
composio tools execute NOTION_APPEND_BLOCK_CHILDREN \
  --block_id "b55c9c91-384d-452b-81db-d1ef79372b75" \
  --children "[{"object": "block", "type": "heading_2", "heading_2": {"rich_text": [{"text": {"content": "Lacinato kale"}}]}}]"

Archive Notion PageArchives (moves to trash) or unarchives (restores from trash) a specified notion page

bash
composio tools execute NOTION_ARCHIVE_NOTION_PAGE \
  --page_id "a1b2c3d4-e5f6-7890-1234-567890abcdef"

Create commentAdds a comment to a notion page (via `parent page id`) or to an existing discussion thread (via `discussion id`); cannot create new discussion threads on specific blocks (inline comments)

bash
composio tools execute NOTION_CREATE_COMMENT \
  --comment '{"content":"Looks good to me!"}'

Set up Notion Triggers

Listen for events in real time using triggers:

All Page EventsTriggers when any Notion page is created or updated across the workspace

bash
# Find your connected account ID
composio connected-accounts list --toolkits notion

# Create a trigger
composio triggers create NOTION_ALL_PAGE_EVENTS_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "interval": 2
}'

# Listen for trigger events in real time
composio triggers listen --toolkits notion --table

New CommentTriggers when a new comment is added to a specified Notion block or page

bash
# Find your connected account ID
composio connected-accounts list --toolkits notion

# Create a trigger
composio triggers create NOTION_COMMENTS_ADDED_TRIGGER \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "block_id": "<string>",
  "interval": 2
}'

# Listen for trigger events in real time
composio triggers listen --toolkits notion --table

New PageTriggers when a new page is added to a Notion database

bash
# Find your connected account ID
composio connected-accounts list --toolkits notion

# Create a trigger
composio triggers create NOTION_PAGE_ADDED_TO_DATABASE \
  --connected-account-id <your-connected-account-id> \
  --trigger-config '{
  "interval": 2,
  "database_id": "<string>"
}'

# Listen for trigger events in real time
composio triggers listen --toolkits notion --table

Generate Type Definitions

Generate typed schemas for Notion tools to get autocomplete and type safety in your project:

bash
# Auto-detect language
composio generate --toolkits notion

# TypeScript
composio ts generate --toolkits notion

# Python
composio py generate --toolkits notion

Tips & Tricks

  • Always inspect a tool's input schema before executing: composio tools info <TOOL_NAME>
  • Pipe output with jq for better readability: composio tools execute TOOL_NAME -d '{}' | jq
  • Set COMPOSIO_API_KEY as an environment variable for CI/CD pipelines
  • Use composio dev logs tools to inspect execution logs and debug issues

Next Steps

  • Try asking your coding agent to perform various Notion operations
  • Explore cross-app workflows by connecting more toolkits
  • Set up triggers for real-time automation
  • Use composio generate for typed schemas in your projects

How to build Notion MCP Agent with another framework

FAQ

What is the Composio Universal CLI?

The Composio Universal CLI is a single command-line interface that lets coding agents and developers interact with 850+ SaaS applications. It handles authentication, tool discovery, action execution, and trigger setup — all from the terminal, without needing to configure MCP servers.

Which coding agents work with the Composio CLI?

Any coding agent that can run shell commands works with the Composio CLI — including Claude Code, Codex, OpenCode, OpenClaw, and others. Once the CLI is installed, agents automatically discover and use the composio commands to interact with Notion and other connected apps.

How is the CLI different from using an MCP server for Notion?

MCP servers require configuration and can be token-heavy for complex workflows. The CLI gives agents a direct, lightweight interface — no server setup needed. Agents simply call composio commands like any other shell tool. It's faster to set up, more reliable for multi-step tool chaining, and works natively with how coding agents already operate.

How safe is my Notion data when using the Composio CLI?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Notion data and credentials are handled as safely as possible. You can also bring your own OAuth credentials for full control.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.