MCP TCP Service for PWM Control
Project description
mcp2tcp: 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
mcp2tcp 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": {
"mcp2tcp": {
"command": "uvx",
"args": ["mcp2tcp"]
}
}
}
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 forC:\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\.mcp2tcp\config.yaml - macOS:
/Users/YourName/.mcp2tcp/config.yaml - Linux:
/home/username/.mcp2tcp/config.yaml - Best for: Personal configuration
- Create the
.mcp2tcpdirectory if it doesn't exist - No special permissions required
3. System-wide Configuration (For Multi-user Setup)
- Windows:
C:\ProgramData\mcp2tcp\config.yaml(requires admin rights) - macOS/Linux:
/etc/mcp2tcp/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
-
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
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 mseep_mcp2tcp-0.1.2.tar.gz.
File metadata
- Download URL: mseep_mcp2tcp-0.1.2.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f9bf8cd684b40c3d8db055a669ec82abf460934aa4cb2d4543106a575c7103
|
|
| MD5 |
0080e73761454c0feb35900894997d8f
|
|
| BLAKE2b-256 |
a800b6b6c6504b7f84131e75847658de0b403119cdb3de45891777840ec675d0
|
File details
Details for the file mseep_mcp2tcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mseep_mcp2tcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3e892526dd3794869e5146ed0a11947fb8309a8ddc0d39490b3c7b1fafca93e
|
|
| MD5 |
68fc85a3c55589eb0320aebf1059be68
|
|
| BLAKE2b-256 |
83620ae09c6785ac8e3a3276ded6181733843a1837c710a464242384746caa9a
|