fix(server): use os.tmpdir() for shared state path (Windows compatibility)#23
Open
thiagomendonca-eu wants to merge 1 commit into
Open
Conversation
The shared state path was hardcoded to '/tmp/mcp-pointer-shared-state.json', a POSIX path. On Windows it resolves to 'C:\tmp\...' which usually doesn't exist, so saveState() fails with ENOENT (silently swallowed by try/catch) and getPointedElement() always returns null — the tool reports "No element is currently pointed" even though the extension sent the element successfully. Use path.join(os.tmpdir(), 'mcp-pointer-shared-state.json') so it works on Windows, macOS and Linux while preserving cross-instance shared state (same user resolves to the same temp dir). Fixes etsd-tech#22
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.
What
Fixes the hardcoded POSIX
/tmp/path used for the shared-state file, which silently breaks the tool on Windows.Closes #22
Problem
On Windows, Node resolves
/tmp/...toC:\tmp\...(root of the current drive), which usually doesn't exist. As a result:📨 Received message from browser).saveState()→fs.writeFile('/tmp/...')fails withENOENT.try/catch(onlylogger.error), so nothing is visible in the production build.getPointedElement()→readState()→ENOENT→ returnsnull.Net effect: the extension reports
✓ Element sent successfully, butget-pointed-elementalways returns"No element is currently pointed"on Windows.Fix
Cross-platform, and it preserves the cross-instance shared-state behavior — all server instances for the same user resolve to the same temp dir on every OS.
Testing
0.6.0, Claude Code.get-pointed-elementalways empty.C:\tmpworks around it (state file appears, tool returns the element).os.tmpdir()andget-pointed-elementreturns the pointed element.os.tmpdir()resolves to the existing system temp dir (/tmpon Linux,/var/folders/...on macOS).Single-file change, no API or behavior change beyond the path resolution.