N.I.L.O. Docs

CLI API

This document records the current public nilo CLI surface, hidden compatibility entries, and Core call boundaries. The CLI owns terminal user experience; business behavior must come from Core services.

Entrypoint

Core Boundary

CLI -> Core or Runtime
MCP -> Core or Runtime

The CLI must not call the Notion SDK or import the MCP adapter. Shared business behavior belongs in Core and shared process/execution behavior belongs in Runtime. Core and Runtime must not import CLI or MCP. When adding a command, first confirm the corresponding shared capability exists; adapter modules may define only CLI-specific parsing, presentation, and interaction.

Public Root Commands

project, local, root status, config global/local, and config set/get/unset/list remain hidden compatibility entries. They are not part of the public command surface.

The CLI follows Git/gh-style scope: global commands work from any directory, while project commands resolve the nearest .notion_mcp/ context by walking upward to the user home.

Short Alias Contract

Every public canonical command path has an explicit alphabetic alias of at most six characters. Canonical names remain the documented interface; aliases execute the same callback and are hidden from normal help to keep help concise.

Root examples:

Canonical Alias
init ini
version ver
config cfg
pwd cwd
page pg
block blk
database db
data-source ds
server srv

Leaf examples include retrieve -> get, create -> new, update -> upd, trash -> del, and server run -> server start. The complete validated mapping is defined in src/nilo/cli/aliases.py.

Function Calling Error Contract

When --json appears anywhere in an invocation, Click/Typer usage errors are emitted as exactly one compact JSON line. The stable envelope contains ok=false and an error object with type, code, message, and details.exit_code. Stable usage codes include cli_missing_parameter, cli_invalid_parameter, cli_unknown_option, and cli_usage_error. Human invocations without --json retain normal help and error rendering.

Project Context

Project context is provided by Core:

ProjectResolver
ProjectConfigStore
AttachmentStore
ContextResolver

Resolution order:

explicit id > attached state > error

Project-local configuration:

.notion_mcp/config.json

Attachment state:

.notion_mcp/state/page.attach.json
.notion_mcp/state/database.attach.json

Project-local configuration and attachment state must not store tokens.

Project configuration may override only non-sensitive Core settings. Global credentials always remain global. Project initialization rejects the user home as a project root and incrementally adds .notion_mcp/ to the root .gitignore.

Page CLI

Page ID inputs are normalized through src/nilo/core/identifiers.py. Public <page_id> arguments accept raw IDs, copied Notion URLs, and Markdown links that contain Notion URLs.

Public commands:

Hidden compatibility entries remain for old page content/current/deattach aliases, the old page-scoped block group, and the old page insert group. They must not be documented as public user commands.

Block CLI

Public commands:

insert-before is not a stable public command. block remove is only a hidden compatibility alias for trash behavior.

Database and DataSource

Semantic model:

database = container
data_source = table under database
page = page or data source entry
block = page content node

Use database for container-level operations. Use data-source for table-level schema, query, templates, and entry creation. Use database shortcuts only for the active data source on the attached database.

Database Container Commands

database create creates a database container and an initial data source. database update only updates container-level fields and does not modify data source schema.

Database Shortcut Commands

These commands operate only on the active data source of the attached database:

The public CLI does not expose database query --data-source, database page create <data_source_id>, database page update <page_id>, or a three-argument database property rename. Explicit data source operations must use data-source; page property updates use page update.

DataSource Commands

Other Object Domains

Raw API is an advanced fallback entrypoint and should not be the normal path for page or database editing.

Removed Legacy Entrypoints

These old root commands are no longer public CLI entries:

Use nilo config --global ... for configuration and nilo server ... for MCP server lifecycle.