Complete technical documentation for self-hosting clawdbot on your own infrastructure. This guide assumes familiarity with Linux, Node.js, and server administration.
Before proceeding, ensure you have:
node -v and npm -v)SSH into your server and update system packages:
ssh root@your-server-ip # Update system packages sudo apt update && sudo apt upgrade -y # Install required dependencies sudo apt install -y curl wget git build-essential # Install Node.js 18 via NodeSource curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt install -y nodejs # Verify installation node -v # Should output v18.x.x npm -v # Should output 9.x.x or higher
Set up database and caching services:
# Install PostgreSQL sudo apt install -y postgresql postgresql-contrib # Start PostgreSQL service sudo systemctl start postgresql sudo systemctl enable postgresql # Create database and user sudo -u postgres psql << EOF CREATE USER clawdbot WITH PASSWORD 'your_secure_password'; CREATE DATABASE clawdbot_db OWNER clawdbot; GRANT ALL PRIVILEGES ON DATABASE clawdbot_db TO clawdbot; EOF # Install Redis sudo apt install -y redis-server # Configure Redis for production sudo sed -i 's/supervised no/supervised systemd/' /etc/redis/redis.conf sudo systemctl restart redis sudo systemctl enable redis # Verify Redis is running redis-cli ping # Should return PONG
Clone the repository and set up environment variables:
# Clone the repository cd /opt sudo git clone https://github.com/clawdbot/clawdbot.git cd clawdbot # Install dependencies (may take several minutes) npm install --legacy-peer-deps # Create environment configuration cp .env.example .env nano .env
Configure the following environment variables in .env:
# Required API Keys ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxx # Database Configuration DATABASE_URL=postgresql://clawdbot:your_secure_password@localhost:5432/clawdbot_db # Redis Configuration REDIS_URL=redis://localhost:6379 # MCP Server Configuration MCP_TRANSPORT=stdio MCP_SERVER_PORT=3100 # Security JWT_SECRET=generate_a_64_character_random_string_here ENCRYPTION_KEY=generate_another_32_character_string # Optional: Integration Keys TELEGRAM_BOT_TOKEN=your_telegram_bot_token DISCORD_BOT_TOKEN=your_discord_bot_token WHATSAPP_API_KEY=your_whatsapp_business_api_key # Server Configuration NODE_ENV=production PORT=3000
Set up the MCP server configuration for Claude integration:
# Create MCP configuration directory
mkdir -p ~/.config/clawdbot
# Create claude_desktop_config.json
cat > ~/.config/clawdbot/claude_desktop_config.json << 'EOF'
{
"mcpServers": {
"clawdbot": {
"command": "node",
"args": ["/opt/clawdbot/dist/mcp-server.js"],
"transport": "stdio",
"env": {
"NODE_ENV": "production",
"LOG_LEVEL": "info"
}
}
},
"globalShortcut": "Ctrl+Shift+Space",
"theme": "system"
}
EOF
# Set proper permissions
chmod 600 ~/.config/clawdbot/claude_desktop_config.jsonInitialize database schema and build production assets:
# Generate Prisma client npx prisma generate # Run database migrations npx prisma migrate deploy # Build production bundle npm run build # Verify build output ls -la dist/ # Should contain compiled JavaScript files
Create a systemd service for automatic startup and process management:
# Create systemd service file sudo cat > /etc/systemd/system/clawdbot.service << 'EOF' [Unit] Description=Clawdbot AI Assistant After=network.target postgresql.service redis.service [Service] Type=simple User=root WorkingDirectory=/opt/clawdbot ExecStart=/usr/bin/node dist/server.js Restart=on-failure RestartSec=10 StandardOutput=syslog StandardError=syslog SyslogIdentifier=clawdbot Environment=NODE_ENV=production [Install] WantedBy=multi-user.target EOF # Reload systemd and start service sudo systemctl daemon-reload sudo systemctl enable clawdbot sudo systemctl start clawdbot # Check service status sudo systemctl status clawdbot
Set up Nginx as reverse proxy with Let's Encrypt SSL certificate:
# Install Nginx and Certbot
sudo apt install -y nginx certbot python3-certbot-nginx
# Create Nginx configuration
sudo cat > /etc/nginx/sites-available/clawdbot << 'EOF'
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}
EOF
# Enable site and remove default
sudo ln -s /etc/nginx/sites-available/clawdbot /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
# Test and reload Nginx
sudo nginx -t
sudo systemctl reload nginx
# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com --non-interactive --agree-tos -m your@email.comSecure your server with UFW firewall rules:
# Enable UFW firewall sudo ufw default deny incoming sudo ufw default allow outgoing # Allow SSH (important: don't lock yourself out!) sudo ufw allow ssh # Allow HTTP and HTTPS sudo ufw allow 'Nginx Full' # Enable firewall sudo ufw enable # Verify rules sudo ufw status verbose
Test your clawdbot installation:
# Check all services are running sudo systemctl status clawdbot sudo systemctl status nginx sudo systemctl status postgresql sudo systemctl status redis # Test API endpoint curl -X GET https://your-domain.com/api/health # Check logs for any errors sudo journalctl -u clawdbot -f
Error: EACCES permission denied
Fix: Run sudo chown -R $USER:$USER /opt/clawdbot
Error: Cannot connect to PostgreSQL
Fix: Check DATABASE_URL format and ensure PostgreSQL is running with sudo systemctl status postgresql
Error: MCP server failed to start
Fix: Verify claude_desktop_config.json syntax and file permissions
Error: npm install fails with ERESOLVE
Fix: Use npm install --legacy-peer-deps flag