Querying Memory with AI
One of the most powerful features of the MCP-U client is the ability to let AI models (like Claude or Gemini) query historical sensor data themselves. They do this using the sql_readonly_query tool.
Here are some tips and example prompts for getting the most out of this feature.
1. System Prompts & Context
Section titled “1. System Prompts & Context”The AI doesn’t automatically know your database structure. However, the client provides a resource at mcu://cache/schema.
Effective Prompt:
“Read the schema at
mcu://cache/schemato understand the database structure, then write an SQL query to find the average voltage over the last 10 minutes.”
2. Example Use Cases
Section titled “2. Example Use Cases”Detecting Anomalies
Section titled “Detecting Anomalies”“Using the
sql_readonly_querytool, look at thenumeric_observationsview for the resourcevoltage_feedback. Are there any values above 3.5V in the last hour? If so, tell me exactly when they occurred.”
Summarizing Tool Executions
Section titled “Summarizing Tool Executions”“Query the
mcp_u_tool_callstable and give me a summary of how many times theset_ledtool failed versus succeeded today.”
Poller Health Check
Section titled “Poller Health Check”“Check the
buffer_drain_healthview. Are there any error counts for the buffer drains? Are we pulling data consistently?“
3. SQL Safety
Section titled “3. SQL Safety”The sql_readonly_query tool is equipped with a safeguard. It only permits SELECT and WITH statements. If an AI tries to run an INSERT or DROP TABLE command, the client will block the query and return an error.
The tool also enforces a maximum row limit (default: 500) to prevent the AI context window from being overwhelmed by massive datasets.
If the AI needs to process more data, prompt it to use SQL aggregations instead:
“Do not return all the raw data. Instead, write an SQL query that groups the data by hour and returns the
AVG(value_num).”