Skip to content

Commit b40882d

Browse files
Prettier reformat
1 parent 0ba5de8 commit b40882d

File tree

3 files changed

+49
-44
lines changed

3 files changed

+49
-44
lines changed
Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
1-
import {DbOperationArgs, MongoDBToolBase} from "../mongodbTool.js";
2-
import {CallToolResult} from "@modelcontextprotocol/sdk/types.js";
1+
import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
2+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
33
import { ToolArgs, OperationType } from "../../tool.js";
4-
import {z} from "zod";
4+
import { z } from "zod";
55

66
export const ListSearchIndexesArgs = {
7-
indexName: z
8-
.string()
9-
.default('')
10-
.optional()
11-
.describe("The name of the index to return information about. Returns all indexes on collection if not provided."),
12-
}
7+
indexName: z
8+
.string()
9+
.default("")
10+
.optional()
11+
.describe(
12+
"The name of the index to return information about. Returns all indexes on collection if not provided."
13+
),
14+
};
1315

1416
export class CollectionSearchIndexesTool extends MongoDBToolBase {
15-
protected name = "collection-search-indexes";
16-
protected description = "List one or all search indexes on a collection";
17-
protected argsShape = {
18-
...DbOperationArgs,
19-
...ListSearchIndexesArgs,
20-
};
17+
protected name = "collection-search-indexes";
18+
protected description = "List one or all search indexes on a collection";
19+
protected argsShape = {
20+
...DbOperationArgs,
21+
...ListSearchIndexesArgs,
22+
};
2123

22-
protected operationType: OperationType = "read";
24+
protected operationType: OperationType = "read";
2325

24-
protected async execute({ database, collection, indexName }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
25-
const provider = await this.ensureConnected();
26-
const indexes = await provider
27-
.getSearchIndexes(database, collection, indexName);
26+
protected async execute({
27+
database,
28+
collection,
29+
indexName,
30+
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
31+
const provider = await this.ensureConnected();
32+
const indexes = await provider.getSearchIndexes(database, collection, indexName);
2833

29-
return {
30-
content: [
31-
{
32-
text: indexName
33-
? `Found ${indexes.length} search indexes in the collection "${collection}" with name "${indexName}":`
34-
: `Found ${indexes.length} search indexes in the collection "${collection}"`,
35-
type: "text",
36-
},
37-
...(indexes.map((indexDefinition) => {
38-
return {
39-
text: `Name "${indexDefinition.name}", definition: ${JSON.stringify(indexDefinition.latestDefinition)}`,
40-
type: "text",
41-
};
42-
}) as { text: string; type: "text" }[]),
43-
],
44-
};
45-
}
46-
}
34+
return {
35+
content: [
36+
{
37+
text: indexName
38+
? `Found ${indexes.length} search indexes in the collection "${collection}" with name "${indexName}":`
39+
: `Found ${indexes.length} search indexes in the collection "${collection}"`,
40+
type: "text",
41+
},
42+
...(indexes.map((indexDefinition) => {
43+
return {
44+
text: `Name "${indexDefinition.name}", definition: ${JSON.stringify(indexDefinition.latestDefinition)}`,
45+
type: "text",
46+
};
47+
}) as { text: string; type: "text" }[]),
48+
],
49+
};
50+
}
51+
}

src/tools/mongodb/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { DropCollectionTool } from "./delete/dropCollection.js";
1818
import { ExplainTool } from "./metadata/explain.js";
1919
import { CreateCollectionTool } from "./create/createCollection.js";
2020
import { LogsTool } from "./metadata/logs.js";
21-
import {CollectionSearchIndexesTool} from "./read/collectionSearchIndexes.js";
21+
import { CollectionSearchIndexesTool } from "./read/collectionSearchIndexes.js";
2222

2323
export const MongoDbTools = [
2424
ConnectTool,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describeWithMongoDB } from "../mongodbHelpers.js";
22

33
import {
4-
databaseCollectionParameters,
5-
databaseCollectionInvalidArgs,
6-
validateThrowsForInvalidArguments,
7-
validateToolMetadata,
4+
databaseCollectionParameters,
5+
databaseCollectionInvalidArgs,
6+
validateThrowsForInvalidArguments,
7+
validateToolMetadata,
88
} from "../../../helpers.js";
99

1010
describeWithMongoDB("collectionSearchIndexes tool", (integration) => {
@@ -17,4 +17,4 @@ describeWithMongoDB("collectionSearchIndexes tool", (integration) => {
1717
validateThrowsForInvalidArguments(integration, "collection-search-indexes", databaseCollectionInvalidArgs);
1818

1919
// Real tests to be added once search indexes are supported in test env.
20-
});
20+
});

0 commit comments

Comments
 (0)