Add Docker support (#220)

This commit is contained in:
Cody Rigney 2025-04-21 20:26:50 -04:00 committed by GitHub
parent d4f8f87b03
commit dc955c73a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

22
Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM node:22-bookworm-slim
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json at this stage to leverage the build cache
COPY package*.json ./
# Install dependencies
RUN npm ci
# Install chromium and its dependencies, but only for headless mode
RUN npx -y playwright install --with-deps --only-shell chromium
# Copy the rest of the app
COPY . .
# Build the app
RUN npm run build
# Run in headless and only with chromium (other browsers need more dependencies not included in this image)
ENTRYPOINT ["node", "cli.js", "--headless", "--browser", "chromium"]

View File

@ -17,6 +17,8 @@ A Model Context Protocol (MCP) server that provides browser automation capabilit
### Example config
#### NPX
```js
{
"mcpServers": {
@ -30,6 +32,19 @@ A Model Context Protocol (MCP) server that provides browser automation capabilit
}
```
#### Docker
**NOTE:** The Docker implementation only supports headless chromium at the moment.
```js
{
"mcpServers": {
"playwright": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "mcp/playwright"]
}
}
}
```
#### Installation in VS Code
@ -154,6 +169,13 @@ To use Vision Mode, add the `--vision` flag when starting the server:
Vision Mode works best with the computer use models that are able to interact with elements using
X Y coordinate space, based on the provided screenshot.
### Build with Docker
You can build the Docker image yourself.
```
docker build -t mcp/playwright .
```
### Programmatic usage with custom transports
```js