Give AI your browser. Persistent Chrome sessions so AI can check email, review PRs, search the web as you.
src/index.ts- CLI entry (commander,parseAsync)src/commands/- Thin wrappers (<15 lines each), call core methodssetup.ts,login.ts,status.ts,doctor.ts- Phase 1 commandsservice.ts- start/stop/restart wrapperssessions.ts- List tracked sessionsdomain.ts- add/remove/list custom auth domainsrecipe.ts- recipe list/runmcp.ts- Start built-in MCP server
src/lib/core.ts-OpenBrowserclass, single API surface for CLI and SDKsrc/lib/chrome-service.ts- Service management (systemd/launchd), Chrome lifecyclesrc/lib/session.ts- Session health via CDP cookies (PlaywrightconnectOverCDP)src/lib/platform.ts- OS detection, Chrome binary location, lock cleanup, port checking, command detectionsrc/lib/config.ts-~/.openbrowser/config.jsonmanagement (chmod 600, permission warnings)src/lib/output.ts- JSON/text output withCommandOutput<T>envelopesrc/lib/rate-limiter.ts- Per-domain rate limiting for recipessrc/lib/types.ts- All interfaces and auth cookie specssrc/mcp/server.ts- Built-in MCP server (31 tools, stdio transport, tool annotations, URL validation, rate limiting)src/recipes/- Recipe system (base interface, registry, built-in recipes)base.ts- Recipe interface, result types,newPage()helper,withRetry(),RecipeError,warnIfEmpty()index.ts- Recipe registry (getRecipe, listRecipes)github-api.ts- GitHub API token detection + fetch helper (used by prs, issues, notifications)gmail-imap.ts- Raw IMAP client over TLS for Gmail inbox (no dependencies, buffer limits, session timeout)google-calendar-api.ts- Google Calendar API client with OAuth/API key/refresh token supportprs.ts,inbox.ts,linkedin.ts,search.ts- Phase 2 recipesissues.ts,notifications.ts,calendar.ts- Phase 3 recipeslinkedin-profile.ts,linkedin-messages.ts- Phase 3 recipes
- ESM (
"type": "module") with.jsextensions in imports playwright-corenotplaywright(no bundled browsers)- CDP
browser.close()only disconnects, does NOT kill Chrome - Output format auto-detected: JSON when piped, text when TTY
- All JSON output uses
CommandOutput<T>envelope (including setup command) setup()returnsSetupDataand auto-starts service;start()/restart()are async with port check + CDP verification- Modern launchctl API (bootstrap/bootout) with legacy fallback
- Windows blocked at runtime with clear message
- Recipes check session health before running (unless
runWithoutBrowsersucceeds first) - 6 of 9 recipes have API-first paths via
runWithoutBrowser: GitHub (token), Gmail (IMAP), Calendar (API); fall back to browser scraping - Rate limiter enforces per-domain delays (configurable in config.json)
- Custom domains merge with built-in specs in SessionManager
- MCP server uses low-level Server API (not McpServer wrapper, avoids TS deep type issues)
- MCP tool annotations (
readOnlyHint,destructiveHint,openWorldHint) for client permission prompts session_cookiesfilters out sensitive auth cookies (SID, HSID, li_at, user_session, etc.)browser_evaluatemarked as destructive + open-world with security warning in descriptionsetup_guidetool provides interactive setup instructions for API-first recipes- URL validation:
validateUrl()blocks non-http(s) protocols,validateUrlWithDns()also resolves hostname to check for private IPs (DNS rebinding protection). Called inbrowser_navigateandbrowser_new_tab - MCP rate limiting: per-category delays (navigate 500ms, interact 200ms, evaluate 1000ms) prevent runaway agents. Read-only tools are unlimited
- Recipe
warnIfEmpty(): all list-returning recipes append a warning string when results are empty (page structure may have changed) - Config permissions:
saveConfig()sets chmod 600,loadConfig()warns to stderr if file is world-readable - IMAP hardening: 1MB per-command buffer, 5MB session buffer, 10s connect timeout, 30s session timeout
- Exported test helpers:
validateUrl,validateUrlWithDns,isPrivateHost,getToolCategoryfrom server.ts;warnIfEmptyfrom base.ts
npm run build # tsc -> dist/commander- CLI frameworkplaywright-core- CDP connection for cookie/session reading and recipeschalk- Terminal colors for text output@modelcontextprotocol/sdk- MCP server protocolzod- Schema validation (required by MCP SDK)