Coding agent ⇄ swing2mcp ⇄ your Swing application
Your AI coding agent runs your Swing app and checks its own work
On the web, a coding agent can open the page and check its own work, with tools such as Playwright. In a Swing application it could not, short of taking over the screen and the mouse. swing2mcp works from inside the application: no changes to your code, and your mouse stays yours.
- Java 8 and newer
- No changes to your code
- Runs on your machine
- Open source, Apache-2.0
How It Works
A small Java agent lives inside your application's JVM, so it reads the screen as text from the component tree instead of from pixels. The coding agent talks to it through a local MCP server (MCP over stdio, then HTTP on 127.0.0.1 with a token). Watch one request travel. This is an illustration of the real tool calls, not a recording.
Coding agent
Your Swing application
| ID | Full Name | City |
|---|
Overview
swing2mcp runs inside your application's JVM, loaded the way a profiler or a debugger is, next to a small server that coding agents talk to. The coding agent gets the screen as text and uses the real Swing components (buttons, fields, tables, menus). After a code change it can reload the code without a restart and look again.
Quick Start Detail
1. Add the plugin
To your project's pom.xml. This is the only part you need to add.
<plugin> <groupId>io.github.ibrahimcavdar</groupId> <artifactId>swing2mcp-maven-plugin</artifactId> <version>0.2.0</version> </plugin>
2. Connect your coding agent
Once per machine. The command asks which of your coding agents to connect, lists the changes it is about
to make, and waits for your yes. mvn swing2mcp:uninstall removes all of it again.
mvn swing2mcp:setup
3. Start your application with swing2mcp
Instead of your usual way. The application behaves as always; nothing is written into your jar or your code.
mvn swing2mcp:run
4. Tell the coding agent what you want it to do
For example: "Log in with admin/admin, add a customer named Ali Veli from İzmir and check that it shows up in the table."
Feature Summary
| Feature | Description | Details |
|---|---|---|
| No code changes | One plugin entry in the pom; nothing is written into your jar. | Quick start |
| Text, not pixels | The component tree as text, with the Java field names. | snapshot |
| Like a real user | Real key and mouse events; listeners and validation run. | How actions behave |
| Background | The window does not have to be in front. | How actions behave |
| Hot reload | Code changes without a restart. | Hot reload |
| Attach | Connects to an application that is already open. | Connecting |
| Spring | Lists the screens and opens one directly. | Spring |
| Tests | The same steps as a plain Java test, without AI (experimental). | Writing tests |
| Local | Sends nothing off your machine; works with a local model. | Security |
Tool Summary
| Tool | Description |
|---|---|
| list_apps / connect_app | Lists running Java applications / connects to one, without a restart. |
| snapshot | Text summary of the windows, with ref IDs. |
| screenshot | PNG image of a window or component. |
| click | Real mouse click on a button, table cell, list item or tree node; double click, right click, with Ctrl/Shift. |
| hover | Moves the mouse over a component without clicking; can turn the mouse wheel there. |
| type_text | Types real keys into a text field, password, spinner or editable combo. |
| press_key | Enter, Escape, Tab, arrows, F-keys and shortcuts such as Ctrl+S. |
| select_option | Combo, list, tab, table cell, tree node; several rows, items or nodes with Ctrl/Shift. |
| drag | Mouse drag (pan a map, move a slider, a split pane divider, a table column) and drag and drop between components. |
| read_items | Reads tables, lists, trees and combos page by page, as they are shown. |
| expand_node | Expands or collapses a tree node by its path. |
| select_menu | Chooses a menu path such as "File > Open", also in context menus. |
| handle_dialog | Answers a message box, input dialog or file chooser. |
| wait_for | Waits for a text to appear or disappear. |
| hot_reload | Applies compiled code changes without a restart; rebuilds the screen if needed. |
| spring_beans | Lists the beans in Spring applications (screens are shown separately). |
| open_spring_bean | Opens a Spring screen bean directly, without navigating the menu. |
| launch_app / stop_app | Starts / closes the application from the coding agent, for projects without Maven. |