npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@caseman72/switchr-mcp

v1.0.1

Published

MCP server for Switch Bot temperature sensors

Readme

Switchr MCP Server

A Node.js MCP (Model Context Protocol) server that exposes SwitchBot temperature sensors for monitoring via Claude Desktop or Home Assistant.

Features

  • Device Discovery: Automatically discovers all SwitchBot devices (Meter, MeterPlus, WoIOSensor)
  • Temperature Monitoring: Read temperature and humidity from any sensor
  • Flexible Units: Support for both Fahrenheit and Celsius
  • Device Lookup: Find devices by ID or nickname (case-insensitive)
  • Dual Transport: Supports both stdio (Claude Desktop) and HTTP/SSE (Home Assistant)
  • Request Logging: Optional logging of all tool calls for debugging

Installation

cd switchr-mcp
npm install

Configuration

SwitchBot Credentials

SwitchBot API credentials are managed by @caseman72/switchr-api via .env.local. The file is searched in:

  1. Current working directory
  2. ~/.config/switchr-api/.env.local
  3. ~/.switchbot.env.local

Create a .env.local file with your SwitchBot credentials:

SWITCHBOT_TOKEN=your-switchbot-token
SWITCHBOT_SECRET=your-switchbot-secret

Visit the SwitchBot Developer Portal to obtain your API credentials.

Server Configuration (Optional)

Copy config.example.json to config.json to customize server settings:

{
  "server": {
    "transport": "stdio",
    "httpPort": 8001,
    "httpHost": "127.0.0.1"
  },
  "devices": {
    "refreshIntervalMinutes": 60
  },
  "monitoring": {
    "enabled": false,
    "logFile": "./switchr-mcp-requests.log"
  }
}

Usage

stdio Transport (Claude Desktop)

node src/index.js

HTTP Transport (Home Assistant)

The HA custom component requires the MCP server to be exposed over HTTP/SSE. Use mcp-proxy to bridge the stdio server.

Install mcp-proxy

brew install mcp-proxy

Start the proxy

# Binds to all interfaces so Docker can reach it
mcp-proxy --port 8082 --host 0.0.0.0 -- node /path/to/switchr-mcp/src/index.js

Home Assistant Integration

  1. Copy the custom component to your HA config directory:

    cp -r custom_components/switchr_mcp ~/.home-assistant/custom_components/
  2. Restart Home Assistant

  3. Add the integration: Settings → Devices & Services → Add Integration → "Switchr MCP"

  4. Enter connection details:

    • Host: host.docker.internal (for Docker) or your Mac's IP
    • Port: 8082

Auto-start mcp-proxy with launchd

Create ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.switchr.mcp-proxy</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/homebrew/bin/mcp-proxy</string>
        <string>--port</string>
        <string>8082</string>
        <string>--host</string>
        <string>0.0.0.0</string>
        <string>--</string>
        <string>/opt/homebrew/bin/node</string>
        <string>/path/to/switchr-mcp/src/index.js</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/path/to/switchr-mcp</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/switchr-mcp-proxy.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/switchr-mcp-proxy.err</string>
</dict>
</plist>

Then load it:

launchctl load ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist

To stop/unload:

launchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist

Managing the service

# Check status
launchctl list | grep switchr

# View logs
tail -f /tmp/switchr-mcp-proxy.err

# Restart
launchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist
launchctl load ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist

# Stop
launchctl unload ~/Library/LaunchAgents/com.switchr.mcp-proxy.plist

Claude Desktop Integration

Add to ~/.claude/claude_desktop_config.json:

{
  "mcpServers": {
    "switchr": {
      "command": "node",
      "args": ["/path/to/switchr-mcp/src/index.js"],
      "env": {}
    }
  }
}

MCP Tools

list_devices

List all discovered SwitchBot devices. Optionally filter to show only temperature sensors.

Parameters:

  • sensorsOnly (optional): If true, only return temperature sensors (Meter, MeterPlus, WoIOSensor)
  • refresh (optional): Force refresh device list from SwitchBot API

get_device_status

Get detailed status of any SwitchBot device. Returns device-specific properties like power state, battery level, etc.

Parameters:

  • deviceId: Device ID or device name

get_temperature

Get temperature and humidity reading from a specific SwitchBot temperature sensor.

Parameters:

  • deviceId: Device ID or device name of the temperature sensor
  • unit (optional): Temperature unit - F for Fahrenheit (default), C for Celsius

Response includes:

  • temperature: Current temperature in requested unit
  • humidity: Current humidity percentage
  • battery: Battery level percentage

get_all_temperatures

Get temperature and humidity readings from all SwitchBot temperature sensors at once.

Parameters:

  • unit (optional): Temperature unit - F for Fahrenheit (default), C for Celsius

get_api_status

Get SwitchBot API rate limit status. Returns remaining calls, reset time, and cache info.

Response includes:

  • rate_limit.remaining: API calls remaining
  • rate_limit.reset_by: When the rate limit resets
  • cache.last_refresh: When devices were last refreshed
  • cache.device_count: Total devices discovered
  • cache.sensor_count: Temperature sensors discovered

Request Monitoring

Enable request logging in config.json:

{
  "monitoring": {
    "enabled": true,
    "logFile": "./switchr-mcp-requests.log"
  }
}

Logs are written in JSON Lines format with timestamps, tool names, parameters, and results.

License

MIT