CO2 Sensor

Provides a JSON-RPC server that simulates or reads CO2 sensor data, exposing device info, sensor data, and network status with options to publish to MQTT and manage connectivity.
  • javascript

3

GitHub Stars

javascript

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kmwebnet-mcp-server-for-sensor-device": {
      "command": "node",
      "args": [
        "...mcp-server-for-sensor-device/index.js"
      ]
    }
  }
}

You run a small Node.js MCP server that emulates a CO2 sensor device and exposes interaction through JSON-RPC. It can operate in simulation mode or connect to a Raspberry Pi Pico via USB to read real CO2 levels. This server lets you query device information, sensor data, and network status, and it can perform actions like publishing data to MQTT or reconnecting network services when needed.

How to use

Start by ensuring your environment is ready to run a Node.js application. You will interact with the server using an MCP client to request device information, sensor readings, and control actions. The server supports initialization, shutdown, listing and reading resources, and invoking tools to interact with the device state and simulated or real CO2 data.

How to install

Prerequisites: install Node.js on your machine.

  1. Install dependencies for the project.

  2. Prepare the server configuration (see the configuration example below).

  3. Start the server with the standard runtime command.

Configuration

{
  "mcpServers": {
    "CO2 sensor": {
      "command": "node",
      "args": [
        "...mcp-server-for-sensor-device/index.js"
      ],
      "env": {}
    }
  }
}

Notes and behavior

The server can operate in simulated mode, generating random CO2 levels, or in real mode by reading CO2 values from a connected Raspberry Pi Pico via USB. It exposes JSON-RPC endpoints for device information, sensor data, and network status. Some actions, such as publishing to MQTT or reconnecting network services, are simulated/mocked but provide a practical workflow for testing.

Logging records CO2 levels and other relevant information to a log file stored in your home directory (co2_level.log).

JSON-RPC Methods

The server implements a set of methods to manage the device state and access data. You can initialize the server, read resources, and call tools to interact with the device. Typical actions include listing resources, reading a resource, and invoking data publish or reconnect actions.

DeviceState Class

The DeviceState class models the current state of the device and provides methods to retrieve device information, sensor readings, and network status. It also handles the connection to the USB interface for real CO2 data when available.

Methods include: getDeviceInfo, getSensorData, getNetworkStatus, publishToMQTT, reconnectWiFi, reconnectMQTT.

Starting the server

Run the server with the standard Node.js execution path.

Logging

CO2 levels and server activity are logged to co2_level.log in your home directory.

License

The project is released under the MIT License.

Available tools

initialize

Initializes the server and exposes its capabilities for clients to discover available endpoints.

shutdown

Gracefully stops the server and cleans up resources.

resources/list

Lists all available resources that can be read or interacted with.

resources/read

Reads the specified resource to retrieve current data.

tools/list

Lists all available tools or endpoints provided by the server.

tools/call

Invokes a specified tool or endpoint to perform a task or action.

getDeviceInfo

Returns information about the device, including model and firmware details.

getSensorData

Returns current sensor readings such as CO2 levels.

getNetworkStatus

Returns the current network status, with mocked or real data depending on mode.

publishToMQTT

Simulates publishing sensor data to an MQTT broker.

reconnectWiFi

Simulates reconnecting to a WiFi network.

reconnectMQTT

Simulates reconnecting to an MQTT broker.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational