diff --git a/packages/provider-cursor/src/server/adapter.test.ts b/packages/provider-cursor/src/server/adapter.test.ts index bbd813400da9d1934aa2bc6e17adadc225b7040a..01adb99515466431e76b8adc03c7fe1bacdb0197 100644 --- a/packages/provider-cursor/src/server/adapter.test.ts +++ b/packages/provider-cursor/src/server/adapter.test.ts @@ -55,6 +55,17 @@ describe("CursorAdapterV2", () => { }); const instanceId = ProviderInstanceId.make("cursor"); const threadId = ThreadId.make("cursor-lifecycle-thread"); + const mcpSessions = yield* McpProviderSessions.McpProviderSessions; + yield* mcpSessions.set({ + environmentId: EnvironmentId.make("cursor-lifecycle-environment"), + threadId, + providerSessionId: "cursor-lifecycle-session", + providerInstanceId: instanceId, + endpoint: "http://127.0.0.1:43123/mcp", + authorizationHeader: "Bearer synthetic-cursor-token", + browserToolsAvailable: true, + }); + let sentWithMcpOverride = true; const modelSelection = { instanceId, model: "composer-2.5" }; const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({ runtimeMode: "full-access", @@ -75,6 +86,7 @@ describe("CursorAdapterV2", () => { close: Effect.void, send: (input) => Effect.gen(function* () { + sentWithMcpOverride = Object.hasOwn(input.options ?? {}, "mcpServers"); // Recorded Cursor task calls (see fixtures/subagent) stream a // partial-tool-call before tool-call-started with the same args. // The run then ends without tool-call-completed, which a live @@ -184,6 +196,8 @@ describe("CursorAdapterV2", () => { Stream.takeUntil((event) => event.type === "turn.terminal"), Stream.runCollect, ); + // Keep injected MCP at agent creation so sends preserve Cursor's ambient servers. + assert.isFalse(sentWithMcpOverride); const rows = events.filter((event) => event.type === "subagent.updated"); assert.equal(rows[0]?.subagent.status, "running"); assert.equal(rows[0]?.subagent.model, model ?? null); diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts index f7cd8005eef5fa4b07055781d520bdac2e74531d..b77ec70ddcac3f646c656f520b2b181a5214268f 100644 --- a/packages/provider-cursor/src/server/adapter.ts +++ b/packages/provider-cursor/src/server/adapter.ts @@ -2206,12 +2206,12 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( const message = yield* resolveUserMessage(turnInput, mcpServers); const pendingUpdates: Array = []; let context: ActiveCursorTurn | null = null; + // MCP send overrides replace the ambient servers loaded when the agent opens. const sdkRun = yield* agent.session.send({ message, options: { model: cursorSdkModelSelection(turnInput.modelSelection), mode: turnInput.runtimePolicy.interactionMode === "plan" ? "plan" : "agent", - ...(mcpServers === undefined ? {} : { mcpServers }), }, onDelta: (update) => { if (context === null) {