Where does the bug appear (feature/product)?
Cursor SDK
Describe the Bug
Three places where the local runtime of @cursor/sdk (1.0.31 through 1.0.36, same code) differs from the docs and the CLI. Each comes down to a small change in the bundle, and we patch all three in-process with a preload that rewrites the SDK as it loads. Sites below are from 1.0.36 dist/cjs/867.js (689.js in 1.0.35). Two related SDK gaps already have staff-confirmed threads, and I’ve added the same kind of detail there: max mode in topic 172554 and sessionStart additional_context in topic 168441.
1. Claude Code-format hook output is ignored, so a Claude PreToolUse deny doesn’t block.
The SDK runs the hooks in ~/.claude/settings.json, but ignores their nested hookSpecificOutput (permissionDecision, permissionDecisionReason, additionalContext). The third-party hooks docs list nested hookSpecificOutput as supported, and the CLI honours it (Cursor-agent: imported Claude Code plugin hooks get a Cursor-shaped payload, so PreToolUse gates fail open).
- Site: the hook executor is built without the flag its output parser checks (
e?.enableClaudeNestedHookSpecificOutputCompatibility??!1):
new wE(r,i,a,(t.createTerminalExecutor??kC)(),t.promptHookClient,void 0,void 0,{commandHookPayloadTransport:…}) - Workaround: add
enableClaudeNestedHookSpecificOutputCompatibility:!0to that options object. With it, the same hook blocks the command.
2. send({ mcpServers }) also turns off the plugin, project and user MCP servers.
The docs say send-level mcpServers “Fully replaces creation-time servers for that run”, with local precedence “Send > create > plugins > project > user”. In practice a run started with send-level servers gets only those: everything from ~/.cursor/mcp.json, .cursor/mcp.json and plugins disappears for that run. The same servers passed to Agent.create() keep the file-based ones.
- Site: the per-send lease hard-codes the three layers off, while the creation-time lease derives them from
settingSources:
per send:createSessionMcpLease:(t,r)=>Tk({…,includeProjectMcp:!1,includeUserMcp:!1,includePluginMcp:!1,inlineMcpServers:r})
at create:includeProjectMcp:ix(i,"project"),includeUserMcp:ix(i,"user"),includePluginMcp:b,inlineMcpServers:e.mcpServers - Workaround: use the creation-time lease’s three
include…values in the per-send lease. - Integrators hit this: T3 Code passes its own MCP server on every send, so its Cursor threads lose all of the user’s MCP servers ([Bug]: Cursor threads lose all user, plugin, and project MCP servers because mcpServers is passed on every send · Issue #15268 · pingdotgg/t3code · GitHub).
3. MCP OAuth logins are per folder, and can’t be done inside a run.
The docs say an OAuth MCP server works in local runs “if you’ve already signed in to that server from the Cursor app”. In practice the SDK reads tokens from ~/.cursor/projects/<folder>/mcp-auth.json, the file agent mcp login writes for that folder. A login made in the Cursor app isn’t seen (as confirmed in topic 159797), and a CLI login covers one folder, so every worktree or new folder needs its own (we have 48 of these files). The file is read once per process, so a new login needs a restart. Inside a run, the agent’s mcp_auth gets “MCP authentication is not supported in local SDK runs”, and the server stays hidden.
- Site: four
new Mm((0,n.join)(l,"mcp-auth.json"))calls, each given the per-folder directory. - Workaround: point those four at one shared file (an env var in our preload) and link the CLI’s per-folder file to it, so one login covers every folder.
Steps to Reproduce
- Hooks: in a scratch
HOME, add a~/.claude/settings.jsonPreToolUsehook with matcherBashwhose command prints{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"blocked by test hook"}}. Create a local agent withlocal: { cwd, settingSources: ["user"], sandboxOptions: { enabled: false } }and ask it to runecho hi > marker.txt. The hook runs, andmarker.txtis still created. With the flag above turned on, the agent gets “Rejected: blocked by test hook” and no file is written. - MCP: with a server in
~/.cursor/mcp.jsonandsettingSources: ["user"], callagent.send(prompt, { mcpServers: { other: … } })and ask the agent to list its MCP servers: onlyotheris there. Without send-levelmcpServers, both are. - MCP OAuth: run
agent mcp login <server>in folder A, then start local agents in folder A and in folder B: the server is ready only in A.
Expected Behavior
- Claude-format hook output is honoured in SDK runs, as the docs and the CLI do.
- Send-level
mcpServersreplace only the creation-time inline servers; plugin, project and user servers stay, as documented. - One login works for every folder (a user-level token store, or the app’s), and the docs describe what the local SDK actually reads.
Operating System
Linux
Version Information
@cursor/sdk 1.0.36 (Node 24), also checked in 1.0.31 and 1.0.35 (in T3 Code nightlies 0.0.46-nightly.20261004.2648 and 0.0.46-nightly.20261006.2735). Cursor CLI 2026.10.01-e373342.
For AI issues: which model did you use?
composer-2.5 for the hook repro; the issues don’t depend on the model.
For AI issues: add Request ID with privacy disabled
Privacy mode was on for these (and the problems are client-side): hook repro on stock 1.0.36 a8e8c07d-1045-491d-9e32-a8df92bb8fbd (command ran), with the flag on f5561fc7-0721-4455-8a93-a064bd9101ed (blocked).
Does this stop you from using Cursor
No - Cursor works, but with this issue