Skip to content

Add Support for any AI Provider ( Ant & Gem current )Β #2

@mirothedj

Description

@mirothedj

🎯 Overview

This PR adds support for Google Gemini as an additional AI provider alongside the existing Anthropic Claude integration, giving users more choice in AI models for their MCP applications.

✨ Features Added

  • Multi-AI Provider Support
  • Google Gemini Integration: Full support for Gemini 1.5 Pro model
  • Provider Selection: Easy switching between Anthropic Claude and Google Gemini
  • Backward Compatibility: Existing Claude-only setups continue to work unchanged
  • New Files
  • python-example/client/client_multi_ai.py - Enhanced client with dual AI provider support
  • python-example/client/run_client.py - Launcher script for easy provider selection
  • python-example/client/SETUP_SUMMARY.md - Comprehensive setup documentation
  • CHANGELOG.md - Project changelog
  • Enhanced Configuration
  • Updated .env file to support both API keys
  • Added google-generativeai dependency to pyproject.toml
  • Command-line arguments for provider selection

**πŸš€ Usage Examples**Quick Start

## Run with Claude (default)

  • python run_client.py --provider anthropic
    ## Run with Gemini
  • python run_client.py --provider gemini
    ## List available providers
  • python run_client.py --list-providers
  • Environment Configuration
    ## Choose your AI provider by setting one of these API keys
  • ANTHROPIC_API_KEY=your_anthropic_api_key
  • GEMINI_API_KEY=your_gemini_api_key
    ## Set the provider you want to use: 'anthropic' or 'gemini'
  • AI_PROVIDER=anthropic

πŸ”§ Technical _Implementation

_Gemini Tool Calling

  • Uses prompt engineering approach for tool invocation (Gemini doesn't natively support MCP tools)_
  • JSON-based tool calling interface
  • Comprehensive error handling and fallbacks
  • Architecture
  • Maintains existing client architecture
  • Polymorphic AI provider interface
  • Clean separation of concerns between providers
  • Compatibility
  • Python 3.11+ (reduced from original 3.12+ requirement)
  • All existing functionality preserved
  • No breaking changes to existing APIs

πŸ§ͺ Testing

Weather Queries Tested
βœ… "What's the weather like in New York City?"
βœ… "Are there any weather alerts in California?"
βœ… "Tell me the forecast for Boston tomorrow."
Provider Switching
βœ… Dynamic provider selection via command line
βœ… Environment variable configuration
βœ… Proper error handling for missing API keys

πŸ“š Documentation Updates
Updated README.md with dual provider instructions
Added comprehensive setup documentation
Created changelog for tracking changes
Enhanced .gitignore for better project hygiene

🎯 Benefits
User Choice: Developers can choose their preferred AI provider
Cost Optimization: Switch between providers based on pricing/features
Redundancy: Fallback options if one provider has issues
Innovation: Easy to add more providers in the future

πŸ” Code Review Notes
All new code follows existing patterns and conventions
Comprehensive error handling and logging
Type hints and documentation maintained
No impact on existing functionality
_

***This enhancement makes the MCP Streamable HTTP example more versatile and demonstrates how MCP can work with multiple AI providers, not just Anthropic Claude.

_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions