Skip to main content
Glama
genicam-mcp

genicam-mcp

by finnhyun12

genicam-mcp

Vendor-neutral industrial camera control via GenICam GenTL.

An MCP server that enumerates, connects to, configures, and captures from industrial cameras through the GenICam GenTL standard — not through a single vendor's SDK.

Point it at any GenTL producer (.cti) and you get the camera's entire GenICam feature tree: exposure, gain, trigger, ROI, pixel format, and everything else the camera exposes.

Why this exists

Existing camera MCP servers bind to one vendor's SDK (typically pypylon, Basler-only) and expose a single "grab a frame" call. This one goes through the vendor-neutral GenTL layer instead, so one code path is meant to drive any GenTL-compliant camera — Basler, HIKrobot, Teledyne FLIR, Allied Vision, XIMEA — regardless of vendor. (Actually tested producers are listed under Verified below.) It also exposes feature control, not just capture.

No vendor SDK is imported. The only path to the hardware is harvesters → .cti. That constraint is the point of the project.

Related MCP server: dwf-mcp-server

Install

Requires Python 3.12 (the genicam wheels this depends on are version-specific).

git clone https://github.com/finnhyun12/genicam-mcp.git
cd genicam-mcp
uv venv --python 3.12
uv sync

Claude Desktop setup

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "genicam": {
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/genicam-mcp", "run", "genicam-mcp"]
    }
  }
}

If uv is not on your PATH, point at the venv interpreter directly:

{
  "mcpServers": {
    "genicam": {
      "command": "/absolute/path/to/genicam-mcp/.venv/bin/python",
      "args": ["-m", "genicam_mcp.server"]
    }
  }
}

On Windows use .venv\\Scripts\\python.exe and escape backslashes in JSON.

Tools

Tool

Purpose

add_producer(cti_path)

Register a GenTL producer (.cti). Call this first. Multiple producers may be registered.

discover_cameras()

List cameras: index, vendor, model, serial, tl_type.

connect(index)

Open a camera. Required before feature access or capture.

disconnect()

Release the camera.

list_features(category=None)

Walk the node map. Returns name, type, readable/writable, current value, range or options.

get_feature(name)

Read one feature with its type and min/max (or enum options).

set_feature(name, value)

Write any GenICam feature — ExposureTime, Gain, TriggerMode, PixelFormat, Width… Values are cast to the node's type.

grab(save_path=None)

Capture one frame → PNG. Returns width, height, pixel_format, saved_path.

Feature names are case-sensitive and vary by camera. Use list_features() to see what a given camera actually offers rather than guessing.

Finding a .cti producer

Vendor SDKs install their producers and register the directory in the GENICAM_GENTL64_PATH environment variable:

# Linux / macOS
echo $GENICAM_GENTL64_PATH
# Windows
$env:GENICAM_GENTL64_PATH

Common locations:

Vendor

Producer

Allied Vision Vimba X

.../Vimba X/cti/VimbaGigETL.cti, VimbaUSBTL.cti

Basler pylon

.../pylon 6/Runtime/x64/ProducerGEV.cti, ProducerU3V.cti

HIKrobot MVS

.../Common Files/MVS/Runtime/Win64_x64/MvProducerGEV.cti, MvProducerU3V.cti

If add_producer is given a bad path, the error message lists the .cti files it found on your machine.

Demo without hardware

Allied Vision Vimba X ships a Camera Simulator TL — a GenTL producer that presents simulated cameras with real test-pattern frames. No camera required.

  1. Install Vimba X (free).

  2. Register the simulator producer and grab a frame:

add_producer("C:\\Program Files\\Allied Vision\\Vimba X\\cti\\VimbaCameraSimulatorTL.cti")
discover_cameras()
connect(0)
set_feature("TestPattern", "GreyVerticalRamp")
grab("frame.png")

This is the exact producer path used for the end-to-end verification below. On that machine it enumerated three simulated cameras; index 0 was Camera Simulator (G1-030_VSWIR) at 656×520 Mono8. TestPattern accepts Off, GreyVerticalRamp, GreyVerticalRampMoving, ColorVerticalBar, ColorHorizontalBar, and ColorVerticalBarMoving — check get_feature("TestPattern") on your install rather than assuming, since the simulator's model list can differ by Vimba X version.

Note: a vendor's virtual camera feature is not the same thing as a simulator transport layer. Basler's pylon Camera Emulator (PYLON_CAMEMU) and HIKrobot's MVS Virtual Device both live above the GenTL layer and are visible only through their own vendor SDKs — GenTL consumers cannot see them. Vimba X's Camera Simulator is itself a .cti, which is why it works here.

Verified

  • ✅ End-to-end (enumerate → connect → feature R/W → grab → PNG): Allied Vision Vimba X — Camera Simulator TL (GenTL producer)

  • ✅ Producer load & camera enumeration: Basler pylon ProducerU3V.cti

genicam-mcp is built against the GenICam GenTL standard and is expected to work with any compliant producer (Basler, HIKrobot, Teledyne FLIR, Allied Vision, XIMEA, …). Only the producers listed above are actually tested; others are unverified — field reports welcome.

Development

uv run pytest                    # fake-GenTL suite; no hardware, no SDK

The real-producer suite is gated on an env var so day-to-day runs stay fast:

GENTL_CTI=/path/to/Producer.cti uv run pytest -m real_producer -v -s

If GENTL_CTI is set but no camera is found, the suite fails rather than skipping — a gate that silently passes is not a gate.

Known quirks

These are documented because each one looks like a broken server when you hit it cold. Knowing them in advance turns a bug report into a shrug.

  • First add_producer can be slow. Basler's ProducerU3V.cti took over 60 s on its first load (USB bus enumeration). Nothing is wrong — it is enumerating the bus. Allow a generous tool timeout on the first call; a short client timeout will cancel the request and can tear down the MCP session with it.

  • A bad producer can take the process down. MvFGProducerCML.cti segfaults (0xC0000005) when loaded without Camera Link hardware. This happens inside the native library, so no Python try/except can catch it — register only producers that match your hardware.

  • Trigger mode blocks capture. If TriggerMode is On, grab() waits for a trigger and then times out. Set set_feature("TriggerMode", "Off") for free-run.

Implementation notes

Three findings shaped this code. They are recorded here because none of them is visible from the source alone, and each cost real time to track down.

A vendor "virtual camera" is not a simulator transport layer. Basler's pylon Camera Emulator (PYLON_CAMEMU) and HIKrobot's MVS Virtual Device both look like the answer to "test without hardware" — and both are invisible to GenTL. They live above the GenTL boundary, inside the vendor SDK, so only that vendor's own tools can see them. Measured on HIKrobot MVS: the vendor SDK enumerated the virtual camera (MV_VIR_GIGE_DEVICE → 1 device, and only when run elevated), while MvProducerGEV.cti reported 0 through the same machine. Vimba X's Camera Simulator works because it is a .cti. The question to ask of any "virtual camera" feature is not whether it exists but which layer it lives in.

Import the native extensions at module load, never inside a tool call. Deferring import harvesters into the tool body seems tidy — it lets the module import cleanly on machines with no SDK. But FastMCP runs tool functions off the event loop, and loading the genicam native extension there hangs forever: the server accepts the CallToolRequest and then simply never answers. A silent hang is far worse than an immediate error, because the client only sees a timeout and the user has nothing to go on. So the import happens at module load and the failure reason is stashed and raised, as a readable message, at first use.

A GenTL buffer is borrowed, not owned. ia.fetch() hands out a buffer from the acquisition queue; once it is returned, the memory is recycled. Keeping a numpy view past that point does not raise — it silently yields whatever the driver wrote next, which in practice means an all-black frame. This surfaced only against the real Vimba simulator, never against the fakes, because a fake buffer is just a live numpy array. The fake now zeroes its data on __exit__ to model the real lifetime contract, so the failure is reproducible without hardware, and test_real_producer.py asserts the frame is not uniformly zero. A capture test that only checks "a PNG exists" passes on a black image.

Scope

One camera at a time; one frame per grab(). Simultaneous multi-camera acquisition, async streaming, GUI, and web serving are deliberately out of scope.

License

MIT — see LICENSE.

Available Tools

8 tools
add_producerA

GenTL producer(.cti) 파일을 등록한다. 다른 모든 툴보다 먼저 호출해야 한다.

.cti 는 카메라 벤더 SDK 가 설치하는 GenTL 표준 드라이버다. 여러 벤더의
카메라를 동시에 쓰려면 이 툴을 여러 번 호출해 복수 등록하면 된다.
경로가 틀리면 이 PC 에서 발견된 .cti 후보를 에러 메시지에 담아 돌려준다.

Args:
    cti_path: .cti 파일의 절대 경로.

Inputs: cti_path (required). Returns: object

connectA

카메라에 연결한다. feature 제어와 캡처 전에 반드시 필요하다.

이 서버는 한 번에 한 대만 연결한다. 이미 연결된 상태에서 호출하면 기존
연결을 먼저 해제한다.

Args:
    index: discover_cameras() 가 돌려준 index.

Inputs: index (required). Returns: object

disconnectA

현재 카메라 연결을 해제한다. 연결돼 있지 않으면 아무 일도 하지 않는다.

Inputs: no named parameters. Returns: object

discover_camerasA

등록된 producer 전체에서 연결 가능한 카메라를 열거한다.

각 항목의 index 를 connect(index) 에 넘긴다. 벤더/모델/시리얼/전송규격
(tl_type: U3V, GEV 등)을 함께 돌려준다. 0대가 나오면 카메라 전원·케이블과
등록한 .cti 가 그 카메라의 전송규격과 맞는지 확인하라.

Inputs: no named parameters. Returns: result

get_featureB

feature 하나의 현재 값과 타입, 허용 범위(min/max) 또는 선택지를 반환한다.

Args:
    name: GenICam feature 이름. 대소문자를 구분한다 (예: 'ExposureTime').

Inputs: name (required). Returns: object

grabA

1프레임을 획득해 PNG 로 저장하고 크기·픽셀포맷·저장경로를 반환한다.

TriggerMode 가 'On' 이면 트리거가 들어올 때까지 대기하다 타임아웃된다.
자유 실행 캡처를 원하면 먼저 set_feature('TriggerMode', 'Off') 를 호출하라.

Args:
    save_path: 저장할 PNG 경로. 생략하면 임시 디렉터리에 저장하고 그
        경로를 돌려준다.

Inputs: save_path. Returns: object

list_featuresA

카메라가 실제로 제공하는 GenICam feature 목록을 반환한다.

카메라마다 지원 feature 가 다르므로, get_feature/set_feature 로 이름을
추측하기 전에 이 툴로 확인하는 것이 확실하다. 각 항목은 이름·타입·
읽기/쓰기 가능 여부·현재 값을 담는다.

Args:
    category: 지정하면 해당 카테고리 서브트리만 반환한다
        (예: 'AcquisitionControl', 'ImageFormatControl'). 생략하면 전체.

Inputs: category. Returns: result

set_featureA

GenICam feature 값을 설정한다 (노출·게인·트리거·픽셀포맷·ROI 등).

값은 대상 노드 타입에 맞춰 자동 캐스팅된다. 설정에 실패하면 허용 범위나
선택 가능한 값을 에러 메시지에 담아 돌려준다.

일부 feature 는 선행 조건이 있다. 예를 들어 ExposureTime 을 바꾸려면
ExposureAuto 를 먼저 'Off' 로 두어야 하는 카메라가 많다.

Args:
    name: GenICam feature 이름 (예: 'ExposureTime', 'Gain', 'TriggerMode').
    value: 설정할 값. 숫자/문자열/불리언.

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

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: registration (add_producer), discovery (discover_cameras), connection (connect/disconnect), feature inspection (list_features, get_feature), feature modification (set_feature), and image capture (grab). No overlap.

    Naming Consistency5/5

    All tool names follow a consistent lowercase snake_case verb_noun pattern (e.g., add_producer, discover_cameras, set_feature). No mixing of conventions.

    Tool Count5/5

    8 tools is well-scoped for a camera control server. Each tool serves a necessary role without redundancy or bloat.

    Completeness4/5

    Covers the full lifecycle: producer registration, camera discovery, connection, feature configuration, image capture, and disconnection. Minor gap: no built-in support for continuous or burst capture, but single-frame grab and trigger control via set_feature suffice for basic use.

    Related MCP Connectors

    Related MCP Servers