Skip to main content
Glama

java_snapshot

Read-only

Inspect an attached Java window as a bounded element tree with handles for later actions, adjusting depth and node limits to prevent oversized output.

Instructions

The bounded tree view of an attached window, one line per element, with handles.

This is the tool to reach for first after attaching: it shows what is in the window, what each element is called, and a handle ([e:1a2b]) for every element a later call can name. Pass a handle to a tool that acts on elements; pass a session id here.

The view is deliberately bounded, and it says so when it was cut short. A Java window can hold thousands of nodes, and returning one puts hundreds of thousands of tokens into the conversation, so read in rings: snapshot at depth 2, then snapshot again if you need to see inside something.

Handles are positions, not references: nothing is held between calls. Each handle records the element's role, name, position among siblings and bounds, and a later call re-finds the element and checks those before doing anything. If the window moved on -- a list reloaded, a dialog replaced a panel -- the handle fails with the difference rather than acting on whatever is there now.

Args: session_id: From java_attach_window. depth: How many levels below the window to read. 2 is a good default; raise it only when the elements you want are not visible at 2. max_nodes: Hard cap on rendered elements. When it is reached the reply says so and names the way to narrow the next read. only_interactive: Drop pure layout scaffolding (panes, panels, viewports). Set it to false when you need the structure rather than the controls, or when an element you expect is missing -- filtering is the usual reason. fields: Extra per-element fields to print: any of states (the default), bounds, description, children, index, depth. Role and name are always printed, because they are what a handle checks itself against.

Returns: One line per element, indented by depth, plus a truncation notice when the view was cut short and a count of elements that have no handle.

Errors: is_error for an unknown session id (the message lists the live ones), or when the window can no longer be read -- which usually means the application closed it.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "session_id": "<session_id>"
    },
    "name": "java_snapshot"
  }
}

Input Schema

NameRequiredDescriptionDefault
depthNo
fieldsNo
max_nodesNo
session_idYes
only_interactiveNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior4/5

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

Beyond the readOnlyHint/openWorldHint annotations, the description discloses that the view is bounded, that truncation is reported in the reply, and — most valuably — that handles are positional snapshots rather than live references, so a stale handle fails with a diff instead of acting on the wrong element. That stale-handle failure mode is exactly the kind of non-obvious behavior an agent needs before chaining calls. It stops short of covering latency or cost characteristics beyond the token-count rationale.

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 one-line purpose before any detail, and the Args/Returns/Errors structure makes it scannable. There is mild redundancy between the prose paragraph about truncation and the max_nodes arg description, but no sentence is pure filler given the tool's complexity.

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

Completeness5/5

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

For a five-parameter, open-world introspection tool with zero schema coverage, the definition covers inputs, output shape, truncation behavior, handle invalidation, and both error paths. Even though an output schema exists, the Returns section adds the semantic detail (indentation by depth, unhandled-element count) that a raw schema would not make obvious.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden, and it does: every one of the five parameters is explained, including where session_id comes from, why depth defaults to 2, that max_nodes is a hard cap tied to the truncation notice, what only_interactive actually drops, and the valid values for fields. It adds semantics the bare JSON schema cannot convey.

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?

"The bounded tree view of an attached window, one line per element, with handles" names a specific resource and output shape, and the following line clarifies the division of labor: a session id goes here, a handle goes to element-acting tools. An agent can distinguish this from java_get_element or java_find without opening any schema.

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

Usage Guidelines5/5

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

It states the entry point explicitly ("the tool to reach for first after attaching") and gives a concrete read strategy ("snapshot at depth 2, then snapshot again if you need to see inside something"). It also supplies a conditional escape hatch for the only_interactive flag, including the diagnostic hint that filtering is the usual reason an expected element is missing.

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