Fix #46: Port file written to $TMPDIR (/var/folders/...) instead of /... - #63
Open
JiwaniZakir wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 #46
Fixes port discovery on macOS by writing port advertisement files to
/tmpinstead ofos.tmpdir(), which resolves to/var/folders/...on some macOS systems.Changes
src/core/port-discovery.tsconst PORT_FILE_DIR = tmpdir()with a platform conditional:process.platform === 'win32' ? tmpdir() : '/tmp'. The Figma Desktop Bridge plugin hardcodes/tmpwhen scanning for port files, so the server must write there regardless of whatos.tmpdir()returns on the host system.tests/port-discovery.test.tsgetPortFilePathtest to assert the expected directory based on platform (/tmpon non-Windows,tmpdir()on Windows).path.startsWith('/tmp/')on non-Windows platforms, explicitly covering the macOSos.tmpdir()divergence scenario.Motivation
On macOS,
os.tmpdir()can return/var/folders/l2/<hash>/T/rather than/tmp. The Figma Desktop Bridge plugin scans only/tmpforfigma-console-mcp-*.jsonport files. When these two paths diverge, the server successfully advertises its port (e.g.figma-console-mcp-9223.json) but writes it to/var/folders/..., which the plugin never checks. The result is the plugin stalling on "MCP scanning..." indefinitely and all write tools failing with "Cannot connect to Figma Desktop."Workarounds like setting
TMPDIR=/tmpin the MCP env config had no effect because the server readsos.tmpdir()at module load time. Hardcoding/tmpon non-Windows systems aligns the server's write location with the plugin's scan location without affecting Windows, whereC:\Users\...\AppData\Local\Tempis the correct path.Testing
Automated: The updated
getPortFilePathtests intests/port-discovery.test.tsverify the correct directory is selected per platform. The new explicit/tmpprefix assertion will catch any regression that reintroducesos.tmpdir()on macOS/Linux.Manual verification: On a macOS host where
os.tmpdir()returns/var/folders/..., after this change the server log should show:and the Figma Desktop Bridge plugin should transition from "MCP scanning..." to a connected state. Confirm
ls /tmp/figma-console-mcp-*.jsonshows the file immediately after the server starts.This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.