Skip to content

Conversation

@anshulkhantwal
Copy link
Contributor

Proposed changes

Checklist

@anshulkhantwal anshulkhantwal requested a review from a team as a code owner September 25, 2025 09:37
Copilot AI review requested due to automatic review settings September 25, 2025 09:37
Copy link
Contributor

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 adds vector search functionality to the MCP server with embedding model support. It introduces new tools for performing vector similarity searches using MongoDB's $vectorSearch aggregation stage, along with Azure AI Inference embedding provider integration and Azure Managed Identity authentication for HTTP transport.

Key changes:

  • Two vector search tool variants (V1 and V2) with different configuration approaches
  • Azure AI Inference embedding provider with retry logic and factory pattern
  • Azure Managed Identity authentication middleware with JWT verification
  • Enhanced configuration options for embedding models and authentication

Reviewed Changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tools/mongodb/read/vectorSearchv1.ts V1 vector search tool requiring path/index arguments
src/tools/mongodb/read/vectorSearchv2.ts V2 vector search tool using pre-configured defaults
src/embedding/* Embedding provider interface, factory, and Azure AI implementation
src/transports/azureManagedIdentityAuth.ts JWT authentication middleware for HTTP transport
src/common/config.ts Configuration schema updates for vector search and auth
tests/* Comprehensive test coverage for new functionality

attempt++;
}

throw new Error(`Embedding request ultimately failed after ${maxRetries + 1} attempt(s): ${lastError?.message}`);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The error message could be more informative by including the original request details. Consider adding context about what was being embedded when the failure occurred.

Suggested change
throw new Error(`Embedding request ultimately failed after ${maxRetries + 1} attempt(s): ${lastError?.message}`);
throw new Error(
`Embedding request ultimately failed after ${maxRetries + 1} attempt(s): ${lastError?.message}\n` +
`Request details: input.length=${input.length}, input[0]=${JSON.stringify(input[0])}, model/deployment=${this.config.deployment}, endpoint=${this.config.endpoint}`
);

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +75
if (!expectedAud) {
logger.warning({
id: 0 as any,
context: "azureManagedIdentityAuth",
message: "No audience or clientId configured; 'aud' claim will not be enforced.",
});
}
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The log ID is hardcoded as 0 as any which bypasses the type system. This should use a proper LogId constant like LogId.azureManagedIdentityAuthError for consistency with the logging framework.

Copilot uses AI. Check for mistakes.
Comment on lines +500 to +505
userConfig.azureManagedIdentityRequiredRoles = commaSeparatedToArray(
userConfig.azureManagedIdentityRequiredRoles
);
userConfig.azureManagedIdentityAllowedAppIds = commaSeparatedToArray(
userConfig.azureManagedIdentityAllowedAppIds
);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The configuration setup repeats similar patterns for array processing. Consider extracting this into a helper function to reduce code duplication and make the configuration setup more maintainable.

Copilot uses AI. Check for mistakes.
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.

1 participant