Skip to main content
Glama
km003c-mcp
by fejesd

km003c-mcp

MCP server for the ChargerLab POWER-Z KM003C USB-C power meter. It exposes measurements, high-rate VBUS/IBUS streaming, USB PD capture with decoding, and the meter's fast-charge protocol trigger as MCP tools (stdio transport).

Install

python -m venv .venv
.venv\Scripts\pip install -e .[dev]

Requires Python 3.11+. On Windows the meter's vendor interface already uses the WinUSB driver, so no extra driver is needed; libusb-package ships the libusb DLL.

Close the ChargerLab POWER-Z PC software first — only one program can hold the meter's USB interface. The server reports DeviceBusyError otherwise.

Related MCP server: instrumentControl

Register with Claude Code

claude mcp add km003c -- <repo>\.venv\Scripts\km003c-mcp.exe

Configuration (environment variables)

Variable

Purpose

KM003C_SERIAL

Pick a meter by USB serial number when several are attached

KM003C_COM_PORT

Override the trigger's virtual serial port (e.g. COM14)

KM003C_LIBUSB_DLL

Use a specific libusb-1.0.dll instead of the bundled one

Tools

Tool

What it does

device_info

Model, hardware/firmware version, serial, trigger COM port

measure

VBUS/IBUS/power, CC1/CC2, D+/D−, VDD, temperature; optional averaging

pd_status

PD-side snapshot (VBUS, IBUS, CC1, CC2)

stream_start / stream_status / stream_samples / stream_stop

Background sampling at 2/10/50/1000 SPS with min/max/mean, energy (Wh), charge (mAh), dropped-sample count and optional CSV

pd_capture_start / pd_capture_read / pd_capture_stop

Background PD sniffing: attach/detach and the full USB PD R3.1 message set decoded - PDOs/RDOs (incl. PPS, AVS, EPR), PD 3.x data objects, extended messages with chunk reassembly, structured VDMs (Discover Identity incl. cable VDOs, SVIDs, DisplayPort and Thunderbolt 3 alt modes)

trigger_detect / trigger_enter

Protocol detection (entry list, entry list+) and entering a protocol

trigger_pd_source_caps / trigger_pd_request

Read the charger's PDOs and request a fixed/PPS/AVS contract

trigger_fast_charge

QC2/QC3/FCP/AFC/SFCP/SCP/VFCP/TFCP/UFCS voltage requests

trigger_reset / trigger_close / trigger_raw

Reset, leave trigger mode, or send any documented command

Trigger requests make the charger raise VBUS on the meter's output — disconnect sensitive loads first. Positive IBUS means current flows from the meter's USB-C receptacle (input) to its plug (output).

Tests

.venv\Scripts\pytest                      # unit tests (no hardware)
$env:KM003C_HW="1"; .venv\Scripts\pytest tests\test_hw.py   # against a real meter

Protocol sources

  • okhsunrog/km003c-protocol-research (MIT) and okhsunrog/km003c-rs (MIT/Apache-2.0): bulk protocol, AES framing, PD event format.

  • ChargerLab's "KM003C/002C Protocol Trigger by Virtual Serial Port" sheet (installed with the POWER-Z software).

  • Linux drivers/hwmon/powerz.c: ADC layout cross-check.

License

MIT — see LICENSE.

Available Tools

18 tools
device_infoA

Identify the attached KM003C: model, hardware/firmware version, serial, trigger port.

Inputs: no named parameters.

measureA

Read VBUS/IBUS/power, CC1/CC2, D+/D-, VDD and temperature (V, A, W, °C).

With samples > 1 the readings are taken interval_ms apart and mean/min/max are returned for vbus_v, ibus_a and power_w. Positive current flows from the meter's USB-C receptacle (input) to its plug (output).

Inputs: samples, interval_ms.

pd_capture_readC

Page through captured PD events from index since; next is the next index to ask.

Inputs: limit, since, decode.

pd_capture_startA

Start capturing USB PD traffic (messages, attach/detach) in the background.

Inputs: no named parameters.

pd_capture_stopA

Stop the PD capture; captured events stay readable until the next start.

Inputs: no named parameters.

pd_statusA

Read the PD-side status snapshot (timestamp, VBUS, IBUS, CC1, CC2).

Not available while a PD capture runs, because reading would consume captured events.

Inputs: no named parameters.

stream_samplesB

Return up to max_samples evenly spaced samples from the running stream's buffer.

Inputs: max_samples.

stream_startA

Start high-rate VBUS/IBUS sampling in the background (2, 10, 50 or 1000 samples/s).

Optionally writes every sample to csv_path. Use stream_status / stream_samples while running and stream_stop for the final statistics (energy, charge, min/max/mean).

Inputs: csv_path, rate_sps.

stream_statusB

Running state, error (if any), live statistics and the most recent samples.

Inputs: no named parameters.

stream_stopB

Stop the stream and return its statistics.

Inputs: no named parameters.

trigger_closeB

Leave protocol trigger mode (pdm close).

Inputs: no named parameters.

trigger_detectA

Detect the fast-charge protocols the attached charger supports (entry list).

extended=True also probes VOOC/MTK PE (entry list+), which takes much longer.

Inputs: extended, timeout_s.

trigger_enterC

Enter a trigger protocol: pd, ufcs, qc, fcp, scp, afc, vfcp, sfcp, tfcp, bc, apple.

Inputs: protocol (required), timeout_s.

trigger_fast_chargeA

Request a voltage via qc, qc3, fcp, afc, sfcp, scp, vfcp, tfcp or ufcs.

Makes the attached charger raise VBUS on the meter's output; disconnect sensitive loads first.

Inputs: protocol (required), voltage_mv (required), request, current_ma.

trigger_pd_requestA

Request PDO position (1-based); voltage_mv is needed for PPS/AVS PDOs.

Makes the attached charger raise VBUS on the meter's output; disconnect sensitive loads first.

Inputs: position (required), current_ma, voltage_mv.

trigger_pd_source_capsB

Ask the charger for its PD Source_Capabilities (pd pdo).

Inputs: no named parameters.

trigger_rawC

Send any trigger command from ChargerLab's virtual serial port sheet verbatim.

Makes the attached charger raise VBUS on the meter's output; disconnect sensitive loads first.

Inputs: command (required), timeout_s.

trigger_resetA

Reset the protocol trigger to its initial state (re-opened on the next trigger call).

Inputs: no named parameters.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools map to a distinct resource+action: measurement, streaming, PD capture, and protocol triggers are cleanly separated, and the start/status/samples/stop quadrilogy is unambiguous. The only fuzzy edges are within the trigger group, where trigger_enter (which accepts 'pd'), trigger_fast_charge, and trigger_pd_request could be confused, and trigger_raw overlaps with all of them as an escape hatch.

    Naming Consistency4/5

    The set uses a systematic prefix scheme (stream_*, pd_capture_*, trigger_*) with verb or noun suffixes applied consistently inside each group. Minor deviation: the three ungrouped tools mix noun and verb forms (device_info, pd_status vs measure), but the pattern is still highly readable.

    Tool Count4/5

    18 tools is on the upper end but each supports a real capability: device identification, one-shot measurement, background streaming, PD traffic capture, and the multi-step trigger workflow. Nothing looks redundant enough to be obviously removable, though the trigger family alone accounts for seven tools.

    Completeness4/5

    The surface covers the device lifecycle well: identify, measure, high-rate stream with CSV output and final statistics, PD capture with paging, and protocol entry/request/reset/close. Gaps are minor: no tool to query currently configured PDO/trigger state after entry, and no raw PD message transmit, but trigger_raw provides a general fallback for unsupported commands.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for the JouleScope JS220 precision energy analyzer, enabling agents to measure current, voltage, power, charge, and energy via tools like measure_energy.
      10
      2
      Apache 2.0
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables unified discovery, query, and control of laboratory instruments (power supplies, oscilloscopes, signal generators, multimeters) via VISA/SCPI, with device-specific libraries and an MCP server exposing 19 tools for natural language interaction.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables LLMs to control an RND 320-KA3005P lab power supply through MCP tools, allowing natural language commands to set voltage/current, toggle output, and read measurements.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to configure an OWON/Digcreat XDM1041 bench multimeter and take measurements over WiFi through MCP. It exposes meter functions, ranges, and verified readings so agents can measure circuits directly.
      GPL 3.0