agent-watch
by sleepyquq
README.md
# agent-watch
[简体中文](README.zh-CN.md)
**Give an AI agent a video page URL and let it sample frames just as it would from a local video.** The agent can preview the video, choose which segment to inspect and at what FPS, and resample from the already captured media.
`agent-watch` opens supported video pages in an isolated headless Microsoft Edge instance and holds playback data in memory through Blob Downloader. Local FFmpeg reads those in-memory tracks to extract timestamped JPEG frames without first saving a full video file. The server connects to your agent over local MCP stdio, and it is currently a v0.1.0 preview released under the MIT license.
## Install with an Agent
Copy this prompt into an agent that can run local commands on Windows and configure your MCP client.
```text
Install and configure agent-watch for my MCP client from https://github.com/sleepyquq/agent-watch.
Check for Node.js 22 or later, Microsoft Edge, FFmpeg, and FFprobe.
Clone the repository, or reuse an existing local copy. Run npm ci and npm run setup in the repository.
Register a local MCP stdio server named agent-watch. Use node as the command, followed by the absolute path to src/cli.js in the repository and the argument mcp.
If FFmpeg or FFprobe is installed outside PATH, configure FFMPEG_PATH or FFPROBE_PATH with its absolute path.
Verify the configured server lists open_video and sample_frames. Tell me the installation path and the result.
```
## Manual Installation
### Prerequisites
You need Node.js (`>=22`), Microsoft Edge, and both FFmpeg and FFprobe available on your system `PATH`. If FFmpeg or FFprobe is not on `PATH`, set the `FFMPEG_PATH` and `FFPROBE_PATH` environment variables to point to the corresponding executables.
### Install Dependencies and Set Up Edge Capture
On Windows, use PowerShell 7 to clone the repository from GitHub, enter the directory, install dependencies, and initialize the extension cache. Running `npm ci` reproduces project dependencies from the lockfile, and `npm run setup` downloads, verifies, and caches Blob Downloader 0.2.0 so you do not need to install the extension manually in your regular Microsoft Edge browser.
```powershell
git clone https://github.com/sleepyquq/agent-watch.git
cd agent-watch
npm ci
npm run setup
```
### Configure Your MCP Client
Clients that support MCP stdio can connect to `agent-watch` through a local startup command. Replace the repository path in the following `mcpServers` JSON example with the absolute path on your machine.
```json
{
"mcpServers": {
"agent-watch": {
"command": "node",
"args": ["C:/path/to/agent-watch/src/cli.js", "mcp"]
}
}
}
```
## Quick Start
Agents choose among available tools. To make frame extraction the first step, name the `agent-watch` MCP in your request. Replace `<video-page-url>` with your link in the prompt below.
```text
Use the agent-watch MCP first to extract frames and analyze what happens on screen.
Start with an overview, then choose a time range and FPS for a closer look. Cite the frame timestamps in your analysis.
Use a browser to check page data such as likes or comments if the task calls for it.
<video-page-url>
```
If you know the range, ask “Use the agent-watch MCP to extract frames from 26 to 29 seconds at 15 FPS.” The agent can sample the same captured media again at another FPS.
If you prefer to try frame extraction from the command line first, run the following command and replace `<video-page-url>` with the target page URL.
```powershell
node src/cli.js extract "<video-page-url>" --start 26 --end 29 --fps 15
```
You can specify the output directory with `output_dir` or the `--out` CLI option. By default, files go into the `agent-watch` folder in your system temporary directory. Each `frames-*` subfolder contains the JPEGs and a `timeline.json` manifest.
## MCP Tools and Examples
| Tool | Key Parameters | Purpose |
| --- | --- | --- |
| `open_video` | `url`, optional `start_seconds` and `end_seconds` pair | Captures web video in the background and returns `video_id` |
| `video_status` | `video_id` | Checks capture progress, available `frame_ranges`, and `save_ready` status |
| `video_overview` | `video_id`, optional `frame_count` | Extracts a small set of timestamped overview frames from captured video |
| `sample_frames` | `video_id`, `start_seconds`, `end_seconds`, `fps` | Samples frames for a range and FPS, returning JPEG paths, actual timestamps, and missing slots |
| `save_video` | `video_id`, optional `output_dir`, `filename` | Saves complete captured audio and video locally when explicitly requested by the user |
| `close_video` | `video_id` | Closes the session and releases media memory |
### Sampling Frames by Segment
To preview first, pass only `url` to `open_video`, poll `video_status` with the returned `video_id`, and call `video_overview` once the status becomes `ready`.
When the target segment is already known, pass the time range directly to `open_video`. Capture stops as soon as the buffered data passes the coverage check for that segment. If coverage validation fails, the server retries once using the same `video_id`.
```json
{"url":"<video-page-url>","start_seconds":26,"end_seconds":29}
```
Once `video_status` becomes `ready`, pass the ID returned by `open_video` into `sample_frames`.
```json
{"video_id":"<video_id>","start_seconds":26,"end_seconds":29,"fps":15}
```
The sampling range includes the start time and excludes the end time. `time_seconds` is the actual playback time of the frame, `source_pts_seconds` is the source presentation timestamp of the decoded frame, and `missing_slots` records sampling positions that did not match a real frame. Call `close_video` when done.
### Saving Full Audio and Video
Frame sampling outputs only JPEG frames and a timestamp manifest. When the user explicitly asks to save the full video, you can reuse a session where `save_ready` is `true`, or call `open_video` with `for_save` set to `true` to capture complete audio and video tracks and then call `save_video` once `video_status` becomes `ready`.
## Tests and Verified Scope
Run the 11 tests from the repository directory.
```powershell
npm test
```
Verified on Windows with Microsoft Edge 158.0.4370.33 and Node.js 24.22.1. From an empty cache, dependency installation, extension download, and MCP frame extraction on a synthetic video all passed. A separate test on a Douyin video page extracted 45/45 frames from 26 to 29 seconds at 15 FPS with no missing frames.
For media processing, FFmpeg handles captured MP4 and WebM tracks. This tool only supports page media that plays in the isolated Edge instance and is captured by Blob Downloader, while compatibility with other websites or operating systems varies by browser and page behavior and has not been broadly verified.
## Related Links
The project repository is hosted at [agent-watch](https://github.com/sleepyquq/agent-watch).
Playback data capture relies on the upstream project [Blob Downloader](https://github.com/aeroxy/blob-downloader).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues