Skip to content

Commit 6b4371d

Browse files
committed
be precise for search index
1 parent 66102db commit 6b4371d

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/tools/mongodb/create/createSearchIndex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
22
import { DbOperationArgs, MongoDBToolBase, SearchIndexArgs } from "../mongodbTool.js";
33
import { OperationType, ToolArgs } from "../../tool.js";
44

5+
const SEARCH_INDEX_TYPE = "search";
6+
57
export class CreateSearchIndexTool extends MongoDBToolBase {
68
protected name = "create-search-index";
79
protected description = "Create an Atlas Search index for a collection";
810
protected argsShape = {
911
...DbOperationArgs,
1012
name: SearchIndexArgs.name,
11-
type: SearchIndexArgs.type,
1213
analyzer: SearchIndexArgs.analyzer,
1314
mappings: SearchIndexArgs.mappings,
1415
};
@@ -19,15 +20,14 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
1920
database,
2021
collection,
2122
name,
22-
type,
2323
analyzer,
2424
mappings,
2525
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2626
const provider = await this.ensureConnected();
2727
const indexes = await provider.createSearchIndexes(database, collection, [
2828
{
2929
name,
30-
type,
30+
type: SEARCH_INDEX_TYPE,
3131
definition: {
3232
analyzer,
3333
mappings,
@@ -38,7 +38,7 @@ export class CreateSearchIndexTool extends MongoDBToolBase {
3838
return {
3939
content: [
4040
{
41-
text: `Created the index "${indexes[0]}" on collection "${collection}" in database "${database}"`,
41+
text: `Created the search index "${indexes[0]}" on collection "${collection}" in database "${database}"`,
4242
type: "text",
4343
},
4444
],

src/tools/mongodb/mongodbTool.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const DbOperationArgs = {
1212

1313
export const SearchIndexArgs = {
1414
name: z.string().describe("The name of the index"),
15-
type: z.enum(["search", "vectorSearch"]).optional().default("search").describe("The type of the index"),
1615
analyzer: z
1716
.string()
1817
.optional()
@@ -42,7 +41,6 @@ export const SearchIndexArgs = {
4241
"document",
4342
"embeddedDocuments",
4443
"geo",
45-
"knnVector",
4644
"number",
4745
"objectId",
4846
"string",
@@ -61,7 +59,7 @@ export const SearchIndexArgs = {
6159
.describe("The field mapping definitions. If `dynamic` is set to false, this is required."),
6260
})
6361
.describe(
64-
"Document describing the index to create. The definition syntax depends on whether you create a standard search index or a Vector Search index."
62+
"Document describing the index to create."
6563
),
6664
};
6765

src/tools/mongodb/update/updateSearchIndex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { OperationType, ToolArgs } from "../../tool.js";
44

55
export class UpdateSearchIndexTool extends MongoDBToolBase {
66
protected name = "update-search-index";
7-
protected description = "Updates a search index for a collection";
7+
protected description = "Updates an Atlas Search index for a collection";
88
protected argsShape = {
99
...DbOperationArgs,
1010
name: SearchIndexArgs.name,
@@ -32,7 +32,7 @@ export class UpdateSearchIndexTool extends MongoDBToolBase {
3232
return {
3333
content: [
3434
{
35-
text: `Successfully updated index "${name}" on collection "${collection}" in database "${database}"`,
35+
text: `Successfully updated search index "${name}" on collection "${collection}" in database "${database}"`,
3636
type: "text",
3737
},
3838
],

0 commit comments

Comments
 (0)