feat(js/plugins/mcp): Refactor to a client manager structure, with dynamic tool calling.
- Modified the current McpClient class to a Client manager class
- GenkitMcpClient is now a dedicated single client-server connection.
- Tools are now fetched dynamically to support adding/removing/disabling clients in the manager.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Oh also I think we should put this work into a launch branch - I created launch/mcp-redux and made #2896 to squash my own work and create a chain of commits. Can you rebase onto the launch/mcp-redux as your merge target?
One more high-level piece of food for thought: in the client manager context, I think we probably want to be very robust to misconfiguration errors. It's possible people will use this for dynamic, user-configured tools and when that happens we should recover gracefully as best we can.
So maybe in the client manager there should be an {error?: {message, status, details}} and if there's an error trying to connect to the server it is put in a disabled state, an error-level log is emitted, and the error is also saved with the server.
I'll work on this in a new commit, updating the PR to reflect the changes so far.