Skip to main content

labmcp

Shared foundations for LabMCP, an open-source collection of Model Context Protocol servers that let AI agents operate laboratory instruments. It is built on FastMCP.

Install labmcp directly if you want to build an instrument server or use the labmcp helper CLI. To use an instrument, install its server instead, e.g. uvx labmcp-mettler-toledo.

The labmcp CLI

uvx labmcp list                          # all instrument servers, by domain
uvx labmcp info mettler-toledo           # models, interfaces, tools
uvx labmcp ports                         # serial ports (and VISA resources with labmcp[visa])
uvx labmcp config ika --address COM3     # MCP client config snippet

Building a server

from labmcp import HAZARD, READ, SAFETY, ConnectContext, InstrumentServer, Limit

def connect(ctx: ConnectContext) -> MyDriver:
    return MyDriver(ctx.open_transport(simulator=MySimulator, baudrate=9600,
                                       read_termination="\r\n", write_termination="\r\n"))

server = InstrumentServer("My Hotplate", connect=connect, package="labmcp-my-hotplate",
                          limits=[Limit("max_temperature_c", 150, "°C", "Hotplate setpoint")])
mcp = server.mcp

@mcp.tool(**READ)
def read_temperature() -> float:
    return server.driver.temperature_c()

@mcp.tool(**HAZARD)
def set_temperature(temperature_c: float) -> str:
    server.check("max_temperature_c", temperature_c, "setpoint")
    server.driver.set_temperature(temperature_c)
    return "ok"

@mcp.tool(**SAFETY)
def heater_off() -> str:
    server.driver.heater_off()
    return "heater off"

def main() -> None:
    server.run()   # --address, --simulate, --read-only, --limit, --check, --audit-log, ...

What you get:

  • Transports: serial (pyserial), raw TCP, VISA (labmcp[visa]: GPIB/USBTMC/LXI/HiSLIP), and a wire-level SimulatedTransport. All are thread-safe and share the same line handling and timeouts.
  • Addresses as URIs: serial:///dev/ttyUSB0?baudrate=9600, tcp://10.0.0.5:5025, visa://GPIB0::22::INSTR.
  • Safety: tool kinds (READ/CONTROL/HAZARD/SAFETY) with MCP annotations, --read-only mode, safety Limits checked before sending, and a command audit log.
  • Built-in tools: get_connection_info, get_command_log, reconnect.
  • SCPI helpers: labmcp.scpi.SCPIDriver and SCPISimulator, with short/long-form matching and error-queue handling.
  • Testing: labmcp.testing.simulated_client(server) gives you an in-memory FastMCP client.

See the contributor guide.

License: Apache-2.0.

Release files for labmcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labmcp 0.1.0
File Size Uploaded
labmcp-0.1.0.tar.gz 55.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for labmcp 0.1.0
File Interpreter ABI Platform
labmcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 114.1 kB

Release files / labmcp-0.1.0.tar.gz

Download URL labmcp-0.1.0.tar.gz
Size 55.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4df23d4cf29d50a3441fc0f469cc44e789c50098276f972cae3bc20dc2e71557
BLAKE2b-256 checksum
How to use checksums
95433f55c4e5ccdbd320bd0c35a2c90ebc6a47e682cd0907ef9ff0f8201589f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / labmcp-0.1.0-py3-none-any.whl

Download URL labmcp-0.1.0-py3-none-any.whl
Size 59.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b08897dd0894baf1bc4c7d6463e21c7e0f4974f9b620a440980f58301c495b78
BLAKE2b-256 checksum
How to use checksums
42de751330840584c32218577b5f29015006e58baae5345fc2795c95e9ed2539
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page