Skip to content

[Bug]: Cursor provider fails to start project MCP servers using ${workspaceFolder} and unresolved environment variables #22199

Closed

Description

@JeremyMoeglich

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

Create server.mjs at the project root:

import { createInterface } from "node:readline";

for await (const line of createInterface({ input: process.stdin })) {
  const { id, method } = JSON.parse(line);
  if (id === undefined) continue;

  const result = method === "initialize"
    ? {
        protocolVersion: "2024-11-05",
        capabilities: { tools: {} },
        serverInfo: { name: "repro", version: "1.0.0" }
      }
    : method === "tools/list" ? { tools: [] } : {};

  console.log(JSON.stringify({ jsonrpc: "2.0", id, result }));
}

Add .cursor/mcp.json:

{
  "mcpServers": {
    "repro": {
      "command": "node",
      "args": ["${workspaceFolder}/server.mjs"]
    }
  }
}
  1. Open the project in Cursor IDE and confirm the MCP server connects.
  2. Open the same project in T3 Code using the Cursor provider.
  3. Ask the agent to discover MCP servers.
  4. The server fails to start because ${workspaceFolder} remains literal.

Expected behavior

${workspaceFolder} resolves to the thread's workspace directory, as it does in Cursor IDE.

Actual behavior

The SDK passes ${workspaceFolder}/server.mjs unchanged to Node. Node exits with MODULE_NOT_FOUND, and the MCP server is unavailable.

Impact

Major degradation or frequent failure

Version or commit

0.1.1-nightly.20261020.3386; bundled @cursor/sdk 1.0.35

Environment

Windows x64; T3 Code Nightly desktop; Cursor provider; full-access mode.

Logs or stack traces

Error: Cannot find module '<working-directory>\${workspaceFolder}\server.mjs'
code: MODULE_NOT_FOUND

Screenshots, recordings, or supporting files

No response

Workaround

An absolute script path avoids the unresolved placeholder, but is unsuitable for shared, Git-tracked configuration and different worktrees.

Activity

  1. added
    bugSomething is broken or behaving incorrectly.
    needs-triageIssue needs maintainer review and initial categorization.
    on Oct 20, 2026
  2. juliusmarminge commented on Oct 22, 2026

    @juliusmarminge
    Member

    Checked current main 8acbefefc5. No matching open issue or PR found.

    On Linux x64, created the reported server.mjs and .cursor/mcp.json fixture and attempted MCP discovery with bundled Cursor SDK 1.0.35, project settings enabled, and full access. The SDK reports logged-out; the turn fails with Invalid User API Key. The isolated dev server started and browser pairing succeeded, but the web client remained on its splash screen.

    The reported placeholder failure remains unverified. An authenticated Cursor environment is needed to continue; Windows desktop was not tested. No implementation changes made.

    Runtime transcript

  3. JeremyMoeglich commented on Nov 13, 2026

    @JeremyMoeglich
    Author

    Note

    Written by claude-opus-5-5 on my behalf.

    This still fails on Nightly 0.1.10-nightly.20261113.4616, which includes #24505 (cc97303). Could this be reopened?

    A wrapped launcher like the one in the report:

    "example": {
      "command": "proto",
      "args": ["run", "node", "--", "${workspaceFolder}/tools/mcp-server.ts"],
      "env": { "EXAMPLE_CONFIG": "${env:EXAMPLE_CONFIG}" }
    }

    On Windows 11, a Composer 2.5 thread in such a project fails tool discovery for the server. Calling its tool returns MCP server does not exist: example. Available servers: t3-code, the same error as before the fix.

    Why: the merged rule resolves a server only in these cases:

    • ${workspaceFolder} is in command or cwd, or
    • command is node, bun, tsx, python or python3, and args[0] starts with ${workspaceFolder}/.

    A wrapped command like proto run node -- ${workspaceFolder}/… matches neither, so it stays with the SDK, which starts it with the placeholder literal. 80f1a6c removed exactly this case ("wrapped") from the test's expected overrides. The same applies to other launchers, such as pnpm exec tsx … or uv run python ….

    Suggested fix: narrowing the rule avoids the duplicate-process leak (8fdb3b6). That leak comes from the SDK itself: with two clients of the same name, qA.load keeps the first and drops the other without closing it:

    // @cursor/sdk 1.2.0, dist/cjs/336.js, class qA, load()
    const n=r+e;n in s||(s[n]=t)}}return new Wk(s)

    T3 already ships patches/@cursor__sdk@1.2.0.patch, which touches 336.js. Closing the dropped client there removes the leak at its source:

    -const n=r+e;n in s||(s[n]=t)}}return new Wk(s)
    +const n=r+e;n in s?Promise.resolve(t.close?.()).catch(()=>{}):(s[n]=t)}}return new Wk(s)

    I tested that on 1ebaebb, which used the wider rule, with a built server and a signed-in Cursor thread over several turns. Without the patch, the SDK's literal copy of an env-only server survived every turn: 3 turns left 3 orphaned processes. With the patch, the literal copy exited about 70 ms after starting, and the agent still called the resolved copy, with the workspace as cwd and the resolved env. The only processes left were the two create-time file servers that main also keeps. The ESM build is minified differently and would need its own hunk; the server loads the CJS build through createRequire.

    With dropped clients closed, a duplicate costs only a brief extra start. T3 could then resolve any stdio server that uses an editor variable, wrapped launchers included, instead of guessing which literal copies can't start.

  4. JeremyMoeglich commented on Nov 13, 2026

    @JeremyMoeglich
    Author

    I should note that this is much less severe as I can work around it for now by using cwd, so this is only an annoyance at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions