CO2 Sensor

by kmwebnet

2 stars
Not rated
GitHub

About

Simulates or interfaces with a CO2 sensor device, providing JSON-RPC endpoints for device information, sensor data, and network management with MQTT publishing capabilities for IoT applications.

Details

Author
kmwebnet
Repository
cyberomusubi/MCP-Server-for-sensor-device
GitHub stars
2
Categories
Productivity, Design, Developer Tools, AI, Infrastructure, Frontend

- Simulates a CO2 sensor device with random CO2 levels in simulation mode.
- Connects to a Raspberry Pi Pico via USB to read real CO2 levels.
- Provides device information, sensor data, and network status via JSON-RPC.
- Supports commands to publish data to MQTT, reconnect WiFi, and reconnect MQTT (some functionalities are mocked).

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name CO2 Sensor
    Command (node, npx, python, etc.) node
    Arguments
    • Argument 1 ...mcp-server-for-sensor-device/index.js

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

To start the server, run the following command:

node index.js

initialize

Initializes the server and returns server capabilities.

shutdown

Shuts down the server.

resources/list

Lists available resources.

resources/read

Reads the specified resource.

tools/list

Lists available tools.

tools/call

Calls the specified tool.

getDeviceInfo

Returns device information.

getSensorData

Returns sensor data.

getNetworkStatus

Returns network status (mocked functionality).

publishToMQTT

Simulates publishing data to MQTT (mocked functionality).

reconnectWiFi

Simulates reconnecting to WiFi (mocked functionality).

reconnectMQTT

Simulates reconnecting to MQTT (mocked functionality).

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

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

Linux

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

Macos

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

Windows

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

MCP Server 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.

Features

- Simulates a CO2 sensor device with random CO2 levels in simulation mode.
- Connects to a Raspberry Pi Pico via USB to read real CO2 levels.
- Provides device information, sensor data, and network status via JSON-RPC.
- Supports commands to publish data to MQTT, reconnect WiFi, and reconnect MQTT (some functionalities are mocked).

Installation

You need to have Node.js installed on your machine to run this application. If you don't have Node.js installed, you can download it from the official website.
1. Clone the repository.
2. Install the dependencies using npm:

   npm install
   

Configuration

Ensure that the claude_desktop_config.json file is correctly configured to run the server. Example configuration:

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

Usage

To start the server, run the following command:

node index.js

JSON-RPC Methods

initialize

Initializes the server and returns server capabilities.

shutdown

Shuts down the server.

resources/list

Lists available resources.

resources/read

Reads the specified resource.

tools/list

Lists available tools.

tools/call

Calls the specified tool.

DeviceState Class

The DeviceState class simulates the device state and provides methods to get device information, sensor data, and network status. It also handles the connection to the Raspberry Pi Pico and reads CO2 levels.

Methods

- getDeviceInfo(): Returns device information.
- getSensorData(): Returns sensor data.
- getNetworkStatus(): Returns network status (mocked functionality).
- publishToMQTT(): Simulates publishing data to MQTT (mocked functionality).
- reconnectWiFi(): Simulates reconnecting to WiFi (mocked functionality).
- reconnectMQTT(): Simulates reconnecting to MQTT (mocked functionality).

Logging

The application logs CO2 levels and other information to a log file located in the user's home directory (co2_level.log).

License

This project is licensed under the MIT License.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.