Skip to content

Memory Database Schema

When the Memory Subsystem is enabled, the mcpu-client creates an SQLite database (mcpu-memory.db by default) to store historical data. The LLM can query this database using the sql_readonly_query tool.

Here is the structure of the most commonly used tables and views.

Stores all historical data points collected from the MCU (both from buffered pins and custom tools).

ColumnTypeDescription
timestamp_msINTEGEREpoch timestamp of the observation.
device_idTEXTID of the device (e.g., esp32-01).
resource_nameTEXTName of the pin or custom resource.
observation_typeTEXTE.g., buffer_drain, custom_buffer_drain.
value_numREALThe numeric value recorded.
sourceTEXTHow the data was acquired (e.g., get_pin_buffer).

Keeps a log of every MCP tool execution invoked by the LLM or user.

ColumnTypeDescription
started_at_msINTEGERWhen the call started.
device_idTEXTTarget device.
tool_nameTEXTName of the executed tool.
params_jsonTEXTJSON string of the input parameters.
result_jsonTEXTJSON string of the result.
statusTEXTok or error.

Audit log of the background poller fetching data from the MCU ring buffers.

ColumnTypeDescription
started_at_msINTEGERWhen the drain occurred.
device_idTEXTTarget device.
resource_nameTEXTThe buffered pin or resource.
returned_countINTEGERHow many samples were pulled.
statusTEXTok or error.

For easier querying, the database provides built-in views:

  • latest_observations: Selects all observations ordered by newest first.
  • numeric_observations: Filters observations to only include those with valid value_num entries.
  • device_signal_summary: Provides aggregates (min, max, avg, sample count) grouped by device and resource.