Skip to content

Review command validation#2086

Open
alzimmermsft wants to merge 6 commits intomicrosoft:mainfrom
alzimmermsft:ReviewCommandValidation
Open

Review command validation#2086
alzimmermsft wants to merge 6 commits intomicrosoft:mainfrom
alzimmermsft:ReviewCommandValidation

Conversation

@alzimmermsft
Copy link
Contributor

What does this PR do?

Reviews tool Command files for validation and other miscellaneous inconsistencies with tool development guidelines.

GitHub issue number?

[Link to the GitHub issue this PR addresses]

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes using script at eng/scripts/Process-PackageReadMe.ps1. See Package README
    • Updated command list in /servers/Azure.Mcp.Server/docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • Run .\eng\scripts\Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

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 standardizes and strengthens command-line validation across multiple MCP tools by moving input checks into System.CommandLine validators, simplifying response/result construction, and aligning JSON/option access patterns.

Changes:

  • Added command.Validators.Add(...) blocks to enforce required/compatible option combinations and removed equivalent runtime checks from ExecuteAsync.
  • Simplified result creation patterns (e.g., new(...), object initializers) and removed redundant Status = OK / empty message assignments where defaults already apply.
  • Updated Cosmos query validation to return error strings for validator consumption (instead of throwing) and adjusted tests accordingly.

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Table/TableNamespaceListCommand.cs Adds option validators for workspace/item requirements; removes runtime 400 responses.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Table/TableNamespaceGetCommand.cs Makes namespace required and adds validators; removes runtime validation.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Table/TableListCommand.cs Makes namespace required and adds validators; removes runtime validation.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Table/TableGetCommand.cs Makes namespace required and adds validators; removes runtime validation.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Table/TableConfigGetCommand.cs Adds validators for workspace/item requirements; removes runtime validation.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Item/OneLakeItemListDfsCommand.cs Adds validator for workspace requirement; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Item/OneLakeItemListCommand.cs Adds validator for workspace requirement; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Item/OneLakeItemDataListCommand.cs Adds validator for workspace requirement; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/PathListCommand.cs Adds workspace/item validators; uses null-forgiving where validated; simplifies result construction.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/FileWriteCommand.cs Adds validators for workspace/item + mutually exclusive content sources + file existence; simplifies content selection.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/FileReadCommand.cs Adds workspace/item validators; removes runtime ArgumentException and redundant OK status assignment.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/FileDeleteCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/DirectoryDeleteCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/DirectoryCreateCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/BlobPutCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/BlobListCommand.cs Adds workspace/item validators; uses null-forgiving where validated; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/BlobGetCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/File/BlobDeleteCommand.cs Adds workspace/item validators; removes runtime ArgumentException.
tools/Fabric.Mcp.Tools.Core/src/Commands/ItemCreateCommand.cs Adds validator requiring workspace identifier; removes runtime ArgumentException.
tools/Azure.Mcp.Tools.Search/src/Commands/Knowledge/KnowledgeBaseRetrieveCommand.cs Adds message parsing validation in the validator; makes ParseMessage static and adjusts error messages.
tools/Azure.Mcp.Tools.MySql/src/Commands/MySqlListCommand.cs Adds validator for --database requiring --server; reorders validation vs binding; simplifies results.
tools/Azure.Mcp.Tools.MonitorInstrumentation/src/Commands/SendBrownfieldAnalysisCommand.cs Updates option retrieval to name-based lookup; removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.MonitorInstrumentation/src/Commands/OrchestratorStartCommand.cs Updates option retrieval to name-based lookup; removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.MonitorInstrumentation/src/Commands/OrchestratorNextCommand.cs Updates option retrieval to name-based lookup; removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.MonitorInstrumentation/src/Commands/ListLearningResourcesCommand.cs Removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.MonitorInstrumentation/src/Commands/GetLearningResourceCommand.cs Updates option retrieval to name-based lookup; removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Metrics/MetricsQueryCommand.cs Normalizes raw string literal usage in Description.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Metrics/MetricsDefinitionsCommand.cs Normalizes raw string literal usage in Description.
tools/Azure.Mcp.Tools.KeyVault/src/Commands/Admin/AdminSettingsGetCommand.cs Simplifies ResponseResult.Create construction.
tools/Azure.Mcp.Tools.Functions/src/Commands/Template/TemplateGetCommand.cs Removes redundant OK/message assignments; minor cleanup.
tools/Azure.Mcp.Tools.Functions/src/Commands/Project/ProjectGetCommand.cs Removes redundant OK/message assignments; minor cleanup.
tools/Azure.Mcp.Tools.Functions/src/Commands/Language/LanguageListCommand.cs Removes redundant OK/message assignments; minor cleanup.
tools/Azure.Mcp.Tools.FileShares/src/Commands/PrivateEndpointConnection/PrivateEndpointConnectionUpdateCommand.cs Simplifies result creation and record shape (relies on camelCase JSON context).
tools/Azure.Mcp.Tools.FileShares/src/Commands/FileShare/FileShareCheckNameAvailabilityCommand.cs Simplifies result creation formatting.
tools/Azure.Mcp.Tools.Extension/src/Commands/CliInstallCommand.cs Moves CLI type normalization/validation into validator; simplifies execute path and result creation.
tools/Azure.Mcp.Tools.Extension/src/Commands/CliGenerateCommand.cs Moves CLI type validation into validator; simplifies execute path and result creation.
tools/Azure.Mcp.Tools.Extension/src/Commands/AzqrCommand.cs Removes redundant null-check and OK status assignment; uses null-forgiving where validated elsewhere.
tools/Azure.Mcp.Tools.Extension/src/Commands/AzCommand.cs Removes redundant null-check; uses null-forgiving for validated option.
tools/Azure.Mcp.Tools.EventHubs/src/Commands/Namespace/NamespaceUpdateCommand.cs Simplifies result creation; removes redundant OK status assignment.
tools/Azure.Mcp.Tools.DeviceRegistry/src/Commands/Namespace/NamespaceListCommand.cs Simplifies result creation; switches exception type patterns to unqualified RequestFailedException.
tools/Azure.Mcp.Tools.Deploy/src/Commands/Architecture/DiagramGenerateCommand.cs Adds validator for required raw topology input; simplifies binding and deserialization flow.
tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.UnitTests/CosmosQueryValidatorTests.cs Updates unit tests for string-returning validator method.
tools/Azure.Mcp.Tools.Cosmos/src/Validation/CosmosQueryValidator.cs Changes validation API to return error message strings (or null) instead of throwing.
tools/Azure.Mcp.Tools.Cosmos/src/Commands/ItemQueryCommand.cs Moves Cosmos SQL validation into command validator and removes runtime validation block.
tools/Azure.Mcp.Tools.ConfidentialLedger/src/Commands/Entries/LedgerEntryGetCommand.cs Adds missing copyright/license header.
tools/Azure.Mcp.Tools.Compute/src/Commands/Disk/DiskUpdateCommand.cs Simplifies result creation; switches exception type patterns to unqualified Azure types.
tools/Azure.Mcp.Tools.Compute/src/Commands/Disk/DiskCreateCommand.cs Adds option-combination validator; removes runtime ArgumentException checks; simplifies result creation; switches exception type patterns.
tools/Azure.Mcp.Tools.CloudArchitect/src/Commands/Design/DesignCommand.cs Improves description formatting, adds validators, and adjusts JSON state deserialization handling.
tools/Azure.Mcp.Tools.AzureTerraformBestPractices/src/Commands/AzureTerraformBestPracticesGetCommand.cs Removes redundant OK/message assignments.
tools/Azure.Mcp.Tools.AzureMigrate/src/Commands/PlatformLandingZone/RequestCommand.cs Simplifies result record and construction; removes runtime required-argument checks.
tools/Azure.Mcp.Tools.AzureMigrate/src/Commands/PlatformLandingZone/GetGuidanceCommand.cs Simplifies result record and construction.
tools/Azure.Mcp.Tools.AzureBestPractices/src/Commands/BestPracticesCommand.cs Removes runtime null checks and makes helper methods static; relies on existing validator.
tools/Azure.Mcp.Tools.AzureBestPractices/src/Commands/AIAppBestPracticesCommand.cs Removes redundant OK/message assignments.
core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs Simplifies null-check/throw patterns for tenant name/id resolution.
core/Azure.Mcp.Core/src/Services/Azure/ResourceGroup/ResourceGroupService.cs Removes broad try/catch wrappers; simplifies return construction and caching flow.
core/Azure.Mcp.Core/src/Areas/Subscription/Commands/SubscriptionListCommand.cs Simplifies result creation.
core/Azure.Mcp.Core/src/Areas/Group/Commands/GroupListCommand.cs Always returns an (possibly empty) list result rather than null results.

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

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants