Skip to main content

MCP Serial Service for PWM Control

Project description

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
  • PWM Control

    • Precise frequency control (0-100Hz)
    • Real-time feedback
    • Multi-channel support
  • 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 (Full support)
  • Continue (Full support)
  • Cline (Resource + Tools)
  • Zed (Basic support)
  • Sourcegraph Cody (Resource support)
  • Firebase Genkit (Partial support)

Quick Start

# Install using uv (recommended)
uv pip install mcp2serial

# Or using traditional pip
pip install mcp2serial

Basic Configuration

Add the following to your MCP client configuration:

{
    "mcpServers": {
        "mcp2serial": {
            "command": "uv",
            "args": [
                "--directory",
                "your_actual_path/mcp2serial",
                "run",
                "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 several locations. The program will search for it in the following order:

  1. Current working directory: ./config.yaml
  2. User's home directory: ~/.mcp2serial/config.yaml
  3. System-wide configuration:
    • Windows: C:\ProgramData\mcp2serial\config.yaml
    • Linux/Mac: /etc/mcp2serial/config.yaml

The first valid configuration file found will be used.

Serial Port Configuration

Create a config.yaml file 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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp2serial-0.1.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp2serial-0.1.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp2serial-0.1.2.tar.gz.

File metadata

  • Download URL: mcp2serial-0.1.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for mcp2serial-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e9238d932346a4f62a83177ad95bbbba6acfe45458dba1e111f225ee89ea4c8c
MD5 d80ae98cb20fb516bbce966bb336c3f6
BLAKE2b-256 36fe2962d1901ef00722057220b9eaae2f1320cd5c3b47a81f61072de176b989

See more details on using hashes here.

File details

Details for the file mcp2serial-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mcp2serial-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for mcp2serial-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c291cc62b8e5814c2b2d7d6c7ec8a75610963b7aa763f63d366644c55f5e0ade
MD5 c636e87059c601d7734d8cd77bd3a289
BLAKE2b-256 5c802f035e795b88381420349a299269433d556d9a58c201601a35b8343747af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page