Managing All Your Dahua Cameras with AI via MCP

brianegge

Getting comfortable
Apr 27, 2020
213
275
Ridgefield, CT
I built an open-source MCP (Model Context Protocol) server for Dahua/Amcrest cameras and wanted to share a practical example of what it enables.

The Problem

I have 15 Dahua/Amcrest cameras. They're on an isolated VLAN with no internet access. Managing settings across all of them means logging into 15 web UIs, or scripting curl commands with digest auth. Neither is fun.

The Solution

The Dahua MCP server wraps the CGI HTTP API so an AI assistant (Claude, in my case) can query and configure cameras through natural conversation. You define your cameras in a JSON config file and the server handles digest auth, CGI response parsing, and multi-camera
routing.

Real Example: Fixing NTP Across 15 Cameras

I asked Claude to "verify all cameras have the right time and timezone settings." It pulled the NTP config from every camera in parallel and came back with this:

Code:
  | Camera           | NTP Enabled | NTP Server        |
  |------------------|:-----------:|-------------------|
  | mailbox-cam      | Yes         | clock.isc.org     |
  | deck-cam         | No          | pool.ntp.org      |
  | swing-cam        | No          | pool.ntp.org      |
  | front-lawn-cam   | Yes         | time.windows.com  |
  | garden-cam       | No          | pool.ntp.org      |
  | treeline-cam     | Yes         | clock.isc.org     |
  | west-lawn-cam    | No          | pool.ntp.org      |
  | peach-tree-cam   | Yes         | clock.isc.org     |
  | shed-cam         | No          | clock.isc.org     |
  | driveway-cam     | No          | pool.ntp.org      |
  | play-cam         | Yes         | clock.isc.org     |
  | front-entry-cam  | No          | pool.ntp.org      |
  | garage-cam       | No          | clock.isc.org     |
  | garage-left-cam  | Yes         | clock.isc.org     |
  | garage-right-cam | Yes         | clock.isc.org     |

8 of 15 cameras had NTP disabled, and the ones that were enabled pointed at 3 different external servers — none of which were reachable since the cameras can't reach the internet.

I told Claude: "The cameras don't have access outside the LAN. Install NTP on my Ubuntu server, create a DNS alias 'ntp' on the EdgeRouter, then point all the cameras to ntp.home."

In one shot it:
  1. Installed chrony on my Ubuntu 24.04 server and configured it to serve NTP to the LAN
  2. Added a static host mapping on my EdgeRouter (ntp.home → 192.168.x.y)
  3. Set all 15 cameras to NTP enabled, server = ntp.home
  4. Verified the settings took on every camera

The whole thing took about 60 seconds. No web UIs, no curl commands, no spreadsheets to track progress.

What the MCP Server Covers

It's not just NTP. The server exposes 20 tools covering the main CGI endpoints:

  • System Info — getSystemInfo, getDeviceType, getSoftwareVersion, getSerialNo, etc. (magicBox.cgi)
  • Config Read — Generic getConfig for any named section (MotionDetect, Encode, Network, NTP, VideoInMode, etc.)
  • Config Write — Generic setConfig, plus convenience wrappers for motion detection and record mode
  • System Control — Reboot, take snapshot
  • Logs — Search device logs (wraps the 3-step startFind/doFind/stopFind API)

Every tool takes a camera name parameter, so one server manages all your cameras. It uses httpx with built-in DigestAuth — no custom auth code needed.

Another Example: Maintenance Reboot Scheduling

Same session, I asked Claude to verify all cameras reboot weekly on Tuesday between 2-4 AM with no overlaps. It pulled the AutoMaintain config from all 15 and found:

  • 2 cameras had auto-reboot disabled
  • 2 cameras were set to the wrong day (Friday, Wednesday)
  • 3 cameras were scheduled outside the 2-4 AM window
  • 2 pairs of cameras had identical reboot times

It then staggered all 15 cameras 8 minutes apart from 2:00 AM to 3:52 AM, every Tuesday. One conversation to audit and fix the entire fleet.

Setup

Camera config is a simple JSON file:
Code:
  {
    "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"}
    ]
  }

Works over stdio for direct CLI use or as a Docker container with HTTP transport. Has a read-only mode if you want to prevent any write operations.

If anyone's interested in trying it out or contributing, happy to share more details. You can find installation instructions on GitHub - brianegge/dahua-mcp: MCP server for Dahua/Amcrest IP camera management