Skip to content

Conversation

himanshusinghs
Copy link
Collaborator

@himanshusinghs himanshusinghs commented Oct 13, 2025

Proposed changes

Adds support for dropping vector search indexes in drop-index tool. The functionality is behind a feature flag.

  • Tests have been added for basic tool functionality and elicitation
  • listSearchIndexes tool and its tests have been modified to re-use some of the existing code.

Checklist

@himanshusinghs himanshusinghs requested a review from a team as a code owner October 13, 2025 12:57
@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 12:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new drop-search-index tool for dropping search indexes from MongoDB collections. The tool is currently restricted to test environments and includes elicitation (confirmation) functionality for safety.

  • Introduces a new drop-search-index tool with proper validation, error handling, and elicitation support
  • Refactors existing search index functionality to support code reuse between list and drop operations
  • Adds comprehensive test coverage including unit, integration, and elicitation tests

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tools/mongodb/delete/dropSearchIndex.ts New tool implementation for dropping search indexes with validation and confirmation
src/tools/mongodb/search/listSearchIndexes.ts Refactored to extract reusable search index retrieval logic
src/tools/mongodb/tools.ts Added the new tool to the exports list
src/common/config.ts Added drop-search-index to confirmation required tools list
tests/integration/tools/mongodb/delete/dropSearchIndex.test.ts Comprehensive test suite for the new tool
tests/integration/tools/mongodb/search/listSearchIndexes.test.ts Updated to use refactored helper functions
tests/integration/helpers.ts Added reusable helper functions for search index operations
tests/integration/tools/mongodb/mongodbClusterProcess.ts Added directConnection parameter to connection string

@himanshusinghs himanshusinghs changed the title feat: introduces drop-search-index tool feat: introduces drop-search-index tool MCP-239 Oct 13, 2025
@himanshusinghs himanshusinghs force-pushed the feat/MCP-239-delete-vector-search-indexes branch from 4e0e3e0 to 3df48c4 Compare October 13, 2025 13:04
@coveralls
Copy link
Collaborator

coveralls commented Oct 13, 2025

Pull Request Test Coverage Report for Build 18466847504

Details

  • 89 of 89 (100.0%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 82.334%

Files with Coverage Reduction New Missed Lines %
src/common/atlas/apiClientError.ts 2 87.65%
Totals Coverage Status
Change from base Build 18382799942: 0.1%
Covered Lines: 5686
Relevant Lines: 6778

💛 - Coveralls

@himanshusinghs himanshusinghs force-pushed the feat/MCP-239-delete-vector-search-indexes branch 4 times, most recently from 10f49db to d6f1b91 Compare October 15, 2025 11:55
- Tool is currently only visible to tests
- Tool has been added to the list of tools requiring elicitation
- Tests have been added for basic tool functionality and elicitation
- listSearchIndexes tool and its tests have been modified to re-use some
  of the existing code.
1. Wraps the toolcall result in untrusted data wrapper
2. Add additional test for confirming that we don't drop when
   confirmation is not provided
@himanshusinghs himanshusinghs force-pushed the feat/MCP-239-delete-vector-search-indexes branch from effaac6 to 7d795ca Compare October 15, 2025 15:39
@himanshusinghs himanshusinghs changed the title feat: introduces drop-search-index tool MCP-239 feat: adds vector search drop support to drop-index tool MCP-239 Oct 15, 2025
@himanshusinghs himanshusinghs changed the title feat: adds vector search drop support to drop-index tool MCP-239 feat: adds support for dropping vector search indexes in drop-index tool MCP-239 Oct 15, 2025
() => runningContainer.stop(),
() => `mongodb://${runningContainer.getHost()}:${runningContainer.getMappedPort(27017)}`
() =>
`mongodb://${runningContainer.getHost()}:${runningContainer.getMappedPort(27017)}/?directConnection=true`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the direct connection here? It shouldn't be necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately it is. Without it the connection just keeps hanging because driver tries to resolve involved clusters and since the internal ports are never exposed the driver is unable to connect. BTW this is also what is recommended by the CLI when you kick start a deployment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see that in your PR you're using the service provider from server instance itself and because our connection code handles it internally (in generateConnectionInfoFromCliArgs) it works fine but for tests I think it would be better to continue using the test mongo client provided by the MdbIntegration.

}
}

export async function waitUntilSearchManagementServiceIsReady(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why aren't we using waitUntilSearchIsReady

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably you should take a look at mongodbHelpers.ts and see what can be reused and refactor.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are the same methods. I just renamed / refactored them to re-use parts of the logic.

import { type DbOperationArgs, MongoDBToolBase } from "../tools/mongodb/mongodbTool.js";
import type { ToolArgs } from "../tools/tool.js";

export abstract class MongoDBToolWithSearchErrorHandler extends MongoDBToolBase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure we want this. In #626 we are using the MongoDBToolBase, and it would be best to have all errors centralised in one single place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just now stumbled upon it while I was going through your PR. Certainly that's more preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants