Skip to content

Commit ddcee48

Browse files
Huijirocursoragent
andcommitted
fix(cursor): unblock summarize stream and reuse timed catalog probe
Keep the SDK summary stream pump off callbackChain so onDelta cannot deadlock wait, and return sdkModels from the timed status check so refresh no longer awaits a second unbounded catalog.read. Document that OAuth plugin MCP needs agent mcp login for the T3 project folder because local SDK runs reject interactive auth. Co-authored-by: Cursor <[email protected]>
1 parent aa15082 commit ddcee48

5 files changed

Lines changed: 150 additions & 110 deletions

File tree

‎docs/user/cursor.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ not expose yet.
1717

1818
Custom Cursor MCP servers and plugins are not configured in T3 Code. They load from the environment
1919
machine's Cursor config when the agent opens: project `.cursor/mcp.json`, user `~/.cursor/mcp.json`,
20-
and installed plugins under `~/.cursor/plugins`, via the SDK `settingSources` layers. OAuth MCP
21-
logins are per workspace folder (`agent mcp login`); a login from the Cursor desktop app is not
22-
reused. After you add or change skills, plugins, or MCP servers, use **Restart agent session**.
20+
and installed plugins under `~/.cursor/plugins`, via the SDK `settingSources` layers. Plugin tools
21+
can appear without a login; OAuth MCP servers still need credentials. Run `agent mcp login <server>`
22+
with the cwd set to the T3 project root (tokens land in
23+
`~/.cursor/projects/<folder-slug>/mcp-auth.json`). Cursor desktop Connections auth does not write
24+
that file, and the local SDK cannot complete interactive MCP OAuth itself—auth attempts fail with
25+
messages such as "MCP authentication is not supported in local SDK runs" or that the auth server
26+
does not support dynamic client registration. After you add or change skills, plugins, or MCP
27+
servers, or after a successful CLI login, use **Restart agent session**.
2328

2429
## Sign in
2530

‎packages/provider-cursor/src/server/CursorAgentSdk.ts‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,24 +470,29 @@ export const makeCursorAgentSdkRunner = Effect.fn("makeCursorAgentSdkRunner")(fu
470470
return callbackChain;
471471
};
472472

473-
if (input.pumpStream) {
474-
callbackChain = callbackChain.then(async () => {
475-
for await (const message of input.run.stream()) {
476-
const update = summaryMessageToInteractionUpdate(message);
477-
if (update !== undefined) {
478-
await dispatchUpdate(update);
479-
}
480-
}
481-
});
482-
}
473+
// Keep the stream pump off callbackChain — awaiting dispatchUpdate from inside a
474+
// callbackChain task deadlocks when the next link waits for that same task to finish.
475+
const pumpDone =
476+
input.pumpStream === true
477+
? (async () => {
478+
for await (const message of input.run.stream()) {
479+
const update = summaryMessageToInteractionUpdate(message);
480+
if (update !== undefined) {
481+
await dispatchUpdate(update);
482+
}
483+
}
484+
})().catch((cause) => {
485+
callbackFailure ??= { cause };
486+
})
487+
: Promise.resolve();
483488

484489
return {
485490
runId: input.run.id,
486491
agentId: input.run.agentId,
487492
wait: Effect.tryPromise({
488493
try: async () => {
489494
const result = await input.run.wait();
490-
await callbackChain;
495+
await Promise.all([callbackChain, pumpDone]);
491496
if (callbackFailure !== undefined) {
492497
throw callbackFailure.cause;
493498
}

‎packages/provider-cursor/src/server/driver.ts‎

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { CursorSettings } from "../settings.ts";
88
import * as Effect from "effect/Effect";
99
import * as Crypto from "effect/Crypto";
1010
import * as FileSystem from "effect/FileSystem";
11-
import * as Option from "effect/Option";
1211
import * as Path from "effect/Path";
1312
import * as Schema from "effect/Schema";
1413
import * as HttpClient from "effect/http/HttpClient";
@@ -229,47 +228,54 @@ export const CursorDriver: ProviderDriver<
229228
},
230229
auth.usesApiKey ? "api-key" : "browser",
231230
).pipe(
232-
Effect.filterOrElse(
233-
(snapshot) =>
234-
!(
235-
effectiveConfig.enabled &&
236-
snapshot.installed &&
237-
snapshot.auth.status === "authenticated"
238-
),
239-
(snapshot) =>
240-
host.settings.get.pipe(
241-
Effect.flatMap((settings) =>
242-
readCursorUsageLimits(
243-
effectiveConfig,
244-
{ ...processEnv, CURSOR_API_KEY: apiKey },
245-
settings.cursorKeychainUsageEnabled,
231+
Effect.flatMap(({ provider: statusProvider, sdkModels }) =>
232+
Effect.succeed(statusProvider).pipe(
233+
Effect.filterOrElse(
234+
(snapshot) =>
235+
!(
236+
effectiveConfig.enabled &&
237+
snapshot.installed &&
238+
snapshot.auth.status === "authenticated"
239+
),
240+
(snapshot) =>
241+
host.settings.get.pipe(
242+
Effect.flatMap((settings) =>
243+
readCursorUsageLimits(
244+
effectiveConfig,
245+
{ ...processEnv, CURSOR_API_KEY: apiKey },
246+
settings.cursorKeychainUsageEnabled,
247+
),
248+
),
249+
Effect.map((usageLimits) => ({ ...snapshot, usageLimits })),
246250
),
247-
),
248-
Effect.map((usageLimits) => ({ ...snapshot, usageLimits })),
249251
),
252+
Effect.map((provider) => ({ provider, sdkModels })),
253+
),
250254
),
251255
),
252256
),
253257
Effect.provideService(HttpClient.HttpClient, httpClient),
254258
Effect.provideService(FileSystem.FileSystem, fileSystem),
255259
Effect.provideService(Path.Path, path),
256260
Effect.provideService(CursorKeychain.CursorKeychain, keychain),
257-
Effect.map(stampSnapshot),
258-
Effect.tap((provider) =>
259-
Effect.gen(function* () {
261+
Effect.map(({ provider, sdkModels }) => ({
262+
provider: stampSnapshot(provider),
263+
sdkModels,
264+
})),
265+
Effect.tap(({ provider, sdkModels }) =>
266+
Effect.sync(() => {
260267
// A failed check lists only custom models, so keep the last loaded catalog.
261268
if (provider.models.some((model) => !model.isCustom)) {
262269
catalogModels = provider.models;
263270
}
264-
const apiKey = yield* auth.readApiKey.pipe(Effect.orElseSucceed(() => undefined));
265-
if (apiKey === undefined || apiKey.trim() === "") return;
266-
const catalog = yield* CursorSdkCatalog.CursorSdkCatalog;
267-
const snapshot = yield* catalog.read(apiKey).pipe(Effect.option);
268-
if (Option.isSome(snapshot)) {
269-
catalogSdkModels = snapshot.value.models;
271+
// Reuse the timed status probe — a second unbounded catalog.read would
272+
// defeat the probe timeout when the first request stalled.
273+
if (sdkModels !== undefined) {
274+
catalogSdkModels = sdkModels;
270275
}
271276
}),
272277
),
278+
Effect.map(({ provider }) => provider),
273279
Effect.provide(CursorSdkCatalog.layer),
274280
);
275281

‎packages/provider-cursor/src/server/status.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("Cursor SDK model discovery", () => {
155155
describe("checkCursorProviderStatus", () => {
156156
it.effect("uses the SDK catalog when CURSOR_API_KEY is configured", () =>
157157
Effect.gen(function* () {
158-
const provider = yield* checkCursorProviderStatus(
158+
const { provider, sdkModels } = yield* checkCursorProviderStatus(
159159
{
160160
...baseCursorSettings,
161161
customModels: ["internal/cursor-model"],
@@ -190,12 +190,13 @@ describe("checkCursorProviderStatus", () => {
190190
{ slug: "internal/cursor-model", isCustom: true },
191191
],
192192
});
193+
expect(sdkModels).toEqual([sdkParameterizedModel]);
193194
}),
194195
);
195196

196197
it.effect("surfaces SDK authentication failures", () =>
197198
Effect.gen(function* () {
198-
const provider = yield* checkCursorProviderStatus(baseCursorSettings, {
199+
const { provider, sdkModels } = yield* checkCursorProviderStatus(baseCursorSettings, {
199200
CURSOR_API_KEY: "invalid-test-key",
200201
}).pipe(
201202
Effect.provide(
@@ -215,6 +216,7 @@ describe("checkCursorProviderStatus", () => {
215216
auth: { status: "unauthenticated" },
216217
message: "Cursor SDK authentication failed. Check CURSOR_API_KEY.",
217218
});
219+
expect(sdkModels).toBeUndefined();
218220
}),
219221
);
220222

@@ -233,7 +235,7 @@ describe("checkCursorProviderStatus", () => {
233235
"explains a rejected plan for $authenticationType authentication",
234236
({ authenticationType, message }) =>
235237
Effect.gen(function* () {
236-
const provider = yield* checkCursorProviderStatus(
238+
const { provider, sdkModels } = yield* checkCursorProviderStatus(
237239
baseCursorSettings,
238240
{ CURSOR_API_KEY: "free-plan-key" },
239241
authenticationType,
@@ -258,12 +260,13 @@ describe("checkCursorProviderStatus", () => {
258260
auth: { status: "unknown" },
259261
message,
260262
});
263+
expect(sdkModels).toBeUndefined();
261264
}),
262265
);
263266

264267
it.effect("requires a Cursor API key without probing any external Cursor binary", () =>
265268
Effect.gen(function* () {
266-
const provider = yield* checkCursorProviderStatus(baseCursorSettings).pipe(
269+
const { provider, sdkModels } = yield* checkCursorProviderStatus(baseCursorSettings).pipe(
267270
Effect.provide(
268271
CursorSdkCatalog.layerTest(() =>
269272
Effect.die("SDK catalog must not be used without CURSOR_API_KEY"),
@@ -277,6 +280,7 @@ describe("checkCursorProviderStatus", () => {
277280
auth: { status: "unauthenticated" },
278281
message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.",
279282
});
283+
expect(sdkModels).toBeUndefined();
280284
}),
281285
);
282286
});

‎packages/provider-cursor/src/server/status.ts‎

Lines changed: 86 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ const EMPTY_CAPABILITIES: ModelCapabilities = createModelCapabilities({
3434

3535
const CURSOR_SDK_CATALOG_TIMEOUT_MS = 15_000;
3636

37+
export interface CursorProviderStatusResult {
38+
readonly provider: ServerProviderDraft;
39+
readonly sdkModels: ReadonlyArray<SDKModel> | undefined;
40+
}
41+
3742
export const buildInitialCursorProviderSnapshot = Effect.fn(
3843
"CursorProviderStatus.buildInitialCursorProviderSnapshot",
3944
)(function* (cursorSettings: CursorSettings): Effect.fn.Return<ServerProviderDraft> {
@@ -248,41 +253,47 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
248253
cursorSettings: CursorSettings,
249254
environment?: NodeJS.ProcessEnv,
250255
authenticationType: "api-key" | "browser" = "api-key",
251-
): Effect.fn.Return<ServerProviderDraft, never, CursorSdkCatalog.CursorSdkCatalog> {
256+
): Effect.fn.Return<CursorProviderStatusResult, never, CursorSdkCatalog.CursorSdkCatalog> {
252257
const checkedAt = DateTime.formatIso(yield* DateTime.now);
253258
const fallbackModels = getCursorFallbackModels(cursorSettings);
254259

255260
if (!cursorSettings.enabled) {
256-
return buildServerProvider({
257-
presentation: CURSOR_PRESENTATION,
258-
enabled: false,
259-
checkedAt,
260-
models: fallbackModels,
261-
probe: {
262-
installed: false,
263-
version: null,
264-
status: "warning",
265-
auth: { status: "unknown" },
266-
message: "Cursor is disabled in T3 Code settings.",
267-
},
268-
});
261+
return {
262+
provider: buildServerProvider({
263+
presentation: CURSOR_PRESENTATION,
264+
enabled: false,
265+
checkedAt,
266+
models: fallbackModels,
267+
probe: {
268+
installed: false,
269+
version: null,
270+
status: "warning",
271+
auth: { status: "unknown" },
272+
message: "Cursor is disabled in T3 Code settings.",
273+
},
274+
}),
275+
sdkModels: undefined,
276+
};
269277
}
270278

271279
const sdkApiKey = environment?.CURSOR_API_KEY?.trim();
272280
if (!sdkApiKey) {
273-
return buildServerProvider({
274-
presentation: CURSOR_PRESENTATION,
275-
enabled: cursorSettings.enabled,
276-
checkedAt,
277-
models: fallbackModels,
278-
probe: {
279-
installed: true,
280-
version: null,
281-
status: "error",
282-
auth: { status: "unauthenticated" },
283-
message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.",
284-
},
285-
});
281+
return {
282+
provider: buildServerProvider({
283+
presentation: CURSOR_PRESENTATION,
284+
enabled: cursorSettings.enabled,
285+
checkedAt,
286+
models: fallbackModels,
287+
probe: {
288+
installed: true,
289+
version: null,
290+
status: "error",
291+
auth: { status: "unauthenticated" },
292+
message: "Sign in with Cursor or add CURSOR_API_KEY in provider settings.",
293+
},
294+
}),
295+
sdkModels: undefined,
296+
};
286297
}
287298

288299
const sdkCatalog = yield* CursorSdkCatalog.CursorSdkCatalog;
@@ -307,50 +318,59 @@ export const checkCursorProviderStatus = Effect.fn("checkCursorProviderStatus")(
307318
? "Cursor needs a paid plan to run in T3 Code. Upgrade this account or sign in with a different one."
308319
: "Cursor needs a paid plan to run in T3 Code. Upgrade the account that owns CURSOR_API_KEY or use a key from a paid account.";
309320
}
310-
return buildServerProvider({
311-
presentation: CURSOR_PRESENTATION,
312-
enabled: cursorSettings.enabled,
313-
checkedAt,
314-
models: fallbackModels,
315-
probe: {
316-
installed: true,
317-
version: null,
318-
status: "error",
319-
auth: { status: failure.authenticationFailure ? "unauthenticated" : "unknown" },
320-
message,
321-
},
322-
});
321+
return {
322+
provider: buildServerProvider({
323+
presentation: CURSOR_PRESENTATION,
324+
enabled: cursorSettings.enabled,
325+
checkedAt,
326+
models: fallbackModels,
327+
probe: {
328+
installed: true,
329+
version: null,
330+
status: "error",
331+
auth: { status: failure.authenticationFailure ? "unauthenticated" : "unknown" },
332+
message,
333+
},
334+
}),
335+
sdkModels: undefined,
336+
};
323337
}
324338

325339
if (Option.isNone(catalogResult.success)) {
326-
return buildServerProvider({
327-
presentation: CURSOR_PRESENTATION,
328-
enabled: cursorSettings.enabled,
329-
checkedAt,
330-
models: fallbackModels,
331-
probe: {
332-
installed: true,
333-
version: null,
334-
status: "error",
335-
auth: { status: "unknown" },
336-
message: `Cursor SDK catalog request timed out after ${CURSOR_SDK_CATALOG_TIMEOUT_MS}ms.`,
337-
},
338-
});
340+
return {
341+
provider: buildServerProvider({
342+
presentation: CURSOR_PRESENTATION,
343+
enabled: cursorSettings.enabled,
344+
checkedAt,
345+
models: fallbackModels,
346+
probe: {
347+
installed: true,
348+
version: null,
349+
status: "error",
350+
auth: { status: "unknown" },
351+
message: `Cursor SDK catalog request timed out after ${CURSOR_SDK_CATALOG_TIMEOUT_MS}ms.`,
352+
},
353+
}),
354+
sdkModels: undefined,
355+
};
339356
}
340357

341358
const snapshot = catalogResult.success.value;
342359
const discoveredModels = buildCursorDiscoveredModelsFromSdk(snapshot.models);
343-
return buildCursorProviderSnapshot({
344-
checkedAt,
345-
cursorSettings,
346-
parsed: {
347-
version: null,
348-
status: "ready",
349-
auth: cursorSdkAuth(snapshot.user, authenticationType),
350-
},
351-
discoveredModels,
352-
...(discoveredModels.length === 0
353-
? { discoveryWarning: "Cursor SDK model discovery returned no built-in models." }
354-
: {}),
355-
});
360+
return {
361+
provider: buildCursorProviderSnapshot({
362+
checkedAt,
363+
cursorSettings,
364+
parsed: {
365+
version: null,
366+
status: "ready",
367+
auth: cursorSdkAuth(snapshot.user, authenticationType),
368+
},
369+
discoveredModels,
370+
...(discoveredModels.length === 0
371+
? { discoveryWarning: "Cursor SDK model discovery returned no built-in models." }
372+
: {}),
373+
}),
374+
sdkModels: snapshot.models,
375+
};
356376
});

0 commit comments

Comments
 (0)