-
Notifications
You must be signed in to change notification settings - Fork 55
feat: Add drop-search-index tool #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
de22ac5
7ec6141
17f9022
98ac5bc
f1f2b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { z } from "zod"; | ||
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; | ||
import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js"; | ||
import { ToolArgs, OperationType } from "../../tool.js"; | ||
|
||
export class DropSearchIndexTool extends MongoDBToolBase { | ||
protected name = "drop-search-index"; | ||
protected description = | ||
"Deletes a text or vector search index from the database."; | ||
protected argsShape = { | ||
...DbOperationArgs, | ||
indexName: z.string().describe("The name of the search or vector index to delete"), | ||
}; | ||
protected operationType: OperationType = "delete"; | ||
|
||
protected async execute({ database, collection, indexName }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { | ||
const provider = await this.ensureConnected(); | ||
const result = await provider.dropSearchIndex(database, collection, indexName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Should the tool be a bit smarter and check whether the index exists first? If it doesn't, maybe we notify the LLM? I guess the more context LLM has, the better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
return { | ||
content: [ | ||
{ | ||
text: `"Successfully dropped index "${indexName}" from database "${database}"`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: looks like we don't need double quotes
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, see 17f9022 |
||
type: "text", | ||
}, | ||
], | ||
}; | ||
} | ||
} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to repeat this often, so let's register a
in mongodbTool.ts and import it here and use it on L16 and anywhere else we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, see 17f9022