Repository navigation
fix(headless): name the fallback socket directory in --help - #665
Conversation
The help said the server always serves on $XDG_RUNTIME_DIR/ghidra-mcp/ghidra-<pid>.sock. With XDG_RUNTIME_DIR unset, McpHttpServer.resolveSocketDir serves from $TMPDIR/ghidra-mcp-<user>/ instead, then java.io.tmpdir and /tmp. List both directories in the help and pin them with an offline test. Fixes #653
cd48c45 to
5750902
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
rahul05ranjan
left a comment
There was a problem hiding this comment.
Checked the help text against McpHttpServer.resolveSocketDir (src/main/java/com/xebyte/core/McpHttpServer.java:469-484 on dev) and the wording matches the actual order: $XDG_RUNTIME_DIR/ghidra-mcp → $TMPDIR/ghidra-mcp-<user> → java.io.tmpdir/ghidra-mcp-<user> → /tmp/ghidra-mcp-<user>, with ghidra-<pid>.sock as the file name from startUds (line 336). The old text really did promise the XDG path unconditionally, so this is a genuine docs fix.
Two small notes on the test (HeadlessUsageSocketDirTest):
testUsageNamesUserSuffixedFallbackDirassertsusage().contains("/tmp"), which stays satisfied by unrelated lines even if the final/tmpfallback disappeared from the help. Anchoring it to the distinctive part (e.g.contains("then /tmp")) would keep the test honest against a regression that only drops the last fallback. Minor either way since the other assertions are exact.- Making
printUsagepublic static is the only API surface change and is fine for the cross-package test; not worth churn if you don't care.
The System.setOut capture is fine given the JVM test is single-threaded and the original stream is restored in finally.
|
Thanks @rahul05ranjan. I anchored the last fallback check to Offline Java tier (Gradle, Ghidra 12.2, JDK 25): 968 tests, 0 failures. |
What this changes
The headless server's
--helpsaid it always serves on$XDG_RUNTIME_DIR/ghidra-mcp/ghidra-<pid>.sock. WithXDG_RUNTIME_DIRunset it actually serves from$TMPDIR/ghidra-mcp-<user>/, and the help never mentioned that directory or its-<user>suffix. The help now lists both directories, in the orderMcpHttpServer.resolveSocketDirpicks them. Where the socket goes is unchanged.Fixes #653
Why
On
devat 5f6c416, built with Gradle against Ghidra 12.2 on Linux:--helpprinted the two "Always serves on $XDG_RUNTIME_DIR/ghidra-mcp/..." lines quoted in the issue.XDG_RUNTIME_DIRunset andTMPDIR=$WORK/tmploggedServing on $WORK/tmp/ghidra-mcp-<user>/ghidra-<pid>.sock.The new tail of the help:
printUsageis nowpublic static(it reads no instance state), so the new offline testHeadlessUsageSocketDirTestcan capture its output and check that it names both directories and the socket file name.Tests you ran
uv run pytest tests/unit/: run asuv run --frozen --python 3.13 pytest tests/unit/ --no-covon CPython 3.13.17. Passed, 0 failures, 13 skips (the Windows-only and live-server ones)../gradlew test --tests 'com.xebyte.offline.*' "-PGHIDRA_INSTALL_DIR=<dir>": Ghidra 12.2, Temurin JDK 25. 119 suites, 968 tests, 0 failures, 0 skipped, including the 3 new tests.powershell -File tests\pester\Run-Tests.ps1: not applicable, no PowerShell changes.pytest tests/ -m readonly,./gradlew test): not run.XDG_RUNTIME_DIR, and its socket path matched the new help both times.I didn't run the Maven
-Pcoverage-gatecommand: only Maven 3.8.7 is available here and the project needs 3.9+. The change adds a test that covers the edited method.If you touched an @mcptool or @PARAM annotation
mvn test -Dtest=RegenerateEndpointsJson -Dregenerate=truepython -m tools.audit_server_scope --writepython -m tools.gen_readme_api_reference --writeChecklist
devand targetingdevCHANGELOG.mdupdated, if this is user-visibleScreenshots