# Losant MCP

> Losant gives your AI agent full command over connected hardware and smart infrastructure. Use it to list applications, control device states in real-time, query complex time-series data, or trigger maintenance workflows—all through natural conversation.

## Overview
- **Category:** iot-hardware
- **Price:** Free
- **Tags:** iot-platform, device-management, workflow-automation, time-series, smart-city

## Description

Losant gives your AI agent full command over connected hardware and smart infrastructure. You talk to your agent, and it executes commands against your whole IoT platform.

**Managing Your Infrastructure**
You can start by listing all active applications with `list_applications`, or you can pull the full metadata package for a specific app using `get_application`. If you need to make an exact copy of an existing setup to test something out, run `clone_application`; conversely, if an application is dead weight, you can delete it entirely with `delete_application`. You'll also manage data structures by initializing a new table with `create_data_table`, or viewing all tables tied to an app using `list_data_tables`. Need to clean up? You can remove selected records from a data table rows using `delete_data_table_rows`.

For device management, you'll add a new physical or simulated unit with `create_device`, and check the current operational status for any single ID via `get_device`. To see your whole fleet, run `list_devices`; when you’re done with a piece of hardware, you delete its record using `delete_device`. You can also update non-operational metadata—like changing a device's location or owner—using `update_device`, and if an app needs tweaks but shouldn't be deleted, use `update_application`.

**Building and Controlling Workflows**
You define complex operational sequences using `create_workflow` to build out multi-step logic, like a maintenance routine. The agent can then retrieve the full step-by-step definition of that workflow with `get_workflow`, or view all defined workflows for an app by calling `list_workflows`. If you need to adjust the sequence later on, use `update_workflow`. To execute a workflow's logic without relying on standard triggers—say, forcing the next step in a safety protocol—you press a virtual button via `press_virtual_button`. You can also remove an entire defined workflow using `delete_workflow`.

**Interacting with Data and Sensors**
When you need to know what's going on, your agent handles it. To find out the single most recent reading for any sensor or metric, call `query_last_value`. If you gotta deep dive into history, pull a full time-stamped log over a date range using `query_time_series`, or run a targeted query against a data table to pull only records matching specific criteria using `query_data_table_rows`. You can also simply view all visible rows from a data table immediately with `get_data_table_rows`. To save your findings, you export all relevant device readings into a downloadable file using `export_data`, or generate and download a full backup of an application's configuration via `export_application`.

For quick analysis, the platform lets you run a pre-built data analysis notebook by executing it with `execute_notebook`. You can also get a list of all available notebooks ready to go using `list_notebooks`, and if you need a summary view of your system status, you fetch the configuration and current state of a dashboard using `get_dashboard`, or see every configured dashboard name with `list_dashboards`.

**Sending Commands and Reporting**
This is where the action is. You send an immediate command—like telling a valve to open or rebooting a unit—to a specific device using `send_device_command`. If you need to test something out or log a state manually, you push that value directly with `send_device_state`, and if you want to simulate a physical button press for testing purposes, use the dedicated tool. You can also change what your agent reports about a device's connection status—Online or Offline—via `set_device_connection_status`. To generate an official report based on a dashboard’s current state, run `send_dashboard_report`.

**Core Utilities and File Handling**
For general visibility, you can list all uploaded files attached to an application using `list_files`, or upload new documents or data files into the app's storage area with `upload_file`. You also manage your underlying resource base by getting a list of every available file (`list_files`), and retrieving a simple summary of all applications connected via `list_applications`.

If you need to perform foundational system tasks, you can get a full rundown of what's in an app with `get_application`, or use the general update commands: for example, listing notebooks via `list_notebooks` and then running them if needed. You don’t have to write custom API scripts; everything is built into these callable tools.

## Tools

### clone_application
Makes an exact copy of a Losant application to start fresh development work.

### create_application
Sets up and initializes a brand new IoT application within the platform.

### create_data_table
Initializes a structured data table to store specific operational records.

### create_device
Adds a new physical or simulated device record to the system's inventory.

### create_workflow
Builds out and defines a multi-step operational workflow (e.g., maintenance sequence).

### delete_application
Removes an entire application and all associated resources from the platform.

### delete_data_table_rows
Permanently removes selected rows of records from a data table.

### delete_device
Deletes a specific device record, taking it out of the active fleet management pool.

### delete_workflow
Removes an entire defined workflow logic from the system.

### execute_notebook
Runs a pre-built data analysis notebook to perform complex, contained calculations on stored data.

### export_application
Generates and downloads a complete backup file of an entire application's configuration.

### export_data
Pulls all relevant device data from the platform and packages it into a downloadable export file.

### get_application
Retrieves the full metadata package for one specific Losant application.

### get_dashboard
Fetches the configuration and current state of a specified dashboard view.

### get_data_table_rows
Retrieves all visible rows from a specific data table for immediate viewing.

### get_device
Gets the current operational status and details for one single device ID.

### get_workflow
Retrieves the full step-by-step logic definition of a specific workflow.

### import_application
Uploads and registers an existing application backup into your Losant environment.

### insert_data_table_row
Adds a single, specific row of data to an existing data table record set.

### list_applications
Retrieves a list and summary of all active applications connected to the platform.

### list_dashboards
Gets names and identifiers for every dashboard configured within your account.

### list_data_tables
Shows all data tables associated with a given application ID.

### list_devices
Retrieves a list of every device registered under a specific application's management scope.

### list_files
Lists all files uploaded to the platform for a given application.

### list_notebooks
Shows all available notebooks ready for execution within an application context.

### list_workflows
Retrieves a list and summary of all defined workflows for an application.

### press_virtual_button
Simulates a physical button press, forcing the next step in a specific workflow's logic sequence.

### query_data_table_rows
Runs a targeted query against a data table to find specific records based on criteria.

### query_last_value
Gets the single most recent recorded value for any monitored sensor or metric.

### query_time_series
Pulls a full, time-stamped history of data over a specified date range.

### send_dashboard_report
Generates and sends out a report based on the current state of a specific dashboard.

### send_device_command
Sends an immediate, actionable command (e.g., 'reboot', 'readout') to a targeted device.

### send_device_state
Manually pushes a specific state value to a device for testing or logging purposes.

### set_device_connection_status
Changes the reported connection status of a device (e.g., Online/Offline) for monitoring.

### update_application
Modifies meta-data or settings on an existing application without deleting it.

### update_device
Updates non-operational metadata for a device, like its location or owner.

### update_workflow
Modifies the steps and logic within an existing workflow definition.

### upload_file
Transfers a document or data file into the application's storage area.

## Prompt Examples

**Prompt:** 
```
List all my Losant applications.
```

**Response:** 
```
I've retrieved your applications. You have 3 active apps: 'Smart Factory' (ID: 60a...), 'Office HVAC' (ID: 61b...), and 'Fleet Tracker' (ID: 62c...). Which one would you like to explore?
```

**Prompt:** 
```
Show me all devices in application 60a123456789.
```

**Response:** 
```
In the 'Smart Factory' application, I found 12 devices. 10 are currently 'Online' and 2 are 'Offline'. Notable devices include 'Main Boiler' and 'Assembly Line 1'. Would you like the details for a specific one?
```

**Prompt:** 
```
Trigger the 'Emergency Reset' virtual button in workflow 5f987654321.
```

**Response:** 
```
The virtual button for 'Emergency Reset' in workflow 5f987654321 has been successfully pressed. The workflow logic is now executing.
```

## Capabilities

### Manage Applications and Resources
List, create, clone, or delete core IoT applications, data tables, files, and notebooks using commands like `list_applications` or `create_data_table`.

### Control Device Hardware
Send immediate commands to specific devices (e.g., turn a valve on/off) or update their connection status in real time using tools like `send_device_command`.

### Analyze Time-Series Data
Query complex historical data, fetching both the last known value (`query_last_value`) and full time-series logs for deep analysis without writing custom queries. Use `export_data` to save findings.

### Automate Workflows
View, manage, or manually trigger specific logic paths within a workflow by pressing virtual buttons using the `press_virtual_button` tool, bypassing standard operational triggers.

### Maintain and Update Systems
Perform necessary maintenance tasks like updating device metadata (`update_device`), modifying application settings (`update_application`), or deleting unused workflows via `delete_workflow`.

## Use Cases

### Emergency Equipment Shutdown
A machine overheats and the normal shutdown sequence fails. Instead of logging into the maintenance portal, you instruct your agent: 'Run the emergency protocol for Unit 4.' The agent then calls `press_virtual_button` on the specific safety workflow, triggering immediate cooling measures.

### Monthly Audit Data Pull
You need to prove peak power usage last month. You tell your agent: 'Get me all time-series data for the main grid panel from June 1st to June 30th.' The agent executes `query_time_series` and then uses `export_data`, delivering a complete CSV file ready for compliance.

### Onboarding a New Sensor
A new sensor needs monitoring. You ask your agent to set up the system. It first runs `list_applications` to find the right project, then calls `create_device` with the serial number, and finally uses `update_device` to tag it as 'Active'.

### Troubleshooting a Broken Link
A key sensor reports erratic data. You tell your agent: 'Check the last known state for Sensor A.' The agent runs `query_last_value`, confirming the reading is zero, and then suggests you run `get_device` to check its connection status.

## Benefits

- Real-time control: Forget writing custom API calls for simple checks. You can send a direct command to any device, like 'reboot' or 'check status,' using `send_device_command` instantly.
- Deep history access: Need to see how the temperature varied over the last 72 hours? Use `query_time_series`. It pulls full, time-stamped data sets so you don't have to write a date range query yourself.
- Workflow automation on demand: If a system hits an unexpected state, you don't wait for it to fail. You can manually trigger the next step in a maintenance sequence by running `press_virtual_button`.
- Data portability: Don't get stuck with proprietary dashboards. When you pull data using `export_data`, you get clean, actionable files that feed directly into your analysis tools.
- System management from chat: Need to onboard a new sensor line? You can list and create resources (`list_applications` -> `create_device`) without ever leaving the conversational interface.

## How It Works

The bottom line is: your AI client uses pre-built tools to interact with complex industrial systems, giving you real-time control without needing technical API knowledge.

1. First, subscribe to the Losant server and provide your specific API Token.
2. Next, tell your AI agent what you need—for example, 'Check the last reading from the assembly line sensor.'
3. The agent translates that request into a tool call (`query_last_value`), connects to the Losant platform via Vinkius, and returns the data directly in the chat.

## Frequently Asked Questions

**How do I check the connection status using Losant MCP Server?**
You use `get_device` to retrieve the current operational details for a specific device ID. This shows you if it's reported as online, offline, or in maintenance mode.

**Can I run historical data reports with Losant MCP Server?**
Yes. To pull past metrics, you use `query_time_series`. You specify the desired time range and the agent retrieves all associated sensor readings for analysis.

**What is the best way to trigger a manual override with Losant MCP Server?**
You use `press_virtual_button` on the specific workflow ID. This tool simulates pressing a physical button, forcing the workflow logic to execute its next defined step.

**How do I add a brand new sensor line using Losant MCP Server?**
You first use `create_application` if needed, then call `create_device`, providing all necessary metadata for the new asset in your system.

**How do I use the `list_applications` tool in Losant MCP Server?**
It instantly retrieves a complete list of all applications linked to your account. You get names, unique IDs, and basic statuses so you can quickly find the right resource without navigating dashboards.

**How do I populate or change data using `insert_data_table_row` with Losant MCP Server?**
This tool lets your agent manually write specific records to a data table. You provide the row's exact values and the target table ID, effectively injecting new structured data when needed.

**What is the function of `execute_notebook` when using Losant MCP Server?**
It runs Jupyter-style code directly against your connected data sources. This lets you perform complex computations or deep scientific analysis that standard query tools can't handle.

**If I need the current reading right now, how do I use `query_last_value` with Losant MCP Server?**
This tool fetches the single most recent data point for a specific metric. It's perfect when you just need to know 'what is it right now,' avoiding the overhead of large time-series exports.

**Can I manually trigger a Losant workflow using this integration?**
Yes! You can use the `press_virtual_button` tool by providing the Application ID and Workflow ID. This allows your AI agent to trigger specific automation logic on demand.

**How do I check the current status of a specific sensor or device?**
Use the `get_device` tool with the Application ID and Device ID. The agent will return the full device metadata, including its last reported state and connection status.

**Is it possible to retrieve historical data for analysis?**
Absolutely. You can use `query_time_series` to fetch historical attribute data or `query_last_value` for the most recent data points across your device fleet.