# RCWeb screenshot recipe

Version: 13

## Screenshot of the current screen

Capture only when requested. Substitute the selected `ROOM_ID` and exact discovered `CLIENT_ID`; use `timeout_ms: 30000`. Return metadata unchanged. The chat shows the image; the model cannot see its pixels.

```javascript
var target = {room: 'ROOM_ID', client: 'CLIENT_ID'};
if (!window.rc || !rc.connected || rc.room !== target.room || rc.client !== target.client) {
    fail('The selected screen is no longer connected.');
} else if (window.__rcMcpCapture1 && window.__rcMcpCapture1.version === 2) {
    window.__rcMcpCapture1.capture(target, reply, fail);
} else {
    var script = document.createElement('script');
    var finished = false;
    var timer;
    var loaded = function (ok) {
        if (finished) return;
        finished = true;
        window.clearTimeout(timer);
        script.onload = script.onerror = null;
        if (script.parentNode) script.parentNode.removeChild(script);
        try {
            if (ok && window.__rcMcpCapture1 && window.__rcMcpCapture1.version === 2) {
                window.__rcMcpCapture1.capture(target, reply, fail);
            } else fail('The screenshot helper could not load on this screen.');
        } catch (error) { fail(String(error.message || error)); }
    };
    timer = window.setTimeout(function () { loaded(false); }, 8000);
    script.src = '/mcp/capture-bundle.js?v=2';
    script.onload = function () { loaded(true); };
    script.onerror = function () { loaded(false); };
    document.head.appendChild(script);
}
```
