devicechain-mcp
OfficialREADME.md
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="branding/logos/logo.svg">
<img alt="DeviceChain" src="branding/logos/logo-light.svg" width="300">
</picture>
</p>
**DeviceChain is an Apache 2.0 IoT platform you run on Kubernetes, ready for AI agents.** Devices connect over MQTT, HTTP, Sparkplug B or LwM2M, or through a LoRaWAN network server. Rules raise alarms and send commands back, and dashboards, over-the-air updates and multi-tenant access are built in. An optional [MCP server](https://docs.devicechain.io/concepts/mcp) lets Claude, Cursor or VS Code read devices, telemetry, alarms and commands with the signed-in user's own token, and an assistant's proposals to acknowledge or clear alarms wait for a person to approve them (Preview). There is no device cap and no enterprise edition.
<p align="center">
<a href="https://devicechain.io/#see-it-run"><img src="branding/media/sitepulse-loop.webp" width="720" alt="A haul truck in a 3D quarry: its telemetry arrives over MQTT, a low-fuel rule fires, a refuel command is sent, the truck heads for the fuel bay while other trucks keep to their own lanes of the two-way haul road, it refuels, and the command completes."></a>
<br>
<sub>Sitepulse, a simulated quarry whose machines are real devices on a real DeviceChain instance: a truck's fuel drops low, a rule raises an alarm and sends it to refuel, and the truck reports the command done. Rendered from a recorded run.</sub>
</p>
<p align="center">
<a href="https://devicechain.io/#see-it-run"><img src="branding/media/towerpulse-loop.webp" width="480" alt="A simulated facility-services campus, a five-floor tower and a two-floor lab annex: a hot meeting room raises an alarm and a boost-cooling command is sent, then an annex chiller stops reporting, a critical alarm is raised and a restart command brings it back."></a>
<br>
<sub>Towerpulse, a second simulated site: 31 devices on a real DeviceChain instance. A hot meeting room triggers a rule that raises an alarm and sends a boost-cooling command, and an annex chiller that stops reporting is restarted by command. Rendered from a recorded run, with time jumps labelled.</sub>
</p>
## Watch
<table>
<tr>
<td width="50%" valign="top">
<a href="https://youtu.be/fWnVhI7icOk"><img src="https://i.ytimg.com/vi/fWnVhI7icOk/hqdefault.jpg" alt="Video: Install DeviceChain on a laptop and send your first device reading" width="100%"></a>
<br>
<b>Getting started.</b> <a href="https://youtu.be/fWnVhI7icOk">Install DeviceChain on a laptop and send your first device reading</a>. English audio, with English and Spanish captions.
</td>
<td width="50%" valign="top">
<a href="https://youtu.be/VMoWwXf4IAI"><img src="https://i.ytimg.com/vi/VMoWwXf4IAI/hqdefault.jpg" alt="Video: DeviceChain in a simulated quarry: reading, rule, alarm, command" width="100%"></a>
<br>
<b>End to end.</b> <a href="https://youtu.be/VMoWwXf4IAI">DeviceChain in a simulated quarry: reading, rule, alarm, command</a>. The tour from a reading to a rule, an alarm and a command.
</td>
</tr>
<tr>
<td width="50%" valign="top">
<a href="https://youtu.be/nCxsli5rwzI"><img src="https://i.ytimg.com/vi/nCxsli5rwzI/hqdefault.jpg" alt="Video: Build IoT dashboards in DeviceChain: canvas, slots, widgets, /dash" width="100%"></a>
<br>
<b>Dashboards.</b> <a href="https://youtu.be/nCxsli5rwzI">Build IoT dashboards in DeviceChain: canvas, slots, widgets, /dash</a>. English audio, with English and Spanish captions.
</td>
</tr>
</table>
More on the [DeviceChain YouTube channel](https://www.youtube.com/@devicechain-iot).
[](LICENSE)
[](https://github.com/devicechain-io/devicechain/actions/workflows/ci.yml)
[](https://github.com/devicechain-io/devicechain/releases/latest)
[](https://artifacthub.io/packages/search?repo=devicechain)
[](https://scorecard.dev/viewer/?uri=github.com/devicechain-io/devicechain)
- **Closes the loop.** A rule can raise an alarm and command the device, and a command is tracked until the device reports the result or its time-to-live runs out ([commands](https://docs.devicechain.io/concepts/commands), [event processing](https://docs.devicechain.io/concepts/event-processing)).
- **Measured, with the results published.** Throughput was measured on Google Kubernetes Engine and every stored event was checked, with the setup and the limits of each run stated ([measured throughput](https://docs.devicechain.io/deployment/bootstrap#measured-throughput)). Container images and the Helm chart are signed ([verifying releases](https://docs.devicechain.io/deployment/verifying-releases)).
- **Open, with tenants built in.** One installation serves many tenants, each isolated from the others, and a membership can be limited to one customer's data ([multi-tenancy](https://docs.devicechain.io/concepts/multi-tenancy), [security model](https://docs.devicechain.io/concepts/security-model)). All of it is Apache 2.0 and in this repository.
### Try it locally
You need Docker, `kubectl`, `kind` and OpenTofu 1.10 or later on your `PATH`, plus `dcctl` and
`dc-simulator` from the [releases page](https://github.com/devicechain-io/devicechain/releases).
Give Docker at least 4 CPUs, 8 GB of memory and 40 GB of free disk. Most of the time is the
bootstrap; the [quickstart](https://docs.devicechain.io/quickstart/first-device) budgets about half
an hour end to end. The commands are for a bash shell (on Windows, Git Bash or WSL).
```bash
dcctl install local --compact # a kind cluster sized for a laptop
dcctl bootstrap local devicechain --host localhost --no-tls # an instance, served at http://localhost/
dcctl sim create building --manifest buildingpulse # a tenant and a sign-in for it
```
The simulator sends its readings to the device ingest port, which a local install does not
publish. Forward it in a second terminal and leave it running, then start the simulator:
```bash
kubectl -n dci-devicechain port-forward svc/event-sources 8081:8081 # second terminal
dcctl sim run building --simulator ./dc-simulator # Ctrl+C stops it
```
It provisions twelve thermostats across three buildings, with a rule that raises an alarm when a
temperature goes above 30, and then sends readings every five seconds. Open http://localhost/ and
sign in as `building@sim.devicechain.local`, the identity `sim create` made for the tenant
`sim-building`. Its password is the `simPassword` field in `~/.devicechain/sims/building.json`.
Under **Monitor → Alarms**, `bp-over-temp` alarms raise and clear as the temperatures rise and
fall. (The bootstrap also prints a password for `superuser@devicechain.local`, which administers
the instance and sees no tenant data.)
[Your first device](https://docs.devicechain.io/quickstart/first-device) continues from here: it
creates a device, sends a reading with `curl` and shows it in the console.
[Docs](https://docs.devicechain.io) · [Examples](examples/) · [Roadmap](ROADMAP.md) · [Contributing](CONTRIBUTING.md) · [Discussions](https://github.com/devicechain-io/devicechain/discussions) · [Releases](https://github.com/devicechain-io/devicechain/releases)
The current release is **v1.6.0**; **v1.7** is in progress. See [Status](#status) for the compatibility promises.
DeviceChain™ takes in telemetry from device fleets, keeps a record of each device and the assets,
areas and customers it belongs to, detects conditions in the data as it arrives, and sends
commands back. It is meant for teams that build an IoT product or run a fleet and want to run the
platform in a Kubernetes cluster they control, with their data kept there.
## What it does
### Ingest
Devices send data over these transports:
- MQTT, through the broker built into NATS (port 1883)
- HTTP, as a `POST` of a JSON event (the same body a device publishes over MQTT)
- [Eclipse Sparkplug B](https://docs.devicechain.io/concepts/sparkplug), with DeviceChain joining
your existing Sparkplug broker as a Host Application
- [OMA LwM2M](https://docs.devicechain.io/concepts/lwm2m) over CoAP/UDP with DTLS
The transports differ in what they support. HTTP devices can opt into command polling with the
`HTTP_PULL` command channel on their device type (available since v1.4). Sparkplug commands (`NCMD` and
`DCMD`) are opt-in and off by default, and LwM2M telemetry is decoded from SenML-JSON only. Sparkplug and LwM2M are not in
the default install; add them at bootstrap with `--enable-area sparkplug-ingest` or
`--enable-area lwm2m-ingest`. The
[transport matrix](https://docs.devicechain.io/reference/transport-matrix) lists what each one
does and what it lacks. A runnable Sparkplug example, with an Eclipse Tahu edge node and a
Mosquitto broker, is in [`examples/sparkplug-commands`](examples/sparkplug-commands).
### Device model
You describe a kind of device once, in a versioned device profile that lists its metrics,
commands and detection rules. Publishing a new profile version changes the behaviour of every
device of that type in one step, and rollback undoes it. Devices can be linked to assets, areas
and customers. The links you mark as tracked are written onto each event when it arrives, so a
query for everything in one building finds its readings without walking the relationship graph,
and history stays where it was when a device is moved. A profile can also declare the
configuration a device receives; each device has its own copy, and you can restore an earlier
revision of it or copy another device's
([configuration](https://docs.devicechain.io/guides/connecting-a-device#restore-copy-configuration)).
A device can be disabled, which discards its events and refuses commands to it, and keeps its data
([disabling a device](https://docs.devicechain.io/guides/device-credentials#disabling-a-device)).
Any published profile version can be exported as a W3C Web of Things Thing Model. See the
[domain model](https://docs.devicechain.io/concepts/domain-model).
### Detection and alarms
Detection rules run in the event-processing service as events arrive. Condition types include
thresholds, conditions held for a duration, repeated occurrences, rate of change, silence,
connectivity, windowed aggregates and conditions met by several devices in one area. A rule can
raise an alarm, send a command to a device, call a webhook, or publish to MQTT, Kafka, AWS SNS or
AWS SQS. The webhook and publish actions need the `outbound-connectors` area, which is off by
default. Rules are written as forms, on a visual canvas that can replay history against a draft,
or from a plain-language description when the optional AI service is enabled. Alarms reach people
by email or webhook, with escalation. See
[event processing and alarms](https://docs.devicechain.io/concepts/event-processing).
### Commands and dashboards
Commands are validated against the device's profile, then tracked until the device reports the
result or the command's time-to-live runs out
([commands](https://docs.devicechain.io/concepts/commands)). Dashboards are versioned per tenant
and render with React widget packages published to npm, which you can embed in your own
application ([dashboards](https://docs.devicechain.io/concepts/dashboards)). A dashboard can be imported,
cloned or started from a template. The console exports the device list, the alarm list, a command
batch and the audit journals as CSV, up to 10,000 rows each.
### Sign-in and updates
People can sign in through your own OpenID Connect identity provider, and a tenant can require it
([single sign-on](https://docs.devicechain.io/concepts/single-sign-on)). Over-the-air updates have a per-tenant artifact catalogue with a
verified upload, signers (an artifact nobody has signed cannot be assigned unless you allow that),
assignment to one device or, as a rollout, to a device group a capped number of devices at a time,
and a resumable download. The console has screens for them. Rollouts have no waves, canary
promotion or schedules, and only a device connected over MQTT can receive a managed update
([over-the-air updates](https://docs.devicechain.io/concepts/over-the-air-updates)).
### APIs and data access
The management and query APIs are GraphQL, and their schemas are published in the docs
([schema index](https://docs.devicechain.io/schema/index.json)). Introspection is off in a running
instance. Client libraries are the `@devicechain/client` TypeScript package on npm and the
`DeviceChain.Sdk` .NET package on NuGet, which also targets Unity. Telemetry lives in TimescaleDB,
so BI tools and `psql` can read it through a read-only analytics schema
([SQL and BI access](https://docs.devicechain.io/guides/sql-and-bi-access)). An optional
[MCP server](https://docs.devicechain.io/concepts/mcp) gives AI assistants read-only access to a
tenant, under the signed-in user's own token.
## How it runs
DeviceChain is a set of Go services on Kubernetes, with a React console. NATS JetStream carries
messaging, device MQTT connections and key-value state. PostgreSQL holds entity data, and a
second PostgreSQL database with the TimescaleDB extension holds events. Each tenant's data is
separated by a tenant column that every query is scoped to, and by per-tenant messaging subjects.
All tenants share one set of services
([multi-tenancy](https://docs.devicechain.io/concepts/multi-tenancy)).
A default install sizes the CPU request of each service on the event path from measurement
([service sizing](https://docs.devicechain.io/deployment/bootstrap#service-sizing)). On
Google Kubernetes Engine, on three 4-vCPU, 16 GB database nodes and three 4-vCPU, 8 GB service
nodes, an HA install at its defaults sustained 10,000 events a second for 10 minutes, on each of
two development builds that went into v0.22.0, and stored every accepted event exactly once,
checked event by event: none missing, none stored twice, none unexpected. In those runs the
event-path services and the broker's stream leaders were held to one balanced placement across
the three service nodes. With placement left to the scheduler, the v0.19.0 release candidate was
measured the same way at 6,000 events a second. Each event carried one reading, from one tenant
whose ingest ceiling was raised for the test. These results describe that workload and cluster,
not a capacity guarantee. See
[measured throughput](https://docs.devicechain.io/deployment/bootstrap#measured-throughput). Each
tenant is allowed 1,000 readings a second by default
([governance](https://docs.devicechain.io/concepts/governance)).
The `--ha` flag on `dcctl install` runs the message broker as a three-node cluster with every
stream replicated, and both databases as three-instance clusters. Without `--compact`, it also
runs `event-management` as two pods. It needs three schedulable
nodes (on kind, three workers). An `--ha` install keeps running when any one node is lost; a
second node lost at the same time stops writes. `dcctl ha verify` checks that the broker holds
the replication the install declares ([high availability](https://docs.devicechain.io/deployment/bootstrap#ha)).
The [disaster recovery](https://docs.devicechain.io/deployment/disaster-recovery) page covers
backups and restore. A restore covers the two databases; JetStream stream state and object
storage have not been through a restore drill.
DeviceChain started as a rebuild of the [SiteWhere](https://github.com/sitewhere/sitewhere) IoT
platform. It begins from SiteWhere's domain (devices, device types, assets, areas and customers)
and replaces the Java and Spring stack with Go services. There is no tool to import data from a
SiteWhere installation.
## Status
DeviceChain follows [semantic versioning](https://semver.org) from v1.0.0. The device wire, the
GraphQL API, the npm and C# SDKs and `dcctl` change incompatibly only in a major release, and a
deprecation lasts at least two minor releases first; the
[versioning policy](https://docs.devicechain.io/deployment/versioning-policy) says exactly what is
covered. Each release lists anything you must do first in the
[release notes](https://github.com/devicechain-io/devicechain/releases) and the
[upgrade guide](https://docs.devicechain.io/deployment/releases-and-upgrades). Read them before
you upgrade.
`dcctl install local` and `dcctl bootstrap local` are tested end to end on kind. To use another
cluster, pass `--kube-context <ctx>` to both commands; that path is not part of the end-to-end
tests. For Google Kubernetes Engine, [`deploy/gke`](deploy/gke/README.md) creates a cluster sized
for DeviceChain and walks through installing onto it.
## Install
`dcctl` is the command-line tool that installs and runs DeviceChain. Download it for Linux, macOS
or Windows from the [releases page](https://github.com/devicechain-io/devicechain/releases). It
carries the Helm chart, the operator manifests and the OpenTofu configuration inside it, so the
binary is all you need from this repository. It drives these tools, which must be on your `PATH`:
- `kubectl`
- OpenTofu (`tofu`) or `terraform`
- `docker`, only when `dcctl` runs the cluster itself (the `local` provider, which runs kind on
Docker) or builds images from source (`--build`). Installing into an existing cluster with
`--kube-context` from published images needs no Docker daemon.
- `kind`, for the local provider
The cluster must run Kubernetes 1.29 or newer. `dcctl preflight local` checks the tools, and the
Kubernetes version once a cluster exists, without changing anything. For a small machine,
[`--compact`](https://docs.devicechain.io/deployment/bootstrap#--compact) on `dcctl install`
lowers resource requests and leaves out the monitoring stack.
`dcctl install` prepares a Kubernetes cluster once. `dcctl bootstrap` then creates an instance:
one DeviceChain deployment with its own console, message broker and databases. Tenants are
created inside an instance.
```bash
# Prepare the cluster. This creates a kind cluster named "devicechain" if there is none, and
# installs the DeviceChain operator, a shared PostgreSQL server and its backup store, the
# CloudNativePG operator, cert-manager, Prometheus and Grafana, and Traefik with Gateway API.
dcctl install local
# Create an instance served at http://localhost/.
dcctl bootstrap local devicechain --host localhost --no-tls
```
Bootstrap prints the console URL and a generated password for `superuser@devicechain.local`.
[Your first device](https://docs.devicechain.io/quickstart/first-device) continues from here. It
walks you through creating a tenant, sending a reading with `curl` and seeing it in the console.
To remove the instance, run `dcctl destroy local devicechain`. The cluster and what
`dcctl install` put on it stay; `kind delete cluster --name devicechain` removes them. Destroy
keeps the instance's root-key escrow file. Move it aside before you bootstrap again under the
same name.
To build `dcctl` from source, run `make build` in `backend/cli`. A binary you build yourself has
no default image version, so pass `--build` to both commands to build the images from source
(this needs `ko`), or `--version vX.Y.Z` to deploy a published release.
## Documentation
The documentation is at [docs.devicechain.io](https://docs.devicechain.io). Its source is in
[`docs/`](docs/). Good places to start:
- [Your first device](https://docs.devicechain.io/quickstart/first-device)
- [Connecting a device](https://docs.devicechain.io/guides/connecting-a-device)
- [GraphQL API](https://docs.devicechain.io/reference/graphql-api)
- [Releases and upgrades](https://docs.devicechain.io/deployment/releases-and-upgrades)
- [Local development](https://docs.devicechain.io/guides/local-development), for working on the
source
- [`llms.txt`](https://docs.devicechain.io/llms.txt), an index of the docs for AI assistants
## Getting help and contributing
Ask questions and propose ideas in
[Discussions](https://github.com/devicechain-io/devicechain/discussions). Report bugs through
[issues](https://github.com/devicechain-io/devicechain/issues/new/choose), which have short forms
for install failures, missing telemetry and docs problems. A rough report of where you got stuck
is still useful. Report security vulnerabilities privately to
[admin@devicechain.io](mailto:admin@devicechain.io) (see [SECURITY.md](SECURITY.md)).
To contribute code, read [CONTRIBUTING.md](CONTRIBUTING.md). Contributors sign a CLA before a
change can be merged.
## License
DeviceChain is licensed under the [Apache License 2.0](LICENSE) (see also [NOTICE](NOTICE)).
Copyright is held by The DeviceChain Authors.
The project's licensing intent is stated in [CONTRIBUTING.md](CONTRIBUTING.md#licensing-intent).
"DeviceChain" and the DeviceChain logo are trademarks of IoT Innovations, LLC. The Apache 2.0
license covers the code, not the marks. See [TRADEMARK.md](TRADEMARK.md) for the trademark policy.
This server cannot be deployed
Maintenance
ActivityActive
ResponsivenessUsually handled