|
1 |
| -# Browserbase MCP Server |
| 1 | +# Playwright Browserbase MCP Server |
2 | 2 |
|
3 |
| - |
| 3 | +A Model Context Protocol server that uses Playwright and Browserbase |
| 4 | +to provide browser automation tools. |
4 | 5 |
|
5 |
| -## Get Started |
| 6 | +## Setup |
6 | 7 |
|
7 |
| -1. Run `npm install` to install the necessary dependencies, then run `npm run build` to get `dist/index.js`. |
| 8 | +1. Install dependencies: |
| 9 | + ```bash |
| 10 | + npm install |
| 11 | + ``` |
| 12 | +2. Set environment variables (e.g., in a `.env` file): |
| 13 | + * `BROWSERBASE_API_KEY`: Your Browserbase API key. |
| 14 | + * `BROWSERBASE_PROJECT_ID`: Your Browserbase project ID. |
| 15 | +3. Compile TypeScript: |
| 16 | + ```bash |
| 17 | + npm run build |
| 18 | + ``` |
8 | 19 |
|
9 |
| -2. Set up your Claude Desktop configuration to use the server. |
| 20 | +## Running |
10 | 21 |
|
11 |
| -```json |
12 |
| -{ |
13 |
| - "mcpServers": { |
14 |
| - "browserbase": { |
15 |
| - "command": "node", |
16 |
| - "args": ["path/to/mcp-server-browserbase/browserbase/dist/index.js"], |
17 |
| - "env": { |
18 |
| - "BROWSERBASE_API_KEY": "<YOUR_BROWSERBASE_API_KEY>", |
19 |
| - "BROWSERBASE_PROJECT_ID": "<YOUR_BROWSERBASE_PROJECT_ID>" |
20 |
| - } |
21 |
| - } |
22 |
| - } |
23 |
| -} |
| 22 | +```bash |
| 23 | +node dist/index.js |
24 | 24 | ```
|
25 | 25 |
|
26 |
| -3. Restart your Claude Desktop app and you should see the tools available clicking the 🔨 icon. |
27 |
| - |
28 |
| -4. Start using the tools! Below is an image of Claude closing a browser session. |
29 |
| - |
30 |
| -<p align="center"> |
31 |
| - <img src="../assets/browserbase-demo.png" alt="demo" width="600"/> |
32 |
| -</p> |
33 |
| - |
34 |
| - |
35 |
| -## Tools |
36 |
| - |
37 |
| -### Browserbase API |
38 |
| - |
39 |
| -- **browserbase_create_session** |
40 |
| - |
41 |
| - - Create a new cloud browser session using Browserbase |
42 |
| - - No required inputs |
43 |
| - |
44 |
| -- **browserbase_navigate** |
45 |
| - |
46 |
| - - Navigate to any URL in the browser |
47 |
| - - Input: `url` (string) |
48 |
| - |
49 |
| -- **browserbase_screenshot** |
50 |
| - |
51 |
| - - Capture screenshots of the entire page or specific elements |
52 |
| - - Inputs: |
53 |
| - - `name` (string, required): Name for the screenshot |
54 |
| - - `selector` (string, optional): CSS selector for element to screenshot |
55 |
| - - `width` (number, optional, default: 800): Screenshot width |
56 |
| - - `height` (number, optional, default: 600): Screenshot height |
57 |
| - |
58 |
| -- **browserbase_click** |
59 |
| - |
60 |
| - - Click elements on the page |
61 |
| - - Input: `selector` (string): CSS selector for element to click |
62 |
| - |
63 |
| -- **browserbase_fill** |
64 |
| - |
65 |
| - - Fill out input fields |
66 |
| - - Inputs: |
67 |
| - - `selector` (string): CSS selector for input field |
68 |
| - - `value` (string): Value to fill |
69 |
| - |
70 |
| -- **browserbase_evaluate** |
71 |
| - |
72 |
| - - Execute JavaScript in the browser console |
73 |
| - - Input: `script` (string): JavaScript code to execute |
74 |
| - |
75 |
| -- **browserbase_get_content** |
76 |
| - |
77 |
| - - Extract all content from the current page |
78 |
| - - Input: `selector` (string, optional): CSS selector to get content from specific elements |
79 |
| - |
80 |
| -- **browserbase_parallel_sessions** |
81 |
| - - Create multiple browser sessions and navigate to different URLs |
82 |
| - - Input: `sessions` (array): Array of objects containing: |
83 |
| - - `url` (string): URL to navigate to |
84 |
| - - `id` (string): Session identifier |
85 |
| - |
86 |
| -### Resources |
87 |
| - |
88 |
| -The server provides access to two types of resources: |
89 |
| - |
90 |
| -1. **Console Logs** (`console://logs`) |
91 |
| - |
92 |
| - - Browser console output in text format |
93 |
| - - Includes all console messages from the browser |
94 |
| - |
95 |
| -2. **Screenshots** (`screenshot://<name>`) |
96 |
| - - PNG images of captured screenshots |
97 |
| - - Accessible via the screenshot name specified during capture |
98 |
| - |
99 |
| -## Key Features |
100 |
| - |
101 |
| -- Cloud browser automation |
102 |
| -- Web data extraction |
103 |
| -- Console log monitoring |
104 |
| -- Screenshot capabilities |
105 |
| -- JavaScript execution |
106 |
| -- Basic web interaction (navigation, clicking, form filling) |
107 |
| - |
108 |
| -## License |
109 |
| - |
110 |
| -This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository. |
| 26 | +The server communicates over stdio according to the Model Context Protocol. |
| 27 | + |
| 28 | +## Structure |
| 29 | + |
| 30 | +* `src/`: TypeScript source code |
| 31 | + * `index.ts`: Main entry point, env checks, shutdown |
| 32 | + * `server.ts`: MCP Server setup and request routing |
| 33 | + * `sessionManager.ts`: Handles Browserbase session creation/management |
| 34 | + * `tools/`: Tool definitions and implementations |
| 35 | + * `resources/`: Resource (screenshot) handling |
| 36 | + * `types.ts`: Shared TypeScript types |
| 37 | +* `dist/`: Compiled JavaScript output |
| 38 | +* `tests/`: Placeholder for tests |
| 39 | +* `utils/`: Placeholder for utility scripts |
| 40 | +* `Dockerfile`: For building a Docker image |
| 41 | +* Configuration files (`.json`, `.ts`, `.mjs`, `.npmignore`) |
| 42 | + |
| 43 | +## TODO |
| 44 | + |
| 45 | +* Implement true `ref`-based interaction logic for click, type, drag, hover, select_option. |
| 46 | +* Implement element-specific screenshots using `ref`. |
| 47 | +* Add more standard Playwright MCP tools (tabs, navigation, etc.). |
| 48 | +* Add tests. |
0 commit comments