pyjab-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pyjab-mcp list the open Java windows and click the Login button"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pyjab-mcp
An MCP server that lets an AI agent drive Java desktop applications — Swing and AWT — through pyjab, which reads the JVM's own accessibility tree via Java Access Bridge. JavaFX is not supported: it publishes its accessibility through UI Automation rather than Java Access Bridge, so a JavaFX window is not a Java window as far as JAB is concerned (pyjab#227).
mcp-name: io.github.gaozhao1989/pyjab-mcp
It never modifies, restarts or injects into the target application. That constraint is the point: launch parameters, classpaths and dependency JARs stay exactly as they are, which is what makes this usable against a production Java client that you cannot change.
The alternative is to put an agent inside the target JVM. An agent is attached to a JVM
that is already running, or named on the command line with -javaagent when the application
starts, and either way the tool's code sits inside someone else's process — a JVM it did not
launch and does not control. This server does neither: it loads nothing into the application
and reads the accessibility tree through Java Access Bridge from outside it, which is how it
can attach to a process it did not launch.
The dynamic half of that — attaching an agent to a JVM that is already running — is the half
the JDK has a direction on, with no release date attached.
JEP 451 shipped in JDK 21 as the preparation stage: loading an
agent into an already-running JVM now warns. The JEP states its aim as "prepare users for a
future release which disallows the dynamic loading of agents by default", a release that has
not been named; its own non-goals leave agents named with -javaagent at startup, and any use
of the Attach API that is not loading an agent, outside that direction.
Status
Released on PyPI — 16 tools: java_diagnostics, java_list_windows,
java_attach_window, java_snapshot, java_find, java_get_element, java_get_text,
java_get_table, java_click, java_set_text, java_select, java_fill_form,
java_send_keys, java_focus_window, java_wait_for, and java_screenshot. It needs
pyjab>=1.11.0: 1.9.0 brought the tree walk a snapshot is built on, 1.10.0 brought the public
window listing and JABDriver.detach(), which releases a driver's binding without terminating
the process — this server has no tool that releases a session, so a binding lasts for the life
of the process — and 1.11.0 brought JABDriver.send_keys, so java_send_keys sends a real
chord, and JABDriver.focus(), so java_focus_window can bring a window forward.
java_send_keys sends a chord to whichever window has the keyboard focus, and attaching does
not give a window focus (pyjab#180).
java_focus_window is the missing half: it brings the window forward and, because asked for
focus and got focus are different facts, it reports whether the window actually came
forward rather than assuming it did. It probes for the API rather than assuming it, so an
install below the pin is told which release has it instead of failing with an AttributeError.
Two elements can share a name, which is why a handle carries where an element is as well as what it is called: searching by name returns every match, each gets its own handle, and the end-to-end suite checks that clicking one acts on that one and not the other.
Nothing is acted on until it has been checked. Every action re-finds the element and compares role, name, position among siblings and bounds against what the snapshot recorded, then acts on the element it just checked — and if anything differs, it does nothing and reports the difference.
java_get_table is where this substrate earns its place: it reads a JTable through the
JVM's own AccessibleTable interface — row and column counts, then cell text, a page of rows
at a time — rather than through a platform bridge that does not carry that information at all.
Live behaviour is verified on a hosted Windows runner by windows-gui.yml: the end-to-end
suite attaches to a real Swing application, snapshots it, resolves a handle against the real
element, and checks that a window opened after the bridge had been idle is still seen. That
last one is the reason the layer exists — a message pump on the wrong thread passes every
other test in this repository. What it still cannot cover is your application: the run drives
pyjab's test app, and the one that matters is the one you care about.
It needs the same pyjab>=1.11.0 the tool list above pins, and for the releases named there;
the one addition worth repeating here is JABDriver.focus(), which java_focus_window uses to
bring a window forward and report whether it came forward. That
return value is why the tool exists at all: what a caller needs to know before sending a chord
is where the keyboard focus actually is, not that focus was requested.
A handle from java_snapshot is a position, not a reference. A later call re-finds the
element and checks its role, name, position and bounds before doing anything, so a window
that moved on produces a message rather than an action on the wrong control.
The one thing that was already settled is the question the whole direction rested on.
Measured on a real Java window, through the same UIAutomationCore that generic Windows
automation uses:
elements | named | depth | |
generic UI Automation, the Java window | 6 | 5 | 3 |
pyjab, the same window | 601 | 513 | 12 |
control: UI Automation, the whole desktop | 147 | 99 | finished |
The control is what makes the six mean anything: the same measurement over the whole desktop finishes, so the measurement works and the Java window is the hard case.
Related MCP server: open-computer-use
Where to read first
file | what |
| how the server is put together, the constraints that shape it, and what each guard enforces |
| connecting Claude Desktop, Claude Code, Cursor and VS Code |
| how a release happens, and what has to exist before one |
| what changed, and why |
Maintainer working notes are kept out of this repository deliberately. Everything a user or a
contributor needs is above, and the rules that are not prose are enforced by the guards in
tools/ — which run in CI on every push.
Requirements
Windows
Python 3.10 or newer
A JDK with Java Access Bridge enabled —
"%JAVA_HOME%\bin\jabswitch" -enable, then restart the Java application — for the application being drivenpyjab, which brings the rest
Install
pip install pyjab-mcpWorking on the server itself is pip install -e ".[dev]" — see Working on it.
Or install the bundle: one file, no build step
v0.1.0–v0.1.2 predate the bundle and carry no assets; every release cut since carries one. It is
pyjab-mcp-<version>.mcpb — the built wheel and its dependency closure, installed together into
one tree per supported CPython minor, plus one entry script, in a single file. Each tree carries
the package itself, so the file holds one copy of pyjab_mcp per minor rather than one wheel
beside the trees. Download it from the
releases page and hand it to the client:
Claude Desktop installs a .mcpb by opening it, and docs/CLIENTS.md has the
details.
The bundle changes none of the requirements above, and it narrows one of them to the
interpreters it actually carries. It bundles no Python interpreter and no JDK: this server
drives Java Access Bridge, so 64-bit Windows, 64-bit CPython 3.10-3.13, and a JDK with Java
Access Bridge enabled are still what the machine has to provide — and the Java application it
drives still has to be running before you attach to it. That range is narrower than pip install, which has no upper bound, and it is not a detail: the bundle is tens of megabytes
because it carries one dependency tree per supported minor, since pydantic-core, cffi,
rpds-py, cryptography and pywin32 ship compiled wheels tagged for one minor each. Started
on any other interpreter it stops with a sentence naming the interpreter it found and the ones
the file carries, rather than an ImportError from a native module.
The interpreter has to be the python on PATH. The manifest declares no user_config
fallback, so the client runs whatever python resolves to there — and a machine with CPython
installed but not on PATH gets a client that shows no tools, with nothing in it that names the
cause: no interpreter ever starts, so the bundle's own refusal cannot run. where.exe python
prints the interpreter that will be used; if it prints nothing, put the installation's directory
on PATH.
MCPB enforces no permissions. There is no manifest-level sandbox — a bundled server runs
with the full privileges of the user who installed it, exactly as it would if you had started
it by hand. Read the source before installing a .mcpb from anyone, this one included.
Use
The console script the package installs:
{
"mcpServers": {
"pyjab-mcp": { "command": "python", "args": ["-m", "pyjab_mcp"] }
}
}Claude Desktop reads %APPDATA%\Claude\claude_desktop_config.json, and takes this (double
the backslashes — JSON needs it):
{
"mcpServers": {
"pyjab-mcp": { "command": "C:\\Users\\you\\.venv\\Scripts\\pyjab-mcp.exe", "args": [] }
}
}Claude Code writes the same entry for you: claude mcp add pyjab-mcp -- pyjab-mcp.
docs/CLIENTS.md has Cursor and VS Code as well, the config file each one reads, the Windows path problem that makes most setups fail, and what to do when a tool answers with an error.
Start with java_diagnostics. It reports which part of the environment is missing —
Java Access Bridge not enabled, no bridge DLL, a 32-bit interpreter (which makes it search for the 32-bit bridge DLL) —
instead of leaving a tool call to fail with a locator error.
What it does, and what it cannot
Java Access Bridge exposes what an application declares about itself: a tree of roles, names, values, states and the actions a control supports. That is what this server drives, and it sets the boundary of what it can reach.
It works on Java applications that expose accessibility — Swing and AWT applications and
applets running as desktop applications. JavaFX is not supported: it publishes its
accessibility through UI Automation rather than Java Access Bridge. Buttons, menus, tables,
trees, lists, text fields and their values are all readable and actionable, and
java_get_table reads a table's cells through the table's own interface rather than the
pixels.
It cannot reach, because the information is not there to read:
Not supported | Why |
Canvas-drawn interfaces — a | There are no accessible children, so there is nothing to find, click or read. |
added regression tests for four such behaviours. | |
Java inside a browser (an embedded JVM, a Java Web Start descendant) | The browser owns the window and does not publish the applet's Java accessibility tree through JAB. |
Applets in a plugin host | Same reason: no JAB tree reaches the desktop. |
Non-Java Windows applications | Nothing here speaks UIA. A UIA-based MCP server is the right tool. |
Anything pixel-based — reading a screenshot to guess at layout, clicking coordinates | Deliberately out of scope. Guessing at pixels is what this project exists to replace. |
Also worth knowing:
The application must be JAB-enabled before it starts. Enabling JAB afterwards does not add the tree to a process already running; restart it.
This server only attaches. It never launches an application, and it never terminates one —
JABDriver.detach()releases the binding and leaves the process running.A picture is not structure.
java_screenshotis for looking; anything you want to act on has to be found in the tree, because that is where handles and names live.
Deliberately not in scope
The list above is what the substrate cannot reach. This is the other kind: things this server could do and does not, so that somebody evaluating it against a hosted alternative knows what they would be giving up — and what would have to change to add each one.
not there | why, and what adding it would take |
Remote transport (streamable HTTP, SSE) | It speaks MCP over stdio only: a client starts it locally, and it attaches to applications on the same desktop. A remote transport means a Windows host to connect to, an authentication story, and deciding what a second client may do to an application the first one is driving. |
More than one session at a time | Sessions are cheap and independent ( |
An audit log | Nothing here writes a journal of what it did. The transcript the MCP client keeps is the audit trail, and its completeness is the client's business. A server-side log would be an append-only file plus a decision about what it must never contain (window titles and cell values are user data). |
Batch execution |
|
CI integration | The end-to-end layer in this repository is the answer for this repository. Driving somebody else's application from their pipeline needs a headless-ish Windows runner with a desktop session — which exists (the |
Each is a deliberate boundary rather than an unfinished feature, and the ones that are
architectural (transport, multi-tenancy) would change the shape of ServerState rather than sit
beside it.
Support
Free support — bugs, questions and feature requests go to GitHub issues. Include the output of
pyjab-mcp --versionand of thejava_diagnosticstool: between them they answer most environmental questions before they are asked.Commercial and enterprise support — deployment inside a restricted network, adaptation to a particular application, or an SLA: gaozhao89@qq.com (the address in this package's metadata). The open-source package is complete and unrestricted; there is no licence key, no quota and no feature held back for it.
Verifying it
The suite that runs on every push cannot drive an application: it needs Windows, a JDK, a
desktop session and a running Swing app. That layer is tests/e2e/, skipped unless
PYJAB_MCP_E2E=1, and windows-gui.yml runs it on a hosted windows-latest runner — by
hand, or on a weekly schedule. It starts a second JVM after the bridge has been idling,
because a message pump on the wrong thread passes everything else and fails exactly that.
gh workflow run windows-gui.yml -f java=17 # the end-to-end run and the JDK matrix
gh run watchIt is not a status check: nobody runs it unless somebody asks (or the week comes round), so a green default CI run still says nothing about a live window.
Releasing
Tag-driven: bump src/pyjab_mcp/__init__.py, move the changelog's Unreleased section under
the new version, set server.json, then python tools/check_release_version.py vX.Y.Z and tag.
docs/RELEASING.md has the whole procedure, the two one-time setups (a
PyPI pending publisher and the registry namespace), and what the four release jobs do.
Working on it
python -m pytest tests/ # the portable suite, any platform
python tools/check_pyjab_api_surface.py # every pyjab call is public, released, recorded
python tools/check_documented_surface.py # docs/ARCHITECTURE.md's tool table and the code agree
python tools/check_local_only_files.py # maintainer notes stay unpublished
python tools/check_pyjab_readiness.py # which pyjab APIs the pin expects, and whether it resolves them
python tools/check_pyjab_changelog.py # every marked pyjab change has an answer here
python tools/check_published_references.py # shipped files do not cite unpublished ones
python tools/check_changelog_immutable.py # a released changelog section is frozen
python tools/check_release_version.py vX.Y.Z # the four places a version lives agree
python -m pytest tests/contract/ # the pyjab shapes this project depends on
python -m build && python tools/check_dist_contents.py --dist distTwo more -- check_release_l3.py and check_release_unpublished.py -- only mean anything with a
tag or a run to read, so they run inside the release pipeline rather than by hand.
The guards are the project's rules made mechanical, in the same shape pyjab uses for its own:
a registry of what is allowed, checked in both directions, so adding a call site fails until
somebody writes down why it is acceptable. docs/ARCHITECTURE.md lists them and what each
one enforces.
Available Tools
16 toolsjava_attach_windowA
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.
Inputs: hwnd, title. Returns: result
java_clickADestructive
Click an element: a button, a menu item, a check box, a link, a tree node.
By default this uses the element's accessibility action, which is what the
application itself exposes: no mouse moves, no window comes to the front, and it works
where there is no interactive desktop. Use simulate=True when the accessibility
action is ignored — it drives real mouse input, which requires the window to come to
the front and cannot work from a service session, and it needs real geometry (cells in
some tables report bounds = -1, and there is no point to click).
The element is checked before it is clicked: role, name, position among siblings and bounds are compared against what the snapshot recorded, and if anything differs nothing is clicked — the difference is reported instead. That is deliberate: a click that lands on whatever moved into the position is worse than a message.
Args: session_id: From java_attach_window. handle: The element to click. click: "left", "double" or "right". simulate: Drive real mouse input instead of the accessibility action.
Returns: What was clicked and how, so the next call knows what state the window is in.
Errors:
is_error for an unknown handle, for an element that changed since the
snapshot, and for a click value that is not one of the three.
Inputs: handle (required), session_id (required), click, simulate. Returns: result
java_diagnosticsARead-only
Report whether this machine can drive a Java application right now.
Use this first when anything fails, and after installing a JVM or enabling Java Access Bridge. It reports the platform, the interpreter, the installed pyjab and which of its public APIs are present, whether Java Access Bridge is enabled, where the bridge DLL is, and the state of the bridge thread.
It is read-only and never writes to the environment: it does not enable Java Access Bridge, because a diagnostics tool that changes what it is reporting on is worse than none.
Args: load_bridge: When true, also start the bridge thread first and report whether it came up. This is the end-to-end check; it is off by default so that a mere report cannot load a DLL.
Returns:
A multi-line report. A line that could not be measured says
UNAVAILABLE (reason) and is never reported as zero or as "missing" --
"nothing is there" and "I could not read" are different answers.
Errors: None for the environment itself: an unusable environment is what this tool reports, so it does not fail because of one.
Inputs: load_bridge. Returns: result
java_fill_formADestructive
Fill several fields in one call: a list of {"handle": ..., "value": ...}.
A form is usually several fields, and setting them one at a time costs a round trip each. This is the same verification and the same typing, applied in order, with one reply that says what happened to every field.
It does not stop at the first failure. A form that is half filled with no report is worse than one that is half filled with one: every field is attempted, and each line says whether it worked and why not.
Args:
session_id: From java_attach_window.
fields: [{"handle": "e:1a2b", "value": "admin"}, ...], applied in order.
simulate: Type real keystrokes instead of using the accessibility action.
Returns: One line per field — set, or the reason it was not — and a count.
Errors:
is_error only for an unknown session, an empty list, or a malformed entry.
A field that fails is reported in the reply, because that is a result rather than
a failed call.
Inputs: fields (required), session_id (required), simulate. Returns: result
java_findARead-only
Search an attached window and get a handle for each match.
Use this when a snapshot is too large to read, or when you know what the control is called and do not want to walk the tree to find it. A snapshot shows you the shape of the window; this asks a question about it.
Give exactly one selector. name and description are exact matches -- for a
substring use xpath with contains(), which is pyjab's locator syntax:
//push button[@name=contains('Save')]. states takes a comma-joined list such as
"enabled,showing".
Every match gets a handle, and a handle is checked before it is used: the locator recorded here is resolved again later and compared against the role, name, position and bounds seen now. If a match cannot be given a locator that finds it again, it is listed without a handle rather than with one that might resolve to something else.
Args: session_id: From java_attach_window. name: Exact accessible name. role: Role, as pyjab spells it: "push button", "text", "check box", "table". description: Exact accessible description, for controls with no name. states: Comma-joined states, e.g. "enabled,showing". xpath: A pyjab locator, for substrings, unions and paths. max_results: Stop after this many matches.
Returns: One line per match with its handle and locator, or a measurement that nothing matched -- with the selector that found nothing in it, so the next attempt can be narrower rather than identical.
Errors:
is_error for an unknown session id, for no selector or more than one, or when
the window can no longer be read.
Inputs: session_id (required), name, role, xpath, +3 more. Returns: result
java_focus_windowADestructive
Bring an attached window to the front, and report whether it actually came forward.
Use it before java_send_keys, whose chord goes to whichever window has the keyboard
focus: attaching a window does not give it focus (measured in pyjab#180), so a
shortcut can otherwise land somewhere else entirely.
The reply is the point, not the action. "I asked for focus" and "the window is now
in front" are two different facts, and this tool answers with the second one. It does so
by reading back the state pyjab left behind, because Windows' SetForegroundWindow has
no useful return of its own. So there are three answers, not two:
the window is the foreground window now;
it is not — a normal answer rather than a failure, because Windows refuses foreground activation from a non-interactive session (a service, a scheduled task) and no amount of retrying changes that. An error would be wrong here: nothing failed, and the caller has a fact it can act on;
pyjab answered something that is neither
TruenorFalse, so this server cannot say — reported as such rather than filed under "did not come forward", because "I could not tell" is not a measurement.
It is not free: when the window is not already in front, pyjab sends a space keystroke first, which is what Windows' foreground-activation rules require of a process that wants the foreground — and that keystroke goes to whatever currently has the focus. A caller that cannot tolerate a stray keystroke elsewhere should not call this.
This needs pyjab 1.11.0, which released JABDriver.focus(). The call is probed rather
than assumed, like every pyjab capability here: an install below the pin is told which
release has it instead of raising an AttributeError.
Args: session_id: From java_attach_window.
Returns: Whether the window is now the foreground window, said plainly, with the next step.
Errors:
is_error only for an unknown session, or a pyjab below the pin — which names the
release that has the API. "It did not come forward" is a result, not an error.
Inputs: session_id (required). Returns: result
java_get_elementARead-only
Everything known about one element, and whether it is still the same element.
Use this after java_snapshot or java_find to look at one control in detail, or to confirm that a handle still points at what it did. The handle is resolved again and compared against what was recorded when it was handed out; if anything differs -- role, name, position among siblings, bounds -- this reports the difference instead of presenting the element as if nothing had changed.
Args:
session_id: From java_attach_window.
handle: An e:... handle from a snapshot or a find.
Returns: The element's role, name, description, states, bounds, index and depth, its locator, and the verification result.
Errors:
is_error for an unknown handle (the message says to take a fresh snapshot),
for a handle belonging to another session, or when the element has changed.
Inputs: handle (required), session_id (required). Returns: result
java_get_tableARead-only
Read a Java table, a page of rows at a time.
Use this on a handle for a table element -- from java_snapshot or java_find. This is
the tool a platform-level automation cannot replace: it reads the table's own
accessibility interface, so cell text, row and column counts come from the JVM rather
than from pixels or from a bridge that does not carry them.
It never returns the whole table. A large table is 200 rows in pyjab's own test
application and thousands in a real one, so the read is paged by row_start and
bounded by row_count and max_cells, and the reply says what it left out and how to
ask for it.
Cells are not just text. A cell with no text interface is shown as -, and a cell
that could not be read is shown as ? with a count: "this cell has no text" and "I
could not read this cell" are different answers, and reporting the second as the
first would invent an empty table.
Args: session_id: From java_attach_window. handle: A handle for the table element. row_start: First row to read, 0-based. row_count: How many rows to read. max_cells: Hard cap on cells read in one call, whatever the rows ask for.
Returns: The table's row and column counts, then one line per row, then what was left out.
Errors:
is_error for an unknown handle, an element that changed since the snapshot, or
an element that is not a table -- which is reported with what it is instead, so a
wrong handle and a stale handle do not look the same.
Inputs: handle (required), session_id (required), max_cells, row_count, +1 more. Returns: result
java_get_textARead-only
Read the text of an element: a label, a text field, a table cell, a document.
Use this on a handle from a snapshot or a find. The same verification applies, so a text field that has been replaced since the snapshot reports the change instead of returning whatever is there now.
Long values are cut, and the cut is reported: the reply says how much of the whole text it carries and what the whole text's length is, so a partial read is never presented as the value.
Args:
session_id: From java_attach_window.
handle: An e:... handle from a snapshot or a find.
start: Character to start at, 0-based.
length: How many characters to return.
Returns: The slice of the element's text, with its length and whether it was cut.
Errors:
is_error for an unknown handle, a handle from another session, an element
that has changed, or an element with no text at all -- which is reported as such,
because "this control has no text" and "this control is empty" are different
answers.
Inputs: handle (required), session_id (required), start, length. Returns: result
java_list_windowsARead-only
List the Java windows Java Access Bridge can see on this machine.
Use this to find out whether the application is visible to JAB at all, and to get a title or hwnd for java_attach_window. If the application is not in this list, nothing else will work and the problem is the attachment or the environment, not a locator -- run java_diagnostics next.
Only windows of Java applications are listed; this is not a general Windows window list.
Returns: One line per window, with hwnd, pid and title. "No Java windows are visible" is a measurement and is reported as such, not as an empty string.
Errors:
is_error with an actionable message when pyjab cannot answer. On pyjab 1.9.0
the listing runs through the documented pyjab-inspect windows --json,
because the function behind it is not public API yet; the message says so when
even that is unavailable.
Inputs: no named parameters. Returns: result
java_screenshotARead-only
A PNG of the window, or of one element inside it.
Use it when the accessibility tree is not enough — a chart, a canvas, a layout problem — and remember what it cannot do: a picture is not readable structure. Anything you want to act on should be found in the tree with java_snapshot or java_find, because that is where the handles and the names are. Canvas-drawn interfaces are the case where this is the only thing that works, and the only thing that is not there.
With a handle, the element is verified first, for the same reason an action is: a picture of whatever moved into the position would mislead exactly as a click on it would.
Args: session_id: From java_attach_window. handle: Optional element to photograph instead of the whole window.
Returns: The image itself, as an image content block. Nothing else: a caption would be text, and everything a caller needs to know is in the arguments it passed.
Errors:
is_error for an unknown session or handle, an element that changed, or a
window whose geometry is not reported — there is nothing to grab then, and saying
so beats an empty image.
Inputs: session_id (required), handle.
java_selectADestructive
Select an option in a combo box, list or tab set — or a row or cell in a table.
Two shapes, and which one you want is told by the arguments:
option="Tennis"selects by the text the application shows, for a combo box, a list or a tab.row=2selects a whole table row, androw=2, column=1selects one cell. Table selection goes through the table's own accessible selection, which is the path the application responds to — pyjab's docs are explicit that the cellsget_cell()returns often reportbounds = -1and cannot be clicked.
The element is verified before anything is selected, exactly as java_click describes.
Args: session_id: From java_attach_window. handle: The combo box, list, tab set or table. option: Text to select. Ignored when a row is given. row: Row index to select, 0-based. column: Column index, for one cell rather than the whole row. simulate: Use simulated input where the action supports it.
Returns: What was selected, and how.
Errors:
is_error for an unknown handle, an element that changed, an option the control
does not have, or neither an option nor a row given.
Inputs: handle (required), session_id (required), row, column, +2 more. Returns: result
java_send_keysADestructive
Send a keyboard shortcut — alt+y, ctrl+shift+s — to the window.
Use it for an action the application only exposes as a chord: a menu accelerator, a toolbar shortcut, a keystroke a canvas-drawn control listens for.
Nothing is focused and nothing is clicked. The chord goes to whichever window currently has the keyboard focus. That is deliberate on pyjab's side: clicking a control to focus its window would activate that control, and a shortcut usually exists to avoid exactly that.
So if a call seems to do nothing, the window probably does not have focus — and
attaching does not focus it (measured in pyjab#180). Call
java_focus_window(session_id=...) first and read what it reports: it says whether the
window came forward, which is the fact this tool needs. (Before that tool existed
this reply said to click something harmless first; that workaround is gone from the
shipped text, because it activated whatever it landed on and went through a locator
that could have gone stale — which is the thing a shortcut exists to avoid.)
Chords are written with + between key names and are case-insensitive: ctrl, alt,
shift, tab, enter, esc, spacebar, the arrow keys, and single letters or
digits. Names may be written in any case; the function keys (F1–F24) and escape
as another spelling of esc need pyjab 1.12.1, and plus for a literal + needs
1.12.2. A name that is not a key is an error rather than a silent no-op — a wrong
chord acts on somebody else's application and cannot be taken back.
This needs pyjab 1.11.0, which released JABDriver.send_keys
(gaozhao1989/pyjab#168 went in after 1.10.0). The call is probed rather than assumed,
like every pyjab capability here: an install below the pin is told which release has
the method instead of raising an AttributeError.
Args: session_id: From java_attach_window. keys: The chord, such as "alt+y".
Returns: What was sent, and the reminder that a shortcut's effect has to be looked for — this tool cannot see what the application did with it.
Errors:
is_error for an unknown session, a chord whose key names pyjab does not
recognise (with the name it did not recognise), or a pyjab below the pin — which
names the release that has the API and what to do instead.
Inputs: keys (required), session_id (required). Returns: result
java_set_textADestructive
Type into a text field, text area or editable combo box.
This sets the text rather than appending to it, and it waits for the field to report
the new value before returning, so a following read sees what was typed. By default it
goes through the accessibility action; simulate=True types real keystrokes instead,
which is the fallback when the action is refused.
Use java_fill_form instead when several fields need values: it is one round trip and it reports each field separately.
The element is verified before anything is typed, exactly as java_click describes.
Args: session_id: From java_attach_window. handle: The field to type into. value: The text to set. simulate: Type real keystrokes instead of using the accessibility action.
Returns: What was set, and a reminder to re-read the field to confirm.
Errors:
is_error for an unknown handle, an element that changed, or a field that
refused the text — the message says to try simulate=True when that is the
likely answer.
Inputs: value (required), handle (required), session_id (required), simulate. Returns: result
java_snapshotARead-only
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.
Inputs: session_id (required), depth, fields, max_nodes, +1 more. Returns: result
java_wait_forARead-only
Wait for something to happen, instead of asking too early and being told no.
Three conditions, chosen by what you pass:
window_title="A Dialog"— wait until a Java window with that title (fnmatch, so"*Progress*"works) exists. Use it after an action that opens one.handle=..., text_equals="Saved"— wait until that element's text is this.handle=...alone — wait until its text changes from what it reads when the wait starts, and report both values.
A timeout is a result, not an error. The reply says the condition was not met and what was seen instead, because "not yet" is information an agent can act on — it can wait longer, look somewhere else, or take a snapshot — while an error reads as a failed call. pyjab's own waits raise; this one reports, and the difference is deliberate for a tool a model is driving.
The waiting happens here rather than inside pyjab, and that is also deliberate: the bridge has exactly one owning thread, so a wait that ran on it would block every other call for its whole duration. This polls between calls instead, which also means a client can cancel it.
Args:
session_id: From java_attach_window.
window_title: Title (fnmatch) of a window to wait for.
handle: An element whose text to watch.
text_equals: The text to wait for, with a handle.
timeout: Give up after this many seconds.
poll_interval: Seconds between checks. A window wait re-lists the Java windows
on every poll; on an install below the pin that listing is the
pyjab-inspect subprocess rather than a bridge call, so raise this.
Returns: Whether the condition was met, how long it took, and what was seen.
Errors:
is_error only for an unknown session or handle, or for no condition at all.
A timeout is reported in the reply, not as an error.
Inputs: session_id (required), handle, timeout, text_equals, +2 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 16 tools
Every tool targets a distinct resource or action: discovery (java_list_windows, java_diagnostics), binding (java_attach_window), inspection (java_snapshot vs java_find vs java_get_element vs java_get_text vs java_get_table), and action (java_click vs java_select vs java_set_text vs java_fill_form vs java_send_keys). The descriptions explicitly cross-reference the near-neighbours (set_text → fill_form, send_keys → focus_window, snapshot → find) and state when to prefer which, so an agent can pick correctly. No two tools appear to do the same thing.
All names are snake_case with a uniform `java_` prefix, and most follow verb_noun (java_attach_window, java_get_text, java_fill_form, java_wait_for). A few are noun-only (java_diagnostics, java_screenshot, java_snapshot), which is a minor deviation but still readable and predictable.
Sixteen tools is at the upper edge of comfortable, but each maps to a real step in the drive-a-Java-window workflow (discover, attach, inspect, act, wait) with no filler. The count is justified by the domain's breadth rather than by redundancy.
The surface covers the full lifecycle: environment diagnostics, window discovery, attach, tree/text/table/screenshot inspection, element actions, form filling, keyboard chords, focus, and waiting. Minor gaps remain — no detach/close-session tool, no scrolling or drag-and-drop, and no explicit menu-path helper — but agents can work around these via click and send_keys.
Maintenance
Related MCP Connectors
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Let Claude, ChatGPT and other agents use your Android phone: see the screen, tap, type, open apps.
1Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Real desktops for AI agents, on machines you choose: screenshot, type, click, hire more agents.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables interaction with Java Swing applications through MCP, allowing launching, attaching, taking snapshots, clicking, filling forms, and other UI automation via natural language.4MIT
- AlicenseNot gradedqualityBmaintenanceLets AI agents see and control desktop applications through the accessibility layer, enabling clicking, typing, scrolling, dragging, and window/app management across macOS, Windows, and Linux entirely on the local machine.27MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to drive Linux desktop applications through the AT-SPI2 accessibility bus, addressing UI elements by role and name to read text, set values, and invoke actions without relying on pixels or synthetic keystrokes.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to safely and truthfully control local desktop applications via native accessibility trees, supporting element inspection and automation without proprietary binaries or fake success responses.Apache 2.0