How rzeldent/esp32-cam-ai works
ESP32-CAM MCP Server exposes camera and device controls to AI assistants and automation clients over MCP. The principal workflow is a client request reaching the firmware’s HTTP/MCP entry point, being dispatched to a tool operation, and returning a structured result or error. The README also describes network recovery/discovery, OTA, diagnostics, and browser CORS support. Most tool handling is in one source file; the excerpts do not show every handler or setup relationship, so unverified links are omitted or marked dashed.
Main entry points: main.cpp Request Dispatch · mcp.cpp JSON-RPC Response · camera_config.h Camera Board Settings · mcp_schema_tool.h Tool / Result Schemas
Components 19
MCP and HTTP
- HTTP MCP Endpoint
src/main.cpp - Request Dispatch
src/main.cpp - JSON-RPC Request Parser
lib/mcp/mcp.cpp - JSON-RPC Response
lib/mcp/mcp.cpp - Tool / Result Schemas
lib/mcp/mcp_schema_tool.h - Protocol Errors
lib/mcp/mcp_schema_error.h
Device Tools
- Camera Capture
src/main.cpp - LED and Flash Control
src/main.cpp - GPIO Control
src/main.cpp - System Diagnostics
src/main.cpp
Hardware Configuration
- Camera Board Settings
include/camera_config.h - LED Board Mapping
include/board_config.h - Firmware Defaults
include/settings.h
Connectivity and Reliability
- WiFi Connection
src/main.cpp - mDNS Discovery
src/main.cpp - OTA Updates
src/main.cpp - Watchdog / Reconnect
src/main.cpp
Other components
- AI / Automation Client
- Web Browser
Connections 20
- AI / Automation Client → HTTP MCP Endpoint: sends MCP requests
README.md - HTTP MCP Endpoint → Request Dispatch: routes requests
src/main.cpp - Request Dispatch → JSON-RPC Request Parser: parses JSON-RPC
- Request Dispatch → Camera Capture: dispatches capture
src/main.cpp - Request Dispatch → LED and Flash Control: dispatches controls
src/main.cpp - Request Dispatch → GPIO Control: dispatches GPIO
src/main.cpp - Request Dispatch → System Diagnostics: dispatches diagnostics
src/main.cpp - Request Dispatch → Tool / Result Schemas: builds tool list
src/main.cpp - Camera Capture → Camera Board Settings: uses camera settings
- Camera Capture → Firmware Defaults: uses capture defaults
src/main.cpp - LED and Flash Control → LED Board Mapping: uses LED mapping
src/main.cpp - GPIO Control → Camera Board Settings: checks reserved pins
- Request Dispatch → JSON-RPC Response: creates responses
- Request Dispatch → Protocol Errors: reports failures
src/main.cpp - JSON-RPC Response → AI / Automation Client: returns JSON-RPC
- HTTP MCP Endpoint → Web Browser: allows CORS access
README.md - WiFi Connection → mDNS Discovery: enables discovery
src/main.cpp - WiFi Connection → Watchdog / Reconnect: reconnects on loss
README.md - OTA Updates → AI / Automation Client: accepts firmware updates
- Watchdog / Reconnect → HTTP MCP Endpoint: maintains service
src/main.cpp