agent-labbook 0.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Binbin Shen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-labbook
3
+ Version: 0.13.0
4
+ Summary: Notion auth and project binding for Codex, Claude Code, and other MCP clients.
5
+ Author-email: Binbin Shen <binbinsh@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/binbinsh/agent-labbook
8
+ Project-URL: Repository, https://github.com/binbinsh/agent-labbook
9
+ Keywords: codex,claude-code,mcp,notion,oauth
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp<2,>=1.26.0
22
+ Dynamic: license-file
23
+
24
+ # agent-labbook
25
+
26
+ 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 tokens and bindings locally in `.labbook/`, and returns the API context your agent needs to call Notion directly.
27
+
28
+ Use it when you want to:
29
+
30
+ - connect a repo to specific Notion pages or data sources for an agent
31
+ - let an agent read or update project docs and data sources through the official Notion API
32
+ - avoid building your own Notion auth wrapper for coding agents
33
+
34
+ It is not a full Notion SDK. After setup, your agent should use the official Notion API directly.
35
+
36
+ ## Install
37
+
38
+ Use Agent Labbook as a local MCP server for the current project.
39
+
40
+ Requirements:
41
+
42
+ - Python 3.10 or newer
43
+ - `uv`
44
+ - a Codex, Claude Code, or other MCP-capable client that can run a local MCP server
45
+
46
+ Recommended setup:
47
+
48
+ ```bash
49
+ codex mcp add labbook -- uvx agent-labbook mcp
50
+ claude mcp add --scope project labbook -- uvx agent-labbook mcp
51
+ ```
52
+
53
+ - or use the checked-in [`.mcp.json`](./.mcp.json) when the repository itself is the MCP source
54
+
55
+ ## Typical Flow
56
+
57
+ 1. Run `notion_status`.
58
+ 2. Run `notion_auth_browser`, or `notion_start_headless_auth` if connecting through SSH or another headless environment.
59
+ 3. Choose the Notion pages or data sources for this project.
60
+ 4. Run `notion_get_api_context`.
61
+ 5. Use the returned token, headers, and resource IDs with the official Notion API.
62
+
63
+ ## Hosted Backend
64
+
65
+ The default backend is `https://labbook.superplanner.net`. It is privacy-friendly: it handles OAuth and token refresh without keeping your project tokens or Notion content in server-side storage. Long-lived tokens and bindings stay local in `.labbook/`.
66
+
67
+ If you want to self-host it, see [`docs/self-host.md`](./docs/self-host.md).
68
+
69
+ ## Notes
70
+
71
+ - `.labbook/` should never be committed
72
+ - this repo handles auth and project binding, not general Notion API wrapping
@@ -0,0 +1,49 @@
1
+ # agent-labbook
2
+
3
+ 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 tokens and bindings locally in `.labbook/`, and returns the API context your agent needs to call Notion directly.
4
+
5
+ Use it when you want to:
6
+
7
+ - connect a repo to specific Notion pages or data sources for an agent
8
+ - let an agent read or update project docs and data sources through the official Notion API
9
+ - avoid building your own Notion auth wrapper for coding agents
10
+
11
+ It is not a full Notion SDK. After setup, your agent should use the official Notion API directly.
12
+
13
+ ## Install
14
+
15
+ Use Agent Labbook as a local MCP server for the current project.
16
+
17
+ Requirements:
18
+
19
+ - Python 3.10 or newer
20
+ - `uv`
21
+ - a Codex, Claude Code, or other MCP-capable client that can run a local MCP server
22
+
23
+ Recommended setup:
24
+
25
+ ```bash
26
+ codex mcp add labbook -- uvx agent-labbook mcp
27
+ claude mcp add --scope project labbook -- uvx agent-labbook mcp
28
+ ```
29
+
30
+ - or use the checked-in [`.mcp.json`](./.mcp.json) when the repository itself is the MCP source
31
+
32
+ ## Typical Flow
33
+
34
+ 1. Run `notion_status`.
35
+ 2. Run `notion_auth_browser`, or `notion_start_headless_auth` if connecting through SSH or another headless environment.
36
+ 3. Choose the Notion pages or data sources for this project.
37
+ 4. Run `notion_get_api_context`.
38
+ 5. Use the returned token, headers, and resource IDs with the official Notion API.
39
+
40
+ ## Hosted Backend
41
+
42
+ The default backend is `https://labbook.superplanner.net`. It is privacy-friendly: it handles OAuth and token refresh without keeping your project tokens or Notion content in server-side storage. Long-lived tokens and bindings stay local in `.labbook/`.
43
+
44
+ If you want to self-host it, see [`docs/self-host.md`](./docs/self-host.md).
45
+
46
+ ## Notes
47
+
48
+ - `.labbook/` should never be committed
49
+ - this repo handles auth and project binding, not general Notion API wrapping
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-labbook"
7
+ version = "0.13.0"
8
+ description = "Notion auth and project binding for Codex, Claude Code, and other MCP clients."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Binbin Shen", email = "binbinsh@gmail.com" }
14
+ ]
15
+ keywords = ["codex", "claude-code", "mcp", "notion", "oauth"]
16
+ dependencies = [
17
+ "mcp>=1.26.0,<2",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Developers",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Topic :: Software Development",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/binbinsh/agent-labbook"
32
+ Repository = "https://github.com/binbinsh/agent-labbook"
33
+
34
+ [project.scripts]
35
+ agent-labbook = "labbook.cli:main"
36
+
37
+ [tool.setuptools]
38
+ package-dir = { "" = "src" }
39
+
40
+ [tool.setuptools.packages.find]
41
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-labbook
3
+ Version: 0.13.0
4
+ Summary: Notion auth and project binding for Codex, Claude Code, and other MCP clients.
5
+ Author-email: Binbin Shen <binbinsh@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/binbinsh/agent-labbook
8
+ Project-URL: Repository, https://github.com/binbinsh/agent-labbook
9
+ Keywords: codex,claude-code,mcp,notion,oauth
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: mcp<2,>=1.26.0
22
+ Dynamic: license-file
23
+
24
+ # agent-labbook
25
+
26
+ 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 tokens and bindings locally in `.labbook/`, and returns the API context your agent needs to call Notion directly.
27
+
28
+ Use it when you want to:
29
+
30
+ - connect a repo to specific Notion pages or data sources for an agent
31
+ - let an agent read or update project docs and data sources through the official Notion API
32
+ - avoid building your own Notion auth wrapper for coding agents
33
+
34
+ It is not a full Notion SDK. After setup, your agent should use the official Notion API directly.
35
+
36
+ ## Install
37
+
38
+ Use Agent Labbook as a local MCP server for the current project.
39
+
40
+ Requirements:
41
+
42
+ - Python 3.10 or newer
43
+ - `uv`
44
+ - a Codex, Claude Code, or other MCP-capable client that can run a local MCP server
45
+
46
+ Recommended setup:
47
+
48
+ ```bash
49
+ codex mcp add labbook -- uvx agent-labbook mcp
50
+ claude mcp add --scope project labbook -- uvx agent-labbook mcp
51
+ ```
52
+
53
+ - or use the checked-in [`.mcp.json`](./.mcp.json) when the repository itself is the MCP source
54
+
55
+ ## Typical Flow
56
+
57
+ 1. Run `notion_status`.
58
+ 2. Run `notion_auth_browser`, or `notion_start_headless_auth` if connecting through SSH or another headless environment.
59
+ 3. Choose the Notion pages or data sources for this project.
60
+ 4. Run `notion_get_api_context`.
61
+ 5. Use the returned token, headers, and resource IDs with the official Notion API.
62
+
63
+ ## Hosted Backend
64
+
65
+ The default backend is `https://labbook.superplanner.net`. It is privacy-friendly: it handles OAuth and token refresh without keeping your project tokens or Notion content in server-side storage. Long-lived tokens and bindings stay local in `.labbook/`.
66
+
67
+ If you want to self-host it, see [`docs/self-host.md`](./docs/self-host.md).
68
+
69
+ ## Notes
70
+
71
+ - `.labbook/` should never be committed
72
+ - this repo handles auth and project binding, not general Notion API wrapping
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/agent_labbook.egg-info/PKG-INFO
5
+ src/agent_labbook.egg-info/SOURCES.txt
6
+ src/agent_labbook.egg-info/dependency_links.txt
7
+ src/agent_labbook.egg-info/entry_points.txt
8
+ src/agent_labbook.egg-info/requires.txt
9
+ src/agent_labbook.egg-info/top_level.txt
10
+ src/labbook/__init__.py
11
+ src/labbook/__main__.py
12
+ src/labbook/cli.py
13
+ src/labbook/mcp_server.py
14
+ src/labbook/notion_api.py
15
+ src/labbook/service.py
16
+ src/labbook/state.py
17
+ tests/test_cli.py
18
+ tests/test_mcp_server.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agent-labbook = labbook.cli:main
@@ -0,0 +1 @@
1
+ mcp<2,>=1.26.0
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ __all__ = ["__version__"]
4
+
5
+ __version__ = "0.13.0"
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ from .cli import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ raise SystemExit(main())
@@ -0,0 +1,188 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import platform
6
+ import sys
7
+ from importlib.metadata import PackageNotFoundError, version as package_version
8
+ from typing import Any
9
+ from urllib import error, request
10
+
11
+ from . import __version__
12
+ from .service import status
13
+ from .state import (
14
+ DEFAULT_BACKEND_URL,
15
+ bindings_path,
16
+ effective_backend_url,
17
+ load_project_bindings,
18
+ load_project_session,
19
+ pending_auth_path,
20
+ resolve_project_root,
21
+ session_path,
22
+ )
23
+
24
+
25
+ def _json_dump(payload: dict[str, Any]) -> None:
26
+ sys.stdout.write(json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n")
27
+
28
+
29
+ def _installed_mcp_sdk_version() -> str | None:
30
+ try:
31
+ return package_version("mcp")
32
+ except PackageNotFoundError:
33
+ return None
34
+
35
+
36
+ def _probe_backend_health(backend_url: str) -> dict[str, Any]:
37
+ req = request.Request(
38
+ f"{backend_url}/health",
39
+ headers={"Accept": "application/json"},
40
+ method="GET",
41
+ )
42
+ try:
43
+ with request.urlopen(req, timeout=10) as response:
44
+ raw = response.read().decode("utf-8")
45
+ status_code = response.status
46
+ except error.HTTPError as exc:
47
+ raw = exc.read().decode("utf-8", errors="replace")
48
+ return {
49
+ "ok": False,
50
+ "status_code": exc.code,
51
+ "error": raw or exc.reason,
52
+ }
53
+ except error.URLError as exc:
54
+ return {
55
+ "ok": False,
56
+ "error": str(exc.reason),
57
+ }
58
+
59
+ try:
60
+ decoded = json.loads(raw)
61
+ except json.JSONDecodeError:
62
+ decoded = {"raw": raw}
63
+ return {
64
+ "ok": True,
65
+ "status_code": status_code,
66
+ "payload": decoded,
67
+ }
68
+
69
+
70
+ def _mcp_server_config(*, server_name: str) -> dict[str, Any]:
71
+ return {
72
+ "mcpServers": {
73
+ server_name: {
74
+ "command": "uvx",
75
+ "args": ["agent-labbook", "mcp"],
76
+ }
77
+ }
78
+ }
79
+
80
+
81
+ def _doctor_command(args: argparse.Namespace) -> int:
82
+ project_root = resolve_project_root(args.project_root)
83
+ backend_url = effective_backend_url()
84
+ pending_path = pending_auth_path(project_root)
85
+ payload: dict[str, Any] = {
86
+ "version": __version__,
87
+ "python": {
88
+ "executable": sys.executable,
89
+ "implementation": platform.python_implementation(),
90
+ "version": platform.python_version(),
91
+ },
92
+ "project_root": str(project_root),
93
+ "backend_url": backend_url,
94
+ "backend_url_overridden": backend_url != DEFAULT_BACKEND_URL,
95
+ "state": {
96
+ "session_path": str(session_path(project_root)),
97
+ "session_exists": load_project_session(project_root) is not None,
98
+ "bindings_path": str(bindings_path(project_root)),
99
+ "bindings_exists": load_project_bindings(project_root) is not None,
100
+ "pending_auth_path": str(pending_path),
101
+ "pending_auth_exists": pending_path.exists(),
102
+ },
103
+ "notion_status": status(project_root),
104
+ "mcp": {
105
+ "install_surface": "uvx agent-labbook mcp",
106
+ "sdk": "modelcontextprotocol/python-sdk",
107
+ "sdk_version": _installed_mcp_sdk_version(),
108
+ "transport": "stdio",
109
+ "wire_protocol": "content-length",
110
+ },
111
+ }
112
+ if args.probe_backend:
113
+ payload["backend_probe"] = _probe_backend_health(backend_url)
114
+ _json_dump(payload)
115
+ return 0
116
+
117
+
118
+ def _print_mcp_config_command(args: argparse.Namespace) -> int:
119
+ payload = _mcp_server_config(server_name=args.server_name)
120
+ _json_dump(payload)
121
+ return 0
122
+
123
+
124
+ def _run_mcp_command() -> int:
125
+ try:
126
+ from .mcp_server import main as mcp_main
127
+ except ModuleNotFoundError as exc:
128
+ if exc.name == "mcp":
129
+ raise RuntimeError(
130
+ "The Python 'mcp' package is not installed. "
131
+ "Use 'uvx agent-labbook mcp'."
132
+ ) from exc
133
+ raise
134
+
135
+ mcp_main()
136
+ return 0
137
+
138
+
139
+ def build_parser() -> argparse.ArgumentParser:
140
+ parser = argparse.ArgumentParser(
141
+ prog="agent-labbook",
142
+ description="Agent Labbook CLI and MCP launcher.",
143
+ )
144
+ parser.set_defaults(func=None)
145
+
146
+ subparsers = parser.add_subparsers(dest="command")
147
+
148
+ mcp_parser = subparsers.add_parser("mcp", help="Run the MCP stdio server.")
149
+ mcp_parser.set_defaults(func=lambda _args: _run_mcp_command())
150
+
151
+ doctor_parser = subparsers.add_parser("doctor", help="Inspect local Agent Labbook state.")
152
+ doctor_parser.add_argument("--project-root", default=".", help="Project root to inspect. Defaults to the current directory.")
153
+ doctor_parser.add_argument(
154
+ "--probe-backend",
155
+ action="store_true",
156
+ help="Also query the configured backend /health endpoint.",
157
+ )
158
+ doctor_parser.set_defaults(func=_doctor_command)
159
+
160
+ config_parser = subparsers.add_parser(
161
+ "print-mcp-config",
162
+ help="Print a reusable uvx-based MCP server config snippet.",
163
+ )
164
+ config_parser.add_argument(
165
+ "--server-name",
166
+ default="labbook",
167
+ help="Name to use under mcpServers.",
168
+ )
169
+ config_parser.set_defaults(func=_print_mcp_config_command)
170
+
171
+ return parser
172
+
173
+
174
+ def main(argv: list[str] | None = None) -> int:
175
+ parser = build_parser()
176
+ args = parser.parse_args(argv)
177
+ if args.func is None:
178
+ parser.print_help(sys.stderr)
179
+ return 1
180
+ try:
181
+ return int(args.func(args) or 0)
182
+ except RuntimeError as exc:
183
+ sys.stderr.write(f"{exc}\n")
184
+ return 1
185
+
186
+
187
+ if __name__ == "__main__":
188
+ raise SystemExit(main())