A production-ready, Dockerized MCP (Model Context Protocol) server for controlling and querying SmartThings devices via Personal Access Token (PAT).
.
├── Dockerfile # Production-ready Docker image
├── docker-compose.yml # Docker Compose configuration
├── .dockerignore # Docker build exclusions
├── .env.example # Environment variable template
├── requirements.txt # Python dependencies
├── app/
│ ├── __init__.py
│ ├── main.py # MCP server and tool definitions
│ └── smartthings.py # SmartThings API client
└── README.md # This file
devices (read and execute)locations (read)cp .env.example .env
# Edit .env and add your SMARTTHINGS_PAT
# Build the image
docker build -t smartthings_mcp:latest .
# Run with stdio transport
docker run --rm -i \
-e SMARTTHINGS_PAT=$SMARTTHINGS_PAT \
-e SMARTTHINGS_LOCATION_ID=$SMARTTHINGS_LOCATION_ID \
smartthings_mcp:latest
# Build and run
docker compose build
docker compose run --rm smartthings-mcp python -m app.main
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export SMARTTHINGS_PAT="your_pat_here"
# Run the server
python -m app.main
list_locations()List all SmartThings locations accessible with the current PAT.
Returns: List of location objects with locationId, name, and metadata.
list_rooms(locationId?)List all rooms in a SmartThings location.
Parameters:
locationId (optional): The location ID. Falls back to SMARTTHINGS_LOCATION_ID env var or first available location.Returns: List of room objects with roomId, name, and metadata.
list_devices(locationId?, roomId?)List all SmartThings devices, optionally filtered by location and/or room.
Parameters:
locationId (optional): Filter devices by locationroomId (optional): Filter devices by roomReturns: List of device objects with deviceId, label, capabilities, and metadata.
device_status({ deviceId?, name? })Get the current status of a SmartThings device.
Parameters:
deviceId (optional): The unique device ID (preferred for efficiency)name (optional): Device name/label to search for (slower, searches all devices)Returns: Device information with current status and flattened summary.
Note: Provide at least one of deviceId or name.
switch_device({ deviceId?, name?, command, component? })Turn a SmartThings switch device on or off.
Parameters:
deviceId (optional): The unique device ID (preferred)name (optional): Device name/label to search forcommand (required): Either "on" or "off"component (optional): Device component (default: "main")Returns: Device information and command execution result.
fridge_status({ deviceId?, name? })Get detailed status of a SmartThings refrigerator/fridge device.
Parameters:
deviceId (optional): The unique device IDname (optional): Device name/label to search forReturns: Refrigerator-specific status summary including:
Note: If neither parameter is provided, automatically searches for devices with "fridge" or "refrigerator" in the name.
device_health(deviceId)Get the health status of a SmartThings device.
Parameters:
deviceId (required): The unique device IDReturns: Device health information including online/offline state.
deviceId (avoids listing all devices)| Variable | Required | Default | Description |
|---|---|---|---|
SMARTTHINGS_PAT | ✅ Yes | - | SmartThings Personal Access Token |
SMARTTHINGS_LOCATION_ID | ❌ No | - | Default location ID for room queries |
SMARTTHINGS_BASE_URL | ❌ No | https://api.smartthings.com/v1 | SmartThings API base URL |
MCP_TRANSPORT | ❌ No | stdio | MCP transport method |
# Install dev dependencies
pip install pytest pytest-asyncio httpx
# Run tests
pytest
Set the log level via environment:
# Debug level (verbose)
export LOG_LEVEL=DEBUG
# Info level (default)
export LOG_LEVEL=INFO
# Warning level (quiet)
export LOG_LEVEL=WARNING
This project follows:
SMARTTHINGS_PAT environment variablelocations:read scopelist_devices() to see available devicessmartthings.py (default: 15s)MIT License - feel free to use and modify as needed.
Contributions welcome! Please:
Content type
Image
Digest
sha256:f8ba15c26…
Size
60.1 MB
Last updated
11 months ago
docker pull bjornhovd054/smartthings_mcp