-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: MCP calling node error #3752 #3762
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The provided code appears to be part of an asynchronous function named
executewithin a class that likely handles execution logic for Multi-Cloud Platform (MCP) tools. Here are some observations, adjustments, and improvements:Issues Identified
Potential Missing Import:
You didn't include an import statement for the
Sessionclass fromlangchain_mcp_adapters.sessions.Typo in Session Variable Name:
The variable name used in the context manager (
s) doesn't directly correlate with the method you intend to call (call_tool). It should match either the session object created or the one returned.Asyncio Syntax Adjustment:
If
async_runis intended to be called on the entire coroutine rather than its result, there might need further clarification on this use case.Error Handling:
This function does not handle exceptions or specific error situations well. Adding try-except blocks would be helpful for debugging purposes or recovery actions.
Variable Naming Consistency:
Ensure consistent naming conventions throughout the code, especially variables like
tool_params, which seems more closely related to parameters than actual tool-specific settings.Documentation:
Although not specified in the question, it's important to maintain clear comments and documentation explaining the purpose and functionality of each part of the code.
Suggestions
Changes Made:
Session.stotto match the parameters passed tocall_tool. Also updated the usage inside.await c.session()instead of creating anotherclient.sessionobject because typically, you want reusability unless specifically designed otherwise.These changes aim at making the code more readable, correct, and potentially more reusable or debuggable without additional changes based on what was originally requested. Please let me know if you need further modifications!