fix(server): preserve ambient Cursor MCP servers (#15875)
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
2625327090
commit
c09c235129
2 files changed
+15
-1
No files matched your search
@@ -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);
|
||||
|
||||
@@ -2206,12 +2206,12 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
|
||||
const message = yield* resolveUserMessage(turnInput, mcpServers);
|
||||
const pendingUpdates: Array<InteractionUpdate> = [];
|
||||
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) {
|
||||
|
||||
Reference in new issue
Block a user