• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 15030421235

14 May 2025 08:28PM UTC coverage: 74.11%. First build
15030421235

Pull #252

github

web-flow
Merge 741147a95 into fa6224105
Pull Request #252: feat: Add vector index create and update

207 of 363 branches covered (57.02%)

Branch coverage included in aggregate %.

13 of 22 new or added lines in 3 files covered. (59.09%)

792 of 985 relevant lines covered (80.41%)

52.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/src/tools/mongodb/update/updateVectorIndex.ts
1
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
import { buildVectorFields, DbOperationArgs, MongoDBToolBase, VectorIndexArgs } from "../mongodbTool.js";
3
import { OperationType, ToolArgs } from "../../tool.js";
4

5
export class UpdateVectorIndexTool extends MongoDBToolBase {
6
    protected name = "update-vector-index";
32✔
7
    protected description = "Updates an Atlas Search vector for a collection";
32✔
8
    protected argsShape = {
32✔
9
        ...DbOperationArgs,
10
        name: VectorIndexArgs.name,
11
        vectorDefinition: VectorIndexArgs.vectorDefinition,
12
        filterFields: VectorIndexArgs.filterFields,
13
    };
14

15
    protected operationType: OperationType = "create";
32✔
16

17
    protected async execute({
18
        database,
19
        collection,
20
        name,
21
        vectorDefinition,
22
        filterFields,
23
    }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
NEW
24
        const provider = await this.ensureConnected();
×
25

26
        // @ts-expect-error: Interface expects a SearchIndexDefinition {definition: {fields}}. However,
27
        // passing fields at the root level is necessary for the call to succeed.
NEW
28
        await provider.updateSearchIndex(database, collection, name, {
×
29
            fields: buildVectorFields(vectorDefinition, filterFields),
30
        });
31

NEW
32
        return {
×
33
            content: [
34
                {
35
                    text: `Successfully updated vector index "${name}" on collection "${collection}" in database "${database}"`,
36
                    type: "text",
37
                },
38
            ],
39
        };
40
    }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc