fix(mcp): client must find the daemon socket where #148 moved it#258
Merged
Conversation
The warm MCP daemon (cclsp/intelephense, phpstan-warm, etc.) never worked when supertool is invoked via the `./supertool` symlink — every `diag:` call took 60s then reported "MCP server 'lsp' unavailable". Three compounding bugs, all masked by the same timeout: 1. #148 moved daemon sockets from /tmp to the per-user runtime dir (_paths.socket_pid_paths). daemon/status/stop migrated; MCPClient did not — it hardcoded /tmp/supertool-mcp-{h}.sock and polled a path the daemon never binds. Now it computes the path via _paths.socket_pid_paths, the single source of truth, so client and daemon can never drift again. 2. _MCP_DAEMON_SCRIPT used abspath(__file__), which does not follow symlinks, so under `./supertool` it resolved to dvsi/presets/mcp/daemon.py (nonexistent) and the client's daemon-spawn silently failed. Switched to realpath(__file__). 3. (3) also makes the new `from _paths import` resolvable instead of crashing the tool with ModuleNotFoundError. Result: cold 8.6s (one-time intelephense index) -> warm 0.22s, persistent daemon. Adds regression tests: client/daemon socket-path agreement, and a symlink invocation smoke test (would have caught both the path drift and the abspath bug). Co-Authored-By: Max <noreply>
…mutation Review follow-up (#258). The first cut did `sys.path.insert(0, presets/mcp)` + `from _paths import …` at module top-level — process-global, never cleaned up, and `_paths` is a generic name that could shadow other imports. Replace with a lazy importlib file-load under a unique module name (`_supertool_mcp_paths`): - no sys.path mutation - loads only on first MCPClient use, so a missing/broken _paths.py fails MCP ops instead of crashing the whole tool at import - result is cached after first load Also fix stale post-#148 docstrings in daemon.py / status.py that still claimed sockets live in /tmp. Co-Authored-By: Max <noreply>
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.
Problem
The warm MCP daemon (cclsp/intelephense,
phpstan-warm,phpunit-warm,rector-warm) never worked when supertool is invoked via the./supertoolsymlink. Everydiag:call took 60s then returnedMCP server 'lsp' unavailable; thelsp-diagvalidator showed15.0s(its framework timeout killing the doomed connect first).Three compounding bugs, all masked by the same timeout:
/tmpto the per-user runtime dir (_paths.socket_pid_paths).daemon/status/stopwere migrated;MCPClientwas not — it hardcoded/tmp/supertool-mcp-{h}.sockand polled a path the daemon never binds.abspath(__file__)under symlink._MCP_DAEMON_SCRIPTusedos.path.abspath(__file__), which doesn't follow symlinks → resolved todvsi/presets/mcp/daemon.py(nonexistent). The client's daemon-spawn silently failed, so no daemon ever started.abspathbase made the newfrom _paths import …unresolvable, which would crash the tool withModuleNotFoundError.Fix
MCPClientcomputes its socket path via_paths.socket_pid_paths— the single source of truth, so client and daemon can never drift again.os.path.realpath(__file__)(follows the symlink) instead ofabspath, fixing both the daemon-script path and the_pathsimport.Result
diag:against DVSI: cold 8.6s (one-time intelephense index) → warm 0.22s, with a persistent daemon. Was a 60s failure on every call.Tests
TestClientDaemonPathAgreement— client socket path must equal_paths.socket_pid_pathsand must not fall back to bare/tmp.TestSymlinkInvocation— running supertool through a symlink must not crash on import (catches both the path drift and theabspathbug).Co-Authored-By: Max