Skip to main content
Glama

camera-mcp

USB接続の一眼レフ(Canon EOS 6D で開発)を MCP(Model Context Protocol)サーバーとして公開し、 AIアシスタントから自然言語で操作できるようにする試作です。

Wi-Fi API(Canon CCAPI)を持たない世代のカメラでも、Windows用フリーソフト digiCamControl(内部はCanon EDSDK)のCLIをラップすることで 「今夜0時から100秒間隔で、白飛びしないように撮って」が通ります。

これは個人の実験プロジェクトです。 メーカー非公式で、EOS 6D + Windows 環境でしか動作確認していません。


できること(MCPツール9本)

ツール

内容

camera_status

接続状態・現在のISO/絞り/シャッター速度・実行中ジョブ

camera_capture

1枚撮影してファイルパスを返す

camera_set

iso / aperture / shutterspeed / exposurecompensation / whitebalance の変更

camera_focus

ライブビュー中のフォーカスモーター駆動(near/far × ステップ数)

timelapse_start

タイムラプス開始(間隔・枚数・開始/終了時刻の予約。バックグラウンド実行)

timelapse_stop / timelapse_status

停止 / 進行状況(撮影枚数・エラー数・現在の露出)

timelapse_list

過去セッションの一覧

video_create

連番写真から mp4 を生成(ffmpeg)

目玉:フィードバック式自動露出(ホーリーグレイル対応)

夜から朝にかけてのタイムラプスは、固定露出だと明け方に必ず白飛びします。 timelapse_start(auto_exposure=True) を指定すると、

撮影 → 届いた画像の平均輝度と白飛び率を測定 → 目標輝度とのズレを 1/3 段刻みで補正 → 次のコマ

というループが回ります(USB接続で撮影画像が即PCに届くことを利用)。

  • 明るくする方向:シャッターを長く(上限まで)→ 足りなければISOを上げる

  • 暗くする方向:ISOを下げる → その後シャッターを短く

  • 1コマあたりの変化量を制限してチラつきを抑制

  • 既定はオフ。完全固定露出との比較ができます

実測(8秒/ISO6400 で開始した一晩、203コマ)では、夜明けの平均輝度を最大149.4・白飛び率1.4%に抑えて 約100分で16段ぶん露出を下げ切りました。


Related MCP server: Webcam MCP

必要なもの

  • Windows(digiCamControl が Windows 専用のため)

  • Python 3.10 以上

  • digiCamControl(winget install digiCamControl など)

    • 同梱の ffmpeg.exe を動画生成に使います

  • digiCamControl 対応のカメラ(USB接続。開発機は Canon EOS 6D)

  • Python パッケージ:fastmcp==3.4.4 / Pillow


インストール

cd C:\path\to\camera-mcp
py -3 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .

動作確認(カメラ不要のオフラインテスト):

.\.venv\Scripts\python.exe test_ae.py

実機での通しテスト(実際にシャッターを4回切ります):

.\.venv\Scripts\python.exe test_e2e.py

MCPサーバーとして登録する

Claude Code の場合:

claude mcp add camera --scope user -- C:\path\to\camera-mcp\.venv\Scripts\python.exe -m camera_mcp

設定ファイルに直接書く場合(claude_desktop_config.json 等):

{
  "mcpServers": {
    "camera": {
      "command": "C:\\path\\to\\camera-mcp\\.venv\\Scripts\\python.exe",
      "args": ["-m", "camera_mcp"],
      "env": {
        "CAMERA_MCP_DATA_DIR": "D:\\CameraMCP\\sessions"
      }
    }
  }
}

pip install -e . をしていない場合は、スクリプトを直接指すこともできます (args を ["C:\\path\\to\\camera-mcp\\src\\camera_mcp\\server.py"] にする)。

登録後は「1枚撮って」「ISOを800にして」「30秒間隔で撮影開始」といった日本語で呼び出せます。


設定(環境変数)

すべて任意。既定値のままで標準構成なら動きます(src/camera_mcp/config.py)。

環境変数

既定値

用途

CAMERA_MCP_DCC_DIR

C:\Program Files (x86)\digiCamControl

digiCamControl のインストール先

CAMERA_MCP_REMOTE_CMD

<DCC_DIR>\CameraControlRemoteCmd.exe

CLI本体

CAMERA_MCP_APP

<DCC_DIR>\CameraControl.exe

GUI本体(未起動なら自動で起動する)

CAMERA_MCP_FFMPEG

<DCC_DIR>\ffmpeg.exe

動画生成に使う ffmpeg

CAMERA_MCP_DATA_DIR

<ホーム>\CameraMCP\sessions

撮影データの保存先

CAMERA_MCP_STABLE_TIMEOUT

15

撮影ファイルの書き込み完了待ちの上限(秒)

保存先はクラウド同期フォルダの外にすること。 一晩で1,000枚・数GBになるため、 OneDrive等の配下に置くと同期が破綻します(digiCamControl の既定保存先は同期フォルダ配下なので要変更)。


撮影前のチェックリスト(実戦で効いたもの)

  • 電源:一晩撮るならACアダプター推奨。バッテリー運用ならGPS・Wi-Fi・撮影後の画像表示を「切」に

  • オートパワーオフを「切」に

  • ホワイトバランスは固定(太陽光など)。オートだとコマごとに色基準が変わり、後処理の色解析が成立しない

  • 置きピン:AFで合わせてからレンズをMFへ。autofocus=False で撮影する

  • カメラ内蔵時計を合わせる(EXIFの時刻がずれる。本実装の log.jsonl はPC側の時刻を記録している)

  • ae_max_shutter は撮影間隔より必ず短く(露光がインターバルを超えるとリズムが崩れる)

  • シャッター耐久は有限(EOS 6D は約10万回)。間隔と枚数は意識して設計する


既知の制約

  • Windows専用・digiCamControl依存。EOS 6D 以外は未検証

  • digiCamControl と EOS Utility は同時にカメラを掴めない(EOS Utility は終了しておく)

  • セッションを閉じるとジョブも止まる:撮影ループはMCPサーバープロセス内のスレッドで動くため、 クライアント(Claude Code等)を終了するとサーバーごと落ちます。常駐デーモン化は未対応

  • ジョブは同時に1本だけ

  • 測光は全画面平均(200pxサムネイル)。中央重点もROI指定も無いので、 構図内の変化(花が開く等)を明るさの変化と誤認することがあります

  • 白飛び率は縮小画像で測定しているため、実際よりやや小さく出ます(相対比較用の指標)

  • 露出ステップはEVではなくリストのインデックスを数えています。高感度域は刻みが粗いので、 「1コマ最大1段」の意図に対して実際は1段を超えて動くことがあります

  • P制御+デッドバンドのみ(ヒステリシス・積分項なし)。境界付近で明滅(ハンチング)することがあります

  • 雲によるチラつきは撮影中には消せません。フィードバックは常に1コマ遅れなので、 外光が100秒単位で激変する状況では原理的に間に合いません。後処理(デフリッカー)で処理してください

  • UACダイアログや初回接続の承認など、人間の操作が必要な場面があります

先行事例

自動露出ランピング自体は新しい発想ではありません。Magic Lantern の Auto Exposure Ramping、 qDslrDashboard の Auto Holy Grail が同じ考え方を10年以上前から実装しています。 本プロジェクトの位置づけは、その制御ループをMCPツールとして公開し、自然言語で目標を渡せるようにした インターフェース層にあります。

ライセンス

MIT

Available Tools

9 tools
camera_captureA

1枚撮影して保存ファイルのフルパスを返す。autofocus=Falseで置きピン撮影。

Inputs: autofocus. Returns: object

camera_focusA

ライブビュー中にフォーカスモーターを駆動する。near=手前へ, far=奥へ。

レンズの最短撮影距離より近い被写体には合わない(物理限界)。

Inputs: direction (required), size, steps. Returns: object

camera_setB

カメラ設定を変更する。例: iso=800, aperture=5.6, shutterspeed=1/125, iso=Auto。

Inputs: value (required), setting (required). Returns: object

camera_statusA

カメラの接続状態・現在の設定・実行中のタイムラプスジョブを返す。

Inputs: no named parameters. Returns: object

timelapse_listA

過去のタイムラプスセッション一覧(フォルダと枚数)を返す。

Inputs: no named parameters. Returns: result

timelapse_startA

タイムラプス撮影ジョブを開始する(バックグラウンド実行、即座に返る)。

  • name: セッション名(例: asagao)。保存先フォルダ名になる

  • interval_sec: 撮影間隔(秒)

  • count: 撮影枚数の上限(省略可)

  • start_at/end_at: "20:00" 形式。省略時は即開始・無期限(stopで終了)

  • autofocus: 毎回AFするか。夜間はFalse(置きピン)推奨

  • auto_exposure: Trueで自動露出追従(夜→朝の白飛び対策)。Falseなら完全固定露出

  • ae_target: 目標平均輝度(0-255)。夜のシルエット重視なら90前後、標準は115

  • ae_max_shutter: 自動露出が使う最長シャッター秒(インターバルより短くすること)

  • ae_max_iso: 自動露出が使う最大ISO

Inputs: name (required), interval_sec (required), count, end_at, +6 more. Returns: object

timelapse_statusA

タイムラプスジョブの進行状況(撮影枚数・エラー・保存先)を返す。

Inputs: no named parameters. Returns: object

timelapse_stopA

実行中のタイムラプスジョブを停止し、最終状態を返す。

Inputs: no named parameters. Returns: object

video_createA

セッションの連続写真からタイムラプス動画(mp4)を生成する。

session: timelapse_list が返すセッション名、またはフォルダのフルパス。

Inputs: session (required), fps, width. Returns: object

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 9 tools

    Disambiguation4/5

    Most tools are clearly distinct, but camera_status and timelapse_status both report on a running timelapse job, which could cause some confusion. However, camera_status focuses on camera state and settings while timelapse_status is specifically about job progress, so the descriptions help differentiate them.

    Naming Consistency4/5

    The naming follows a consistent pattern of domain_action (e.g., timelapse_start, camera_capture), which is predictable. The only minor inconsistency is video_create using 'video' instead of 'timelapse_' prefix, but this is a small deviation and the overall pattern remains clear.

    Tool Count5/5

    With 9 tools, the server is well-scoped for camera control and timelapse workflows. Each tool serves a distinct and necessary function without redundancy, fitting comfortably within the ideal range.

    Completeness4/5

    The tool surface covers the core lifecycle: camera settings/capture/focus, timelapse start/stop/status, session listing, and video creation. Minor gaps exist, such as no ability to delete sessions or download photos directly, but these are not critical for the primary workflow and can be worked around.

    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