set_camera_recording
Start or stop video recording on UniFi cameras to monitor security footage and manage surveillance activities.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/protect.js:75-91 (handler)MCP tool handler for 'set_camera_recording'. Implements confirmation logic, invokes the UniFi client function, and formats the response.handler: async ({ hostId, cameraId, mode, confirm }) => { if (!confirm) { return { content: [{ type: 'text', text: `Recording mode change cancelled. Set confirm=true to change recording mode to "${mode}".` }] }; } const result = await unifi.setCameraRecording(hostId, cameraId, mode); return { content: [{ type: 'text', text: `Camera recording mode set to "${mode}". ${JSON.stringify(result, null, 2)}` }] }; }
- src/tools/protect.js:69-74 (schema)Zod schema defining input parameters for the tool: hostId, cameraId, mode (enum: always/motion/never), and confirm flag.schema: z.object({ hostId: z.string().describe('The host ID'), cameraId: z.string().describe('The camera ID'), mode: z.enum(['always', 'motion', 'never']).describe('Recording mode: always, motion-only, or never'), confirm: z.boolean().describe('Confirm this action') }),
- src/tools/protect.js:67-92 (registration)Registration of the 'set_camera_recording' tool within the protectTools object, including description, schema, and handler.set_camera_recording: { description: 'Set the recording mode for a camera', schema: z.object({ hostId: z.string().describe('The host ID'), cameraId: z.string().describe('The camera ID'), mode: z.enum(['always', 'motion', 'never']).describe('Recording mode: always, motion-only, or never'), confirm: z.boolean().describe('Confirm this action') }), handler: async ({ hostId, cameraId, mode, confirm }) => { if (!confirm) { return { content: [{ type: 'text', text: `Recording mode change cancelled. Set confirm=true to change recording mode to "${mode}".` }] }; } const result = await unifi.setCameraRecording(hostId, cameraId, mode); return { content: [{ type: 'text', text: `Camera recording mode set to "${mode}". ${JSON.stringify(result, null, 2)}` }] }; } },
- src/unifi-client.js:239-244 (helper)Helper function in UniFi client that makes the actual API call to patch the camera's recording settings.export async function setCameraRecording(hostId, cameraId, mode) { const response = await cloudApi.patch(`/v1/hosts/${hostId}/cameras/${cameraId}`, { recordingSettings: { mode } }); return response.data; }