Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"yaml": "^2.7.1"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.8.0",
"@modelcontextprotocol/sdk": "^1.11.2",
"@mongodb-js/device-id": "^0.2.1",
"@mongodb-js/devtools-connect": "^3.7.2",
"@mongosh/service-provider-node-driver": "^3.6.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/atlas/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class ApiClient {

private getAccessToken = async () => {
if (this.oauth2Client && (!this.accessToken || this.accessToken.expired())) {
this.accessToken = await this.oauth2Client.getToken({});
this.accessToken = await this.oauth2Client.getToken({
agent: this.options.userAgent,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flyby - user agents

});
}
return this.accessToken?.token.access_token as string | undefined;
};
Expand Down
23 changes: 20 additions & 3 deletions src/tools/tool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z, type ZodRawShape, type ZodNever, AnyZodObject } from "zod";
import type { McpServer, RegisteredTool, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { ToolAnnotationsSchema, type CallToolResult, type ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
import { Session } from "../session.js";
import logger, { LogId } from "../logger.js";
import { Telemetry } from "../telemetry/telemetry.js";
Expand All @@ -27,13 +27,17 @@

protected abstract argsShape: ZodRawShape;

protected abstract annotations: ToolAnnotations;

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

constructor(
protected readonly session: Session,
protected readonly config: UserConfig,
protected readonly telemetry: Telemetry
) {}
) {
this.updateAnnotations();
}

public register(server: McpServer): void {
if (!this.verifyAllowed()) {
Expand All @@ -56,7 +60,7 @@
}
};

server.tool(this.name, this.description, this.argsShape, callback);
server.tool(this.name, this.description, this.argsShape, this.annotations, callback);

// This is very similar to RegisteredTool.update, but without the bugs around the name.
// In the upstream update method, the name is captured in the closure and not updated when
Expand Down Expand Up @@ -132,6 +136,19 @@
};
}

protected updateAnnotations() {
this.annotations: ToolAnnotationsSchema = {

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (ubuntu-latest)

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (macos-latest)

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / check-generate

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Run Atlas tests

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Check dependencies

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / check-style

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Run MongoDB tests (windows-latest)

';' expected.

Check failure on line 140 in src/tools/tool.ts

View workflow job for this annotation

GitHub Actions / Report Coverage

';' expected.
description: this.description,
};
if (this.operationType === "read") {
this.annotations.readOnlyHint = true;
}

if (this.operationType == "delete") {
this.annotations.destructiveHint = true;
}
}

protected abstract resolveTelemetryMetadata(
...args: Parameters<ToolCallback<typeof this.argsShape>>
): TelemetryToolMetadata;
Expand Down
Loading