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:
- Current working directory:
./config.yaml - User's home directory:
~/.mcp2serial/config.yaml - System-wide configuration:
- Windows:
C:\ProgramData\mcp2serial\config.yaml - Linux/Mac:
/etc/mcp2serial/config.yaml
- Windows:
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
-
Simple Response (
need_parse: false):- Device returns message starting with "OK" indicates success
- Other responses will be treated as errors
-
Parsed Response (
need_parse: true):- Complete response will be returned in the
result.rawfield
- Complete response will be returned in the
Documentation
For detailed documentation, please visit our GitHub repository.
Support
If you encounter any issues or have questions:
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9238d932346a4f62a83177ad95bbbba6acfe45458dba1e111f225ee89ea4c8c
|
|
| MD5 |
d80ae98cb20fb516bbce966bb336c3f6
|
|
| BLAKE2b-256 |
36fe2962d1901ef00722057220b9eaae2f1320cd5c3b47a81f61072de176b989
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c291cc62b8e5814c2b2d7d6c7ec8a75610963b7aa763f63d366644c55f5e0ade
|
|
| MD5 |
c636e87059c601d7734d8cd77bd3a289
|
|
| BLAKE2b-256 |
5c802f035e795b88381420349a299269433d556d9a58c201601a35b8343747af
|