Skip to main content
Glama

java_attach_window

Bind to a chosen Java window by hwnd or title and return a session ID for follow-up accessibility inspections and controls.

Instructions

Bind to one Java window and return a session id for later calls.

Use this after java_list_windows, once you know which window to drive. Give either an exact hwnd or a title; a title may be an fnmatch pattern ("*Report*") exactly as pyjab matches it. Pass hwnd when several windows share a title pattern.

Binding is also what arms Java Access Bridge for this server: pyjab loads the DLL, hooks the events and registers the JAB prototypes on the thread doing the binding, so the first attach is slower than the later ones.

This never modifies, restarts or injects into the application, and it does not own the process: the application keeps running whatever happens to this session.

Args: title: Window title, matched with fnmatch. Ignored when hwnd is given. hwnd: Window handle from java_list_windows. Takes precedence over title.

Returns: A session id, and the window it is bound to. Pass the session id to java_snapshot.

Errors: is_error when the window cannot be bound, naming what was tried. A window that is not a Java window, or a title that never appears, is the usual reason; java_list_windows shows what JAB can see.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "java_attach_window"
  }
}

Input Schema

NameRequiredDescriptionDefault
hwndNo
titleNo

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With only openWorldHint=true available in annotations, the description carries real behavioural weight: it explains that binding arms Java Access Bridge, loads the DLL, hooks events, and therefore makes the first attach slower. It also states the non-destructive boundary clearly ('never modifies, restarts or injects', 'does not own the process'), which is exactly the assurance an agent needs before driving a live application.

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?

Well front-loaded: the core action and outcome come first, then inputs, then behaviour, then return/errors. Slight redundancy in the Returns block since an output schema already exists, and the Args block repeats precedence information already given in the body, but nothing is confusing or padded.

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?

Covers everything needed to invoke a session-establishing tool: prerequisites (list windows first), input selection, expected return, failure modes, and the performance/state implications of the first attach. Rich enough that an agent could recover from most errors without another call to a docs tool.

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

Parameters4/5

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

Schema description coverage is 0%, and the description fully compensates: it explains that title is fnmatch-matched (with an example pattern), that title is ignored when hwnd is supplied, and that hwnd comes from java_list_windows and wins on conflict. The only gap is the mismatch with the schema's zero required parameters – the description says 'give either' an hwnd or a title, leaving the neither-supplied case undefined.

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 first sentence gives a specific verb and resource ('Bind to one Java window') plus the concrete outcome ('return a session id for later calls'). It also distinguishes itself from siblings by positioning after java_list_windows and by naming java_snapshot as the consumer of the session id.

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?

Explicit sequencing ('Use this after java_list_windows, once you know which window to drive') and explicit selection rules between the two inputs: use hwnd when several windows share a title pattern, and hwnd takes precedence over title. The Errors block also routes back to java_list_windows when a window cannot be found.

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