Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<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 -->
<McpConformanceVersion>0.1.10</McpConformanceVersion>
</PropertyGroup>

<!-- Product dependencies shared -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,32 @@ private void StartConformanceServer()
_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();
_output.WriteLine($"=== Requested conformance package version: {version} ===");

// First, check the actual version that will be used
var versionCheckInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance@{version} --version");
var versionProcess = Process.Start(versionCheckInfo);
if (versionProcess != null)
{
var actualVersion = await versionProcess.StandardOutput.ReadToEndAsync();
await versionProcess.WaitForExitAsync();
_output.WriteLine($"=== Actual conformance package version: {actualVersion.Trim()} ===");
}

var startInfo = NodeHelpers.NpxStartInfo($"-y @modelcontextprotocol/conformance@{version} server --url {_serverUrl}");

var outputBuilder = new StringBuilder();
var errorBuilder = new StringBuilder();
Expand Down
3 changes: 2 additions & 1 deletion tests/ModelContextProtocol.ConformanceServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public static async Task MainAsync(string[] args, ILoggerProvider? loggerProvide

app.MapMcp();

app.MapGet("/health", () => TypedResults.Ok("Healthy"));
// Return plain string to avoid JSON serialization issues when reflection is disabled
Comment thread
eiriktsarpalis marked this conversation as resolved.
Outdated
app.MapGet("/health", () => "Healthy");

await app.RunAsync(cancellationToken);
}
Expand Down
Loading