-
Notifications
You must be signed in to change notification settings - Fork 274
feat(js/plugins/mcp): Refactor to a client manager structure, with dynamic tool calling. #2884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Oh also I think we should put this work into a launch branch - I created |
This commit improves the MCP client and manager's connection handling by: - Renaming `initializeConnection` to `_initializeConnection` and making it private. - Adding try/catch blocks to `_initializeConnection` and `_connect` to handle connection errors more gracefully. - Changing log level from info to debug for connection messages. - Adding checks to ensure clients exist before disabling or enabling them. - Removing unused client property from McpTransportServerConfig. - Removing outdated tests and adding new test files.
The `setup` method on the `GenkitMcpServer` is now explicitly called and awaited before starting the server. This ensures that any asynchronous setup tasks are completed before the server begins processing requests. This change also updates the README and tests to reflect the new explicit setup call.
This commit moves the fetching of dynamic resource tools from the individual MCP client to the MCP manager. This allows the manager to aggregate resource tools from all active clients, providing a unified view of available resources. The `fetchDynamicResourceTools` function is now called within the `getActiveTools` method of the `GenkitMcpManager`, and the `resourceTools` option is added to control whether resource tools are included. Additionally, this commit includes minor refactoring and test updates to accommodate the change.
Updates the Model Context Protocol SDK dependency to version 1.12.0 in the MCP plugin's package.json and pnpm-lock.yaml. This ensures the plugin is using the latest version of the SDK.
Adds a GenkitError to `fromMcpPart` to handle cases where an unsupported part type is encountered, providing a clear message about the unimplemented type.
Uh oh!
There was an error while loading. Please reload this page.