Summary: Features | Tools   Detail: How it works | Quick start

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.

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
 
MCP server
 
your application
agent
 
Swing windows

 

    Coding agent

    Your Swing application

    ACME Customer Manager 3.2 - admin_ □ ×
    CustomersOrdersReports
    Customer Details
    Ankara▾
    Save
    IDFull NameCity

    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.

    Requires:
    Java 8 or newer, Maven 3.6.3 or newer
    Works with:
    Claude Code, Cursor, Codex, OpenCode and any tool that supports MCP, also with a local model
    License:
    Apache License 2.0
    Since:
    0.1.0 (early release: tool names and options may still change before 1.0)
    See Also:
    README, Using swing2mcp, Security

    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

    FeatureDescriptionDetails
    No code changesOne plugin entry in the pom; nothing is written into your jar.Quick start
    Text, not pixelsThe component tree as text, with the Java field names.snapshot
    Like a real userReal key and mouse events; listeners and validation run.How actions behave
    BackgroundThe window does not have to be in front.How actions behave
    Hot reloadCode changes without a restart.Hot reload
    AttachConnects to an application that is already open.Connecting
    SpringLists the screens and opens one directly.Spring
    TestsThe same steps as a plain Java test, without AI (experimental).Writing tests
    LocalSends nothing off your machine; works with a local model.Security

    Tool Summary

    ToolDescription
    list_apps / connect_appLists running Java applications / connects to one, without a restart.
    snapshotText summary of the windows, with ref IDs.
    screenshotPNG image of a window or component.
    clickReal mouse click on a button, table cell, list item or tree node; double click, right click, with Ctrl/Shift.
    hoverMoves the mouse over a component without clicking; can turn the mouse wheel there.
    type_textTypes real keys into a text field, password, spinner or editable combo.
    press_keyEnter, Escape, Tab, arrows, F-keys and shortcuts such as Ctrl+S.
    select_optionCombo, list, tab, table cell, tree node; several rows, items or nodes with Ctrl/Shift.
    dragMouse drag (pan a map, move a slider, a split pane divider, a table column) and drag and drop between components.
    read_itemsReads tables, lists, trees and combos page by page, as they are shown.
    expand_nodeExpands or collapses a tree node by its path.
    select_menuChooses a menu path such as "File > Open", also in context menus.
    handle_dialogAnswers a message box, input dialog or file chooser.
    wait_forWaits for a text to appear or disappear.
    hot_reloadApplies compiled code changes without a restart; rebuilds the screen if needed.
    spring_beansLists the beans in Spring applications (screens are shown separately).
    open_spring_beanOpens a Spring screen bean directly, without navigating the menu.
    launch_app / stop_appStarts / closes the application from the coding agent, for projects without Maven.