Skip to content

Commit f1f1055

Browse files
committed
chore: add hints
1 parent a7e03f7 commit f1f1055

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"yaml": "^2.7.1"
6161
},
6262
"dependencies": {
63-
"@modelcontextprotocol/sdk": "^1.8.0",
63+
"@modelcontextprotocol/sdk": "^1.11.2",
6464
"@mongodb-js/device-id": "^0.2.1",
6565
"@mongodb-js/devtools-connect": "^3.7.2",
6666
"@mongosh/service-provider-node-driver": "^3.6.0",

src/common/atlas/apiClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export class ApiClient {
3434

3535
private getAccessToken = async () => {
3636
if (this.oauth2Client && (!this.accessToken || this.accessToken.expired())) {
37-
this.accessToken = await this.oauth2Client.getToken({});
37+
this.accessToken = await this.oauth2Client.getToken({
38+
agent: this.options.userAgent,
39+
});
3840
}
3941
return this.accessToken?.token.access_token as string | undefined;
4042
};

src/tools/tool.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z, type ZodRawShape, type ZodNever, AnyZodObject } from "zod";
22
import type { McpServer, RegisteredTool, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
3-
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3+
import { ToolAnnotationsSchema, type CallToolResult, type ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
44
import { Session } from "../session.js";
55
import logger, { LogId } from "../logger.js";
66
import { Telemetry } from "../telemetry/telemetry.js";
@@ -27,13 +27,17 @@ export abstract class ToolBase {
2727

2828
protected abstract argsShape: ZodRawShape;
2929

30+
protected abstract annotations: ToolAnnotations;
31+
3032
protected abstract execute(...args: Parameters<ToolCallback<typeof this.argsShape>>): Promise<CallToolResult>;
3133

3234
constructor(
3335
protected readonly session: Session,
3436
protected readonly config: UserConfig,
3537
protected readonly telemetry: Telemetry
36-
) {}
38+
) {
39+
this.updateAnnotations();
40+
}
3741

3842
public register(server: McpServer): void {
3943
if (!this.verifyAllowed()) {
@@ -56,7 +60,7 @@ export abstract class ToolBase {
5660
}
5761
};
5862

59-
server.tool(this.name, this.description, this.argsShape, callback);
63+
server.tool(this.name, this.description, this.argsShape, this.annotations, callback);
6064

6165
// This is very similar to RegisteredTool.update, but without the bugs around the name.
6266
// In the upstream update method, the name is captured in the closure and not updated when
@@ -132,6 +136,19 @@ export abstract class ToolBase {
132136
};
133137
}
134138

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+
135152
protected abstract resolveTelemetryMetadata(
136153
...args: Parameters<ToolCallback<typeof this.argsShape>>
137154
): TelemetryToolMetadata;

0 commit comments

Comments
 (0)