Skip to content

Environment Variables

mcserial reads configuration from environment variables at startup. These variables set server-wide defaults that apply to all connections unless overridden by tool parameters.


Default baud rate used when open_serial_port is called without a baudrate parameter and auto-detection either fails or is not applicable (e.g., URL-based connections).

Default9600
TypeInteger
ExampleMCSERIAL_DEFAULT_BAUDRATE=115200
Terminal window
# Set a higher default for modern devices
export MCSERIAL_DEFAULT_BAUDRATE=115200

Default read timeout in seconds for new connections. Applied as the timeout parameter when open_serial_port is called without an explicit timeout.

Default1.0
TypeFloat (seconds)
ExampleMCSERIAL_DEFAULT_TIMEOUT=2.0
Terminal window
# Longer timeout for slow devices
export MCSERIAL_DEFAULT_TIMEOUT=5.0

Maximum number of simultaneously open serial port connections. Attempts to open more ports than this limit return an error.

Default10
TypeInteger
ExampleMCSERIAL_MAX_CONNECTIONS=20
Terminal window
# Allow more concurrent connections
export MCSERIAL_MAX_CONNECTIONS=20

For other MCP clients, consult their documentation for how to pass environment variables to server processes.


mcserial supports optional dependency groups for specialized hardware.

Adds the hidapi package for Silicon Labs CP2110 HID-to-UART bridge support. Required to use the cp2110:// URL scheme with open_serial_port.

Terminal window
# Install with CP2110 support
uv pip install mcserial[cp2110]
# Or with uvx
uvx --with hidapi mcserial

Without this extra installed, attempting to open a cp2110:// URL returns an error:

cp2110:// requires the hidapi package. Install with: pip install mcserial[cp2110]