Skip to content

Commit 2dcd760

Browse files
authored
Merge pull request #60 from browserbase/kj/smithery
[feature]: dockerfile and smithery setup
2 parents 508958f + f3f6c50 commit 2dcd760

File tree

3 files changed

+113
-16
lines changed

3 files changed

+113
-16
lines changed

browserbase/Dockerfile

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
1-
# Basic Node.js Dockerfile
2-
FROM node:20-slim
1+
# Build stage
2+
FROM node:20-slim AS builder
33

4-
WORKDIR /usr/src/app
4+
WORKDIR /app
55

6-
# Install dependencies
7-
COPY package*.json ./
8-
RUN npm ci --only=production
6+
# Copy package files first for better layer caching
7+
COPY package.json package-lock.json ./
98

10-
# Copy application code
11-
COPY dist ./dist
12-
COPY src ./src
9+
# Install all dependencies including dev dependencies for building
10+
# --ignore-scripts prevents the prepare script from running prematurely
11+
RUN npm ci --ignore-scripts
1312

14-
# Define environment variables (can be overridden)
13+
# Copy all source files
14+
COPY . .
15+
16+
# Build the TypeScript source code manually instead of using the npm script
17+
RUN npx tsc && npx shx chmod +x dist/*.js 2>/dev/null || echo "No executable JS files found"
18+
19+
# Production stage
20+
FROM node:18-alpine
21+
22+
# Set the working directory
23+
WORKDIR /app
24+
25+
# Copy package files
26+
COPY package.json package-lock.json ./
27+
28+
# Install only production dependencies
29+
# --ignore-scripts prevents the prepare script from running
30+
RUN npm ci --omit=dev --ignore-scripts
31+
32+
# Copy built files from builder stage
33+
COPY --from=builder /app/dist /app/dist
34+
COPY --from=builder /app/cli.js /app/cli.js
35+
COPY --from=builder /app/index.js /app/index.js
36+
COPY --from=builder /app/index.d.ts /app/index.d.ts
37+
COPY --from=builder /app/config.d.ts /app/config.d.ts
38+
39+
# Define environment variables (will be provided by Smithery)
1540
ENV NODE_ENV=production
16-
# ENV BROWSERBASE_API_KEY=your_api_key
17-
# ENV BROWSERBASE_PROJECT_ID=your_project_id
1841

19-
# Expose a default port (useful if deploying as a service, though stdio is used now)
20-
EXPOSE 8080
42+
# Expose a default port (useful if deploying as a service)
43+
EXPOSE 8931
2144

22-
CMD [ "node", "dist/index.js" ]
45+
# Command to run the application
46+
CMD [ "node", "cli.js", "--port", "8931" ]

browserbase/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,28 @@ to provide browser automation tools.
3535

3636
## Local Dev
3737

38-
To run locally we can self-host over SSE.
38+
To run locally we can use STDIO or self-host over SSE.
39+
40+
### STDIO:
41+
42+
To your MCP Config JSON file add the following:
43+
44+
```json
45+
{
46+
"mcpServers": {
47+
"playwright": {
48+
"command" : "node",
49+
"args" : ["/path/to/mcp-server-browserbase/browserbase/cli.js"],
50+
"env": {
51+
"BROWSERBASE_API_KEY": "",
52+
"BROWSERBASE_PROJECT_ID": ""
53+
}
54+
}
55+
}
56+
}
57+
```
58+
59+
### SSE:
3960

4061
```bash
4162
node cli.js --port 8931

browserbase/smithery.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2+
3+
startCommand:
4+
# Using stdio type which is the most common for MCPs
5+
type: stdio
6+
configSchema:
7+
# JSON Schema defining the configuration options for the MCP.
8+
type: object
9+
required:
10+
- browserbaseApiKey
11+
- browserbaseProjectId
12+
properties:
13+
browserbaseApiKey:
14+
type: string
15+
description: The API key for Browserbase.
16+
browserbaseProjectId:
17+
type: string
18+
description: The project ID for Browserbase.
19+
port:
20+
type: number
21+
description: The port to listen on.
22+
host:
23+
type: string
24+
description: The host to listen on.
25+
contextId:
26+
type: string
27+
description: The context ID to use for the session.
28+
persist:
29+
type: boolean
30+
description: Whether to persist the context.
31+
proxies:
32+
type: boolean
33+
description: Whether to use proxies.
34+
cookies:
35+
type: object
36+
description: Cookies to use for the session.
37+
browserWidth:
38+
type: number
39+
description: Width of the browser window.
40+
browserHeight:
41+
type: number
42+
description: Height of the browser window.
43+
44+
commandFunction: |
45+
config => ({
46+
command: 'node',
47+
args: ['cli.js'],
48+
env: {
49+
BROWSERBASE_API_KEY: config.browserbaseApiKey,
50+
BROWSERBASE_PROJECT_ID: config.browserbaseProjectId
51+
}
52+
})

0 commit comments

Comments
 (0)