Skip to main content
Glama

camera-mcp

通过 ffmpeg / DirectShow,把本机摄像头能力暴露给 Claude 的 MCP server。

让 Claude 可以直接:列出摄像头 → 拍照 → 录像 → 停止录像,全程本地处理,文件落到磁盘。


功能

工具

说明

list_cameras

列出本机所有 DirectShow 视频设备

take_photo

用指定摄像头拍一张 JPEG

start_recording

后台开始录像(libx264 / mp4),返回 recording_id

stop_recording

优雅停止录像(写 q → ffmpeg 自动收尾,写入 moov 索引)

list_recordings

列出当前所有进行中的录像


Related MCP server: Webcam MCP

环境要求

  • Windows(用了 DirectShow,Linux/macOS 需要换 avfoundation / v4l2)

  • Node.js ≥ 18

  • ffmpeg(在 PATH 里,或自行改成绝对路径)

# Windows 用 winget 装 ffmpeg
winget install ffmpeg

安装 & 构建

cd camera
npm install
npm run build

构建产物在 dist/index.js,可执行项 camera-mcp。


配置到 Claude Code

在 ~/.claude/mcp.json(或项目级 .mcp.json)里加:

{
  "mcpServers": {
    "camera": {
      "command": "node",
      "args": ["C:/Users/hj158/mcp-servers/camera/dist/index.js"]
    }
  }
}

启动后用 claude mcp list 应该能看到 camera: ... √ Connected。


使用示例

帮我拍一张照片

Claude 会调:

take_photo(device="HD Webcam", path="./photos/test.jpg", quality=2)

用 ToDesk Camera 录一段 30 秒视频

start_recording(device="ToDesk Camera", path="./videos/demo.mp4")
# → recording_id: rec_xxxxxxxx_1
# ... 30 秒后 ...
stop_recording(recording_id="rec_xxxxxxxx_1")

工具参数

take_photo

参数

类型

必填

说明

device

string

✅

设备名(必须来自 list_cameras)

path

string

保存路径,默认 ./photos/photo-{timestamp}.jpg

quality

number

JPEG 质量 1-31,数字越小质量越高,默认 2

start_recording

参数

类型

必填

说明

device

string

✅

设备名

path

string

默认 ./videos/video-{timestamp}.mp4

resolution

string

默认 1280x720

fps

number

1-60,默认 30

stop_recording

参数

类型

必填

说明

recording_id

string

✅

start_recording 返回的 ID


工作原理

  • 设备枚举:调 ffmpeg -list_devices true -f dshow -i dummy,正则匹配 "..." (video) 行

  • 拍照:spawn ffmpeg,-frames:v 1 -q:v <quality> 截单帧

  • 录像:spawn ffmpeg 保持长连接,用 Map<recording_id, ChildProcess> 跟踪;停止时往 stdin 写 q,让 ffmpeg 走正常退出流程(否则 mp4 moov 索引缺失,很多播放器打不开)


已知限制

  • Windows-only(DirectShow);跨平台需要按平台分支选择 input format

  • 多进程隔离:每次拍照/录像都新 spawn 一个 ffmpeg,启动开销约 300-500ms

  • 录像启动 500ms 后才检查 exit code,极端情况下启动失败可能要等一下才能发现


License

MIT

Available Tools

5 tools
list_camerasA

列出本机所有可用的摄像头设备名(Windows DirectShow)

Inputs: no named parameters.

list_recordingsA

列出当前所有正在进行的录像

Inputs: no named parameters.

start_recordingB

开始用指定摄像头录像(后台运行,返回 recording_id 用于停止)

Inputs: device (required), fps, path, resolution.

stop_recordingB

停止指定 recording_id 的录像(让 ffmpeg 优雅退出,正确写入 mp4 索引)

Inputs: recording_id (required).

take_photoB

用指定摄像头拍一张照片,保存到本地

Inputs: device (required), path, quality.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool maps to a distinct resource+action: enumerate cameras, capture a still photo, begin a recording, end a recording by id, and enumerate active recordings. There is no overlap between take_photo (one-shot still) and start_recording (ongoing session), and the start/stop/list triple is cleanly separated by recording_id.

    Naming Consistency5/5

    All five tools follow a strict snake_case verb_noun pattern (list_cameras, take_photo, start_recording, stop_recording, list_recordings). Verb choices (list/take/start/stop) are conventional and predictable.

    Tool Count5/5

    Five tools is well-scoped for a local camera capture server: discovery, photo, and the recording lifecycle, with nothing extraneous. Every tool clearly earns its place and there is no filler.

    Completeness4/5

    The core lifecycle is covered: camera discovery, one-shot photo, and start/stop/list for recordings. Minor gaps remain — no tool to list or retrieve previously saved photos/recordings, and no way to configure output path or format — but agents can work around these via local filesystem access.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that provides LLM agents with direct access to webcam hardware for capturing high-resolution photos and recording video sequences. It enables autonomous agents to monitor environments and interact with the physical world through standard Model Context Protocol tools.
      6
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables interaction with local camera devices to capture and process images. It allows LLMs to access video devices with configurable settings such as resolution, orientation, and image format.
      1
      MIT