Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7dc352f
chore(deps): migrate Database Tools to mongodb-mcp-server v3
gagik Oct 14, 2026
13e0ef6
test(compass-generative-ai): exercise MCP server startup failure path
gagik Oct 15, 2026
796bcb1
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Oct 15, 2026
bdbbf0d
fix(compass-generative-ai): restore MCP telemetry for Database Tools
gagik Oct 15, 2026
0127c81
fix(compass-generative-ai): keep MCP telemetry inert while disabled
gagik Oct 15, 2026
707d48e
refactor(compass-generative-ai): split MCP telemetry into its own mod…
gagik Oct 15, 2026
f2fdf74
refactor(compass-generative-ai): let CompassMcpTelemetry own its tear…
gagik Oct 15, 2026
082acf6
docs(compass-generative-ai): point the telemetry field shadows at the…
gagik Oct 16, 2026
22420cd
test(compass-generative-ai): cover the telemetry preference set befor…
gagik Oct 16, 2026
04443e8
docs(compass-generative-ai): point the MCP service workarounds at the…
gagik Oct 16, 2026
66a83f9
test: restore the telemetry sync test and cover the disabled paths
gagik Oct 16, 2026
a6f75ce
test(compass-generative-ai): drop the DO_NOT_TRACK case
gagik Oct 16, 2026
c76e352
docs(compass-generative-ai): point the MCP workaround TODOs at the co…
gagik Oct 16, 2026
84c948b
test(compass-generative-ai): assert MCP telemetry actually reaches th…
gagik Oct 27, 2026
7389247
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Oct 27, 2026
4e10b9a
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Oct 27, 2026
0651f4d
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Oct 29, 2026
fca11a6
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Nov 6, 2026
3bb3767
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Nov 6, 2026
8a671e5
fix(compass-utilities): keep the ai-assistant utility entry free of e…
gagik Nov 6, 2026
b4988c8
chore(compass-generative-ai): upgrade @mongodb-js/mcp-* to 3.2.2
gagik Nov 6, 2026
89fff47
fix(compass-generative-ai): use the preset Atlas base URL for MCP tel…
gagik Nov 6, 2026
eb66376
fix(compass-generative-ai): report the Compass version in MCP server …
gagik Nov 6, 2026
6fdf3c7
docs(compass-generative-ai): trim MCP migration comments
gagik Nov 6, 2026
35d9551
fix(e2e-tests): wait for the assistant confirmation before asserting
gagik Nov 6, 2026
225386d
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik Nov 9, 2026
66eba8b
refactor(compass-generative-ai): move ToolsConnectionRegistry to its …
gagik Nov 9, 2026
7e0edec
fix(webpack-config-compass): pin webpack to 5.107.0
gagik Nov 9, 2026
5c30fcc
chore(compass-utilities): restore the ai-assistant utility entry
gagik Nov 9, 2026
823b31a
chore(webpack-config-compass): keep the caret range for webpack
gagik Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,164 changes: 390 additions & 1,774 deletions package-lock.json
Comment thread
esvm marked this conversation as resolved.
Resolved

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ describe('CompassAssistantProvider', function () {
enableToolCalling = true,
enableGenAIToolCallingAtlasProject = true,
enableGenAIToolCalling = true,
trackUsageStatistics,
maxTimeMS,
query,
pipeline,
Expand All @@ -365,6 +366,7 @@ describe('CompassAssistantProvider', function () {
enableToolCalling?: boolean;
enableGenAIToolCallingAtlasProject?: boolean;
enableGenAIToolCalling?: boolean;
trackUsageStatistics?: boolean;
maxTimeMS?: number;
query?: string;
pipeline?: string;
Expand Down Expand Up @@ -395,6 +397,9 @@ describe('CompassAssistantProvider', function () {
enableToolCalling,
enableGenAIToolCallingAtlasProject,
enableGenAIToolCalling,
...(trackUsageStatistics !== undefined
? { trackUsageStatistics }
: {}),
maxTimeMS,
},
}
Expand Down Expand Up @@ -696,6 +701,41 @@ describe('CompassAssistantProvider', function () {
});
});

it('disables MCP telemetry when usage statistics are off', async function () {
const mockChat = createChat({ messages: [] });
const sendMessageSpy = sinon.spy(mockChat, 'sendMessage');
const mockToolsController = {
setActiveTools: sinon.stub(),
getActiveTools: sinon.stub(),
setContext: sinon.stub(),
startServer: sinon.stub().resolves(),
stopServer: sinon.stub().resolves(),
setConnectionIdForToolCall: sinon.stub(),
};

await renderOpenAssistantDrawer({
chat: mockChat,
toolsController: mockToolsController,
enableToolCalling: true,
trackUsageStatistics: false,
});

userEvent.type(
screen.getByPlaceholderText('Ask a question'),
'Hello assistant'
);
userEvent.click(screen.getByLabelText('Send message'));

await waitFor(() => {
expect(sendMessageSpy.calledOnce).to.be.true;
});

expect(mockToolsController.setContext.callCount).to.equal(1);
expect(mockToolsController.setContext.firstCall.args[0]).to.deep.include({
enableMCPTelemetry: false,
});
});

it('disables tools if enableToolCalling and enableGenAIToolCallingAtlasProject are enabled but enableGenAIToolCalling setting is disabled', async function () {
const mockChat = createChat({
messages: [
Expand Down
24 changes: 16 additions & 8 deletions packages/compass-e2e-tests/tests/assistant-mocked.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,32 @@ describe('MongoDB Assistant (with mocked backend)', function () {

const chatMessages = browser.$(Selectors.AssistantChatMessages);
await chatMessages.waitForDisplayed();
expect(await chatMessages.getText()).to.include(
'Please confirm your request'
// The confirmation is appended once the assistant tools have
// started, so wait for it rather than reading the chat as soon as
// the drawer opens
await browser.waitUntil(async () =>
(await chatMessages.getText()).includes(
'Please confirm your request'
)
);

// Click Cancel button
await browser.clickVisible('button*=Cancel');

// Wait a bit to ensure no request is sent
await browser.waitUntil(async () =>
(await chatMessages.getText()).includes('Request cancelled')
);

// Wait a bit to ensure a wrongly sent request would have been
// recorded by the mock server by now
await browser.pause(300);

const finalMessages = await browser.getDisplayedMessages();
expect(finalMessages.length).to.equal(0);

expect(await chatMessages.getText()).to.include(
'Please confirm your request'
);

expect(await chatMessages.getText()).to.include('Request cancelled');
const finalText = await chatMessages.getText();
expect(finalText).to.include('Please confirm your request');
expect(finalText).to.include('Request cancelled');

// Verify no assistant request was made
expect(mockAssistantServer.getRequests()).to.be.empty;
Expand Down
6 changes: 5 additions & 1 deletion packages/compass-generative-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"@mongodb-js/compass-logging": "^1.19.1",
"@mongodb-js/compass-preferences-model": "^3.9.0",
"@mongodb-js/compass-telemetry": "^1.37.1",
"@mongodb-js/mcp-atlas-api-client": "^3.2.2",
"@mongodb-js/mcp-atlas-telemetry": "^3.2.2",
"@mongodb-js/mcp-core": "^3.2.2",
"@mongodb-js/mcp-tools-mongodb": "^3.2.2",
"@mongodb-js/mcp-types": "^3.2.2",
"@mongodb-js/mock-data-generator": "^1.2.1",
"@mongodb-js/mongodb-build-info": "^1.9.19",
"@mongodb-js/mongodb-schema": "^12.8.11",
Expand All @@ -77,7 +82,6 @@
"ipaddr.js": "^2.5.0",
"mongodb": "^7.5.0",
"mongodb-connection-string-url": "^7.0.2",
"mongodb-mcp-server": "^1.10.0",
"react": "^18.3.1",
"react-redux": "^8.1.3",
"redux": "^4.2.1",
Expand Down
99 changes: 99 additions & 0 deletions packages/compass-generative-ai/src/compass-mcp-telemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { AtlasTelemetry } from '@mongodb-js/mcp-atlas-telemetry';
import type {
TelemetryBaseEvent,
TelemetryConfig,
} from '@mongodb-js/mcp-atlas-telemetry';
import {
ApiClient,
userAgentFromServerMetadata,
type HttpClient,
} from '@mongodb-js/mcp-atlas-api-client';
import type { LoggerBase } from '@mongodb-js/mcp-core';
import type {
IKeychain,
ServerMetadata,
TelemetryCommonProperties,
} from '@mongodb-js/mcp-types';
import { LazyDeviceId } from './lazy-device-id';

const ATLAS_API_BASE_URL = 'https://cloud.mongodb.com/';
Comment thread
esvm marked this conversation as resolved.
Resolved

// Compass only ever runs this in a browser or the Electron renderer.
const httpClient: HttpClient = {
fetch: (...args) => globalThis.fetch(...args),
Request: globalThis.Request,
};

export type CompassMcpTelemetryConfig = {
logger: LoggerBase;
keychain: IKeychain;
serverMetadata: ServerMetadata;
/** Atlas API base URL. Defaults to production when not provided. */
apiBaseUrl?: string;
};

/**
* MCP telemetry for Compass's in-memory Database Tools server. Nothing is set
* up until the first event the usage-statistics preference allows through.
*/
export class CompassMcpTelemetry extends AtlasTelemetry {
private readonly isEnabled: () => boolean;
private setupStarted = false;

constructor(config: TelemetryConfig, isEnabled: () => boolean) {
super(config);
this.isEnabled = isEnabled;
}

public override isTelemetryEnabled(): boolean {
return this.isEnabled() && super.isTelemetryEnabled();
}

public override emitEvents(events: TelemetryBaseEvent[]): void {
// ToolBase checks isTelemetryEnabled() first, so setup only runs for
// allowed events.
if (this.isTelemetryEnabled() && !this.setupStarted) {
this.setupStarted = true;
void this.setup();
}
super.emitEvents(events);
}

public override async close(): Promise<void> {
// Abort first: `super.close()` waits for setup, which waits on the machine id.
this.deviceId.close();
// Flush before releasing the client the drain sends through.
await super.close();
await this.apiClient.close();
}

public override getCommonProperties(): TelemetryCommonProperties {
return {
...super.getCommonProperties(),
hosting_mode: 'compass',
};
}
}

export function createCompassMcpTelemetry(
config: CompassMcpTelemetryConfig,
isEnabled: () => boolean
): CompassMcpTelemetry {
return new CompassMcpTelemetry(
{
...config,
// Always true so the live preference is the only gate.
enabled: true,
deviceId: new LazyDeviceId(config.logger),
apiClient: new ApiClient({
options: {
baseUrl: config.apiBaseUrl ?? ATLAS_API_BASE_URL,
userAgent: userAgentFromServerMetadata(config.serverMetadata),
httpClient,
},
logger: config.logger,
}),
},
isEnabled
);
}
22 changes: 22 additions & 0 deletions packages/compass-generative-ai/src/lazy-device-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DeviceId } from '@mongodb-js/mcp-tools-mongodb';
import type { LoggerBase } from '@mongodb-js/mcp-core';
import type { IDeviceId } from '@mongodb-js/mcp-types';

/** Resolves the machine id on first use so it is never read while telemetry is off. */
export class LazyDeviceId implements IDeviceId {
private readonly logger: LoggerBase;
private resolved?: DeviceId;

constructor(logger: LoggerBase) {
this.logger = logger;
}

get(): Promise<string> {
this.resolved ??= DeviceId.create(this.logger);
return this.resolved.get();
}

close(): void {
this.resolved?.close();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {
ConnectionErrorUnhandled,
ConnectionErrorHandler,
} from 'mongodb-mcp-server';
} from '@mongodb-js/mcp-tools-mongodb';

/**
* Creates a connection error handler for mongodb-mcp-server in Compass.
Expand Down
Loading
Loading