Expose browser tools to MCP clients and gateways.
1npx playwright install chromium
12345678{ "mcpServers": { "libretto-browser-tools": { "command": "npx", "args": ["-y", "libretto-browser-tools"] } } }
npx -y libretto-browser-tools mcp, npx -y libretto-browser-tools --headed for a visible local browser, or npx -y libretto-browser-tools --provider kernel for a cloud provider.| Flag | Effect |
--provider <name> | Browser provider: local (default), kernel, browserbase, browser-use, steel, libretto-cloud |
--headed | Show the browser window (default is headless). Applies to local, kernel, and libretto-cloud |
--allowed-domain <host> | Restrict http(s) navigations to this host (repeatable) |
--blocked-domain <host> | Block http(s) navigations to this host (repeatable) |
KERNEL_API_KEY, BROWSERBASE_API_KEY, BROWSER_USE_API_KEY, STEEL_API_KEY, LIBRETTO_API_KEY). See each provider page for required variables. Local Chromium (npx playwright install chromium) is only required for --provider local.browser_open, browser_connect, browser_exec, browser_snapshot, browser_status, and browser_close.libretto-browser-tools/mcp when you own the MCP server and transport. Install the package (the MCP SDK is included as a dependency).12pnpm add libretto-browser-tools npx playwright install chromium
123456789101112131415161718192021222324import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { LocalBrowserProvider } from "libretto-browser-tools"; import { registerMcpBrowserTools } from "libretto-browser-tools/mcp"; const server = new McpServer({ name: "libretto-browser-tools", version: "1.0.0", }); const { dispose } = registerMcpBrowserTools( server, new LocalBrowserProvider({ headless: true }), // optional: { allowedDomains: ["example.com"] } ); await server.connect(new StdioServerTransport()); async function shutdown() { await server.close(); await dispose(); } process.once("SIGINT", shutdown); process.once("SIGTERM", shutdown);
localhost. Deploy the MCP server on a reachable host, or run the gateway and server on the same network.browser_status.isError: true and keep the actionable Libretto error in text content. A browser_snapshot call with screenshot: true returns the accessibility tree as text and the PNG as MCP image content.browser_exec is marked destructive and open-world because one Playwright script can read or change any page the browser can reach. Enforce access with host policies and domain policy; annotations are hints, not a sandbox.createBrowserTools for another framework