Pin the MCP conformance tester package (#1176)
This commit is contained in:
parent
46d30444a8
commit
a1e9e4102e
5 changed files with 27 additions and 4 deletions
5
.github/workflows/ci-build-test.yml
vendored
5
.github/workflows/ci-build-test.yml
vendored
|
|
@ -67,8 +67,9 @@ jobs:
|
||||||
- name: 📦 Install dependencies for tests
|
- name: 📦 Install dependencies for tests
|
||||||
run: npm install @modelcontextprotocol/server-memory
|
run: npm install @modelcontextprotocol/server-memory
|
||||||
|
|
||||||
- name: 📦 Install dependencies for tests
|
# Keep version in sync with McpConformanceVersion in Directory.Packages.props
|
||||||
run: npm install @modelcontextprotocol/conformance
|
- name: 📦 Install conformance test runner
|
||||||
|
run: npm install @modelcontextprotocol/conformance@0.1.10
|
||||||
|
|
||||||
- name: 🏗️ Build
|
- name: 🏗️ Build
|
||||||
run: make build CONFIGURATION=${{ matrix.configuration }}
|
run: make build CONFIGURATION=${{ matrix.configuration }}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
<System9Version>9.0.11</System9Version>
|
<System9Version>9.0.11</System9Version>
|
||||||
<System10Version>10.0.2</System10Version>
|
<System10Version>10.0.2</System10Version>
|
||||||
<MicrosoftExtensionsVersion>10.2.0</MicrosoftExtensionsVersion>
|
<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>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Product dependencies shared -->
|
<!-- Product dependencies shared -->
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,13 @@
|
||||||
<PackageReference Include="System.Linq.AsyncEnumerable" />
|
<PackageReference Include="System.Linq.AsyncEnumerable" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
|
||||||
|
<_Parameter1>McpConformanceVersion</_Parameter1>
|
||||||
|
<_Parameter2>$(McpConformanceVersion)</_Parameter2>
|
||||||
|
</AssemblyAttribute>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\samples\TestServerWithHosting\TestServerWithHosting.csproj" />
|
<ProjectReference Include="..\..\samples\TestServerWithHosting\TestServerWithHosting.csproj" />
|
||||||
<ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj" />
|
<ProjectReference Include="..\..\src\ModelContextProtocol.Core\ModelContextProtocol.Core.csproj" />
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,21 @@ public class ServerConformanceTests : IAsyncLifetime
|
||||||
_serverTask = Task.Run(() => ConformanceServer.Program.MainAsync(["--urls", _serverUrl], new XunitLoggerProvider(_output), cancellationToken: _serverCts.Token));
|
_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()
|
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 outputBuilder = new StringBuilder();
|
||||||
var errorBuilder = new StringBuilder();
|
var errorBuilder = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class Program
|
||||||
|
|
||||||
app.MapMcp();
|
app.MapMcp();
|
||||||
|
|
||||||
app.MapGet("/health", () => TypedResults.Ok("Healthy"));
|
app.MapGet("/health", () => "Healthy");
|
||||||
|
|
||||||
await app.RunAsync(cancellationToken);
|
await app.RunAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue