Finally - the security of IOT devices combined with the security of MCP!
This is a Model Context Protocol (MCP) server for interacting with YoLink smart devices. This server allows you to enumerate devices and get status information from your YoLink account through the MCP protocol.
- Device Enumeration: List all devices in your YoLink account
- Device Status: Get current status and state information for any device
- MCP Protocol: Full compliance with MCP specification for seamless integration
- Authentication: Secure OAuth2 authentication with YoLink API
- Error Handling: Comprehensive error handling and logging
- Go 1.21 or later
- YoLink account with API access
- YoLink Client ID and Client Secret
- Clone this repository:
git clone <repository-url>
cd yolink-mcp- Install dependencies:
go mod tidy- Build the server:
go build -o yolink-mcp-server .Set the following environment variables with your YoLink API credentials:
export YOLINK_CLIENT_ID="your_client_id_here"
export YOLINK_CLIENT_SECRET="your_client_secret_here"- Visit the YoLink Developer Portal
- Create an account or sign in
- Create a new application to get your Client ID and Client Secret
- Make sure your application has the
yolink:readscope
Start the MCP server:
./yolink-mcp-serverThe server will listen for MCP requests on stdin and send responses to stdout.
Lists all YoLink devices in your account.
Parameters: None
Example MCP Request:
{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/call",
"params": {
"name": "enumerate_devices",
"arguments": {}
}
}Gets the current status of a specific YoLink device.
Parameters:
device_id(string): The ID of the device to get status for
Example MCP Request:
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {
"name": "get_device_status",
"arguments": {
"device_id": "your_device_id_here"
}
}
}This server implements the MCP protocol and can be integrated with any MCP-compatible client. The server supports:
initialize: Server initialization and capability advertisementtools/list: List available toolstools/call: Execute tool calls
You can integrate this server with MCP clients by configuring the client to use this server as a tool provider. The server communicates via stdin/stdout using JSON-RPC messages.
yolink-mcp/
├── main.go # Main entry point and stdin/stdout handling
├── mcp_server.go # MCP protocol implementation
├── yolink_client.go # YoLink API client
├── types.go # Data structures and type definitions
├── go.mod # Go module file
└── README.md # This file
The server includes comprehensive error handling for:
- Authentication failures
- Network connectivity issues
- Invalid device IDs
- API rate limiting
- Malformed MCP requests
All errors are logged using structured logging and returned as proper MCP error responses.
go build -o yolink-mcp-server .go test ./...The server uses structured logging with the following levels:
INFO: General operational informationERROR: Error conditions and failuresDEBUG: Detailed debugging information (when enabled)
POST /oauth/token: AuthenticationPOST /openapi: Device operations (getDeviceList, getState)
This server works with all YoLink device types including:
- Smart switches and outlets
- Sensors (temperature, humidity, door/window, motion, etc.)
- Smart locks
- Garage door controllers
- Water leak sensors
- And more...
- Authentication Error: Verify your
YOLINK_CLIENT_IDandYOLINK_CLIENT_SECRETare correct - Network Issues: Check your internet connection and firewall settings
- Device Not Found: Ensure the device ID is correct and the device is online
- Permission Denied: Verify your YoLink application has the correct scopes
Set log level to debug for verbose output:
export LOG_LEVEL=debug
./yolink-mcp-serverContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- YoLink for providing the IoT device API The MCP protocol specification and community