# Dahua Mcp

> MCP server for Dahua/Amcrest IP camera management

- **Type:** MCP server
- **Install:** `agentstack add mcp-brianegge-dahua-mcp`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [brianegge](https://agentstack.voostack.com/s/brianegge)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [brianegge](https://github.com/brianegge)
- **Source:** https://github.com/brianegge/dahua-mcp

## Install

```sh
agentstack add mcp-brianegge-dahua-mcp
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Dahua MCP Server

MCP server for managing Dahua/Amcrest IP cameras via their CGI HTTP API. Supports multiple cameras from a single instance, with both stdio and HTTP transports.

## Quick Start

### 1. Create a cameras config file

Create `~/.config/dahua-mcp/cameras.yaml` (or `cameras.json`) with your camera credentials. This is the default config location — no env var needed.

**JSON** (`cameras.json`):
```json
{
  "cameras": [
    {
      "name": "front-door",
      "host": "192.168.1.108",
      "port": 80,
      "username": "admin",
      "password": "secret"
    },
    {
      "name": "backyard",
      "host": "192.168.1.109",
      "port": 80,
      "username": "admin",
      "password": "secret"
    }
  ]
}
```

**YAML** (`cameras.yaml`):
```yaml
cameras:
  - name: front-door
    host: 192.168.1.108
    port: 80
    username: admin
    password: secret
  - name: backyard
    host: 192.168.1.109
    port: 80
    username: admin
    password: secret
```

Each camera entry supports:

| Field | Required | Default | Description |
|-------|----------|---------|-------------|
| `name` | Yes | — | Unique camera name used in all tool calls |
| `host` | Yes | — | Camera hostname or IP address |
| `port` | No | `80` | HTTP port (`443` auto-enables HTTPS) |
| `username` | Yes | — | Camera username |
| `password` | Yes | — | Camera password |
| `verify_ssl` | No | `false` | Verify SSL certificates |

### 2. Add the MCP server

#### Option A: stdio (Claude Code / Claude Desktop)

Using the Claude Code CLI (cameras config auto-discovered from `~/.config/dahua-mcp/`):

```sh
# From PyPI
claude mcp add dahua-mcp -- uvx dahua-mcp

# From a local clone
claude mcp add dahua-mcp -- uv run --directory /path/to/dahua-mcp dahua-mcp

# With a custom config path
claude mcp add dahua-mcp -e DAHUA_CAMERAS_CONFIG=/path/to/cameras.json -- uvx dahua-mcp
```

Or manually add to your Claude Code settings (`~/.claude.json`) or Claude Desktop config:

```json
{
  "mcpServers": {
    "dahua-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": ["dahua-mcp"]
    }
  }
}
```

Or run from a local clone:

```json
{
  "mcpServers": {
    "dahua-mcp": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "/path/to/dahua-mcp", "dahua-mcp"]
    }
  }
}
```

To override the config location, add an `env` block:

```json
{
  "env": {
    "DAHUA_CAMERAS_CONFIG": "/custom/path/cameras.yaml"
  }
}
```

#### Option B: Docker container (HTTP transport)

Run the container with your config file volume-mounted:

```sh
docker run -d \
  -v /path/to/cameras.json:/config/cameras.json:ro \
  -p 8000:8000 \
  ghcr.io/brianegge/dahua-mcp:latest
```

Then add the HTTP server to your MCP client config:

```json
{
  "mcpServers": {
    "dahua-mcp": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}
```

To use a YAML config with Docker:

```sh
docker run -d \
  -v /path/to/cameras.yaml:/config/cameras.yaml:ro \
  -e DAHUA_CAMERAS_CONFIG=/config/cameras.yaml \
  -p 8000:8000 \
  ghcr.io/brianegge/dahua-mcp:latest
```

To add bearer token authentication:

```sh
docker run -d \
  -v /path/to/cameras.json:/config/cameras.json:ro \
  -e MCP_HTTP_BEARER_TOKEN=your-secret-token \
  -p 8000:8000 \
  ghcr.io/brianegge/dahua-mcp:latest
```

```json
{
  "mcpServers": {
    "dahua-mcp": {
      "type": "http",
      "url": "http://localhost:8000/mcp",
      "headers": {
        "Authorization": "Bearer your-secret-token"
      }
    }
  }
}
```

## Environment Variables

All settings beyond camera credentials are configured via environment variables:

| Variable | Default | Description |
|----------|---------|-------------|
| `DAHUA_CAMERAS_CONFIG` | `~/.config/dahua-mcp/cameras.yaml` | Path to cameras config file (JSON or YAML). Auto-discovers from `~/.config/dahua-mcp/` if not set. |
| `DAHUA_TIMEOUT` | `20` | HTTP request timeout in seconds |
| `READ_ONLY_MODE` | `false` | Disable all write tools (reboot, set_config, etc.) |
| `DISABLED_TAGS` | — | Comma-separated tags to disable (e.g. `destructive,write`) |
| `LOG_LEVEL` | `INFO` | Logging level |
| `RATE_LIMIT_ENABLED` | `false` | Enable rate limiting |
| `RATE_LIMIT_MAX_REQUESTS` | `60` | Max requests per window |
| `RATE_LIMIT_WINDOW_MINUTES` | `1` | Rate limit window in minutes |
| `MCP_TRANSPORT` | `stdio` | Transport type: `stdio`, `sse`, or `http` |
| `MCP_HTTP_HOST` | `0.0.0.0` | HTTP bind host |
| `MCP_HTTP_PORT` | `8000` | HTTP bind port |
| `MCP_HTTP_BEARER_TOKEN` | — | Optional bearer token for HTTP auth |

## Available Tools

### Discovery

| Tool | Description | Read-Only |
|------|-------------|-----------|
| `list_cameras` | List all configured cameras (name, host, port) | Yes |

### System Info

| Tool | Description | Read-Only |
|------|-------------|-----------|
| `get_system_info` | Get full system info (device type, serial, firmware, etc.) | Yes |
| `get_device_type` | Get the device type/model | Yes |
| `get_software_version` | Get firmware version | Yes |
| `get_machine_name` | Get the camera's machine name | Yes |
| `get_serial_number` | Get the serial number | Yes |
| `get_hardware_version` | Get the hardware version | Yes |
| `get_vendor` | Get the vendor/manufacturer | Yes |

### Config Read

| Tool | Description | Read-Only |
|------|-------------|-----------|
| `get_config` | Get any config section by name | Yes |
| `get_motion_detection` | Get motion detection config | Yes |
| `get_video_in_mode` | Get video input mode (day/night profile) | Yes |
| `get_encoding_config` | Get encoding/streaming config | Yes |
| `get_network_config` | Get network config (IP, gateway, DNS) | Yes |
| `get_ntp_config` | Get NTP time sync config | Yes |

### Config Write

| Tool | Description | Destructive |
|------|-------------|-------------|
| `set_config` | Set arbitrary config key-value pairs | Yes |
| `enable_motion_detection` | Enable/disable motion detection | No |
| `set_record_mode` | Set recording mode (auto/manual/off) | No |

### System Control

| Tool | Description | Destructive |
|------|-------------|-------------|
| `reboot` | Reboot the camera | Yes |
| `take_snapshot` | Take a JPEG snapshot (base64) | No |

### Logs

| Tool | Description | Read-Only |
|------|-------------|-----------|
| `search_logs` | Search camera logs by time range and type | Yes |

## Development

```sh
git clone https://github.com/brianegge/dahua-mcp.git
cd dahua-mcp
uv sync
uv run pre-commit install  # Install ruff format/lint hook
uv run pytest              # Run tests
uv run ruff check .        # Lint
```

## License

MIT License - see LICENSE file for details.

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [brianegge](https://github.com/brianegge)
- **Source:** [brianegge/dahua-mcp](https://github.com/brianegge/dahua-mcp)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-brianegge-dahua-mcp
- Seller: https://agentstack.voostack.com/s/brianegge
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
