Skip to content
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Netclaw.Daemon.Tests.Mcp;

public sealed class McpSdkCatalogNotificationIntegrationTests
public sealed class McpSdkCatalogNotificationIntegrationTests(ITestOutputHelper output)
{
private static readonly McpServerName ServerName = new("notifications");

Expand All @@ -27,9 +27,11 @@ public async Task RawListenAcknowledgementAndToolEvent_RefreshLiveCatalog()
var registry = new ToolRegistry();
await using var harness = McpSmokeHarness.Create(
new Dictionary<string, McpServerEntry> { [ServerName.Value] = entry },
registry);
registry,
output);

await harness.Manager.StartAsync(TestContext.Current.CancellationToken);
harness.AssertConnected(ServerName.Value);
var first = Assert.IsType<McpServerSnapshot>(harness.Manager.GetSnapshot(ServerName));
var lease = Assert.IsType<McpCatalogNotificationLease>(first.NotificationLease);
Assert.Equal(McpCatalogNotificationMode.Modern, lease.Mode);
Expand All @@ -47,4 +49,30 @@ public async Task RawListenAcknowledgementAndToolEvent_RefreshLiveCatalog()
Assert.Equal(first.Generation + 1, second.Generation);
Assert.Contains("dynamic-added", second.ToolFunctions.Keys);
}

[Fact]
public async Task FailedStdioStartup_IsReportedBeforeLeaseAssertions()
{
var entry = new McpServerEntry
{
Transport = "stdio",
Command = $"netclaw-missing-mcp-server-{Guid.NewGuid():N}",
Enabled = true,
};
await using var harness = McpSmokeHarness.Create(
new Dictionary<string, McpServerEntry> { [ServerName.Value] = entry },
new ToolRegistry(),
output);

await harness.Manager.StartAsync(TestContext.Current.CancellationToken);

var failure = Assert.Throws<Xunit.Sdk.TrueException>(
() => harness.AssertConnected(ServerName.Value));
Assert.Contains("state=Unreachable", failure.Message, StringComparison.Ordinal);
Assert.Contains("Failed to reach MCP server", failure.Message, StringComparison.Ordinal);
Assert.Contains("Failed to connect to MCP server", output.Output, StringComparison.Ordinal);
Assert.Contains("System.IO.IOException", output.Output, StringComparison.Ordinal);
Assert.Contains(entry.Command, output.Output, StringComparison.Ordinal);
Assert.Null(harness.Manager.GetSnapshot(ServerName)?.NotificationLease);
}
}
Loading