swing2mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
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
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| launch_appA | Start a Java Swing application with the swing2mcp agent injected and connect to it. |
| 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. |
| 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 |
| 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 ( |
| 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. |
| 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 |
| 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 |
| hot_reloadA | Apply code changes to the running application without restarting it. Workflow: edit the Java sources, compile them (e.g. |
| 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
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 19 tools
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.
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.
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.
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.