# Dev Container Configuration

This directory contains the development container configuration for the RabbitMQ MCP Server project.

## Features

- **Python 3.12** development environment
- **uv** package manager pre-installed
- **RabbitMQ 3.13** with Management Plugin running in a separate container
- **Docker-in-Docker** support for testcontainers
- **VS Code extensions** pre-configured (Python, Pylance, Black, Ruff, etc.)
- **Pre-commit hooks** automatically installed

## Quick Start

### Prerequisites

- [Docker Desktop](https://www.docker.com/products/docker-desktop) installed and running
- [VS Code](https://code.visualstudio.com/) with [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

### Opening the Project

1. Open VS Code
2. Open the project folder
3. When prompted "Reopen in Container", click **Reopen in Container**
   - Or use Command Palette (Cmd/Ctrl+Shift+P) → "Dev Containers: Reopen in Container"

### First Time Setup

The container will automatically:
1. Build the Python 3.12 environment
2. Start RabbitMQ on ports 5672 (AMQP) and 15672 (Management UI)
3. Install all dependencies via `uv sync --all-extras`
4. Install pre-commit hooks

This may take 3-5 minutes the first time.

## Services

### App Container (Development)
- Python 3.12 environment
- uv package manager
- Access to workspace at `/workspace`
- Docker socket mounted for testcontainers

### RabbitMQ Container
- Image: `rabbitmq:3.13-management`
- AMQP Port: `5672`
- Management UI: `http://localhost:15672`
- Default credentials: `guest/guest`

Access RabbitMQ Management UI in your browser: http://localhost:15672

## Common Tasks

```bash
# Run tests
uv run pytest

# Run tests with coverage
uv run pytest --cov=rabbitmq_mcp_server --cov-report=html

# Type checking
uv run mypy src/

# Linting
uv run ruff check src/ tests/

# Formatting
uv run black src/ tests/

# Run MCP server (stdio mode)
uv run python -m rabbitmq_mcp_server

# Run MCP server (HTTP mode)
uv run python -m rabbitmq_mcp_server --transport http --port 8000
```

## Troubleshooting

### RabbitMQ not accessible
```bash
# Check if RabbitMQ container is running
docker ps | grep rabbitmq

# Check RabbitMQ logs
docker logs rabbitmq-mcp-dev

# Restart RabbitMQ
docker restart rabbitmq-mcp-dev
```

### Docker socket issues
If testcontainers fail:
```bash
# Verify Docker socket is accessible
ls -la /var/run/docker.sock

# Check user is in docker group
groups
```

### Rebuild container
If dependencies are not installing correctly:
1. Command Palette → "Dev Containers: Rebuild Container"
2. Or rebuild without cache: "Dev Containers: Rebuild Container Without Cache"

## Directory Structure

```
.devcontainer/
├── devcontainer.json    # Main configuration
├── docker-compose.yml   # Multi-container setup
├── Dockerfile          # Development container image
└── README.md           # This file
```

## Customization

### Adding VS Code Extensions
Edit `devcontainer.json` → `customizations.vscode.extensions`

### Changing Python Version
Edit `Dockerfile` → `FROM python:3.12-slim` (change 3.12 to desired version)

### RabbitMQ Version
Edit `docker-compose.yml` → `image: rabbitmq:3.13-management` (change 3.13 to desired version)

## References

- [VS Code Dev Containers Documentation](https://code.visualstudio.com/docs/devcontainers/containers)
- [Docker Compose Documentation](https://docs.docker.com/compose/)
- [RabbitMQ Docker Image](https://hub.docker.com/_/rabbitmq)
