Get the FREE Ultimate OpenClaw Setup Guide →

MCP -for-sensor-device

This project is a Node.js application designed for use with Claude Desktop. It simulates a CO2 sensor device and provides a JSON-RPC server to interact with the device. The application can run in both simulation mode and real mode, where it connects to a Raspberry Pi Pico via USB to read CO2 levels.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kmwebnet-mcp-server-for-sensor-device node ...mcp-server-for-sensor-device/index.js

How to use

This MCP server implements a JSON-RPC interface to interact with a simulated CO2 sensor device. It can run in two modes: a simulation mode that generates random CO2 levels, and a real mode that connects to a Raspberry Pi Pico via USB to read actual CO2 measurements. The server exposes commands to get device information, retrieve sensor data, and report network status, as well as tools to publish data to MQTT and manage network connections. Typical usage is to start the server and then use the provided JSON-RPC methods such as initialize to discover capabilities, resources/list to enumerate available resources, resources/read to fetch data, and tools/list or tools/call to use or invoke auxiliary tools. Some networking-related actions (publish to MQTT, reconnect WiFi, reconnect MQTT) are mocked to demonstrate integration points without requiring a full MQTT or network setup.

How to install

Prerequisites:

  • Node.js installed on your machine
  • Access to the repository with the MCP server code

Installation steps:

  1. Clone the repository: git clone <repository-url> cd <repository-directory>

  2. Install dependencies: npm install

  3. Configure the server for Claude Desktop:

    • Edit claude_desktop_config.json to include the MCP server entry. Example: { "mcpServers": { "CO2 sensor": { "command": "node", "args": ["...mcp-server-for-sensor-device/index.js"], "env": {} } } }
  4. Start the server (local development): node index.js

  5. Ensure any required hardware (Raspberry Pi Pico) is connected if you plan to run in real mode.

Additional notes

Tips and notes:

  • The device state simulates CO2 levels in software when in simulation mode. Real mode relies on a USB connection to a Raspberry Pi Pico; ensure proper USB access and drivers.
  • Logs are written to the user’s home directory in a file named co2_level.log. Check permissions if the log file cannot be created.
  • The JSON-RPC methods include initialize, shutdown, resources/list, resources/read, tools/list, and tools/call. Some network-related features (publishToMQTT, reconnectWiFi, reconnectMQTT) are mocked for demonstration purposes.
  • If you modify claude_desktop_config.json, restart the server to pick up changes.
  • The server is designed to work with Claude Desktop integration; verify that Claude Desktop is configured to communicate with the MCP server via the expected JSON-RPC endpoints.

Related MCP Servers

Sponsor this space

Reach thousands of developers