Pin the MCP conformance tester package (#1176)

This commit is contained in:
Eirik Tsarpalis 2026-01-26 22:35:31 +02:00 • committed by GitHub
commit a1e9e4102e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 4 deletions

View file

@ -67,8 +67,9 @@ jobs:
- name: 📦 Install dependencies for tests
run: npm install @modelcontextprotocol/server-memory
- name: 📦 Install dependencies for tests
run: npm install @modelcontextprotocol/conformance
# Keep version in sync with McpConformanceVersion in Directory.Packages.props
- name: 📦 Install conformance test runner
run: npm install @modelcontextprotocol/conformance@0.1.10
- name: 🏗️ Build
run: make build CONFIGURATION=${{ matrix.configuration }}

View file

@ -5,6 +5,9 @@
<System9Version>9.0.11</System9Version>
<System10Version>10.0.2</System10Version>
<MicrosoftExtensionsVersion>10.2.0</MicrosoftExtensionsVersion>
<!-- Pin the conformance tester Node package version for CI stability.
Keep in sync npm install step at ci-build-test.yml -->
<McpConformanceVersion>0.1.10</McpConformanceVersion>
</PropertyGroup>
<!-- Product dependencies shared -->

View file

@ -51,6 +51,13 @@
<PackageReference Include="System.Linq.AsyncEnumerable" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>McpConformanceVersion</_Parameter1>
<_Parameter2>$(McpConformanceVersion)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\samples\TestServerWithHosting\TestServerWithHosting.csproj" />
<ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj" />

View file

@ -115,9 +115,21 @@ public class ServerConformanceTests : IAsyncLifetime
_serverTask = Task.Run(() => ConformanceServer.Program.MainAsync(["--urls", _serverUrl], new XunitLoggerProvider(_output), cancellationToken: _serverCts.Token));
}
private static string GetConformanceVersion()
{
var assembly = typeof(ServerConformanceTests).Assembly;
var attribute = assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyMetadataAttribute), false)
.Cast<System.Reflection.AssemblyMetadataAttribute>()
.FirstOrDefault(a => a.Key == "McpConformanceVersion");
return attribute?.Value ?? throw new InvalidOperationException("McpConformanceVersion not found in assembly metadata");
}
private async Task<(bool Success, string Output, string Error)> RunNpxConformanceTests()
{
var startInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance server --url {_serverUrl}");
// Version is configured in Directory.Packages.props for central management
var version = GetConformanceVersion();
var startInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance@{version} server --url {_serverUrl}");
var outputBuilder = new StringBuilder();
var errorBuilder = new StringBuilder();

View file

@ -94,7 +94,7 @@ public class Program
app.MapMcp();
app.MapGet("/health", () => TypedResults.Ok("Healthy"));
app.MapGet("/health", () => "Healthy");
await app.RunAsync(cancellationToken);
}