Getting Started
Get up and running with OpenMCP in minutes
Prerequisites
- Python 3.9+ - Required for running OpenMCP
- Chrome/Chromium - For browser automation (auto-installed via webdriver-manager)
- pip - Python package manager
Installation
Option 1: Install from PyPI (Recommended)
pip install openmcp
Option 2: Install from Source
git clone https://github.com/openmcp-pro/openmcp.git
cd openmcp
pip install -e .
Note: On first run, OpenMCP will automatically download the Chrome WebDriver if not already installed.
Quick Setup
Step 1: Initialize Configuration
openmcp init-config
This creates a config.yaml
file with default settings and generates an API key.
Step 2: Start the Server
openmcp serve
The server will start on http://localhost:9000
by default.
Step 3: Test the Installation
import openmcp
import asyncio
async def test_openmcp():
async with openmcp.browser() as browser:
await browser.navigate("https://example.com")
await browser.screenshot("test.png")
print("✅ OpenMCP is working!")
asyncio.run(test_openmcp())
Configuration
OpenMCP uses a YAML configuration file. Here's the default configuration:
# config.yaml
server:
host: "0.0.0.0"
port: 9000
log_level: "INFO"
auth:
secret_key: "your-secret-key-here"
api_keys:
default:
name: "default"
permissions: ["browseruse"]
services:
- name: "browseruse"
enabled: true
config:
headless: true
timeout: 30
max_sessions: 5
Environment Variables
You can also configure OpenMCP using environment variables:
# Server configuration
export OPENMCP_HOST=0.0.0.0
export OPENMCP_PORT=9000
export OPENMCP_SECRET_KEY=your-secret-key
# Service configuration
export BROWSERUSE_HEADLESS=true
export BROWSERUSE_TIMEOUT=30
export BROWSERUSE_MAX_SESSIONS=5
CLI Commands
openmcp serve
Start the OpenMCP server
# Basic usage
openmcp serve
# Custom host and port
openmcp serve --host 0.0.0.0 --port 8000
# With custom config file
openmcp serve --config /path/to/config.yaml
# Enable auto-reload for development
openmcp serve --reload
openmcp init-config
Initialize a default configuration file
# Create config.yaml in current directory
openmcp init-config
# Create config in specific location
openmcp init-config --output /path/to/config.yaml
# Force overwrite existing config
openmcp init-config --force
openmcp create-key
Create a new API key
# Create a new API key
openmcp create-key my-app
# Create key with expiration
openmcp create-key my-app --expires 30
# Use custom config file
openmcp create-key my-app --config /path/to/config.yaml
openmcp list-services
List available MCP services
openmcp list-services
Docker Setup
Using Docker Compose (Recommended)
# docker-compose.yml
version: '3.8'
services:
openmcp:
image: openmcp/openmcp:latest
ports:
- "9000:9000"
environment:
- OPENMCP_SECRET_KEY=your-secret-key
volumes:
- ./config.yaml:/app/config.yaml:ro
restart: unless-stopped
# Start with Docker Compose
docker-compose up -d
Using Docker directly
# Build the image
docker build -t openmcp .
# Run the container
docker run -p 9000:9000 \
-e OPENMCP_SECRET_KEY=your-secret \
-v $(pwd)/config.yaml:/app/config.yaml:ro \
openmcp
Troubleshooting
Chrome/WebDriver Issues
If you encounter Chrome or WebDriver issues:
# Install Chrome manually (Ubuntu/Debian)
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google.list
sudo apt-get update
sudo apt-get install google-chrome-stable
# Or use Chromium
sudo apt-get install chromium-browser
Port Already in Use
If port 9000 is already in use:
# Use a different port
openmcp serve --port 8000
# Or set in config.yaml
server:
port: 8000
Permission Issues
If you get permission errors:
# Install in user directory
pip install --user openmcp
# Or use virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install openmcp