Prevent Julia LS setup from clobbering Serena's stdio MCP pipe (#1580)

* Prevent Julia LS probe from clobbering Serena's stdio MCP pipe

When Serena runs over the stdio MCP transport, stdin/stdout *are* the JSON-RPC channel.
The Julia language-server setup spawns probe/install subprocesses with `capture_output=True`,
which redirects the child's stdout/stderr but not its stdin, so the Julia child inherits
Serena's stdin (the MCP pipe) and clobbers it. The stdio server then exits within
milliseconds of `initialize`, and the client reports "tools fetch failed".

- Pass `stdin=subprocess.DEVNULL` to both `subprocess.run` calls in `julia_server.py`
  (`_setup_runtime_dependency` probe and `_install_language_server` install).
- Add a comment explaining the stdio-transport hazard.

Fixes #1577

* Add changelog entry for the Julia stdio MCP fix

Document the fix under the Unreleased "Language Servers" section.
This commit is contained in:
Feng Lin authored and GitHub committed 2026-06-16 16:56:21 +02:00
1 parent f84452cdd3
commit dd7eb6d72a
2 files changed
+13 -3

No files matched your search

+4
View File
@@ -32,6 +32,10 @@ Status of the `main` branch. Changes prior to the next official version change w
results in svelte-only mode (`languages: [svelte]`). They are now routed to the companion TS server,
so symbols defined in plain `.ts`/`.js` files are again discoverable via `find_symbol`/
`get_symbols_overview`, and `find_referencing_symbols` no longer fails to locate `.ts`/`.js` symbols. #1552
- `JuliaLanguageServer`: Fix the stdio MCP server exiting right after `initialize` ("tools fetch failed")
when `julia` is enabled. The runtime probe/install subprocesses now run with `stdin=subprocess.DEVNULL`,
so they can no longer inherit and clobber Serena's stdin, which is the JSON-RPC pipe under the stdio
transport. #1577
- Improve quoting of arguments in shell executions
* JetBrains:
@@ -78,10 +78,14 @@ class JuliaLanguageServer(SolidLanguageServer):
f"Checked locations: {common_locations}"
)
# Check if LanguageServer.jl is installed
# Check if LanguageServer.jl is installed.
# stdin=DEVNULL: when Serena runs over the stdio MCP transport, the JSON-RPC
# channel *is* the process stdin/stdout. Without this, the Julia child inherits
# Serena's stdin (the MCP pipe) and clobbers it, killing the server right after
# initialize ("tools fetch failed"). See https://github.com/oraios/serena/issues/1577
check_cmd = [julia_path, "-e", "using LanguageServer"]
try:
result = subprocess.run(check_cmd, check=False, capture_output=True, text=True, timeout=10)
result = subprocess.run(check_cmd, check=False, capture_output=True, text=True, timeout=10, stdin=subprocess.DEVNULL)
if result.returncode != 0:
# LanguageServer.jl not found, install it
JuliaLanguageServer._install_language_server(julia_path)
@@ -99,7 +103,9 @@ class JuliaLanguageServer(SolidLanguageServer):
install_cmd = [julia_path, "-e", 'using Pkg; Pkg.add("LanguageServer")']
try:
result = subprocess.run(install_cmd, check=False, capture_output=True, text=True, timeout=300) # 5 minutes for installation
result = subprocess.run(
install_cmd, check=False, capture_output=True, text=True, timeout=300, stdin=subprocess.DEVNULL
) # 5 minutes for installation
if result.returncode == 0:
log.info("LanguageServer.jl installed successfully!")