Skip to content

fix(server): use os.tmpdir() for shared state path (Windows compatibility)#23

Open
thiagomendonca-eu wants to merge 1 commit into
etsd-tech:mainfrom
thiagomendonca-eu:fix/windows-tmpdir-shared-state
Open

fix(server): use os.tmpdir() for shared state path (Windows compatibility)#23
thiagomendonca-eu wants to merge 1 commit into
etsd-tech:mainfrom
thiagomendonca-eu:fix/windows-tmpdir-shared-state

Conversation

@thiagomendonca-eu

Copy link
Copy Markdown

What

Fixes the hardcoded POSIX /tmp/ path used for the shared-state file, which silently breaks the tool on Windows.

Closes #22

Problem

// packages/server/src/services/shared-state-service.ts
static SHARED_STATE_PATH = '/tmp/mcp-pointer-shared-state.json';

On Windows, Node resolves /tmp/... to C:\tmp\... (root of the current drive), which usually doesn't exist. As a result:

  1. The extension sends the element and the server receives it (📨 Received message from browser).
  2. saveState()fs.writeFile('/tmp/...') fails with ENOENT.
  3. The error is swallowed by the try/catch (only logger.error), so nothing is visible in the production build.
  4. getPointedElement()readState()ENOENT → returns null.

Net effect: the extension reports ✓ Element sent successfully, but get-pointed-element always returns "No element is currently pointed" on Windows.

Fix

import os from 'os';
import path from 'path';

static SHARED_STATE_PATH = path.join(os.tmpdir(), 'mcp-pointer-shared-state.json');

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

  • Windows 11, Node 24, Chrome 145, extension/server 0.6.0, Claude Code.
  • Before: no state file written; get-pointed-element always empty.
  • Confirmed root cause: manually creating C:\tmp works around it (state file appears, tool returns the element).
  • After (this fix): state file is written to os.tmpdir() and get-pointed-element returns the pointed element.
  • No change on macOS/Linux: os.tmpdir() resolves to the existing system temp dir (/tmp on Linux, /var/folders/... on macOS).

Single-file change, no API or behavior change beyond the path resolution.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Server never persists pointed element — hardcoded /tmp path breaks get-pointed-element

1 participant