Repository navigation
chore(compass-assistant): migrate Database Tools to mongodb-mcp-server v3 COMPASS-11280 #8580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 13e0ef6
test(compass-generative-ai): exercise MCP server startup failure path
gagik 796bcb1
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik bdbbf0d
fix(compass-generative-ai): restore MCP telemetry for Database Tools
gagik 0127c81
fix(compass-generative-ai): keep MCP telemetry inert while disabled
gagik 707d48e
refactor(compass-generative-ai): split MCP telemetry into its own mod…
gagik f2fdf74
refactor(compass-generative-ai): let CompassMcpTelemetry own its tear…
gagik 082acf6
docs(compass-generative-ai): point the telemetry field shadows at the…
gagik 22420cd
test(compass-generative-ai): cover the telemetry preference set befor…
gagik 04443e8
docs(compass-generative-ai): point the MCP service workarounds at the…
gagik 66a83f9
test: restore the telemetry sync test and cover the disabled paths
gagik a6f75ce
test(compass-generative-ai): drop the DO_NOT_TRACK case
gagik c76e352
docs(compass-generative-ai): point the MCP workaround TODOs at the co…
gagik 84c948b
test(compass-generative-ai): assert MCP telemetry actually reaches th…
gagik 7389247
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik 4e10b9a
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik 0651f4d
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik fca11a6
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik 3bb3767
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik 8a671e5
fix(compass-utilities): keep the ai-assistant utility entry free of e…
gagik b4988c8
chore(compass-generative-ai): upgrade @mongodb-js/mcp-* to 3.2.2
gagik 89fff47
fix(compass-generative-ai): use the preset Atlas base URL for MCP tel…
gagik eb66376
fix(compass-generative-ai): report the Compass version in MCP server …
gagik 6fdf3c7
docs(compass-generative-ai): trim MCP migration comments
gagik 35d9551
fix(e2e-tests): wait for the assistant confirmation before asserting
gagik 225386d
Merge remote-tracking branch 'origin/main' into gagik/mcp-server-v3
gagik 66eba8b
refactor(compass-generative-ai): move ToolsConnectionRegistry to its …
gagik 7e0edec
fix(webpack-config-compass): pin webpack to 5.107.0
gagik 5c30fcc
chore(compass-utilities): restore the ai-assistant utility entry
gagik 823b31a
chore(webpack-config-compass): keep the caret range for webpack
gagik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/compass-generative-ai/src/compass-mcp-telemetry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/'; | ||
|
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 | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
packages/compass-generative-ai/src/tools-connection-error-handler.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.