Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Is McpClientFactory's caching useful? #76

@stephentoub

Description

@stephentoub

Most of the complexity in McpClientFactory, including it being instantiable, tracking clients, having a callback-based creation mechanism, etc., all seems to stem from a desire to be able to cache IMcpClient instances inside of the factory for subsequent use.

Is that valuable? This factory isn't thread-safe, so presumably an individual caller is constructing the factory and then using it in isolation; what scenarios would drive someone to go back to the factory each time it needs a client for a server, but still holding onto the factory instance, rather than just holding on to the client that it needs for that server?

Getting rid of that capability, and just pushing client instance management to the host, would simplify the factory and make it simpler to use, e.g. just a static McpClientFactory.Create method that also has a simpler signature.

cc: @eiriktsarpalis, @PederHP

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions