From a1e9e4102ed7862ab35791610a5dd25e318aeb82 Mon Sep 17 00:00:00 2001 From: Eirik Tsarpalis Date: Mon, 26 Jan 2026 22:35:31 +0200 Subject: [PATCH] Pin the MCP conformance tester package (#1176) --- .github/workflows/ci-build-test.yml | 5 +++-- Directory.Packages.props | 3 +++ .../ModelContextProtocol.AspNetCore.Tests.csproj | 7 +++++++ .../ServerConformanceTests.cs | 14 +++++++++++++- .../Program.cs | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-build-test.yml b/.github/workflows/ci-build-test.yml index ab20348..838dce4 100644 --- a/.github/workflows/ci-build-test.yml +++ b/.github/workflows/ci-build-test.yml @@ -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 }} diff --git a/Directory.Packages.props b/Directory.Packages.props index 42af0c0..b5f5990 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,6 +5,9 @@ 9.0.11 10.0.2 10.2.0 + + 0.1.10 diff --git a/tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj b/tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj index 095560a..934a81c 100644 --- a/tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj +++ b/tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj @@ -51,6 +51,13 @@ + + + <_Parameter1>McpConformanceVersion + <_Parameter2>$(McpConformanceVersion) + + + diff --git a/tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs b/tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs index 312f324..3948ad1 100644 --- a/tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs +++ b/tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs @@ -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() + .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(); diff --git a/tests/ModelContextProtocol.ConformanceServer/Program.cs b/tests/ModelContextProtocol.ConformanceServer/Program.cs index 1042267..00e557e 100644 --- a/tests/ModelContextProtocol.ConformanceServer/Program.cs +++ b/tests/ModelContextProtocol.ConformanceServer/Program.cs @@ -94,7 +94,7 @@ public class Program app.MapMcp(); - app.MapGet("/health", () => TypedResults.Ok("Healthy")); + app.MapGet("/health", () => "Healthy"); await app.RunAsync(cancellationToken); }