Skip to content

Commit 4477c4d

Browse files
committed
update
1 parent 1e31d68 commit 4477c4d

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/tools/mongodb/metadata/listDatabases.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export class ListDatabasesTool extends MongoDBToolBase {
77
protected name = "list-databases";
88
protected description = "List all databases for a MongoDB connection";
99
protected argsShape = {};
10-
1110
protected operationType: OperationType = "metadata";
1211

1312
protected async execute(): Promise<CallToolResult> {

src/tools/tool.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@ export abstract class ToolBase {
2727

2828
protected abstract argsShape: ZodRawShape;
2929

30-
protected abstract annotations: ToolAnnotations;
30+
protected get annotations(): ToolAnnotations {
31+
const annotations: ToolAnnotations = {
32+
title: this.name,
33+
description: this.description,
34+
};
35+
36+
if (this.operationType === "read" || this.operationType === "metadata") {
37+
annotations.readOnlyHint = true;
38+
}
39+
40+
if (this.operationType === "delete") {
41+
annotations.destructiveHint = true;
42+
}
43+
44+
return annotations;
45+
}
3146

3247
protected abstract execute(...args: Parameters<ToolCallback<typeof this.argsShape>>): Promise<CallToolResult>;
3348

3449
constructor(
3550
protected readonly session: Session,
3651
protected readonly config: UserConfig,
3752
protected readonly telemetry: Telemetry
38-
) {
39-
this.updateAnnotations();
40-
}
53+
) {}
4154

4255
public register(server: McpServer): void {
4356
if (!this.verifyAllowed()) {
@@ -136,19 +149,6 @@ export abstract class ToolBase {
136149
};
137150
}
138151

139-
protected updateAnnotations() {
140-
this.annotations: ToolAnnotationsSchema = {
141-
description: this.description,
142-
};
143-
if (this.operationType === "read") {
144-
this.annotations.readOnlyHint = true;
145-
}
146-
147-
if (this.operationType == "delete") {
148-
this.annotations.destructiveHint = true;
149-
}
150-
}
151-
152152
protected abstract resolveTelemetryMetadata(
153153
...args: Parameters<ToolCallback<typeof this.argsShape>>
154154
): TelemetryToolMetadata;

0 commit comments

Comments
 (0)