Skip to content
Open
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 @@ -82,6 +82,7 @@ private async Task TryConnectAsync()
{
await client.DisposeAsync();
McpServers.Remove(Id);
client = null;
}

_runCts = new CancellationTokenSource();
Expand Down Expand Up @@ -109,6 +110,18 @@ private async Task TryConnectAsync()
}
catch (Exception ex)
{
if (client != null)
{
try
{
await client.DisposeAsync();
}
catch (Exception disposeException)
{
this.Get<ILogger<McpServerItemViewModel>>().LogWarning(disposeException, "Failed to dispose MCP client after connection failure.");
}
}

State = McpServerState.Error;
FunctionCount = 0;
Functions.Clear();
Expand Down Expand Up @@ -176,4 +189,4 @@ public sealed class McpAgentConfig : McpServerDefinition
public bool? IsEnabled { get; set; }
}

public sealed partial class McpAgentConfigCollection : Dictionary<string, McpAgentConfig>;
public sealed partial class McpAgentConfigCollection : Dictionary<string, McpAgentConfig>;