-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(samples): Update MultiServerMCPClient usage for langchain-mcp-adapters 0.1.0 #410
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #410 +/- ##
=======================================
Coverage 82.48% 82.48%
=======================================
Files 170 170
Lines 12101 12101
Branches 1842 1842
=======================================
Hits 9982 9982
Misses 1497 1497
Partials 622 622 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
awslabs-mcp
left a comment
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.
Pull Request Review
Summary
This PR addresses an issue in the MultiServerMCPClient usage in two sample applications. The issue is due to a breaking change in the langchain-mcp-adapters 0.1.0 library where MultiServerMCPClient can no longer be used as a context manager.
Changes Analysis
The PR updates two client server implementations:
1.
2.
Both files had the same issue where they were using context manager pattern which is no longer supported. The PR removes the context manager and directly uses the mcp_client instance with .
The change follows option #1 in the error message:
Code Review
- ✅ The implementation follows the recommended approach from the langchain-mcp-adapters error message
- ✅ Code indentation is maintained consistently after removing the context manager block
- ✅ Error handling is preserved
- ✅ No functional changes other than the required MultiServerMCPClient usage pattern change
- ✅ All existing functionality appears to be maintained
Tests
All checks are passing on the PR, and the code change is properly scoped to only what's necessary to fix the issue.
Recommendations
Approved - these changes appropriately address the breaking change in the langchain-mcp-adapters library and should allow the sample applications to work correctly again.
Run ID: 15280314994
awslabs-mcp
left a comment
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.
Pull Request Review
Summary
This PR addresses an issue in the MultiServerMCPClient usage in two sample applications. The issue is due to a breaking change in the langchain-mcp-adapters 0.1.0 library where MultiServerMCPClient can no longer be used as a context manager.
Changes Analysis
The PR updates two client server implementations:
- samples/mcp-integration-with-kb/clients/client_server.py
- samples/mcp-integration-with-nova-canvas/clients/client_server.py
Both files had the same issue where they were using the context manager pattern which is no longer supported. The PR removes the context manager and directly uses the mcp_client instance with the awaited get_tools method.
The change follows option #1 in the error message from the library.
Code Review
- ✅ The implementation follows the recommended approach from the langchain-mcp-adapters error message
- ✅ Code indentation is maintained consistently after removing the context manager block
- ✅ Error handling is preserved
- ✅ No functional changes other than the required MultiServerMCPClient usage pattern change
- ✅ All existing functionality appears to be maintained
Tests
All checks are passing on the PR, and the code change is properly scoped to only what is necessary to fix the issue.
Recommendations
Approved - these changes appropriately address the breaking change in the langchain-mcp-adapters library and should allow the sample applications to work correctly again.
Run ID: 15280314994
awslabs-mcp
left a comment
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.
Pull Request Review
Overview
This pull request addresses an issue with the MultiServerMCPClient usage in two sample applications. The problem stemmed from a breaking change in the langchain-mcp-adapters 0.1.0 library, which no longer allows MultiServerMCPClient to be used as a context manager.
Files Analyzed
samples/mcp-integration-with-kb/clients/client_server.pysamples/mcp-integration-with-nova-canvas/clients/client_server.py
Code Changes Assessment
The changes in both files follow the same pattern:
- Removal of context manager: Removed the
async with mcp_client as clientcontext manager pattern - Direct client usage: Changed from
client.get_tools()toawait mcp_client.get_tools() - Code indentation adjustment: Reduced the indentation level of the affected code blocks
The changes properly follow option #1 from the error message mentioned in the PR description:
client = MultiServerMCPClient(...)
tools = await client.get_tools()
Quality Assessment
- Code correctness: The changes correctly implement the recommended approach for using
MultiServerMCPClientwith version 0.1.0+ - Code style: Proper indentation is maintained throughout the modified sections
- Error handling: All exception handling is preserved with the same structure
- Functional equivalence: The changes maintain the same functionality, only modifying how the MCP client is initialized and used
- Scope of changes: Changes are appropriately limited to only what's necessary to fix the issue
Test Results
All CI checks are passing, indicating that the changes do not introduce any regressions or new issues. The code coverage remains at 82.48%, unchanged from the base branch.
Recommendation
I approve this pull request as it:
- Correctly addresses the breaking change in the langchain-mcp-adapters library
- Makes minimal and focused changes to fix the issue
- Maintains all existing functionality
- Follows good coding practices
- Passes all automated checks
This change will ensure the sample applications continue to work correctly with the updated langchain-mcp-adapters library.
Run ID: 15285849697
…pters 0.1.0 (awslabs#410) * fix: Update MultiServerMCPClient usage for langchain-mcp-adapters 0.1.0 * fix: Update MultiServerMCPClient usage for langchain-mcp-adapters 0.1.0 for kb sample * chore: cleaning up repetitive logs + vars
Fixes
Summary
Was getting the following error when testing the Nova sample:
clients.client_server - ERROR - Error in generate_image: As of langchain-mcp-adapters 0.1.0, MultiServerMCPClient cannot be used as a context manager (e.g., async with MultiServerMCPClient(...)). Instead, you can do one of the following:
tools = await client.get_tools()
async with client.session(server_name) as session:
tools = await load_mcp_tools(session)
Changes
Went with the first approach and updated the code to
tools = await client.get_tools()User experience
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? (Y/N)
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.