Content
## I. Configuration Description
### 1.1 MQTT Configuration
```yaml
mqtt:
broker: "localhost" # MQTT server address
port: 1883 # MQTT server port
client_id: "mcp2mqtt_client" # MQTT client ID
username: "mqtt_user" # MQTT username
password: "mqtt_password" # MQTT password
keepalive: 60 # Keepalive time
topics:
command:
publish: "mcp/command" # Topic for sending commands
subscribe: "mcp/response" # Topic for receiving responses
status:
publish: "mcp/status" # Topic for sending status
subscribe: "mcp/control" # Topic for receiving control commands
```
### 1.2 Command Configuration
```yaml
commands:
set_pwm:
command: "CMD_PWM {frequency}"
need_parse: false
data_type: "ascii"
prompts:
- "Set PWM to maximum"
- "Set PWM to minimum"
mqtt_topic: "mcp/pwm" # MQTT publish topic
response_topic: "mcp/pwm/response" # MQTT response topic
```
## II. Quick Start
### 2.1 Basic Installation
> MCP client test installation on VSCode using Cline plugin, assuming already installed
- uv (test version 0.10.7)
- ffmpeg (test version 2026-03-03)
- MCP client (Cline or Claude Desktop)
### 2.2 Basic Configuration
> Restart Cline or Claude Desktop after modifying configuration
Modify MCP client configuration:
```json
{
"mcpServers": {
"mcp2mqtt": {
"command": "uvx",
"args": [
"mcp2mqtt"
]
}
}
}
```
## III. Running Test
### 3.1 Quick Start from Source
```bash
# Clone repository
git clone https://github.com/BLACKHKER/mcp2mqtt.git
cd mcp2mqtt
# Create virtual environment
uv venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/macOS:
source .venv/bin/activate
# Install development dependencies
uv pip install --editable .
# Run server (using default configuration config.yaml)
uv run src/mcp2mqtt/server.py
or
uv run mcp2mqtt
# Run server with specified configuration (e.g., Pi_config.yaml)
uv run src/mcp2mqtt/server.py --config Pi
or
uv run mcp2mqtt --config Pi
```
### 3.2 MCP Client Configuration
When using MCP protocol-supported clients (e.g., Claude Desktop or Cline), modify client configuration file:
#### Using default demo parameters:
```json
{
"mcpServers": {
"mcp2mqtt": {
"disabled": false,
"timeout": 60,
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"D:/PyCharmWorkspace/mcp2mqtt/src/mcp2mqtt",
"run",
"mcp2mqtt"
]
}
}
}
```
#### Specifying parameter filename
```json
{
"mcpServers": {
"mcp2mqtt": {
"command": "uv",
"args": [
"--directory",
"D:/PyCharmWorkspace/mcp2mqtt/src/mcp2mqtt",
"run",
"mcp2mqtt",
"--config", // Optional parameter, specify configuration file name
"Pico" // Optional parameter, specify configuration file name, no need to add _config.yaml suffix
]
}
}
}
```
### 3.3 Start Device Simulator
The project includes a device simulator `response.py` in the `tests` directory. It can simulate a hardware device that:
- Provides Raspberry Pi information
- Controls Raspberry Pi fan