Playwright browser automation service for LLM-driven UI interaction.
Features:
- Session-based browser management with domain allowlisting
- HTTP API endpoints for browser actions (navigate, click, type, wait, screenshot, snapshot)
- Session lifecycle management (create, close, status)
- Automatic session cleanup (idle timeout, max lifetime)
- Resource limits (max sessions, max actions per session)
- Domain filtering via route interception
API Surface:
- POST /sessions - Create session with allowed_domains
- DELETE /sessions/{id} - Close session
- GET /sessions/{id}/status - Get session info
- POST /sessions/{id}/navigate - Navigate to URL
- POST /sessions/{id}/click - Click element
- POST /sessions/{id}/type - Type into element
- POST /sessions/{id}/wait - Wait for condition
- POST /sessions/{id}/screenshot - Capture screenshot
- POST /sessions/{id}/snapshot - Get accessibility tree
Security:
- Mandatory domain allowlist per session
- Network request filtering
- Session isolation via browser contexts
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
29 lines
716 B
Docker
29 lines
716 B
Docker
# MCP Browser Sidecar Dockerfile
|
|
# Based on Playwright's official Python image with Chromium pre-installed
|
|
|
|
FROM mcr.microsoft.com/playwright/python:v1.40.0-jammy
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy requirements first for layer caching
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY app/ ./app/
|
|
|
|
# Create screenshots directory
|
|
RUN mkdir -p /screenshots && chmod 777 /screenshots
|
|
|
|
# Expose port
|
|
EXPOSE 8931
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8931/health || exit 1
|
|
|
|
# Run the server
|
|
CMD ["uvicorn", "app.server:app", "--host", "0.0.0.0", "--port", "8931"]
|