Pin the MCP conformance tester package (#1176)
This commit is contained in:
parent
46d30444a8
commit
a1e9e4102e
3 changed files with 27 additions and 4 deletions
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class Program
|
|||
|
||||
app.MapMcp();
|
||||
|
||||
app.MapGet("/health", () => TypedResults.Ok("Healthy"));
|
||||
app.MapGet("/health", () => "Healthy");
|
||||
|
||||
await app.RunAsync(cancellationToken);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue