Migrate Search tools to new tool design#2954
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the Azure Search toolset commands from explicit RegisterOptions/BindOptions(ParseResult) patterns to the newer attribute-based options model (Options POCO + [Option]/[OptionContainer]), aligning Search commands with the newer command base classes and reducing direct System.CommandLine usage in the toolset.
Changes:
- Converted Search commands to the new
AuthenticatedCommand<TOptions, TResult>/SubscriptionCommand<TOptions, TResult>style with Options POCO binding. - Replaced legacy option definition classes/base option types with
[Option]-attributed options and a newSearchOptionDescriptionsconstants holder. - Simplified toolset dependencies (e.g., removed explicit
System.CommandLinepackage reference) and adjusted tests/service construction accordingly.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Search/tests/Azure.Mcp.Tools.Search.Tests/Service/ServiceListCommandTests.cs | Updates test base class to match new subscription command shape. |
| tools/Azure.Mcp.Tools.Search/tests/Azure.Mcp.Tools.Search.Tests/Service/SearchServiceTests.cs | Updates service instantiation after constructor signature change. |
| tools/Azure.Mcp.Tools.Search/src/Services/SearchService.cs | Removes logger dependency and updates usings for System.Text.Json. |
| tools/Azure.Mcp.Tools.Search/src/Services/ISearchService.cs | Adds System.Text.Json import for JsonElement return types. |
| tools/Azure.Mcp.Tools.Search/src/Options/Service/ServiceListOptions.cs | Converts subscription options to [Option] attributes + ISubscriptionOption. |
| tools/Azure.Mcp.Tools.Search/src/Options/SearchOptionDescriptions.cs | Adds centralized option description constants for Search options. |
| tools/Azure.Mcp.Tools.Search/src/Options/SearchOptionDefinitions.cs | Removes legacy System.CommandLine-based option definitions. |
| tools/Azure.Mcp.Tools.Search/src/Options/Knowledge/KnowledgeSourceGetOptions.cs | Converts options to [Option] attribute model. |
| tools/Azure.Mcp.Tools.Search/src/Options/Knowledge/KnowledgeBaseRetrieveOptions.cs | Converts options to [Option] attribute model (query/messages/service/retry). |
| tools/Azure.Mcp.Tools.Search/src/Options/Knowledge/KnowledgeBaseGetOptions.cs | Converts options to [Option] attribute model. |
| tools/Azure.Mcp.Tools.Search/src/Options/Index/IndexQueryOptions.cs | Converts options to [Option] attribute model. |
| tools/Azure.Mcp.Tools.Search/src/Options/Index/IndexGetOptions.cs | Converts options to [Option] attribute model. |
| tools/Azure.Mcp.Tools.Search/src/Options/Index/BaseIndexOptions.cs | Removes obsolete base options type. |
| tools/Azure.Mcp.Tools.Search/src/Options/BaseSearchOptions.cs | Removes obsolete base options type. |
| tools/Azure.Mcp.Tools.Search/src/Models/IndexInfo.cs | Removes explicit JSON property annotations (rely on serializer naming policy). |
| tools/Azure.Mcp.Tools.Search/src/Models/FieldInfo.cs | Removes explicit JSON property annotations (rely on serializer naming policy). |
| tools/Azure.Mcp.Tools.Search/src/GlobalUsings.cs | Removes global usings no longer needed after migration. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Service/ServiceListCommand.cs | Migrates to SubscriptionCommand<TOptions, TResult> and options binding model. |
| tools/Azure.Mcp.Tools.Search/src/Commands/SearchJsonContext.cs | Simplifies source-gen context declaration. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Knowledge/KnowledgeSourceGetCommand.cs | Migrates to AuthenticatedCommand<TOptions, TResult> + options binding model. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Knowledge/KnowledgeBaseRetrieveCommand.cs | Migrates to AuthenticatedCommand<TOptions, TResult> and moves validation into ValidateOptions. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Knowledge/KnowledgeBaseGetCommand.cs | Migrates to AuthenticatedCommand<TOptions, TResult> + options binding model. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Index/IndexQueryCommand.cs | Migrates to AuthenticatedCommand<TOptions, TResult> and updates result type. |
| tools/Azure.Mcp.Tools.Search/src/Commands/Index/IndexGetCommand.cs | Migrates to AuthenticatedCommand<TOptions, TResult> + options binding model. |
| tools/Azure.Mcp.Tools.Search/src/Azure.Mcp.Tools.Search.csproj | Updates core ProjectReference path and removes System.CommandLine PackageReference. |
| servers/Azure.Mcp.Server/changelog-entries/1782416793886.yaml | Adds changelog entry indicating breaking changes for Search tools. |
jongio
left a comment
There was a problem hiding this comment.
Clean migration that follows the pattern established by the ACR, StorageSync, and Monitor migrations. One minor nit below.
Note: the existing Copilot bot comment about options.Messages.Index() not compiling is incorrect. Enumerable.Index() is available in .NET 9+ and the repo targets net10.0, so it compiles fine (CI confirms).
| namespace Azure.Mcp.Tools.Search.Options.Index; | ||
|
|
||
| public class IndexQueryOptions : BaseIndexOptions | ||
| public class IndexQueryOptions |
There was a problem hiding this comment.
Nit: all other options classes in this PR are public sealed class (consistent with the StorageSync migration pattern). This one is public class without sealed. Likely just an oversight.
What does this PR do?
Migrates Search tools to new design where Register and Bind options are based on
Optionattributes.GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline