Deployment
Local Development
cd agent
# Install dependencies
uv sync
# Copy and edit environment variables
cp .env.example .env
# Run the agent
uv run ziada-mcpThe agent starts on port 8081 by default.
Docker
Dockerfile
Multi-stage build:
- Build stage: Uses
uvto build a wheel - Runtime stage: Python 3.12-slim with the wheel installed
docker-compose.yml
services:
agent:
build: .
ports:
- "8081:8081"
env_file: .env
healthcheck:
test: ["CMD", "python", "-c", "import socket; s=socket.socket(); s.connect(('localhost',8081)); s.close()"]
interval: 30s
timeout: 5s
retries: 3Important: The healthcheck uses TCP connection (not HTTP) because each HTTP probe opens an MCP session and triggers the API's 15-minute login rate-lock.
Build and Run
docker compose build
docker compose up -dProduction (VPS)
Server: 13.140.167.42 (SSH alias: camel)
Architecture
Internet -> Nginx (TLS) -> Agent (port 8087 -> container 8081)Deploy Steps
# SSH into server
ssh camel
# Navigate to project
cd ~/ziadapos-go/deploy
# Pull latest changes
git pull
# Rebuild and restart
docker compose build agent
docker compose up -d --force-recreate agent
# Verify health
docker compose ps agentNginx Configuration
The agent is exposed at https://agent.ziadapos.com/mcp via nginx reverse proxy.
CI/CD (GitHub Actions)
Pipeline
-
Test job:
ruff check(lint)pytest(tests)
-
Deploy job (on push to main):
- rsync to VPS
- Docker build
- Docker compose up
- Health verification
Workflow File
.github/workflows/deploy.yml
Troubleshooting
Login Rate Lock
If the account gets locked due to too many login attempts:
# Clear the lock from Redis
redis-cli DEL "login:lock:<identifier>"Environment Changes
If you change .env variables, you must recreate the container:
docker compose up -d --force-recreate agentEnvironment variables are baked at container creation time.
Checking Logs
docker compose logs -f agentRestarting
docker compose restart agentTesting
cd agent
# Run linting
ruff check src/
# Run tests
pytest tests/ -vTest Coverage
6 tests covering:
- All domain tools are registered (>= 109 tools)
- Prompts are registered
- OpenAI tool schema conversion
- Agent loop: tool call then answer
- Agent loop: handles tool errors gracefully
- HTTP bridge endpoint
- Phone number normalization