Skip to content

Commit d148376

Browse files
committed
chore: rename agentRunner to mcpClient
1 parent 0c620b2 commit d148376

File tree

7 files changed

+31
-18
lines changed

7 files changed

+31
-18
lines changed

src/common/connectionManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class ConnectionManager extends EventEmitter<ConnectionManagerEvents> {
8888
connectionString: settings.connectionString,
8989
components: {
9090
appName: `${packageInfo.mcpServerName} ${packageInfo.version}`,
91-
// clientName: this.agentRunner?.name || "unknown", //TODO: MCP-68 - get client name from session
91+
// deviceId: deviceId, //TODO: MCP-68 - get deviceId from session
92+
// clientName: this.clientInfo?.name || "unknown",
93+
clientName: "unknown", //TODO: MCP-68 - get client name from session
9294
},
9395
});
9496

src/common/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const LogId = {
1414
serverClosed: mongoLogId(1_000_004),
1515
serverCloseFailure: mongoLogId(1_000_005),
1616
serverDuplicateLoggers: mongoLogId(1_000_006),
17+
serverMcpClientSet: mongoLogId(1_000_007),
1718

1819
atlasCheckCredentials: mongoLogId(1_001_001),
1920
atlasDeleteDatabaseUserFailure: mongoLogId(1_001_002),

src/common/session.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ export class Session extends EventEmitter<SessionEvents> {
3434
readonly exportsManager: ExportsManager;
3535
readonly connectionManager: ConnectionManager;
3636
readonly apiClient: ApiClient;
37-
agentRunner?: {
38-
name: string;
39-
version: string;
37+
mcpClient?: {
38+
name?: string;
39+
version?: string;
40+
title?: string;
4041
};
4142

4243
public logger: CompositeLogger;
@@ -69,13 +70,22 @@ export class Session extends EventEmitter<SessionEvents> {
6970
this.connectionManager.on("connection-errored", (error) => this.emit("connection-error", error.errorReason));
7071
}
7172

72-
setAgentRunner(agentRunner: Implementation | undefined): void {
73-
if (agentRunner?.name && agentRunner?.version) {
74-
this.agentRunner = {
75-
name: agentRunner.name,
76-
version: agentRunner.version,
77-
};
73+
setMcpClient(mcpClient: Implementation | undefined): void {
74+
if (!mcpClient) {
75+
this.mcpClient = undefined;
76+
this.logger.debug({
77+
id: LogId.serverMcpClientSet,
78+
context: "session",
79+
message: "MCP client info not found",
80+
});
81+
return;
7882
}
83+
84+
this.mcpClient = {
85+
name: mcpClient.name || "unknown",
86+
version: mcpClient.version || "unknown",
87+
title: mcpClient.title || "unknown",
88+
};
7989
}
8090

8191
async disconnect(): Promise<void> {

src/helpers/deviceId.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getDeviceId } from "@mongodb-js/device-id";
22
import nodeMachineId from "node-machine-id";
3-
import logger, { LogId } from "../common/logger.js";
3+
import { LogId, CompositeLogger } from "../common/logger.js";
44

55
export const DEVICE_ID_TIMEOUT = 3000;
66

@@ -13,11 +13,11 @@ export const DEVICE_ID_TIMEOUT = 3000;
1313
*
1414
* @example
1515
* ```typescript
16-
* const deviceId = await getDeviceIdForConnection();
16+
* const deviceId = await getDeviceIdForConnection(logger);
1717
* console.log(deviceId); // Outputs the device ID or "unknown" in case of failure
1818
* ```
1919
*/
20-
export async function getDeviceIdForConnection(): Promise<string> {
20+
export async function getDeviceIdForConnection(logger: CompositeLogger): Promise<string> {
2121
const controller = new AbortController();
2222

2323
try {

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ export class Server {
9797
});
9898

9999
this.mcpServer.server.oninitialized = (): void => {
100-
this.session.setAgentRunner(this.mcpServer.server.getClientVersion());
100+
this.session.setMcpClient(this.mcpServer.server.getClientVersion());
101101

102102
this.session.logger.info({
103103
id: LogId.serverInitialized,
104104
context: "server",
105-
message: `Server started with transport ${transport.constructor.name} and agent runner ${this.session.agentRunner?.name}`,
105+
message: `Server started with transport ${transport.constructor.name} and agent runner ${this.session.mcpClient?.name}`,
106106
});
107107

108108
this.emitServerEvent("start", Date.now() - this.startTime);

src/telemetry/telemetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ export class Telemetry {
9898
return {
9999
...this.commonProperties,
100100
transport: this.userConfig.transport,
101-
mcp_client_version: this.session.agentRunner?.version,
102-
mcp_client_name: this.session.agentRunner?.name,
101+
mcp_client_version: this.session.mcpClient?.version,
102+
mcp_client_name: this.session.mcpClient?.name,
103103
session_id: this.session.sessionId,
104104
config_atlas_auth: this.session.apiClient.hasCredentials() ? "true" : "false",
105105
config_connection_string: this.userConfig.connectionString ? "true" : "false",

tests/unit/common/session.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe("Session", () => {
8585
});
8686

8787
it("should include client name when agent runner is set", async () => {
88-
session.setAgentRunner({ name: "test-client", version: "1.0.0" });
88+
session.setMcpClient({ name: "test-client", version: "1.0.0" });
8989

9090
await session.connectToMongoDB("mongodb://localhost:27017", config.connectOptions);
9191
expect(session.serviceProvider).toBeDefined();

0 commit comments

Comments
 (0)