camera-mcp

camera-mcp

MCP server for controlling USB-connected DSLR cameras (e.g., Canon EOS 6D) via natural language, with features like capture, exposure settings, and autonomous timelapse with feedback-based auto exposure.

Category
Visit Server

README

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段ぶん露出を下げ切りました。


必要なもの

  • 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured