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 TCP Communication
- Connect and send commands to TCP server
- 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:
tcp:
# TCP服务器配置
remote_ip: "127.0.0.1" # 远端IP地址
port: 9999 # 端口号
connect_timeout: 3.0 # 连接超时时间,单位为秒
receive_timeout: 2.0 # 接收超时时间,单位为秒
communication_type: "client" # 通信类型,client或server
response_start_string: "CMD" # 可选,TCP应答的开始字符串,默认为OK
commands:
# PWM控制命令
set_pwm:
command: "CMD_PWM {frequency}" # frequency为0-100的整数,表示PWM占空比
need_parse: false # 不需要解析响应内容
data_type: "ascii" # 数据类型,ascii或hex
parameters:
- name: "frequency"
type: "integer"
description: "PWM frequency value (0-100)"
required: true
prompts:
- "把PWM调到最大 (frequency=100)"
- "把PWM调到最小 (frequency=0)"
- "请将PWM设置为{frequency} (0-100的整数)"
- "关闭PWM (frequency=0)"
- "把PWM调到一半 (frequency=50)"
# PICO信息查询命令
get_pico_info:
command: "CMD_PICO_INFO" # 实际发送的命令格式,server会自动添加\r\n
need_parse: true # 需要解析响应内容
data_type: "ascii" # 数据类型,ascii或hex
prompts:
- "查询Pico板信息"
- "显示开发板状态"
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
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.
Metadata
Release files for mcp2tcp 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp2tcp-0.3.0.tar.gz | 1.4 MB | Without provenance | Details for mcp2tcp-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp2tcp-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for mcp2tcp-0.3.0-py3-none-any.whl |
Total release size: 1.4 MB
Release files / mcp2tcp-0.3.0.tar.gz
| Download URL | mcp2tcp-0.3.0.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3333de87c27661d866467a3d77ee6007d924e57edea6b4ec8fdc354540e43df0
|
|
BLAKE2b-256 checksum How to use checksums |
80142d5d435e65e72d7e7dbc64a9a7e67f047b46a88d7919f6835b9defff7a95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Release files / mcp2tcp-0.3.0-py3-none-any.whl
| Download URL | mcp2tcp-0.3.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33f0cf845bcb31b9369d95f8af3c3515c8259bf2ef0e212f8a5c0f0fd15457bc
|
|
BLAKE2b-256 checksum How to use checksums |
690dd28ccba0f34b45bc9ef339a7e4f53261f67e57c488e16af147c4d8fbe911
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.11
|
Security for mcp2tcp 0.3.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.