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.

Metadata

Release files for labmcp 0.1.1

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.1
File Size Uploaded
labmcp-0.1.1.tar.gz 62.4 kB Details

Built distribution (wheel)

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

Total release size: 128.2 kB

Release files / labmcp-0.1.1.tar.gz

Download URL labmcp-0.1.1.tar.gz
Size 62.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8a77f3bfdfc34cfe84c89fbab310b41a8aaeecc8080c75307575d52df2fa1d08
BLAKE2b-256 checksum
How to use checksums
cbb85526e9eeae3106f3e6490c31cc23112845a9d10337527a68fadb4b241142
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 26, 2026.

Transparency log

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

Download URL labmcp-0.1.1-py3-none-any.whl
Size 65.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f27abf1c38f25d97f281b46fdae221836b5b7ef0b18b9aef636b9870f495d9f7
BLAKE2b-256 checksum
How to use checksums
361e1ce88103c5564d1f8f9d807e2275ae985a184c2836e3b8cd927a8fdbee64
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 26, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

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