Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault

No arguments

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

swing2mcp lets you see and operate Java Swing desktop applications. Typical flow: launch_app (or list_apps/connect_app for one already running) -> wait_for -> snapshot -> click / type_text / select_option using [ref=eN] values from the snapshot. Actions return the updated snapshot. A modal dialog blocks other windows until it is closed. Use screenshot to check visual layout or custom-painted components.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}

Tools

Functions exposed to the LLM to take actions

NameDescription
launch_appA

Start a Java Swing application with the swing2mcp agent injected and connect to it. command is a shell command line, e.g. java -jar app.jar or a start script; the agent is added through JAVA_TOOL_OPTIONS, so the application itself is not changed. Application output goes to a log file. Returns once the agent is up, usually before the first window: call wait_for next.

list_appsA

List running Java applications. Those with the swing2mcp agent show their windows; the connected one is marked with *. The others can be connected with connect_app, which loads the agent into them without restarting.

connect_appA

Connect to a running Java application by pid (see list_apps). If it was started without swing2mcp, the agent is loaded into it first: no restart, and the application keeps its state (open windows, logged-in user). Works with Java 8+ processes of the same OS user.

stop_appC

Terminate an application (default: the connected one).

snapshotA

Describe what is on screen: every visible window as an indented outline of components (role, label, value, state) with a [ref=eN] for each element. Use refs with click, type_text, select_option and screenshot. Refs stay valid while the component exists. field= is the Java field holding the component, class= an application class. Prefer this over screenshot; use screenshot for custom-painted parts and layout.

screenshotA

PNG image of a window or component, painted by Swing itself (works even if the window is covered). Without ref: the modal dialog, active window or main frame.

clickA

Click a component like a user would, with real mouse press/release events: a focusable component takes the focus first (so the previous field's input verifier and focus-lost handlers run). Menu items, even inside closed menus, are activated directly. For tables, lists and trees pass value (the cell's text, the item's text, or a tree path like "Root/Child") or row (and col for tables). Use clickCount=2 for double-click, button=right for context menus, modifiers="Ctrl" or "Shift" to add to or extend the selection (select_option with values/indexes does several at once). Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

type_textA

Type into a text field, text area, password field, spinner or editable combo box like a user: the field gets the focus (the previous field's input verifier runs; if it refuses, nothing is typed and the result says why), the old text is selected and each character is sent as real key events, so key listeners, document filters and formatters run. Replaces the content unless append=true; submit=true then presses Enter. "\n" types Enter and "\t" types Tab (moves to the next field). Formatted fields and spinners commit on Enter or when the focus leaves them. The application window does not need to be in front. mode=set sets the text directly without key events (faster, but skips key listeners). Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

press_keyA

Press keys like a user: "Enter", "Escape", "Tab", "Shift+Tab", "Up", "F5", "Ctrl+S", "Alt+F4", or several separated by spaces ("Tab Tab Enter"). Keys go to the component that has the keyboard focus (marked "focused" in the snapshot), or to ref after focusing it, so key bindings, menu shortcuts, the default button and focus traversal work as for a user. Without ref, keys go to the open modal dialog if there is one. The application window does not need to be in front. The result says where the focus is afterwards. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

select_optionA

Select an entry by visible text (value) or position (index) in a combo box, list, tab pane, table or tree. Table: value is the text of any cell of the row (limit it to a column with col); the cell is selected as by a click. Tree: value is a path like "Root/Child/Leaf" (the root may be left out; " > " also separates); ancestors are expanded on the way, as a user would. Several entries of a list, table or tree: values or indexes (ranges like "2-5"), or a range from value/index to another; they are selected with real clicks, the first plain, the others with Ctrl, a range's end with Shift. add=true keeps the current selection; deselect=true Ctrl-clicks the given entries that are selected. The result lists what is selected afterwards. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

select_menuA

Choose a menu item like a user: path such as "File > Export > PDF" in the window's menu bar. Menus are opened level by level, so code that fills or enables items when a menu opens runs; a disabled item is reported, not clicked. A path ending at a menu leaves it open. With context=true, ref is right-clicked and the path is chosen in the context menu that opens (without ref: in the context menu already open). ref without context picks the menu bar of that component's window or internal frame. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

dragA

Drag with the mouse like a user: press at the start, move, release at the end. The start is ref (an item by value/row/col, a slider's thumb, a split pane's divider, x/y, or its center; edge=right starts at a cell's or header column's right border, e.g. to resize a column). The end is dx/dy from the start, or toRef with toValue (item text or tree path; a number for a slider value or divider location), toRow/toCol, at=before/on/after, or toX/toY. mode=auto (default) picks: mouse - real mouse events inside the application (pan a map or canvas, move a slider, a divider, a table column; window may be in the background); transfer - drag and drop between components through the application's TransferHandlers (lists, tables, trees, text, drop zones): the source's data is dropped on the target at a real drop location, canImport/importData and the source's exportDone run as for a user, without the operating system's drag and drop; picked for drag-enabled sources; os - the real mouse pointer (window comes to the front; only for drag and drop that needs the operating system). The result says what changed (slider value, divider, column widths, a custom component's picture) or what the drop did. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

handle_dialogA

Answer a dialog like a user: press one of its buttons by text or by role (ok, yes, no, cancel; open/save in file choosers; these work in any UI language), "close" for the window's close box. text first types the answer of an input dialog (or picks it in its combo box); path first puts a file or directory path into a file chooser and, unless button says otherwise, presses its Open/Save button. Without ref: the open modal dialog (or the newest dialog). The result repeats the dialog's title and message. To answer a dialog that an action will open, pass dialog= to that action instead. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

read_itemsA

Read the contents of a table, list, tree or combo box, page by page, as the user sees them (the text the cells show, with the underlying value where it reads differently). The snapshot shows only the first rows. Table: rows from start (view order, as sorted/filtered on screen), optionally only some columns. Tree: without path, the visible rows; with path, that node and its descendants down to depth levels, read from the tree model without expanding anything (trees that load children on expand need expand_node first). find keeps only entries containing that text.

expand_nodeA

Expand (or collapse) a tree node given by its path, like clicking its toggle: ancestors are expanded on the way and expansion listeners run, so trees that load children on expand fill in. Says if the application vetoed it. Waits first (up to timeoutMs) until the component is visible, enabled, editable where needed, and not blocked by a modal dialog or busy overlay, so no wait_for is needed for a component that is about to become usable. Returns the new snapshot.

wait_forA

Wait until text appears anywhere in the snapshot (or disappears with gone=true). Without text, waits for the first window to appear, which is useful right after launch_app. Returns the snapshot; a timeout is an error, with the snapshot at that moment.

hot_reloadA

Apply code changes to the running application without restarting it. Workflow: edit the Java sources, compile them (e.g. mvn -q compile in the application's module, or let the IDE build), then call hot_reload. Changed classes are found in the class directories (target/classes) and loaded into the running JVM. If only event handlers, painting or business logic changed, open screens keep their state; if a screen's construction code changed (constructor, initComponents, @PostConstruct...), that screen is rebuilt. Changes that add or remove methods or fields (including new lambdas) cannot be applied on a standard JVM: the result explains which, and nothing is changed; then restart the application. Only classes whose code really changed are reloaded, even if the build rewrote all class files. In a multi-module project, a module that the application runs from its jar needs classesDir (or start the application with mvn swing2mcp:run -Dswing2mcp.classesDirs=...). Returns the new snapshot.

spring_beansA

For Spring applications: list the beans of the application's Spring context, which is found automatically without any change to the application. Window and panel beans are listed first and can be shown with open_spring_bean. Fails politely if the application has no Spring.

open_spring_beanA

For Spring applications: show a window or panel bean directly instead of navigating menus. Windows and dialogs are opened (prototype beans give a fresh instance); a panel that is not on screen yet is shown in a new frame; a panel in a hidden tab gets its tab selected. Returns the new snapshot.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.8/5.0

Scored across 19 tools

Disambiguation4/5

Each tool targets a distinct interaction (click, type_text, drag, select_menu, handle_dialog, expand_node), and the lifecycle tools (launch/connect/list/stop_app) are clearly separated. A few boundaries blur: click on table/list items overlaps with select_option, and click can activate menu items that select_menu also handles, but the descriptions explain when to prefer each (multi-select ranges, menu-open side effects). Minor overlap only, well mitigated.

Naming Consistency4/5

All names are snake_case and mostly verb-led (launch_app, connect_app, read_items, type_text, handle_dialog, expand_node), which is predictable. A handful are bare nouns/verbs without an object (snapshot, click, drag, screenshot) and spring_beans is a noun, so it is not a strict uniform verb_noun pattern, but it is consistently readable.

Tool Count4/5

19 tools is on the heavy side of the suggested 3-15 range, but the UI-automation domain genuinely needs distinct primitives for pointer, keyboard, selection, trees, menus, dialogs, waiting, and app lifecycle. Each tool covers a real, non-redundant capability, so the count is justified rather than padded.

Completeness4/5

Coverage is strong: app lifecycle, full snapshot + screenshot, mouse/keyboard/text input, table/list/tree reading and selection, menus, dialogs, waiting, hot reload, and Spring integration. Minor gaps remain, such as explicit scrolling within long lists/tables or window-level operations (resize/maximize/close), though snapshots and waiting behavior largely work around them.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues