General cleanups to improve reliability#2223
Merged
alzimmermsft merged 2 commits intomicrosoft:release/azure/2.xfrom Mar 26, 2026
Merged
General cleanups to improve reliability#2223alzimmermsft merged 2 commits intomicrosoft:release/azure/2.xfrom
alzimmermsft merged 2 commits intomicrosoft:release/azure/2.xfrom
Conversation
* General cleanups to improve reliability * Few small tweaks * Change log level, remove default param value, update parameter description * Use ConcurrentDictionary inside group keys instead of managing two dictionaries * Fix logic * Give some breadcrumps to display error * Add ConcurrentHashSet for convenience
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies a set of reliability and hardening updates across MCP core and multiple Azure tools, focusing on preventing hangs (regex timeouts), avoiding silent failures, adding safe upper bounds to potentially unbounded listings, and improving troubleshooting/logging.
Changes:
- Introduces
RegexHelper(default 3s timeout) and updates several validators/services to use it. - Adds resource-count caps (e.g., tenants, subscriptions, function apps) and improves exception/cancellation handling and logging.
- Improves safety and correctness in a few flows (e.g., Kusto identifier validation, non-root Docker runtime, tenant-aware subscription enumeration).
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Redis/src/Services/RedisService.cs | Adds logger injection and logs partial failures while allowing cancellation to propagate. |
| tools/Azure.Mcp.Tools.Postgres/src/Validation/SqlQueryValidator.cs | Switches regex calls to use shared default timeout. |
| tools/Azure.Mcp.Tools.Postgres/src/Services/PostgresService.cs | Removes unused Azure.ResourceManager using. |
| tools/Azure.Mcp.Tools.MySql/src/Services/MySqlService.cs | Uses RegexHelper for consistent timeouts/creation. |
| tools/Azure.Mcp.Tools.Monitor/tests/Azure.Mcp.Tools.Monitor.LiveTests/MonitorCommandTests.cs | Updates test wiring for new logger parameters. |
| tools/Azure.Mcp.Tools.Monitor/src/Services/MonitorWebTestService.cs | Uses RegexHelper for compiled regex with timeout. |
| tools/Azure.Mcp.Tools.Kusto/src/Validation/KustoIdentifierValidator.cs | Adds Kusto identifier validation to reduce KQL injection risk. |
| tools/Azure.Mcp.Tools.Kusto/src/Services/KustoService.cs | Validates table name before schema query. |
| tools/Azure.Mcp.Tools.Kusto/src/Options/KustoOptionDefinitions.cs | Expands --limit description with intended bounds. |
| tools/Azure.Mcp.Tools.Kusto/src/Commands/SampleCommand.cs | Clamps --limit to safe bounds before building query. |
| tools/Azure.Mcp.Tools.FunctionApp/src/Services/FunctionAppService.cs | Adds a max function-app cap with warning logging. |
| tools/Azure.Mcp.Tools.EventGrid/src/Commands/Subscription/SubscriptionListCommand.cs | Ensures tenant is honored when enumerating subscriptions. |
| tools/Azure.Mcp.Tools.Cosmos/src/Validation/CosmosQueryValidator.cs | Uses RegexHelper for safe regex timeouts. |
| tools/Azure.Mcp.Tools.AzureMigrate/src/Helpers/AzureMigrateProjectHelper.cs | Passes tenant through to subscription resolution. |
| tools/Azure.Mcp.Tools.AppConfig/tests/Azure.Mcp.Tools.AppConfig.LiveTests/AppConfigCommandTests.cs | Updates test wiring for new logger parameters. |
| core/Microsoft.Mcp.Core/src/Services/Caching/SingleUserCliCacheService.cs | Makes group-key tracking thread-safe and avoids concurrent enumeration issues. |
| core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs | Reduces console exception detail for headless/X11 detection path. |
| core/Microsoft.Mcp.Core/src/Models/ConcurrentHashSet.cs | Adds a minimal concurrent set used by cache group-key tracking. |
| core/Microsoft.Mcp.Core/src/Helpers/RegexHelper.cs | Introduces shared regex creation helper with default timeout and wrapping errors. |
| core/Microsoft.Mcp.Core/src/Helpers/EmbeddedResourceHelper.cs | Uses RegexHelper for resource name pattern matching with timeout. |
| core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Runtime/McpRuntime.cs | Provides fallback message when exception message is empty. |
| core/Azure.Mcp.Core/tests/Azure.Mcp.Core.LiveTests/Services/Azure/Authentication/AuthenticationIntegrationTests.cs | Updates DI setup for new SubscriptionService logger dependency. |
| core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs | Adds tenant listing cap and logger dependency. |
| core/Azure.Mcp.Core/src/Services/Azure/Subscription/SubscriptionService.cs | Adds subscription listing cap and logger dependency. |
| Dockerfile | Runs the server as a non-root user in the Alpine runtime image. |
philon-msft
approved these changes
Mar 26, 2026
conniey
approved these changes
Mar 26, 2026
conniey
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
General cleanups to improve reliability:
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