Path: redb-route/redb.Route.Llm.Mcp/IMcpRegistry.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Llm.Mcp/IMcpRegistry.cs ---- using System.Collections.Concurrent; namespace redb.Route.Llm.Mcp; /// /// Registry of singletons keyed by server name. /// Populated by on host startup; queried by /// at tools/call time. /// public interface IMcpRegistry { /// Adds a client to the registry. Replaces any existing entry with the same name. void Register(IMcpClient client); /// Returns the client for the given server name, or null when none is registered. IMcpClient? GetClient(string serverName); /// Snapshot of all clients currently in the registry. IReadOnlyCollection All(); /// Removes a client from the registry by name. Returns the removed client, or null. IMcpClient? Remove(string serverName); } /// Default in-memory thread-safe . public sealed class McpRegistry : IMcpRegistry { private readonly ConcurrentDictionary _clients = new(StringComparer.OrdinalIgnoreCase); /// public void Register(IMcpClient client) { ArgumentNullException.ThrowIfNull(client); _clients[client.ServerName] = client; } /// public IMcpClient? GetClient(string serverName) { ArgumentException.ThrowIfNullOrWhiteSpace(serverName); return _clients.TryGetValue(serverName, out var client) ? client : null; } /// public IReadOnlyCollection All() => [.. _clients.Values]; /// public IMcpClient? Remove(string serverName) { ArgumentException.ThrowIfNullOrWhiteSpace(serverName); return _clients.TryRemove(serverName, out var client) ? client : null; } }