Skip to content

feat: MQTT CLI exposure — events mqtt-tail, doctor check, capabilities surface (v2.1.0)#10

Merged
chenliuyun merged 4 commits intomainfrom
feat/mqtt-cli-exposure
Apr 19, 2026
Merged

feat: MQTT CLI exposure — events mqtt-tail, doctor check, capabilities surface (v2.1.0)#10
chenliuyun merged 4 commits intomainfrom
feat/mqtt-cli-exposure

Conversation

@chenliuyun
Copy link
Copy Markdown
Collaborator

Summary

  • events mqtt-tail: new subcommand to stream live MQTT shadow events as JSONL (--topic, --max, --json)
  • doctor: 8th check reports MQTT config status (warn if unconfigured, ok with broker URL if set)
  • capabilities: surfaces.mqtt entry exposes env vars, CLI command, MCP resource, and configured flag for programmatic discovery
  • mcp serve stdio path: now initialises EventSubscriptionManager when MQTT env vars are present (matching the HTTP path), so switchbot://events resource works in stdio mode
  • --help: Environment section extended with all 4 MQTT env vars
  • schema description fix: account_overview.mqtt field description changed from "HTTP mode only" to "present when MQTT env vars are configured"

Test plan

  • 692 tests pass (npm test)
  • doctor --json shows mqtt: warn without env vars, ok with
  • capabilities --jsonsurfaces.mqtt.configured: false, surfaces.mcp.tools has 8 entries, resources: ["switchbot://events"]
  • events mqtt-tail exits 2 with UsageError when MQTT not configured
  • Smoke-tested doctor and devices list against real SwitchBot API

chenliuyun added 4 commits April 19, 2026 18:17
…bilities surface

- events mqtt-tail: new subcommand that connects to the configured MQTT
  broker via SwitchBotMqttClient and streams shadow events as JSONL;
  supports --topic (default "#"), --max (stop after N events); requires
  SWITCHBOT_MQTT_HOST/USERNAME/PASSWORD env vars (UsageError if missing)
- doctor: add 8th check 'mqtt' — warn if env vars unset, ok with host:port
  detail; no live connectivity test to keep doctor offline-safe
- capabilities: add surfaces.mqtt object with mode, envVars, cliCmd,
  mcpResource, protocol, and configured (bool) — agents can now
  programmatically discover the MQTT surface
- index.ts: extend Environment section in --help to list all 4 MQTT vars
- tests: 4 new mqtt-tail tests (UsageError, JSONL output, JSON envelope,
  --max validation); 2 new doctor mqtt tests (warn/ok); 1 capabilities test
  for surfaces.mqtt shape
- mcp stdio mode: initialize EventSubscriptionManager and pass it to
  createSwitchBotMcpServer() so switchbot://events is registered in BOTH
  stdio and HTTP modes — was only available in HTTP mode before (Issue 1)
- mcp help text: update "seven tools" → "eight tools", add account_overview
  to list, add switchbot://events resource section with MQTT env var note
- events command description: replace webhook-only wording with description
  covering both tail (webhook) and mqtt-tail (MQTT stream) subcommands
- doctor mqtt detail: explicitly state credentials are not verified and
  direct user to mqtt-tail for live connectivity testing (Issue 2 clarification)
…nt in both stdio and HTTP when MQTT is configured
When --max triggers ac.abort(), the abort signal path ran cleanup but
left the process.once SIGINT/SIGTERM handlers dangling. After the test
finishes Vitest sends SIGTERM, cleanup fired again with a torn-down mock
where disconnect() returns undefined, causing an unhandled TypeError.
@chenliuyun chenliuyun merged commit 68f6945 into main Apr 19, 2026
3 checks passed
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
v2.4.0 release note claimed every mqtt-tail event is appended to device
history, but control events (__connect, __reconnect, __disconnect,
__heartbeat) have no deviceId and were only emitted to stdout. Route
them into a dedicated ~/.switchbot/device-history/__control.jsonl
alongside the per-device files, sharing the same 50MB rotation logic.
Errors are swallowed — history writes never block the event stream.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
Document every fix landed in this branch beyond the history-aggregate
feature: bugs #1, #4, #5, #6, #8, #9, #10, #11, #12, #13, #14, #15,
#16, #17, #18 from the OpenClaw v2.4.0 smoke-test report. Call out
the deferred items (#2, #7) explicitly so readers don't assume they
were overlooked.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
v2.4.0 release note claimed every mqtt-tail event is appended to device
history, but control events (__connect, __reconnect, __disconnect,
__heartbeat) have no deviceId and were only emitted to stdout. Route
them into a dedicated ~/.switchbot/device-history/__control.jsonl
alongside the per-device files, sharing the same 50MB rotation logic.
Errors are swallowed — history writes never block the event stream.
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
Document every fix landed in this branch beyond the history-aggregate
feature: bugs #1, #4, #5, #6, #8, #9, #10, #11, #12, #13, #14, #15,
#16, #17, #18 from the OpenClaw v2.4.0 smoke-test report. Call out
the deferred items (#2, #7) explicitly so readers don't assume they
were overlooked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant