Skip to content

Commit 8633f55

Browse files
committed
restrcture
1 parent 7b1ca25 commit 8633f55

29 files changed

+2784
-1559
lines changed

browserbase/.npmignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Ignore node_modules, build output, logs, env files, etc.
2+
node_modules
3+
dist
4+
*.log
5+
.env*
6+
7+
# Ignore IDE/editor files
8+
.vscode
9+
.idea
10+
*.swp
11+
*.swo
12+
13+
# Ignore OS files
14+
.DS_Store
15+
Thumbs.db

browserbase/Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Basic Node.js Dockerfile
2+
FROM node:20-slim
3+
4+
WORKDIR /usr/src/app
5+
6+
# Install dependencies
7+
COPY package*.json ./
8+
RUN npm ci --only=production
9+
10+
# Copy application code
11+
COPY dist ./dist
12+
COPY src ./src
13+
14+
# Define environment variables (can be overridden)
15+
ENV NODE_ENV=production
16+
# ENV BROWSERBASE_API_KEY=your_api_key
17+
# ENV BROWSERBASE_PROJECT_ID=your_project_id
18+
19+
# Expose a default port (useful if deploying as a service, though stdio is used now)
20+
EXPOSE 8080
21+
22+
CMD [ "node", "dist/index.js" ]

browserbase/README.md

+41-103
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,48 @@
1-
# Browserbase MCP Server
1+
# Playwright Browserbase MCP Server
22

3-
![cover](../assets/browserbase-mcp.png)
3+
A Model Context Protocol server that uses Playwright and Browserbase
4+
to provide browser automation tools.
45

5-
## Get Started
6+
## Setup
67

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+
```
819

9-
2. Set up your Claude Desktop configuration to use the server.
20+
## Running
1021

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
2424
```
2525

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.

browserbase/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
],
1616
"scripts": {
1717
"build": "tsc && shx chmod +x dist/*.js",
18-
"playwright": "tsc && shx chmod +x dist/playwright.js",
1918
"prepare": "npm run build",
2019
"watch": "tsc --watch",
2120
"inspector": "npx @modelcontextprotocol/inspector build/index.js"

browserbase/playwright.config.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Basic Playwright config - primarily useful if adding actual
5+
* tests later, might not be strictly needed for the MCP server itself.
6+
*/
7+
export default defineConfig({
8+
testDir: './tests',
9+
fullyParallel: true,
10+
forbidOnly: !!process.env.CI,
11+
retries: process.env.CI ? 2 : 0,
12+
workers: process.env.CI ? 1 : undefined,
13+
reporter: 'html',
14+
use: {
15+
trace: 'on-first-retry',
16+
// Base URL to use in actions like `await page.goto('/')`
17+
// baseURL: 'http://127.0.0.1:3000',
18+
},
19+
20+
/* Configure projects for major browsers */
21+
// projects: [
22+
// {
23+
// name: 'chromium',
24+
// use: { ...devices['Desktop Chrome'] },
25+
// },
26+
// ],
27+
28+
/* Run your local dev server before starting the tests */
29+
// webServer: {
30+
// command: 'npm run start',
31+
// url: 'http://127.0.0.1:3000',
32+
// reuseExistingServer: !process.env.CI,
33+
// },
34+
});

0 commit comments

Comments
 (0)