• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 19166075826

07 Nov 2025 10:49AM UTC coverage: 80.026% (-0.1%) from 80.151%
19166075826

Pull #716

github

web-flow
Merge b5964dd5c into 454e81617
Pull Request #716: chore: add connection metadata to telemetry

1363 of 1802 branches covered (75.64%)

Branch coverage included in aggregate %.

21 of 51 new or added lines in 7 files covered. (41.18%)

8 existing lines in 1 file now uncovered.

6490 of 8011 relevant lines covered (81.01%)

70.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/tools/atlasLocal/connect/connectDeployment.ts
1
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
import { AtlasLocalToolBase } from "../atlasLocalTool.js";
3✔
3
import type { OperationType, ToolArgs } from "../../tool.js";
4
import type { Client } from "@mongodb-js/atlas-local";
5
import { CommonArgs } from "../../args.js";
3✔
6
import type { ConnectionMetadata } from "../../../telemetry/types.js";
7

8
export class ConnectDeploymentTool extends AtlasLocalToolBase {
3✔
9
    public name = "atlas-local-connect-deployment";
85✔
10
    protected description = "Connect to a MongoDB Atlas Local deployment";
85✔
11
    public operationType: OperationType = "connect";
85✔
12
    protected argsShape = {
85✔
13
        deploymentName: CommonArgs.string().describe("Name of the deployment to connect to"),
85✔
14
    };
85✔
15

16
    protected async executeWithAtlasLocalClient(
3✔
17
        client: Client,
3✔
18
        { deploymentName }: ToolArgs<typeof this.argsShape>
3✔
19
    ): Promise<CallToolResult> {
3✔
20
        // Get the connection string for the deployment
21
        const connectionString = await client.getConnectionString(deploymentName);
3✔
22

23
        // Connect to the deployment
24
        await this.session.connectToMongoDB({ connectionString });
2✔
25

26
        return {
2✔
27
            content: [
2✔
28
                {
2✔
29
                    type: "text",
2✔
30
                    text: `Successfully connected to Atlas Local deployment "${deploymentName}".`,
2✔
31
                },
2✔
32
            ],
2✔
33
            _meta: {
2✔
34
                ...(await this.lookupTelemetryMetadata(client, deploymentName)),
2✔
35
            },
2✔
36
        };
2✔
37
    }
3✔
38

39
    protected override resolveTelemetryMetadata(result: CallToolResult): ConnectionMetadata {
3✔
NEW
40
        const parentMetadata = super.resolveTelemetryMetadata(result);
×
NEW
41
        const connectionMetadata = this.getConnectionInfoMetadata();
×
42
        // Explicitly merge, preferring parentMetadata for known overlapping keys (project_id, org_id)
43
        // since parent has deployment-specific information
NEW
44
        const { project_id, org_id, ...restConnectionMetadata } = connectionMetadata;
×
NEW
45
        const finalProjectId = parentMetadata.project_id ?? project_id;
×
NEW
46
        const finalOrgId = parentMetadata.org_id ?? org_id;
×
NEW
47
        return {
×
NEW
48
            ...parentMetadata,
×
NEW
49
            ...restConnectionMetadata,
×
50
            // Only include project_id and org_id if they are defined
NEW
51
            ...(finalProjectId !== undefined && { project_id: finalProjectId }),
×
NEW
52
            ...(finalOrgId !== undefined && { org_id: finalOrgId }),
×
NEW
53
        };
×
NEW
54
    }
×
55
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc