Skip to main content

Notion auth and project binding for Codex, Claude Code, and other MCP clients.

Project description

Agent Labbook

Agent Labbook is the Notion connection layer for Codex, Claude Code, and other MCP clients. It starts Notion auth, lets you choose which pages or data sources belong to a project, stores project bindings in .labbook/, stores long-lived tokens in a shared credential provider, and returns the API context your agent needs to call Notion directly.

Use it when you want to:

  • connect a repo to specific Notion pages or data sources for an agent
  • let an agent read or update project docs and data sources through the official Notion API
  • avoid building your own Notion auth wrapper for coding agents

It is not a full Notion SDK. After setup, your agent should use the official Notion API directly.

Install

Use Agent Labbook as a local MCP server for the current project.

Requirements:

  • Python 3.10 or newer
  • uv
  • a Codex, Claude Code, or other MCP-capable client that can run a local MCP server

Recommended setup:

codex mcp add labbook -- uvx agent-labbook mcp
claude mcp add --scope project labbook -- uvx agent-labbook mcp
  • or use the checked-in .mcp.json when the repository itself is the MCP source

Typical Flow

  1. Read labbook://agent-labbook/project/status or run notion_status.
  2. If notion_status reports saved_credentials_error or credential_provider_diagnostics_error, fix the local notion-access-broker helper installation before starting OAuth. A fresh OAuth flow cannot persist shared credentials without it.
  3. If status shows saved shared credentials for this integration, run notion_list_saved_credentials and then notion_attach_saved_credential for the workspace you want to reuse.
  4. If you want to reopen the hosted root-page selection UI without re-running OAuth, run notion_selection_browser.
  5. Check notion_status.preferred_browser_flow, notion_status.recommended_open_browser, and notion_status.browser_environment_hint before you start a browser flow.
  6. Otherwise run notion_auth_browser, or notion_start_headless_auth if connecting through SSH or another headless environment. For browser auth, pass a long timeout_seconds such as 1800 so the background localhost listener stays alive while you finish Notion consent and resource selection.
  7. Choose the Notion pages or data sources for this project.
  8. Run notion_status again after the browser says the project is connected, after attaching the saved credential, or after reopening the selection UI.
  9. If notion_status reports pending_handoff_ready=true, run notion_finalize_pending_auth.
  10. Read labbook://agent-labbook/project/bindings or run notion_list_bindings if you want a read-only snapshot of the explicit project roots.
  11. Run notion_get_api_context.
  12. Use the returned token, headers, and resource IDs with the official Notion API.

MCP Design

  • Read-only context is exposed as MCP resources:
    • labbook://agent-labbook/setup-guide
    • labbook://agent-labbook/project/status
    • labbook://agent-labbook/project/bindings
  • Reusable workflows are exposed as prompts:
    • notion_connect_project
    • notion_use_bound_resources
  • Mutating actions stay in tools. In particular, notion_status is now read-only and notion_finalize_pending_auth is the explicit step that persists a pending browser handoff.
  • Tools now declare outputSchema as well as inputSchema, so MCP clients can discover stable structured outputs and the low-level server can validate successful tool payloads before returning them.
  • notion_status also reports credential provider diagnostics so you can tell whether 1Password or keyring is currently available and which one would be selected by default.
  • notion_status now also reports browser-environment hints so SSH and other headless sessions can prefer headless auth or open_browser=false before a localhost callback flow is attempted.

Hosted Backend

The default app backend is https://superplanner.ai/notion/agent-labbook. The default shared OAuth backend is https://superplanner.ai/notion/oauth.

The app backend renders the Labbook selection UI and project-specific routes. The shared OAuth backend handles Notion OAuth, token refresh, and signed handoff bundles without keeping your project tokens or Notion content in server-side storage. Long-lived tokens live in the shared local credential provider selected through the notion-access-broker Python helpers, and project bindings stay in .labbook/.

Credential Storage

Agent Labbook no longer writes access tokens or refresh tokens into .labbook/session.json.

  • If the local op CLI is installed and can access 1Password, the default provider automatically prefers 1password
  • If NOTION_ACCESS_BROKER_1PASSWORD_VAULT is set, 1Password is pinned to that vault; otherwise it uses the default vault
  • If 1Password is unavailable, the default falls back to keyring
  • You can still force either provider with NOTION_ACCESS_BROKER_CREDENTIAL_PROVIDER=keyring|1password
  • notion-access-broker is installed as a normal package dependency for released builds; NOTION_ACCESS_BROKER_SRC=/path/to/notion-access-broker[/src] is only needed when you want a local checkout to override the installed helper during development
  • A fresh project can reuse an existing integration credential through notion_list_saved_credentials and notion_attach_saved_credential
  • A project with an attached or reusable credential can reopen the hosted selection UI through notion_selection_browser without re-running OAuth consent
  • .labbook/session.json stores only the selected credential reference and project metadata, not the token secrets themselves

If you want to self-host it, see docs/self-host.md. For versioning and migration boundaries, see docs/versioning.md.

Notes

  • .labbook/ should never be committed
  • this repo handles auth and project binding, not general Notion API wrapping

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_labbook-0.14.3.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_labbook-0.14.3-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file agent_labbook-0.14.3.tar.gz.

File metadata

  • Download URL: agent_labbook-0.14.3.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_labbook-0.14.3.tar.gz
Algorithm Hash digest
SHA256 1109043612dc900d5edf76f810a6f2130f33bbc2c33cd489d541fa6460988b2f
MD5 54a94882c1ad75ffdb964751e5ea6310
BLAKE2b-256 a08b151445929a7c729f397d6f5e4f286f28eb63c88ec56df6761ac684e95153

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_labbook-0.14.3.tar.gz:

Publisher: publish-pypi.yml on binbinsh/agent-labbook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agent_labbook-0.14.3-py3-none-any.whl.

File metadata

  • Download URL: agent_labbook-0.14.3-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_labbook-0.14.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e8c832a0587ea3fb6c405de65af447f99cbcd4582da7430021d5916b08711aa3
MD5 fe94329d154876882b0b38c219818f04
BLAKE2b-256 3a14b5488b2615115a8304c9241a8846823015d4cc9e30aab1a99df847021c87

See more details on using hashes here.

Provenance

The following attestation bundles were made for agent_labbook-0.14.3-py3-none-any.whl:

Publisher: publish-pypi.yml on binbinsh/agent-labbook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page