Skip to content

Commit 0705f9a

Browse files
committed
update to http server, docker build working
1 parent 44884c7 commit 0705f9a

File tree

3 files changed

+85
-42
lines changed

3 files changed

+85
-42
lines changed

browserbase/Dockerfile

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

44
WORKDIR /app
55

6-
# Install dependencies
7-
COPY browserbase/package.json browserbase/package-lock.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-
# Install dependencies
11-
RUN npm install
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
1212

13-
# Copy the rest of the application source code
14-
COPY browserbase/ .
13+
# Copy all source files
14+
COPY . .
1515

16-
# Build the TypeScript source code
17-
RUN npm run build
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"
1818

19-
# Create the final image from a smaller Node.js runtime
19+
# Production stage
2020
FROM node:18-alpine
2121

2222
# Set the working directory
2323
WORKDIR /app
2424

25-
# Copy built files from the builder stage
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
2633
COPY --from=builder /app/dist /app/dist
27-
COPY --from=builder /app/package.json /app/package.json
28-
COPY --from=builder /app/package-lock.json /app/package-lock.json
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
2938

30-
# Define environment variables (can be overridden)
39+
# Define environment variables (will be provided by Smithery)
3140
ENV NODE_ENV=production
32-
ENV BROWSERBASE_API_KEY=<YOUR_BROWSERBASE_API_KEY>
33-
ENV BROWSERBASE_PROJECT_ID=<YOUR_BROWSERBASE_PROJECT_ID>
3441

35-
# Expose a default port (useful if deploying as a service) 8931 is standard for sse mcp
42+
# Expose a default port (useful if deploying as a service)
3643
EXPOSE 8931
3744

38-
CMD [ "node", "cli.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: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
22

3-
startCommand:
4-
type: stdio
5-
configSchema:
6-
# JSON Schema defining the configuration options for the MCP.
7-
type: object
8-
required:
9-
- browserbaseApiKey
10-
- browserbaseProjectId
11-
properties:
12-
browserbaseApiKey:
13-
type: string
14-
description: The API key for Browserbase.
15-
browserbaseProjectId:
16-
type: string
17-
description: The project ID for Browserbase.
18-
commandFunction:
19-
|-
20-
config => ({command: 'node', args: ['cli.js'], env: {BROWSERBASE_API_KEY: config.browserbaseApiKey, BROWSERBASE_PROJECT_ID: config.browserbaseProjectId}})
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+
# commandFunction: |
20+
# config => ({
21+
# command: 'node',
22+
23+
# env: {
24+
# BROWSERBASE_API_KEY: config.browserbaseApiKey,
25+
# BROWSERBASE_PROJECT_ID: config.browserbaseProjectId
26+
# }
27+
# })
2128

29+
startCommand:
2230
type: http
2331
configSchema:
2432
type: object
@@ -36,6 +44,12 @@ startCommand:
3644
browserbaseProjectId:
3745
type: string
3846
description: The project ID for Browserbase.
39-
commandFunction:
40-
|-
41-
config => ({command: 'node', args: ['cli.js --port', config.port], env: {BROWSERBASE_API_KEY: config.browserbaseApiKey, BROWSERBASE_PROJECT_ID: config.browserbaseProjectId}})
47+
commandFunction: |
48+
config => ({
49+
command: 'node',
50+
args: ['cli.js', '--port', config.port.toString()],
51+
env: {
52+
BROWSERBASE_API_KEY: config.browserbaseApiKey,
53+
BROWSERBASE_PROJECT_ID: config.browserbaseProjectId
54+
}
55+
})

0 commit comments

Comments
 (0)