- Prerequisites
- Step 1. Connect MCP server to ThingsBoard
- Step 2. Querying devices in ThingsBoard
- Step 3. Generating sample data for AQI sensor
- Step 4. Analyzing data for anomalies
- MCP versatility in real-world scenarios
This document describes how to use the ThingsBoard MCP Server to query platform data, generate sample telemetry, and detect anomalies in your ThingsBoard time-series data.
We will use natural language queries to interact with ThingsBoard using MCP (via Claude or another LLM provider).
With the help of ThingsBoard MCP, you can:
- Find devices matching specific criteria in your ThingsBoard platform.
- Simulate or ingest telemetry (e.g., AQI sensor data) directly into ThingsBoard for a specific device.
- Analyze device data for anomalies. This can easily be adapted to search for spikes, data gaps, or other patterns.
Prerequisites
Before you begin, ensure that you have:
- An account at ThingsBoard Cloud or a self-hosted ThingsBoard installation on your own infrastructure.
- Authentication credentials (username and password) with sufficient permissions.
- An LLM Agent (e.g., Claude Desktop) capable of running MCP Servers.
Step 1. Connect MCP server to ThingsBoard
The first step is to start your LLM Agent with the ThingsBoard MCP Server.
In this guide, we will use Claude Desktop to start the ThingsBoard MCP Server and connect it to a ThingsBoard instance.
You may use any other MCP-enabled client.
Run MCP via Docker:
1
docker pull thingsboard/mcp
Claude Desktop Configuration
Add the following configuration to your claude_desktop_config.json
:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"mcpServers": {
"thingsboard": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"THINGSBOARD_URL",
"-e",
"THINGSBOARD_USERNAME",
"-e",
"THINGSBOARD_PASSWORD",
"-e",
"LOGGING_PATTERN_CONSOLE",
"thingsboard/mcp"
],
"env": {
"THINGSBOARD_URL": "<thingsboard_url>",
"THINGSBOARD_USERNAME": "<thingsboard_username>",
"THINGSBOARD_PASSWORD": "<thingsboard_password>",
"LOGGING_PATTERN_CONSOLE": ""
}
}
}
}
Once you start Claude Desktop, you will see thingsboard tools available:
For advanced setup (running the binary instead of Docker or building locally), refer to the ThingsBoard MCP GitHub repository.
Step 2. Querying devices in ThingsBoard
Here is list of devices inside ThingsBoard platform:
Using Claude Desktop, you can make requests using natural language.
Example query:
1
Get devices of type 'Air Quality Sensor'
ThingsBoard MCP will translate this into a ThingsBoard API query and return structured results:
Step 3. Generating sample data for AQI sensor
Based on your requests, MCP can simulate (generate) telemetry for any device.
Example query:
1
Generate sample data for Office #1 AQI Sensor for the last 3 days and save it as timeseries data. Use sampling rate as 1 hour
MCP automatically adds the generated time series data into ThingsBoard, making it available for dashboards and analytics.
Step 4. Analyzing data for anomalies
Once telemetry is available, you can request MCP to analyze it for anomalies.
Example query:
1
Analyze AQI of Office #1 AQI Sensor for anomalies in the last 3 days and show results in a table.
MCP will return anomaly detection results in a tabular format:
MCP versatility in real-world scenarios
The ThingsBoard MCP Server extends far beyond anomaly detection for AQI sensors. It can be applied to a wide range of use cases, including:
- Industrial IoT Monitoring — Detect unusual vibration, temperature, or pressure changes in machinery.
- Energy Management — Identify consumption spikes in smart meters and optimize energy usage.
- Environmental Monitoring — Detect sudden changes in air or water quality and trigger alerts.
- Predictive Maintenance — Analyze equipment performance trends and anticipate failures before they occur.
- Smart City Applications — Monitor traffic flow, street lighting, or waste collection anomalies.
By combining MCP's natural language interface with ThingsBoard's data visualization and alerting capabilities, you can rapidly prototype and deploy AI-driven IoT solutions across a wide range of industries.