Conversation
…er (#52) Stabilize the pylink-square MCP server (crashes caused by repeated J-Link DLL load / USB connect-disconnect on every tool call) by connecting all J-Link tools through a persistent localhost J-Link Remote Server on port 19020, and have mcp_server.py launch that daemon when it isn't listening. AI-authored (deepseek-v4-flash-free, 4k context) — researched SEgger KB, designed/implemented: - jlink_connection.py: shared --remote-host/--remote-port/--direct args and a connect() that opens via jlink.open(ip_addr=host:port) with direct-USB fallback. - Converted all 13 J-Link tool scripts to the shared helper. - mcp_server.py: spawns JLinkRemoteServer -Port <port> [-USB <serial>] on startup if not already listening (persists across MCP restarts), routes every tool call through it via --remote-host/--remote-port; added --device/--speed/--remote-port/--usb-serial with JLINK_MCP_* env fallbacks. - .gitignore/gotcha/PLAN/README docs. Human review: chose the localhost-server default, confirmed port 19020, provided the Remote Server launch options, and requested serial numbers not appear in examples/commits. Verified live on hardware through the tunnel: debug_target, run_for, rtt_read --continuous. Host LLVM build + all 18 unit tests pass; no C++ sources touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #52
Problem
The pylink-square MCP server crashes periodically. Every tool call created a
fresh
pylink.JLink(), opened USB, connected, and discarded it — repeatedJ-Link DLL load / USB connect-disconnect churn inside a long-lived process.
Change
All 13 J-Link tools now connect through a persistent localhost J-Link
Remote Server (default
127.0.0.1:19020) instead of opening USB per call.mcp_server.pylaunches the daemon on startup when nothing is listening andintentionally leaves it running across MCP restarts.
jlink_connection.py(new): shared--remote-host/--remote-port/--directargs +
connect()viajlink.open(ip_addr="host:port")with direct-USBfallback.
mcp_server.py:ensure_remote_server()spawnsJLinkRemoteServer -Port <port> [-USB <serial>]; every handler routesthrough it with
--remote-host/--remote-port; new--device/--speed/--remote-port/--usb-serialCLI withJLINK_MCP_*envfallbacks.
Verification
debug_target,run_for --seconds 2,rtt_read --continuous 4all connect/read correctly.(cross presets unaffected; CI will still validate).