Skip to content

[Azure Workbooks] Refactor MCP server, fix live tests#1646

Merged
matteing merged 9 commits intomainfrom
users/sergiomattei/Workbooks
Mar 3, 2026
Merged

[Azure Workbooks] Refactor MCP server, fix live tests#1646
matteing merged 9 commits intomainfrom
users/sergiomattei/Workbooks

Conversation

@matteing
Copy link
Copy Markdown
Contributor

@matteing matteing commented Feb 4, 2026

What does this PR do?

This PR contains several quality improvements and bug fixes to the Workbooks MCP. It also fixes live tests.

  • Type Safety: Fixes SourceId type mismatch by converting ResourceIdentifier to string, improving type consistency
  • Code Cleanup: Removes unused FuzzyMatchInfo model and associated ScopeResolution property to reduce technical debt
  • Parameter Optimization: Removes unused subscriptions parameter from BuildWorkbooksQuery and BuildCountQuery methods
  • Error Handling: Fixes HandleWorkbookException return type from object? to WorkbookError for better type safety and clarity
  • Refactoring: Refactors GetWorkbooksAsync to use tuple pattern, eliminating dead code branches and improving maintainability

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 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

- Fix SourceId type mismatch: convert ResourceIdentifier to string
- Remove unused FuzzyMatchInfo model and ScopeResolution property
- Remove unused subscriptions parameter from BuildWorkbooksQuery and BuildCountQuery
- Fix HandleWorkbookException return type from object? to WorkbookError
- Refactor GetWorkbooksAsync to use tuple pattern, removing dead code branch
- Add documentation for static semaphore rate limiting behavior
Copy link
Copy Markdown
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 refactors the Azure Workbooks MCP tool to support batch operations (show/delete), expands list filtering/output options, and updates unit/live tests to match the new service/command contracts.

Changes:

  • Refactors IWorkbooksService/WorkbooksService to add async batch APIs (GetWorkbooksAsync, DeleteWorkbooksAsync) and a richer list API returning metadata (WorkbookListResult) with filters/output modes.
  • Updates Workbooks commands/options to support --workbook-ids, cross-scope listing, max-results, output format, and additional filters.
  • Updates unit tests and live tests to validate the new behavior and result schemas.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs Implements new list/batch APIs, KQL query building, throttling, and error mapping.
tools/Azure.Mcp.Tools.Workbooks/src/Services/IWorkbooksService.cs Updates the service contract to new async/list/batch operations.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/ListWorkbooksCommand.cs Switches to global command, adds new list options/filters/output handling.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/ShowWorkbooksCommand.cs Migrates show to batch --workbook-ids and returns Workbooks+Errors.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/DeleteWorkbooksCommand.cs Migrates delete to batch --workbook-ids and returns Succeeded+Errors.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/UpdateWorkbooksCommand.cs Updates to the new async update service method name.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/CreateWorkbooksCommand.cs Updates to the new async create service method name.
tools/Azure.Mcp.Tools.Workbooks/src/Commands/WorkbooksJsonContext.cs Adds source-gen serializers for new result/error models and lists.
tools/Azure.Mcp.Tools.Workbooks/src/Options/WorkbooksOptionDefinitions.cs Adds new CLI options (workbook-ids, filters, output-format, max-results, include-total-count).
tools/Azure.Mcp.Tools.Workbooks/src/Options/Workbook/ListWorkbooksOptions.cs Adds list scopes/filters/output knobs and maps them to WorkbookFilters.
tools/Azure.Mcp.Tools.Workbooks/src/Options/Workbook/ShowWorkbooksOptions.cs Switches show input from single ID to array of IDs.
tools/Azure.Mcp.Tools.Workbooks/src/Options/Workbook/DeleteWorkbookOptions.cs Switches delete input from single ID to array of IDs.
tools/Azure.Mcp.Tools.Workbooks/src/Models/WorkbookListResult.cs New model for list results with total count/paging metadata.
tools/Azure.Mcp.Tools.Workbooks/src/Models/WorkbookBatchResult.cs New models for batch show and batch delete outcomes.
tools/Azure.Mcp.Tools.Workbooks/src/Models/WorkbookError.cs New model for per-workbook errors.
tools/Azure.Mcp.Tools.Workbooks/src/Models/OutputFormat.cs New enum for list output shape (Summary/Standard/Full).
tools/Azure.Mcp.Tools.Workbooks/src/Models/WorkbookFilters.cs Adds semantic filters (name-contains, modified-after) and updates HasFilters.
tools/Azure.Mcp.Tools.Workbooks/tests/Azure.Mcp.Tools.Workbooks.UnitTests/*.cs Updates unit tests for new service signatures and result schemas.
tools/Azure.Mcp.Tools.Workbooks/tests/Azure.Mcp.Tools.Workbooks.LiveTests/WorkbooksCommandTests.cs Adds/updates live tests for list/show/delete batch behavior and new list features.
tools/Azure.Mcp.Tools.Workbooks/tests/Azure.Mcp.Tools.Workbooks.LiveTests/assets.json Updates the assets tag for recorded/live test resources.

Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs
Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs
Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs
Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs
Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Services/WorkbooksService.cs
Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/ListWorkbooksCommand.cs Outdated
matteing and others added 4 commits February 10, 2026 13:36
…kbooksCommand.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…stWorkbooksCommand

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@matteing matteing enabled auto-merge (squash) February 19, 2026 23:31
@matteing matteing disabled auto-merge February 19, 2026 23:33
@matteing
Copy link
Copy Markdown
Contributor Author

/azp run mcp - pullrequest - live

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Comment thread tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/ListWorkbooksCommand.cs Outdated
@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure MCP Server Feb 24, 2026
Address review feedback to use SubscriptionCommand instead of GlobalCommand,
consistent with all other tools in the repo.

- Change ListWorkbooksOptions base from GlobalOptions to SubscriptionOptions
- Change ListWorkbooksCommand base from GlobalCommand to SubscriptionCommand
- Remove manual subscription option registration/binding (handled by base)
- Update test for required subscription validation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@KarishmaGhiya
Copy link
Copy Markdown
Member

Fixes #1144

…pe discovery

Change ListWorkbooksCommand base class from SubscriptionCommand to
GlobalCommand so subscription is optional. This enables the cross-scope
discovery feature where workbooks can be listed across all accessible
subscriptions when --subscription is omitted.

Update unit test to verify the command succeeds without subscription
instead of expecting a validation error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@matteing matteing enabled auto-merge (squash) March 2, 2026 19:19
…mmand

Change ListWorkbooksCommand base class back to SubscriptionCommand so
subscription is required. Remove duplicate subscription option registration
and binding that were added when using GlobalCommand. Update unit test
to expect validation error when subscription is missing. Remove live test
that expected cross-scope discovery without subscription.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@matteing
Copy link
Copy Markdown
Contributor Author

matteing commented Mar 2, 2026

/azp run mcp - pullrequest - live

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@matteing matteing merged commit ef34d37 into main Mar 3, 2026
29 checks passed
@matteing matteing deleted the users/sergiomattei/Workbooks branch March 3, 2026 21:40
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure MCP Server Mar 3, 2026
colbytimm pushed a commit to colbytimm/microsoft-mcp that referenced this pull request Apr 20, 2026
* Fix bugs in Workbooks toolset identified during code review

- Fix SourceId type mismatch: convert ResourceIdentifier to string
- Remove unused FuzzyMatchInfo model and ScopeResolution property
- Remove unused subscriptions parameter from BuildWorkbooksQuery and BuildCountQuery
- Fix HandleWorkbookException return type from object? to WorkbookError
- Refactor GetWorkbooksAsync to use tuple pattern, removing dead code branch
- Add documentation for static semaphore rate limiting behavior

* Revert accidental changes to LiveTestSettingsFixture

* Update tools/Azure.Mcp.Tools.Workbooks/src/Commands/Workbooks/ListWorkbooksCommand.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* review(workbooks): Review suggestions from GitHub Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(workbooks): remove unused assignment

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: replace HasOption/GetValueForOption with GetValueOrDefault in ListWorkbooksCommand

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: restore SubscriptionCommand base class for ListWorkbooksCommand

Address review feedback to use SubscriptionCommand instead of GlobalCommand,
consistent with all other tools in the repo.

- Change ListWorkbooksOptions base from GlobalOptions to SubscriptionOptions
- Change ListWorkbooksCommand base from GlobalCommand to SubscriptionCommand
- Remove manual subscription option registration/binding (handled by base)
- Update test for required subscription validation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: make subscription optional in ListWorkbooksCommand for cross-scope discovery

Change ListWorkbooksCommand base class from SubscriptionCommand to
GlobalCommand so subscription is optional. This enables the cross-scope
discovery feature where workbooks can be listed across all accessible
subscriptions when --subscription is omitted.

Update unit test to verify the command succeeds without subscription
instead of expecting a validation error.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants