Skip to content

Commit 39a7def

Browse files
committed
reformat
1 parent ab608c8 commit 39a7def

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/telemetry/telemetry.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ type EventResult = {
1212
};
1313

1414
/**
15-
* Checks if telemetry is currently enabled
16-
* This is a method rather than a constant to capture runtime config changes
17-
*
18-
* Follows the Console Do Not Track standard (https://consoledonottrack.com/)
19-
* by respecting the DO_NOT_TRACK environment variable
20-
*/
15+
* Checks if telemetry is currently enabled
16+
* This is a method rather than a constant to capture runtime config changes
17+
*
18+
* Follows the Console Do Not Track standard (https://consoledonottrack.com/)
19+
* by respecting the DO_NOT_TRACK environment variable
20+
*/
2121
export function isTelemetryEnabled(): boolean {
2222
// Check if telemetry is explicitly disabled in config
2323
if (config.telemetry === "disabled") {

src/tools/mongodb/mongodbTool.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export abstract class MongoDBToolBase extends ToolBase {
7575
return this.session.connectToMongoDB(connectionString, this.config.connectOptions);
7676
}
7777

78-
protected resolveToolMetadata(args: { [x: string]: any; }, extra: RequestHandlerExtra<ServerRequest, ServerNotification>): ToolMetadata {
78+
protected resolveToolMetadata(
79+
args: { [x: string]: any },
80+
extra: RequestHandlerExtra<ServerRequest, ServerNotification>
81+
): ToolMetadata {
7982
const metadata = super.resolveToolMetadata(args, extra);
8083

8184
// Add projectId to the metadata if running a MongoDB operation to an Atlas cluster

src/tools/tool.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { McpServer, RegisteredTool, ToolCallback } from "@modelcontextproto
33
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
44
import { Session } from "../session.js";
55
import logger, { LogId } from "../logger.js";
6-
import { Telemetry, isTelemetryEnabled } from "../telemetry/telemetry.js";
7-
import { type ToolEvent} from "../telemetry/types.js";
6+
import { Telemetry, isTelemetryEnabled } from "../telemetry/telemetry.js";
7+
import { type ToolEvent } from "../telemetry/types.js";
88
import { UserConfig } from "../config.js";
99

1010
export type ToolArgs<Args extends ZodRawShape> = z.objectOutputType<Args, ZodNever>;
@@ -14,7 +14,7 @@ export type ToolCategory = "mongodb" | "atlas";
1414
export type ToolMetadata = {
1515
projectId?: string;
1616
orgId?: string;
17-
}
17+
};
1818

1919
export abstract class ToolBase {
2020
protected abstract name: string;
@@ -27,7 +27,6 @@ export abstract class ToolBase {
2727

2828
protected abstract argsShape: ZodRawShape;
2929

30-
3130
protected abstract execute(...args: Parameters<ToolCallback<typeof this.argsShape>>): Promise<CallToolResult>;
3231

3332
constructor(
@@ -133,17 +132,14 @@ export abstract class ToolBase {
133132
};
134133
}
135134

136-
137135
/**
138-
*
136+
*
139137
* Resolves the tool metadata from the arguments passed to the tool
140-
*
138+
*
141139
* @param args - The arguments passed to the tool
142140
* @returns The tool metadata
143141
*/
144-
protected resolveToolMetadata(
145-
...args: Parameters<ToolCallback<typeof this.argsShape>>
146-
): ToolMetadata {
142+
protected resolveToolMetadata(...args: Parameters<ToolCallback<typeof this.argsShape>>): ToolMetadata {
147143
const toolMetadata: ToolMetadata = {};
148144
try {
149145
// Parse the arguments to extract project_id and org_id
@@ -156,21 +152,23 @@ export abstract class ToolBase {
156152
if (parsedArgs.success && parsedArgs.data?.orgId) {
157153
toolMetadata.orgId = parsedArgs.data?.orgId;
158154
}
159-
}
160-
catch (error) {
155+
} catch (error) {
161156
logger.info(LogId.telmetryMetadataError, "tool", `Error resolving tool metadata: ${error as string}`);
162157
}
163158
return toolMetadata;
164159
}
165160

166-
167161
/**
168162
* Creates and emits a tool telemetry event
169163
* @param startTime - Start time in milliseconds
170164
* @param result - Whether the command succeeded or failed
171165
* @param args - The arguments passed to the tool
172166
*/
173-
private async emitToolEvent(startTime: number, result: CallToolResult, ...args: Parameters<ToolCallback<typeof this.argsShape>>): Promise<void> {
167+
private async emitToolEvent(
168+
startTime: number,
169+
result: CallToolResult,
170+
...args: Parameters<ToolCallback<typeof this.argsShape>>
171+
): Promise<void> {
174172
if (!isTelemetryEnabled()) {
175173
return;
176174
}

0 commit comments

Comments
 (0)