Add pre-flight version check for registry stdio servers#2338
Open
Add pre-flight version check for registry stdio servers#2338
Conversation
When a registry stdio server (like azd) specifies a minVersion, the provider now checks if the command is installed and meets the version requirement before attempting to create the MCP client. Previously, all failures from stdio client creation were caught with a generic 'dependencies not installed' message, which was confusing when the tool was installed but at the wrong version. Now users get specific messages: - Not installed: 'azd' is not installed or not found in the system PATH. - Wrong version: 'azd' version 1.11.0 is installed, but version 1.20.0 or later is required. Changes: - Add MinVersion and VersionArgs properties to RegistryServerInfo - Add CheckCommandVersionAsync with 30s timeout, concurrent stream reading, and proper process cleanup - Add versionArgs/minVersion to azd entry in registry.json - Add 7 unit tests covering all version check scenarios Fixes #1025 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a generic pre-flight version check for registry-defined stdio MCP servers so users get a clear, actionable error when a required dependency is installed but below a minimum version (e.g., azd < 1.20.0), addressing the confusion described in #1025.
Changes:
- Extended registry server configuration to support
minVersionandversionArgs. - Added process-based version probing + version parsing in
RegistryServerProviderbefore creating stdio clients. - Updated the built-in
registry.jsonentry forazdto require>= 1.20.0and added unit tests covering parsing and common failure/success cases.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
servers/Azure.Mcp.Server/src/Resources/registry.json |
Declares azd’s minimum required version and how to query it. |
core/Microsoft.Mcp.Core/src/Areas/Server/Models/RegistryServerInfo.cs |
Adds MinVersion / VersionArgs to the registry server model. |
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs |
Implements the pre-flight version check and version parsing logic used during client creation. |
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Discovery/RegistryServerProviderTests.cs |
Adds tests for version parsing and version-check behavior paths. |
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
alzimmermsft
reviewed
Apr 3, 2026
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
core/Microsoft.Mcp.Core/src/Areas/Server/Commands/Discovery/RegistryServerProvider.cs
Outdated
Show resolved
Hide resolved
… timeout - Gate version check on clientFactory == CreateStdioClientAsync so HTTP servers don't trigger an unrelated local process check - Fall back to parsing stderr when stdout has no version string, since some tools print version info to stderr - Observe stdout/stderr tasks after timeout+kill to prevent unobserved task exceptions from disposed stream reads Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove partial class; move version pattern to registry config - Add VersionPattern property to RegistryServerInfo for non-semver tools - Make versionArgs required when minVersion is set (throw if missing) - Remove stderr redirect; read only stdout for version output - Add tests for custom pattern and missing versionArgs validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Problem
When
azdis installed but at a version below the minimum (1.20.0), the error message says "This tool may require dependencies that are not installed" instead of telling the user their version is too old. This is confusing — the tool IS installed, just outdated.Fixes #1025
Solution
Add a generic pre-flight version check to
RegistryServerProviderthat runs before creating the stdio MCP client. Registry servers can now declareminVersionandversionArgsinregistry.jsonto enable version checking.Error messages are now specific:
'azd' is not installed or not found in the system PATH.'azd' version 1.11.0 is installed, but version 1.20.0 or later is required.Changes
RegistryServerInfo.csMinVersionandVersionArgspropertiesRegistryServerProvider.csCheckCommandVersionAsyncwith 30s timeout, concurrent stdout/stderr reading, proper process cleanup; addedParseVersionFromOutputwithGeneratedRegexregistry.jsonminVersion: 1.20.0andversionArgs: ["version"]for azdRegistryServerProviderTests.csDesign Decisions
minVersion/versionArgsProcess.Kill(entireProcessTree: true)on timeout,Process.Start()return value checked[GeneratedRegex]for source-generated regexTesting
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess 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.