@@ -3,8 +3,8 @@ import type { McpServer, RegisteredTool, ToolCallback } from "@modelcontextproto
3
3
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
4
4
import { Session } from "../session.js" ;
5
5
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" ;
8
8
import { UserConfig } from "../config.js" ;
9
9
10
10
export type ToolArgs < Args extends ZodRawShape > = z . objectOutputType < Args , ZodNever > ;
@@ -14,7 +14,7 @@ export type ToolCategory = "mongodb" | "atlas";
14
14
export type ToolMetadata = {
15
15
projectId ?: string ;
16
16
orgId ?: string ;
17
- }
17
+ } ;
18
18
19
19
export abstract class ToolBase {
20
20
protected abstract name : string ;
@@ -27,7 +27,6 @@ export abstract class ToolBase {
27
27
28
28
protected abstract argsShape : ZodRawShape ;
29
29
30
-
31
30
protected abstract execute ( ...args : Parameters < ToolCallback < typeof this . argsShape > > ) : Promise < CallToolResult > ;
32
31
33
32
constructor (
@@ -133,17 +132,14 @@ export abstract class ToolBase {
133
132
} ;
134
133
}
135
134
136
-
137
135
/**
138
- *
136
+ *
139
137
* Resolves the tool metadata from the arguments passed to the tool
140
- *
138
+ *
141
139
* @param args - The arguments passed to the tool
142
140
* @returns The tool metadata
143
141
*/
144
- protected resolveToolMetadata (
145
- ...args : Parameters < ToolCallback < typeof this . argsShape > >
146
- ) : ToolMetadata {
142
+ protected resolveToolMetadata ( ...args : Parameters < ToolCallback < typeof this . argsShape > > ) : ToolMetadata {
147
143
const toolMetadata : ToolMetadata = { } ;
148
144
try {
149
145
// Parse the arguments to extract project_id and org_id
@@ -156,21 +152,23 @@ export abstract class ToolBase {
156
152
if ( parsedArgs . success && parsedArgs . data ?. orgId ) {
157
153
toolMetadata . orgId = parsedArgs . data ?. orgId ;
158
154
}
159
- }
160
- catch ( error ) {
155
+ } catch ( error ) {
161
156
logger . info ( LogId . telmetryMetadataError , "tool" , `Error resolving tool metadata: ${ error as string } ` ) ;
162
157
}
163
158
return toolMetadata ;
164
159
}
165
160
166
-
167
161
/**
168
162
* Creates and emits a tool telemetry event
169
163
* @param startTime - Start time in milliseconds
170
164
* @param result - Whether the command succeeded or failed
171
165
* @param args - The arguments passed to the tool
172
166
*/
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 > {
174
172
if ( ! isTelemetryEnabled ( ) ) {
175
173
return ;
176
174
}
0 commit comments