Skip to content

Commit a1e9e41

Browse files
Pin the MCP conformance tester package (#1176)
1 parent 46d3044 commit a1e9e41

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

.github/workflows/ci-build-test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ jobs:
6767
- name: 📦 Install dependencies for tests
6868
run: npm install @modelcontextprotocol/server-memory
6969

70-
- name: 📦 Install dependencies for tests
71-
run: npm install @modelcontextprotocol/conformance
70+
# Keep version in sync with McpConformanceVersion in Directory.Packages.props
71+
- name: 📦 Install conformance test runner
72+
run: npm install @modelcontextprotocol/conformance@0.1.10
7273

7374
- name: 🏗️ Build
7475
run: make build CONFIGURATION=${{ matrix.configuration }}

Directory.Packages.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<System9Version>9.0.11</System9Version>
66
<System10Version>10.0.2</System10Version>
77
<MicrosoftExtensionsVersion>10.2.0</MicrosoftExtensionsVersion>
8+
<!-- Pin the conformance tester Node package version for CI stability.
9+
Keep in sync npm install step at ci-build-test.yml -->
10+
<McpConformanceVersion>0.1.10</McpConformanceVersion>
811
</PropertyGroup>
912

1013
<!-- Product dependencies shared -->

tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
<PackageReference Include="System.Linq.AsyncEnumerable" />
5252
</ItemGroup>
5353

54+
<ItemGroup>
55+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
56+
<_Parameter1>McpConformanceVersion</_Parameter1>
57+
<_Parameter2>$(McpConformanceVersion)</_Parameter2>
58+
</AssemblyAttribute>
59+
</ItemGroup>
60+
5461
<ItemGroup>
5562
<ProjectReference Include="..\..\samples\TestServerWithHosting\TestServerWithHosting.csproj" />
5663
<ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj" />

tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,21 @@ private void StartConformanceServer()
115115
_serverTask = Task.Run(() => ConformanceServer.Program.MainAsync(["--urls", _serverUrl], new XunitLoggerProvider(_output), cancellationToken: _serverCts.Token));
116116
}
117117

118+
private static string GetConformanceVersion()
119+
{
120+
var assembly = typeof(ServerConformanceTests).Assembly;
121+
var attribute = assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyMetadataAttribute), false)
122+
.Cast<System.Reflection.AssemblyMetadataAttribute>()
123+
.FirstOrDefault(a => a.Key == "McpConformanceVersion");
124+
return attribute?.Value ?? throw new InvalidOperationException("McpConformanceVersion not found in assembly metadata");
125+
}
126+
118127
private async Task<(bool Success, string Output, string Error)> RunNpxConformanceTests()
119128
{
120-
var startInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance server --url {_serverUrl}");
129+
// Version is configured in Directory.Packages.props for central management
130+
var version = GetConformanceVersion();
131+
132+
var startInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance@{version} server --url {_serverUrl}");
121133

122134
var outputBuilder = new StringBuilder();
123135
var errorBuilder = new StringBuilder();

tests/ModelContextProtocol.ConformanceServer/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static async Task MainAsync(string[] args, ILoggerProvider? loggerProvide
9494

9595
app.MapMcp();
9696

97-
app.MapGet("/health", () => TypedResults.Ok("Healthy"));
97+
app.MapGet("/health", () => "Healthy");
9898

9999
await app.RunAsync(cancellationToken);
100100
}

0 commit comments

Comments
 (0)