Skip to main content
Glama
cyberomusubi

CO2 Sensor MCP Server

by cyberomusubi

传感器设备的 MCP 服务器

该项目是一个 Node.js 应用程序,专为 Claude Desktop 设计。它模拟了一个二氧化碳传感器设备,并提供一个 JSON-RPC 服务器与该设备交互。该应用程序可以在模拟模式和真实模式下运行,在真实模式下,它通过 USB 连接到 Raspberry Pi Pico 来读取二氧化碳浓度。

特征

  • 在模拟模式下模拟具有随机二氧化碳水平的二氧化碳传感器设备。

  • 通过 USB 连接到 Raspberry Pi Pico 以读取真实的二氧化碳水平。

  • 通过 JSON-RPC 提供设备信息、传感器数据和网络状态。

  • 支持发布数据到MQTT、重新连接WiFi、重新连接MQTT的命令(部分功能模拟)。

Related MCP server: CoinGecko

安装

您需要在计算机上安装 Node.js 才能运行此应用程序。如果您尚未安装 Node.js,可以从官方网站下载。

  1. 克隆存储库。

  2. 使用 npm 安装依赖项:

    npm install

配置

确保正确配置claude_desktop_config.json文件以运行服务器。示例配置:

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

用法

要启动服务器,请运行以下命令:

node index.js

JSON-RPC 方法

initialize

初始化服务器并返回服务器功能。

shutdown

关闭服务器。

resources/list

列出可用资源。

resources/read

读取指定的资源。

tools/list

列出可用的工具。

tools/call

调用指定的工具。

DeviceState 类

DeviceState类模拟设备状态,并提供获取设备信息、传感器数据和网络状态的方法。它还负责处理与 Raspberry Pi Pico 的连接并读取二氧化碳浓度。

方法

  • getDeviceInfo() :返回设备信息。

  • getSensorData() :返回传感器数据。

  • getNetworkStatus() :返回网络状态(模拟功能)。

  • publishToMQTT() :模拟将数据发布到 MQTT(模拟功能)。

  • reconnectWiFi() :模拟重新连接到 WiFi(模拟功能)。

  • reconnectMQTT() :模拟重新连接到 MQTT(模拟功能)。

日志记录

该应用程序将二氧化碳水平和其他信息记录到位于用户主目录 ( co2_level.log ) 中的日志文件中。

执照

该项目已获得 MIT 许可。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A beginner-friendly MCP-inspired JSON-RPC server built with Node.js, offering basic client-server interaction through an 'initialize' capabilities handshake and an 'echo' function.
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A powerful and flexible Node.js Express server that provides a comprehensive interface to the CoinGecko cryptocurrency data API. This server supports both the free public API and the Pro API with automatic fallback.
    5
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Node.js Express server that provides access to CoinGecko's cryptocurrency data through a comprehensive API interface, supporting both free and Pro APIs with automatic fallback functionality.
    1
    MIT