-
Notifications
You must be signed in to change notification settings - Fork 2k
Move MCPClient to root-level lib and manage optional dependencies #1238
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
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.
Thanks for the catch.
However, I am afraid that with the current structure of the codebase, we cannot import MCPClient
at the root level of the lib because mcp
and mcpadapt
are optional dependencies.
We should either fix the import to account for the optional nature of those dependencies, or fix the docs accordingly. In principle, I think it would be better to fix the import so the usage is consistent and neat.
It can be imported as follows:
Example: https://github.com/sergiopaniego/samples/blob/main/smolagents_mcp.py |
@sergiopaniego Thanks, yep the issue isn't with being able to import it, but rather that the docs are incorrect about how to import it. @albertvillanova made an update so that the import error is supressed, this should address the optional dependency issue? |
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.
Thanks @sergiopaniego for chiming in and for your quick workaround: much appreciated. 🤗
And thank you @njbrake for the fast update!
Apologies for the confusion earlier: I realize I wasn't clear in my previous message. I didn't mean to suggest modifying the import at the root level. Rather, my intention was to handle the optional dependencies within the class __init__
method, as we already do for most of the models in models.py
.
@albertvillanova ah, thanks for the clarification! Sorry I misunderstood you 😅 . I've made changes which I believe address your suggestion. Let me know what you think 👍 |
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.
Thanks a lot for the fix!
I just made a small code style adjustment for alignment, nothing major.
The readme instructions added in #1200
say to import MCPClient like
This PR is to add MCPClient to the
__init__
so that the code in the readme is accurate