Skip to content

Commit 717bd30

Browse files
perfectra1ngreptile-apps[bot]stickerdaniel
authored
make sure to validate that browsers are installed when running login (#269)
* make sure to validate that browsers are installed when running login * Update linkedin_mcp_server/bootstrap.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * refactor: centralize browser install guard for all CLI modes Move ensure_browser_installed() from get_profile_and_exit() into main(), guarding both --login and --status paths. The --status path also launches a browser (get_or_create_browser) and would crash with the same opaque error if Chromium wasn't installed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Daniel Sticker <daniel.sticker@rwth-aachen.de>
1 parent 7d0a0dc commit 717bd30

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

linkedin_mcp_server/bootstrap.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,25 @@ async def _run_browser_setup() -> None:
217217
metadata_path.write_text(json.dumps(metadata, indent=2, sort_keys=True) + "\n")
218218

219219

220+
def ensure_browser_installed() -> None:
221+
"""Install Patchright Chromium synchronously if not already present.
222+
223+
Used by CLI modes (--login, --status) to guarantee the browser exists
224+
before launching it. The normal server path uses async background setup
225+
instead (non-blocking).
226+
"""
227+
configure_browser_environment()
228+
if browser_setup_ready():
229+
return
230+
print(" Installing Patchright Chromium browser...")
231+
try:
232+
asyncio.run(_run_browser_setup())
233+
except Exception as exc:
234+
print(f" ❌ Browser installation failed: {exc}")
235+
raise
236+
print(" Browser installed.")
237+
238+
220239
def _safe_task_done(task: asyncio.Task[None] | None) -> bool:
221240
return task is not None and task.done()
222241

linkedin_mcp_server/cli_main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import inquirer
99

10-
from linkedin_mcp_server.bootstrap import configure_browser_environment
10+
from linkedin_mcp_server.bootstrap import (
11+
configure_browser_environment,
12+
ensure_browser_installed,
13+
)
1114
from linkedin_mcp_server.core import AuthenticationError
1215
from linkedin_mcp_server.authentication import clear_auth_state
1316
from linkedin_mcp_server.config import get_config
@@ -284,6 +287,11 @@ def main() -> None:
284287
if config.server.logout:
285288
clear_profile_and_exit()
286289

290+
# Ensure browser is installed for CLI modes that need it.
291+
# Normal server startup uses async background setup instead.
292+
if config.server.login or config.server.status:
293+
ensure_browser_installed()
294+
287295
# Handle --login flag
288296
if config.server.login:
289297
get_profile_and_exit()

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)