Skip to main content

MCP2Serial: Bridge between AI Models and Physical World

Connect AI Large Language Models to hardware devices through the Model Context Protocol (MCP).

GitHub Repository | Documentation

Features

  • Intelligent Serial Communication

    • Automatic port detection and configuration
    • Multiple baud rate support (default 115200)
    • Real-time status monitoring and error handling
  • MCP Protocol Integration

    • Full Model Context Protocol support
    • Resource management and tool invocation
    • Flexible prompt system

Supported Clients

MCP2Serial supports all clients implementing the MCP protocol, including:

  • Claude Desktop (Test ok)
  • Continue (Should work)
  • Cline (Test ok)

Quick Start

make sure you have installed uv

```bash
windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
MacOS
curl -LsSf https://astral.sh/uv/install.sh | sh

Basic Configuration

Add the following to your MCP client configuration:

{
    "mcpServers": {
        "mcp2serial": {
            "command": "uvx",
            "args": ["mcp2serial"]
        }
    }
}

Serial Port Configuration

Create or modify config.yaml to configure serial port parameters:

serial:
  port: COM11  # Windows example, on Linux might be /dev/ttyUSB0
  baud_rate: 115200  # Baud rate
  timeout: 1.0  # Serial timeout (seconds)
  read_timeout: 0.5  # Read timeout (seconds)

If port is not specified, the program will automatically search for available serial ports.

Configuration File Location

The configuration file (config.yaml) can be placed in different locations depending on your needs. The program searches for the configuration file in the following order:

1. Current Working Directory (For Development)

  • Path: ./config.yaml
  • Example: If you run the program from C:\Projects, it will look for C:\Projects\config.yaml
  • Best for: Development and testing
  • No special permissions required

2. User's Home Directory (Recommended for Personal Use)

  • Windows: C:\Users\YourName\.mcp2serial\config.yaml
  • macOS: /Users/YourName/.mcp2serial/config.yaml
  • Linux: /home/username/.mcp2serial/config.yaml
  • Best for: Personal configuration
  • Create the .mcp2serial directory if it doesn't exist
  • No special permissions required

3. System-wide Configuration (For Multi-user Setup)

  • Windows: C:\ProgramData\mcp2serial\config.yaml (requires admin rights)
  • macOS/Linux: /etc/mcp2serial/config.yaml (requires sudo/root)
  • Best for: Shared configuration in multi-user environments
  • Create the directory with appropriate permissions

The program will use the first valid configuration file it finds in this order. Choose the location based on your needs:

  • For testing: use current directory
  • For personal use: use home directory (recommended)
  • For system-wide settings: use ProgramData or /etc

Serial Port Configuration

Create your config.yaml in one of the above locations with the following structure:

serial:
  port: COM11  # or /dev/ttyUSB0 for Linux
  baud_rate: 115200
  timeout: 1.0
  read_timeout: 0.5

commands:
  # Add your commands here
  # See the Command Configuration section for examples

Command Configuration

Add or remove custom commands in config.yaml:

commands:
  # PWM control command example
  set_pwm:
    command: "PWM {frequency}\n"  # Actual command format to send
    need_parse: false  # No need to parse response
    prompts:  # Prompt list
      - "Set PWM to {value}"
      - "Turn off PWM"

  # LED control command example
  led_control:
    command: "LED {state}\n"  # state can be on/off or other values
    need_parse: false
    prompts:
      - "Turn on LED"
      - "Turn off LED"
      - "Set LED state to {state}"

  # Command example with response parsing
  get_sensor:
    command: "GET_SENSOR\n"
    need_parse: true  # Need to parse response
    prompts:
      - "Read sensor data"

Response Parsing

  1. Simple Response (need_parse: false):

    • Device returns message starting with "OK" indicates success
    • Other responses will be treated as errors
  2. Parsed Response (need_parse: true):

    • Complete response will be returned in the result.raw field

Documentation

For detailed documentation, please visit our GitHub repository.

Support

If you encounter any issues or have questions:

  1. Check our Issues page
  2. Read our Wiki
  3. Create a new issue if needed

License

This project is licensed under the MIT License.

Metadata

Release files for mcp2serial 0.1.3

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

Source distribution (sdist)

Source distribution for mcp2serial 0.1.3
File Size Uploaded Provenance
mcp2serial-0.1.3.tar.gz 5.5 MB Without provenance Details

Built distribution (wheel)

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

Total release size: 5.5 MB

Release files / mcp2serial-0.1.3.tar.gz

Download URL mcp2serial-0.1.3.tar.gz
Size 5.5 MB
Tags Source
SHA-256 checksum
How to use checksums
2e455b0bf51f6d17fc090b0c7e3cdc02776319d1b4e361aeaa0cd4d34a5269d6
BLAKE2b-256 checksum
How to use checksums
54d56d923199b171ec6fdb05f9eff9386b3827a6cf7c75926a0bd0846a065540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release files / mcp2serial-0.1.3-py3-none-any.whl

Download URL mcp2serial-0.1.3-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d3e6959e0d9afc9dd556412c08a90a73d01e3678e5914d6ed30b12e4d482903
BLAKE2b-256 checksum
How to use checksums
04e6da0960c585067ec9491826f96858de6305bf17e1a2870587533f47df3799
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Security for mcp2serial 0.1.3

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.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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