Skip to content

Normalize command result payloads to object roots - #3165

Open
vcolin7 wants to merge 15 commits into
microsoft:mainfrom
vcolin7:vcolin7-normalize-result-shapes
Open

Normalize command result payloads to object roots#3165
vcolin7 wants to merge 15 commits into
microsoft:mainfrom
vcolin7:vcolin7-normalize-result-shapes

Conversation

@vcolin7

@vcolin7 vcolin7 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR normalizes command results that currently expose raw arrays, singleton arrays, loosely shaped payloads, mismatched generic result contracts, or multiple object variants. It keeps rename-only churn out of scope while making the affected Azure, core, and Fabric command outputs consistently object-rooted and AOT-safe.

The implementation:

  • consolidates ToolsListCommand variants into one nullable result contract and omits the inactive field;
  • wraps substantive guidance, query, template, Monitor, Fabric Docs, and OneLake payloads in command-specific object results;
  • aligns command TResult declarations and ResponseResult.Create metadata with the emitted object;
  • preserves existing JSON property names and null-omission behavior;
  • adds focused serialization/output-shape tests and source-generated JSON registrations;
  • adds Azure and Fabric breaking-change changelog entries.

Commands that were already normalized on main, intentional message-only/payload-free commands, and candidates whose only change would be a *Result to *CommandResult rename are deliberately excluded.

Validation completed:

  • all touched projects build successfully;
  • affected focused test suites pass across core tools, guidance, SQL, Search, Functions, Monitor, Fabric Docs, and OneLake;
  • spelling check passes;
  • Build-Local.ps1 -VerifyNpx completed builds, trimming, and package generation, but its final cache cleanup encountered a persistent environmental EPERM on a locked D:\npm-cache\_npx directory.

GitHub issue number?

N/A

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
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • 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 running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • 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 command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • 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

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 multiple MCP command outputs (across core, Azure tools, and Fabric tools) to consistently emit object-root JSON payloads, aligning TResult contracts and ResponseResult.Create(...) type metadata to the actual serialized shapes and ensuring the results remain AOT-safe via source-generated JsonSerializerContext registrations.

Changes:

  • Replaced raw-array / singleton-array / variant-shaped results with command-specific object-root *CommandResult wrappers.
  • Updated source-generated JSON contexts to register the new wrapper result types for AOT-safe serialization.
  • Updated and added tests to validate the new output shapes; added breaking-change changelog entries for Azure and Fabric servers.

Reviewed changes

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

Show a summary per file
File Description
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Shortcut/ShortcutListCommandTests.cs Adds test verifying shortcut list wrapper result shape.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Shortcut/ShortcutGetCommandTests.cs Adds test verifying shortcut get wrapper result shape.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Shortcut/ShortcutCreateCommandVariantsTests.cs Updates create-variant tests to deserialize wrapper result shapes.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Settings/SettingsGetCommandTests.cs Adds test verifying settings wrapper result shape.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Security/DataAccessRoleListCommandTests.cs Adds tests verifying role list wrapper and null-omission behavior.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Security/DataAccessRoleGetCommandTests.cs Adds test verifying role get wrapper result shape.
tools/Fabric.Mcp.Tools.OneLake/tests/Fabric.Mcp.Tools.OneLake.Tests/Commands/Security/DataAccessRoleCreateOrUpdateCommandTests.cs Updates test to deserialize the new upsert wrapper result.
tools/Fabric.Mcp.Tools.OneLake/src/Models/OneLakeJsonContext.cs Registers OneLake wrapper result types for AOT-safe serialization.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutListCommand.cs Changes list result to object-root wrapper type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutGetCommand.cs Changes get result to object-root wrapper type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateS3CompatibleCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateOneLakeCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateOneDriveSharePointCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateGcsCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateDataverseCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateAzureBlobCommand.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateAmazonS3Command.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Shortcut/ShortcutCreateAdlsGen2Command.cs Wraps create result in object-root command result type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Settings/SettingsGetCommand.cs Changes settings result to object-root wrapper type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Security/DataAccessRoleListCommand.cs Changes list result to object-root wrapper type (with null-omission attributes).
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Security/DataAccessRoleGetCommand.cs Changes get result to object-root wrapper type.
tools/Fabric.Mcp.Tools.OneLake/src/Commands/Security/DataAccessRoleCreateOrUpdateCommand.cs Changes upsert result to object-root wrapper type.
tools/Fabric.Mcp.Tools.Docs/tests/Fabric.Mcp.Tools.Docs.Tests/Commands/GetWorkloadDefinitionCommandTests.cs Updates tests to validate wrapper output and fields.
tools/Fabric.Mcp.Tools.Docs/tests/Fabric.Mcp.Tools.Docs.Tests/Commands/GetWorkloadApisCommandTests.cs Updates tests to validate wrapper output and fields.
tools/Fabric.Mcp.Tools.Docs/tests/Fabric.Mcp.Tools.Docs.Tests/Commands/GetPlatformApisCommandTests.cs Updates tests to validate wrapper output and fields.
tools/Fabric.Mcp.Tools.Docs/tests/Fabric.Mcp.Tools.Docs.Tests/Commands/GetBestPracticesCommandTests.cs Updates tests to validate wrapper output and fields.
tools/Fabric.Mcp.Tools.Docs/tests/Fabric.Mcp.Tools.Docs.Tests/Commands/CombinedWorkflowTests.cs Updates combined workflow test to deserialize wrapper and validate nested JSON content.
tools/Fabric.Mcp.Tools.Docs/src/Commands/PublicApis/GetWorkloadApisCommand.cs Wraps public API result in an object-root wrapper with stable JSON name.
tools/Fabric.Mcp.Tools.Docs/src/Commands/PublicApis/GetPlatformApisCommand.cs Wraps public API result in an object-root wrapper with stable JSON name.
tools/Fabric.Mcp.Tools.Docs/src/Commands/FabricJsonContext.cs Registers Fabric Docs wrapper result types for AOT-safe serialization.
tools/Fabric.Mcp.Tools.Docs/src/Commands/BestPractices/GetWorkloadDefinitionCommand.cs Wraps definition string in an object-root wrapper with stable JSON name.
tools/Fabric.Mcp.Tools.Docs/src/Commands/BestPractices/GetBestPracticesCommand.cs Wraps best-practices list in an object-root wrapper with stable JSON name.
tools/Azure.Mcp.Tools.WellArchitectedFramework/tests/Azure.Mcp.Tools.WellArchitectedFramework.Tests/Commands/ServiceGuide/ServiceGuideGetCommandTests.cs Updates tests to validate wrapper output shape and field access.
tools/Azure.Mcp.Tools.WellArchitectedFramework/src/Commands/WellArchitectedFrameworkJsonContext.cs Registers the new wrapper result type for AOT-safe serialization.
tools/Azure.Mcp.Tools.WellArchitectedFramework/src/Commands/ServiceGuide/ServiceGuideGetCommand.cs Wraps guidance list into an object-root command result.
tools/Azure.Mcp.Tools.Sql/tests/Azure.Mcp.Tools.Sql.Tests/Server/ServerGetCommandTests.cs Updates tests to validate wrapper output and server list behavior.
tools/Azure.Mcp.Tools.Sql/src/Commands/SqlJsonContext.cs Registers SQL wrapper result types for AOT-safe serialization.
tools/Azure.Mcp.Tools.Sql/src/Commands/Server/ServerGetCommand.cs Wraps server list output into an object-root command result.
tools/Azure.Mcp.Tools.Search/tests/Azure.Mcp.Tools.Search.Tests/Index/IndexQueryCommandTests.cs Updates test to validate wrapper output and JSON shape.
tools/Azure.Mcp.Tools.Search/src/Commands/SearchJsonContext.cs Registers search wrapper result types for AOT-safe serialization.
tools/Azure.Mcp.Tools.Search/src/Commands/Index/IndexQueryCommand.cs Wraps index query results into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.Tests/Log/WorkspaceLogQueryCommandTests.cs Updates test to validate wrapper output deserialization.
tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.Tests/Log/ResourceLogQueryCommandTests.cs Updates test to validate wrapper output deserialization.
tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.Tests/Instrumentation/Commands/InstrumentationCommandResultTests.cs Adds tests ensuring instrumentation commands return object-root payloads.
tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.Tests/HealthModels/HealthModelListCommandTests.cs Updates test to validate wrapper output and JSON property access.
tools/Azure.Mcp.Tools.Monitor/src/Commands/MonitorJsonContext.cs Registers monitor wrapper result types for AOT-safe serialization.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Log/WorkspaceLogQueryCommand.cs Wraps log query results into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Log/ResourceLogQueryCommand.cs Wraps log query results into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Instrumentation/SendEnhancementSelectCommand.cs Wraps string result into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Instrumentation/SendBrownfieldAnalysisCommand.cs Wraps string result into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Instrumentation/OrchestratorStartCommand.cs Wraps string result into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/Instrumentation/OrchestratorNextCommand.cs Wraps string result into an object-root command result.
tools/Azure.Mcp.Tools.Monitor/src/Commands/HealthModels/HealthModelListCommand.cs Wraps health model list into an object-root command result.
tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.Tests/Project/ProjectGetCommandTests.cs Updates tests for singleton-to-object result normalization.
tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.Tests/Language/LanguageListCommandTests.cs Updates tests for singleton-to-object result normalization.
tools/Azure.Mcp.Tools.Functions/tests/Azure.Mcp.Tools.Functions.Tests/FunctionsCommandTests.cs Updates tool-level tests to deserialize normalized object results.
tools/Azure.Mcp.Tools.Functions/src/Commands/Project/ProjectGetCommand.cs Changes project template result from singleton array to single object result.
tools/Azure.Mcp.Tools.Functions/src/Commands/Language/LanguageListCommand.cs Changes language list result from singleton array to single object result.
tools/Azure.Mcp.Tools.Functions/src/Commands/FunctionsJsonContext.cs Removes now-unneeded list registrations; keeps normalized object registrations.
tools/Azure.Mcp.Tools.AzureTerraformBestPractices/tests/Azure.Mcp.Tools.AzureTerraformBestPractices.Tests/AzureTerraformBestPracticesGetCommandTests.cs Updates tests to validate wrapper output shape.
tools/Azure.Mcp.Tools.AzureTerraformBestPractices/src/Commands/AzureTerraformBestPracticesJsonContext.cs Registers new wrapper result type for AOT-safe serialization.
tools/Azure.Mcp.Tools.AzureTerraformBestPractices/src/Commands/AzureTerraformBestPracticesGetCommand.cs Wraps best-practices output into an object-root command result.
tools/Azure.Mcp.Tools.AzureBestPractices/tests/Azure.Mcp.Tools.AzureBestPractices.Tests/BestPracticesCommandTests.cs Updates tests to validate wrapper outputs for multiple scenarios.
tools/Azure.Mcp.Tools.AzureBestPractices/tests/Azure.Mcp.Tools.AzureBestPractices.Tests/AIAppBestPracticesCommandTests.cs Updates test to validate wrapper output shape.
tools/Azure.Mcp.Tools.AzureBestPractices/src/Commands/BestPracticesCommand.cs Wraps best-practices output into an object-root command result.
tools/Azure.Mcp.Tools.AzureBestPractices/src/Commands/AzureBestPracticesJsonContext.cs Registers best-practices wrapper result types for AOT-safe serialization.
tools/Azure.Mcp.Tools.AzureBestPractices/src/Commands/AIAppBestPracticesCommand.cs Wraps best-practices output into an object-root command result.
tools/Azure.Mcp.Tools.Advisor/tests/Azure.Mcp.Tools.Advisor.Tests/Recommendation/RecommendationApplyCommandTests.cs Updates tests to validate wrapper output shape and caching behavior.
tools/Azure.Mcp.Tools.Advisor/src/Commands/Recommendation/RecommendationApplyCommand.cs Wraps recommendation rules into an object-root command result.
tools/Azure.Mcp.Tools.Advisor/src/Commands/AdvisorJsonContext.cs Registers new wrapper result type for AOT-safe serialization.
servers/Fabric.Mcp.Server/changelog-entries/1784946362379.yaml Adds breaking-change entry for Fabric Docs and OneLake output shape normalization.
servers/Azure.Mcp.Server/changelog-entries/1784946361604.yaml Adds breaking-change entry for Azure tool output shape normalization.
core/Microsoft.Mcp.Core/src/Models/ModelsJsonContext.cs Updates core model JSON context for ToolsList result shape normalization.
core/Microsoft.Mcp.Core/src/Areas/Tools/Commands/ToolsListCommand.cs Consolidates ToolsList variants into a single object-root result contract.
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.Tests/Areas/Tools/ToolsListCommandTests.cs Updates tests to validate ToolsList now emits object-root payloads.

@vcolin7
vcolin7 requested a review from a team as a code owner July 28, 2026 22:04

[JsonConverter(typeof(ToolsListResultConverter))]
public sealed record ToolsListResult(
public sealed record ToolsListCommandResult(

@alzimmermsft Alan Zimmer (alzimmermsft) Aug 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a breaking change on the JSON response shape. I'm fine with it overall, but we are changing the response for azmcp tools list, which will break a lot of CLI usage. This is changing tool listing from:

[
  {tool},
  {tool},
  ...
]

to

{
  "Commands": [
    {tool},
    {tool},
    ...
  ]
}

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants