Skip to main content

carrot-mcp-io

Carrot MCP IO Server - High-performance async serial, TCP, and UDP transport server for hardware and network communication, powered by the carrot-io engine.

Tools

Tool Description
version Get server version and carrot-io engine info
list_transports List available transport types and system serial ports
open Open a physical serial or network connection (serial, tcp, udp)
close Close an open connection
read Read data with physical framing options (default available, until delimiter, exact fixed-length)
recv Non-blocking read directly from buffer
write Send raw bytes (hex or ascii with escape support)
query Atomic Request-Response (write command, optional delay, read response until delimiter or timeout)
script Execute a sequence of I/O operations (write/read/query/wait/flush)
history Get structured TX/RX communication and timing history

Transports

Serial

{
  "open": {
    "port": "COM3",
    "transport": "serial",
    "baudrate": 115200
  }
}

TCP

{
  "open": {
    "port": "mydevice",
    "transport": "tcp",
    "host": "192.168.1.100",
    "net_port": 5000
  }
}

UDP

{
  "open": {
    "port": "sensor",
    "transport": "udp",
    "host": "192.168.1.200",
    "net_port": 8888
  }
}

Physical Stream Framing (Delimiter & Fixed Length)

In real-world embedded/hardware communication, raw stream bytes require clear framing boundaries:

  1. Delimiter Truncation (until): Reads until a line break or delimiter string arrives (e.g. \n, \r\n for SCPI instruments or AT commands).
    {
      "read": {
        "port": "COM3",
        "until": "\n",
        "fmt": "ascii"
      }
    }
    
  2. Fixed Length (exact=True): Waits until exactly size bytes arrive from the hardware before returning (for fixed sensor telemetry blocks).
    {
      "read": {
        "port": "COM3",
        "size": 32,
        "exact": true,
        "fmt": "hex"
      }
    }
    
  3. Atomic Request-Response (query): Writes command, waits optional physical delay seconds, and reads response:
    {
      "query": {
        "port": "COM3",
        "ascii": "*IDN?\n",
        "until": "\n",
        "fmt": "ascii"
      }
    }
    

Buffer & Concurrency Behavior

  • Powered by carrot-io's pure async FifoBuffer ring buffer, zero-copy reads, and hot-path memory logging.
  • Concurrency-safe: non-blocking coroutines with read/write locks, no background thread polling or GIL lock contention.
  • Full process lifecycle safety: automatic cleanup on server termination and atexit fallback to prevent OS COM port deadlocks.

Return Format

All tools return a dict with {"status": "ok"|"error", ...}.

  • read/recv/query return data in the specified format (default "hex", uppercase e.g. "48656C6C6F")
  • read/recv/query with fmt="ascii" return decoded string (e.g. "Hello\nWorld")
  • write/query support hex or ascii input, ascii supports escape sequences (\n, \x00, etc.)
  • script executes a sequence of operations and returns a list of step results

Script Example

[
  {"op": "write", "ascii": "AT+RST\r\n"},
  {"op": "wait", "ms": 50},
  {"op": "read", "until": "\n", "expect": "ready\r\n", "fmt": "ascii"},
  {"op": "query", "ascii": "AT+CSQ\r\n", "until": "\n", "fmt": "ascii"}
]

Script Return Format

Each step result contains:

  • op: Operation type ("write" | "read" | "query" | "wait" | "flush")
  • step: Step index (0-based)
  • status: "ok" or "error"

Additional fields by op:

  • write: {bytes_written}
  • read/query: {data, length} + {matched, expected} if expect is provided
  • wait: {ms}
  • On error: {message}

Metadata

Release files for carrot-mcp-io 1.0.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 carrot-mcp-io 1.0.0
File Size Uploaded Provenance Actions
carrot_mcp_io-1.0.0.tar.gz 7.2 kB Without provenance Details for carrot_mcp_io-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for carrot-mcp-io 1.0.0
File Interpreter ABI Platform Actions
carrot_mcp_io-1.0.0-py3-none-any.whl Python 3 none any Details for carrot_mcp_io-1.0.0-py3-none-any.whl

Total release size: 15.7 kB

Release files / carrot_mcp_io-1.0.0.tar.gz

Download URL carrot_mcp_io-1.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
888099da5f6a88ab4f5663e02a5f02d2ca5d1f9c6c8ac26d0ede0645283c1099
BLAKE2b-256 checksum
How to use checksums
8b9268e0bd58d9202b47985628789b96d9ea9348b3202d5cfd39ca10762c2d7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / carrot_mcp_io-1.0.0-py3-none-any.whl

Download URL carrot_mcp_io-1.0.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1441e526aa5bd00c4866a074784b5ceed8e80a3a9fbc6c0ffc31f154f5b831d2
BLAKE2b-256 checksum
How to use checksums
621498f224b21dc660d5d54ec7dc8286e777934a46df22a88c59679e6efc0691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for carrot-mcp-io 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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