Skip to content

Commit 83b461c

Browse files
committed
Prefer headless auth by default for MCP flows
1 parent 81f4208 commit 83b461c

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "agent-labbook"
7-
version = "0.13.9"
7+
version = "0.13.10"
88
description = "Notion auth and project binding for Codex, Claude Code, and other MCP clients."
99
readme = "README.md"
1010
requires-python = ">=3.10"

src/labbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__all__ = ["__version__"]
44

5-
__version__ = "0.13.9"
5+
__version__ = "0.13.10"

src/labbook/service.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def _build_setup_guide() -> str:
287287
"# Agent Labbook Public Integration Setup",
288288
"",
289289
"For MCP users:",
290-
"1. Call `notion_auth_browser` for a direct browser flow, or `notion_start_headless_auth` if the browser cannot be opened locally.",
290+
"1. Prefer `notion_start_headless_auth` for agent-driven setup. Use `notion_auth_browser` only when the browser and MCP server are running on the same machine.",
291291
f" For browser auth, prefer a long wait and pass `timeout_seconds: {DEFAULT_BROWSER_AUTH_TIMEOUT_SECONDS}` because users may need several minutes to finish consent and resource selection.",
292292
f" `page_limit` now controls the size of the initial recent-items catalog. Values below {MIN_BROWSER_AUTH_PAGE_LIMIT} are clamped, but remote search still searches the whole shared workspace.",
293293
"2. Complete the official Notion public integration consent page.",
@@ -651,10 +651,8 @@ def status(project_root: str | Path | None = None) -> dict[str, Any]:
651651

652652
if pending_auth and str(pending_auth.get("mode") or "") == "headless" and not authenticated:
653653
recommended_action = "notion_complete_headless_auth"
654-
elif not authenticated and remote_session_reason:
655-
recommended_action = "notion_start_headless_auth"
656654
elif not authenticated:
657-
recommended_action = "notion_auth_browser"
655+
recommended_action = "notion_start_headless_auth"
658656
elif not bindings_ready:
659657
recommended_action = "notion_bind_resources"
660658
else:
@@ -668,8 +666,12 @@ def status(project_root: str | Path | None = None) -> dict[str, Any]:
668666
"recommended_browser_auth_timeout_seconds": DEFAULT_BROWSER_AUTH_TIMEOUT_SECONDS,
669667
"recommended_browser_auth_page_limit": DEFAULT_BROWSER_AUTH_PAGE_LIMIT,
670668
"browser_auth_hint": (
671-
"When using notion_auth_browser, prefer a long timeout_seconds value and keep waiting for the browser handoff "
672-
f"to complete. Recommended starting point: {DEFAULT_BROWSER_AUTH_TIMEOUT_SECONDS}."
669+
"Use notion_auth_browser only when the browser and MCP server are on the same machine. When you do use it, "
670+
f"prefer a long timeout_seconds value and keep waiting for the browser handoff to complete. Recommended starting point: {DEFAULT_BROWSER_AUTH_TIMEOUT_SECONDS}."
671+
),
672+
"headless_auth_hint": (
673+
"Prefer notion_start_headless_auth for MCP and SSH-driven workflows. It does not depend on a 127.0.0.1 callback "
674+
"to the machine running the MCP server."
673675
),
674676
"remote_auth_hint": (
675677
"Detected an SSH or likely headless shell session. Prefer notion_start_headless_auth because the local-browser "

tests/test_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
class ServiceTests(unittest.TestCase):
31-
def test_status_recommends_long_browser_auth_timeout(self) -> None:
31+
def test_status_recommends_headless_by_default(self) -> None:
3232
with tempfile.TemporaryDirectory() as tmpdir:
3333
with mock.patch.dict(
3434
"os.environ",
@@ -38,12 +38,13 @@ def test_status_recommends_long_browser_auth_timeout(self) -> None:
3838
with mock.patch("labbook.service.platform.system", return_value="Darwin"):
3939
payload = status(tmpdir)
4040

41-
self.assertEqual(payload["recommended_action"], "notion_auth_browser")
41+
self.assertEqual(payload["recommended_action"], "notion_start_headless_auth")
4242
self.assertEqual(
4343
payload["recommended_browser_auth_timeout_seconds"],
4444
DEFAULT_BROWSER_AUTH_TIMEOUT_SECONDS,
4545
)
46-
self.assertIn("timeout_seconds", payload["browser_auth_hint"])
46+
self.assertIn("same machine", payload["browser_auth_hint"])
47+
self.assertIn("127.0.0.1", payload["headless_auth_hint"])
4748

4849
def test_page_limit_is_clamped_to_minimum(self) -> None:
4950
self.assertEqual(normalize_browser_auth_page_limit(None), DEFAULT_BROWSER_AUTH_PAGE_LIMIT)

0 commit comments

Comments
 (0)