Skip to main content
Glama
kengrary

JVMind MAT Heap Dump Analyzer

SQL in thread stacks

mat_sql_in_threads
Read-onlyIdempotent

Scan thread stacks in a parsed heap dump for JDBC PreparedStatement objects and SQL strings to find long-running or heavy queries held by threads at OOM time, filtering harmless heartbeat SQL.

Instructions

Read-only scan of thread stacks for JDBC PreparedStatement objects and SQL strings, used to spot long-running or heavy queries held by threads at OOM time. Requires the report_id of a parsed dump (status=DONE). Results are sorted risky-first, then by the owning thread's retained heap, and include threadId, threadName, threadRetainedBytes, frame, source, objectId, sql, risk (risky|harmless|unknown), and reason. With onlyRisky=true, heartbeat/validation statements such as SELECT 1, SELECT 'x', /* ping */ and VALUES(1) are filtered out; pass onlyRisky=false to see all SQL-like strings.

Input Schema

NameRequiredDescriptionDefault
onlyRiskyNotrue (default) drops harmless heartbeat/validation SQL (SELECT 1, SELECT 'x', /* ping */, VALUES(1)); false returns every SQL-like string found.
report_idYesReport ID returned by open_heapdump or dump_java_heap; the dump must have finished parsing (status must be DONE).

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.1
    • addedInput schema / properties / onlyRisky / description
      Added value: +"true (default) drops harmless heartbeat/validation SQL (SELECT 1, SELECT 'x', /* ping */, VALUES(1)); false returns every SQL-like string found."
    • addedInput schema / properties / report_id / description
      Added value: +"Report ID returned by open_heapdump or dump_java_heap; the dump must have finished parsing (status must be DONE)."
  2. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover the safety profile (readOnly, idempotent, closed-world), and the description adds genuinely new behavior: results are sorted risky-first then by retained heap, and heartbeat/validation statements are filtered by default. It omits anything about result size limits, pagination, or truncation on large dumps, which for a scan tool is a remaining gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose and prerequisite in the first two sentences, then the filtering semantics. The enumeration of every returned field is wasted space given an output schema exists, but the rest is dense and earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the return-value restatement is redundant, and prerequisites, default filtering, and sort order are all covered. Missing only operational details such as how many rows come back or behavior on a huge dump.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description's explanation of onlyRisky and its example statements largely restates the parameter's own schema description rather than adding new semantics; report_id's prerequisite is the only real added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Read-only scan of thread stacks for JDBC PreparedStatement objects and SQL strings') with a concrete investigative goal (heavy queries held by threads at OOM time). This clearly distinguishes it from siblings like mat_threadlocals (thread-local contents) and mat_oql (arbitrary queries).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear triggering context ('spot long-running or heavy queries held by threads at OOM time') and a hard prerequisite (report_id of a parsed dump with status=DONE). It does not explicitly name alternative tools or say when to prefer e.g. mat_oql, so it stops short of full alternative routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.