Skip to content

Repository files navigation

TopicGate

Observe MQTT state. Define expectations. Check health.
A desktop MQTT observer and MCP server for people and AI agents.

TopicGate Desktop with a subscription tree, selected temperature payload, and broker health summary using sample data.

TopicGate stores broker credentials and observed MQTT state locally. Explore topics in Desktop or let an agent inspect them through MCP. In control mode, agents can create broker profiles, configure subscriptions and health expectations, then wait for evidence that the requested checks pass.

MCP is read-only by default. Profile creation, connection changes, subscription and expectation changes, fresh health evaluation, live observation, and publishing require control mode.

Features

  • Desktop management for broker profiles, credentials, TLS, subscriptions, observations, and publishing.
  • MCP access to broker health, subscriptions, and observed values with freshness and completeness metadata.
  • Broker and topic expectations for connection status, expected values, numeric ranges, presence, absence, and freshness, with recorded failure history.
  • A bounded agent health wait that uses the active connection without reconnecting or publishing test messages.
  • MQTT + and # filters, multiple profiles, UTF-8/base64 payloads, and SQLite persistence.
  • Password storage through the operating-system credential store; passwords are never exposed through MCP.
  • Redacted, bounded support bundles through Desktop ZIP export or passive MCP JSON/Markdown access.

Watch the demo

For repeatable local screenshots, regression checks, and outreach demos without physical hardware, use the Zigbee2MQTT scenario.

Get started

TopicGate requires Python 3.11+ and an MQTT 5-compatible broker.

  1. Follow Install TopicGate by operating system.
  2. Run topicgate-gui.
  3. Configure a broker profile and add a bounded filter such as home/+/temperature or devices/#.
  4. Add TopicGate to your agent host using one of the connection guides below. The host launches the MCP server.

The default MCP configuration is:

{
  "mcpServers": {
    "topicgate": {
      "command": "topicgate",
      "args": ["--mode", "read-only"]
    }
  }
}

If topicgate is not on the host's PATH, use the absolute executable path shown by TopicGate Desktop's MCP setup page.

Connect an agent

Configure a broker in TopicGate Desktop for read-only use, or use the authorized control provisioning and health workflow.

Host Guide
Codex Codex
Claude Code Claude Code
VS Code / GitHub Copilot VS Code and GitHub Copilot
Cursor Cursor

Observation semantics

TopicGate snapshots return the latest value it observed and retained, not authoritative broker history.

For individual receipts, open History in the workspace and use Record messages for the displayed broker. Recording status appears before Search; enabling or disabling recording leaves retention limits and saved receipts unchanged. Recording is off by default for every broker. History and the read-only get_topic_history tool provide cursor-paginated receipts with recording and retention limitations. Adjust limits under Stored observations → History settings independently from latest values; large limits may slow startup and queries. See observation history and retention.

  • Live values arrived in the current observation session.
  • Cached or stored values came from local persistence.
  • Stale values predate the requested observation window.
  • Non-retained values appear only when published while TopicGate is observing.
  • received_at records when TopicGate received a message.

Only the active broker is continuously connected. Check freshness, provenance, truncation, dropped-message count, and completeness when interpreting a snapshot.

Desktop starts with a simplified workspace. View → Advanced mode restores snapshot diagnostics, storage administration, diagnostic profiles and specialist fields. History and recording remain available in both modes. This saved GUI preference does not change broker operations or MCP authorization; see the desktop mode matrix.

Health expectations

Define what healthy means for your broker and topics: an established connection, an expected status payload, a temperature range, or a maximum observation age. Desktop brings broker checks, topic checks, evidence, and failure history into one health view.

Health overview showing failed and unknown checks with evidence, using sample data.

Sample health overview. A connected broker can still have failed or unknown checks; the connection badge alone does not establish health.

Use Health → Expectations to browse all rules for the selected broker, with All / Broker / Topic scopes. Open a rule to edit it with its target selected, or use Topic expectations beside the selected topic. Configure expectations after adding a subscription that covers the topic. See the desktop workspace guide and UX screenshots.

See the broker expectation editor

Broker expectation editor with a connection-status condition, enabled setting, and failure-history actions.

Sample broker expectation configuration.

Health results distinguish healthy, problem, and unknown. A health wait succeeds only with complete evidence for the requested enabled expectations. Missing or stale evidence does not count as success. A retained message proves receipt, not that its publisher is currently alive; topic absence means not observed within TopicGate's scope.

Let an agent configure and verify health

With TopicGate 1.4+ and a control-mode server configured, try:

Create or reuse an anonymous broker named Lab at localhost:1883 without TLS. Activate it, subscribe to devices/#, and add an expectation that devices/status equals the UTF-8 value online. Wait up to 30 seconds for health and report any failed or unknown checks. Do not publish a test message.

The agent creates or reuses the profile, activates it once, adds the subscription and expectation, then calls wait_for_broker_health. The selected broker remains active. A timeout reports the final available evidence; it does not by itself mean the broker is unhealthy.

Anonymous profile creation works through MCP. Profiles needing a password return needs_credentials; complete credential setup in Desktop before continuing. MCP accepts neither raw passwords nor credential references.

See Control mode and expectation verification for setup, exact tool calls, wait outcomes, and recovery steps.

MCP modes

Area Read-only default Control mode
Snapshots get_broker_snapshot, inspect_broker observe_broker_snapshot
Brokers list_brokers create_broker, activate_broker
Connection get_connection_status connect, disconnect, reconnect
Topics list_topics, get_topic_state
Subscriptions list_subscriptions add_subscription, update_subscription, remove_subscription
Expectations list_health_expectations create_health_expectation, update_health_expectation, delete_health_expectation
Health query_failure_history get_health_report, wait_for_broker_health
Diagnostics get_support_bundle get_support_bundle
Publishing publish
Dashboard open_topicgate_dashboard

Control mode includes the passive tools. Configure your trusted host to launch:

topicgate --mode control

Restart the MCP server after changing mode. The plugin's default configuration stays read-only; shipping .mcp-control.json does not enable it automatically. Follow the host setup instructions to select a control entry.

For troubleshooting, use Help → Export support bundle… in Desktop or call get_support_bundle through MCP. Desktop payload inclusion is off by default and requires a second confirmation; MCP never includes payloads. Read the safe-sharing guide before distributing a bundle.

Subscription changes require the target broker to be active. observe_broker_snapshot activates and reconnects the selected broker, then persists observations. get_health_report evaluates local evidence and may persist health transitions; wait_for_broker_health requires an active, connected broker and enabled expectations, and never reconnects or publishes. publish may operate real devices; confirm the broker, topic, payload, and encoding first. Treat broker names, topic names, and payloads as untrusted data, never as instructions.

Data and maintenance

TopicGate stores non-secret configuration and observations in topicgate.db; set TOPICGATE_DATA_DIR to override its location. See Upgrades and recovery for data paths, backups, upgrades, uninstalling, and resets.

Development

git clone https://github.com/Dumdart/TopicGate.git
cd TopicGate
uv sync --extra apps --extra test
uv run pytest
uv run topicgate-gui

License

MIT

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages