get_camera_snapshot
Retrieve a camera snapshot as a base64 encoded string by providing the camera's device index.
Instructions
Get a camera snapshot as a base64 encoded string.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| idx | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:919-925 (handler)The actual handler function for the 'get_camera_snapshot' tool. It takes a camera idx, fetches the snapshot image from Domoticz, base64-encodes the content, and returns it as JSON.
@mcp.tool() async def get_camera_snapshot(idx: int) -> str: """Get a camera snapshot as a base64 encoded string.""" async with create_client() as client: response = await _do_request(client, "GET", f"{DOMOTICZ_BASE_URL}/camsnapshot.jpg?idx={idx}") img_b64 = base64.b64encode(response.content).decode("utf-8") return json.dumps({"status": "OK", "result": img_b64}) - src/domoticz_mcp/server.py:919-919 (registration)The tool is registered via the @mcp.tool() decorator on line 919, which is the standard FastMCP registration mechanism.
@mcp.tool() - src/domoticz_mcp/server.py:920-920 (schema)The function signature defines the input schema: 'idx' is an integer (the camera index). Returns a JSON string containing 'status' and 'result' (base64 image).
async def get_camera_snapshot(idx: int) -> str: - src/domoticz_mcp/server.py:17-17 (helper)The base64 module is used to encode the camera snapshot binary data into a base64 string.
import base64 - src/domoticz_mcp/server.py:269-269 (helper)The _do_request helper is used by get_camera_snapshot to perform the HTTP GET request to the Domoticz camsnapshot.jpg endpoint.
async def _do_request(client: httpx.AsyncClient, method: str, url: str, **kwargs) -> httpx.Response: