Skip to content

Conversation

@Tenfleques
Copy link

Problem

The MCP example in cookbook/mcp/agent_http.py had several issues preventing it from running properly:

  1. Async Context Manager Error: MultiServerMCPClient was using async with syntax which is no longer supported in langchain-mcp-adapters 0.1.0+
  2. Authentication Issues: GIGACHAT_BASE_URL in .env.example was causing 401 Unauthorized errors
  3. Missing Dependencies: No requirements.txt with pinned versions for reproducible setup
  4. Outdated Documentation: README referenced packages without versions

This was causing a NotImplementedError:

As of langchain-mcp-adapters 0.1.0, MultiServerMCPClient cannot be used as a context manager (e.g., async with MultiServerMCPClient(...)).

Solution

This PR provides comprehensive fixes:

🔧 MCP Client Compatibility

  • Removed async with usage for MultiServerMCPClient
  • Updated to use recommended pattern: direct instantiation + await client.get_tools()

🔐 Authentication Fix

  • Removed GIGACHAT_BASE_URL from .env.example that was causing auth errors
  • Added guidance in README about this change

📦 Dependency Management

  • Added requirements.txt with pinned package versions:
    • langchain-gigachat==0.3.11
    • langchain-mcp-adapters==0.1.8
    • langgraph==0.5.1
    • rich==14.0.0

📖 Documentation Updates

  • Updated README to reference requirements.txt for installation
  • Added note about GIGACHAT_BASE_URL removal
  • Provided both pip install -r requirements.txt and manual installation options

Testing

  • Code runs without the previous NotImplementedError
  • No more authentication errors with GigaChat
  • MCP tools are properly loaded and accessible to the agent
  • Installation instructions work with provided requirements.txt

Files Changed

  • cookbook/mcp/agent_http.py: Fixed MCP client instantiation pattern
  • cookbook/mcp/.env.example: Removed problematic GIGACHAT_BASE_URL
  • cookbook/mcp/requirements.txt: Added pinned dependencies (new file)
  • cookbook/mcp/README.md: Updated installation and setup instructions

Impact

This fixes the MCP example to work properly with current versions of all dependencies and provides a better setup experience for users.

…bility

- Remove async with usage for MultiServerMCPClient (langchain-mcp-adapters 0.1.0+ compatibility)
- Remove GIGACHAT_BASE_URL from .env.example to fix authorization errors
- Add requirements.txt with pinned package versions for reproducible setup
- Update README.md to reference requirements.txt and include installation notes
- Add guidance about GIGACHAT_BASE_URL removal in README

Resolves:
- NotImplementedError when using async context manager with MultiServerMCPClient
- Authentication errors caused by GIGACHAT_BASE_URL configuration
- Missing dependency versions causing potential compatibility issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant