Skip to content

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

Description

@thiagomendonca-eu

Summary

On Windows, get-pointed-element always returns "No element is currently pointed", even though the Chrome extension connects fine and reports ✓ Element sent successfully. The element never reaches the MCP tool.

Root cause

SharedStateService.SHARED_STATE_PATH is hardcoded to a POSIX path:

// packages/server/src/services/shared-state-service.ts:6
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. So:

  1. Extension sends the element → server receives it (📨 Received message from browser).
  2. saveState() calls fs.writeFile('/tmp/...') → fails with ENOENT (directory doesn't exist).
  3. The error is swallowed by the try/catch (only logger.error, and the Web Store build is IS_DEV=false, so nothing is visible in the SW console).
  4. getPointedElement()readState()ENOENT → returns null → tool returns "No element is currently pointed".

The browser side is 100% fine — it's purely the server failing to persist state on Windows.

Environment

  • OS: Windows 11
  • Node: v24
  • Chrome: 145
  • Extension 0.6.0, @mcp-pointer/server@0.6.0
  • Client: Claude Code

Reproduction

  1. Install on a Windows machine that has no C:\tmp directory.
  2. Alt+Click an element — the service worker console shows ✓ Element sent successfully.
  3. Call get-pointed-element → always "No element is currently pointed".

Confirmation

Manually creating C:\tmp works around it: the state file appears at C:\tmp\mcp-pointer-shared-state.json and the tool returns the element. This confirms the path is the culprit.

Suggested fix

Use os.tmpdir() (cross-platform) instead of the hardcoded /tmp/:

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

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

This preserves the cross-instance shared-state behavior (all instances for the same user resolve to the same temp dir) while working on Windows, macOS and Linux.

I have a PR ready for this and will link it shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions