物联网设备命令行客户端

WoT-MCP CLI是一个交互式命令行工具,用于连接WoT-MCP服务器,管理和交互物联网设备,支持工具调用和资源管理。

  • by macc-n
  • JavaScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 macc-n/wot-mcp-cli

使用说明

WoT MCP命令行界面

用于的交互式命令行界面(CLI)客户端 WoT MCP 服务器。此工具允许您连接到MCP服务器,检查可用的工具和资源,并通过模型上下文协议与物联网设备进行交互。

特性

  • 交互式外壳:键入与服务器交互的命令。
  • 运输方式:支持两者 stdio (直接生成服务器)和 streamable-http (连接到正在运行的服务器)。
  • 工具检查:列出可用的工具及其模式。
  • 工具执行:使用JSON参数调用工具。
  • 资源管理:列出、阅读和订阅资源。

安装

git clone https://github.com/macc-n/wot-mcp-cli.git
cd wot-mcp-cli
npm install
npm run build

用法

标准(默认)

此模式生成 wot-mcp 服务器作为子进程。您需要提供服务器的配置文件。

注: 此模式假定 wot-mcp-cli 和 wot-mcp 位于同一父目录中(即。, ../wot-mcp/dist/main.js 必须存在)。

npm start -- --config ./things-config.json

流式HTTP

连接到现有 wot-mcp 服务器正在运行 streamable-http 模式。

  1. 首先启动WoT MCP服务器:

    cd wot-mcp
    npm start -- --mode streamable-http --port 3000 --config ./things-config.json
    
  2. 连接CLI:

    npm start -- --mode streamable-http --url http://localhost:3000/mcp
    

命令

进入交互式shell后,您可以使用以下命令:

命令 描述 示例
tools 列出所有可用工具 tools
call <tool> [json] 调用带有参数的工具 call set_temperature {"value": 22}
resources 列出所有可用资源 resources
read <uri> 按URI读取资源 read wot://device/properties/temp
subscribe <uri> 订阅资源更新 subscribe wot://device/events/overheat
unsubscribe <uri> 取消订阅更新 unsubscribe wot://device/events/overheat
help 显示帮助消息 help
exit 退出CLI exit