# ๐Ÿš€ LLM Fusion MCP Server > A comprehensive Model Context Protocol (MCP) server providing unified access to multiple major LLM providers through a single interface. [![MCP](https://img.shields.io/badge/MCP-Compatible-blue)](https://modelcontextprotocol.io) [![FastMCP](https://img.shields.io/badge/FastMCP-2.12.2-blue)](https://gofastmcp.com) [![Python](https://img.shields.io/badge/Python-3.10+-green)](https://python.org) [![License](https://img.shields.io/badge/License-MIT-brightgreen)](https://opensource.org/licenses/MIT) This server enables AI assistants to interact with multiple LLM providers simultaneously through the standardized Model Context Protocol interface. Built for the MCP ecosystem, it provides seamless access to Gemini, OpenAI, Anthropic, and Grok models with advanced features like streaming, multimodal processing, and intelligent document handling. --- ## โšก **Why This Server Rocks** ๐ŸŽฏ **Universal LLM Access** - One API to rule them all ๐ŸŒŠ **Always Streaming** - Real-time responses with beautiful progress ๐Ÿง  **Intelligent Document Processing** - Handle files of any size with smart chunking ๐ŸŽจ **Multimodal AI** - Text, images, audio understanding ๐Ÿ”ง **OpenAI-Specific Tools** - Assistants API, DALL-E, Whisper integration โšก **Lightning Fast** - Built with modern Python tooling (uv, ruff, FastMCP) ๐Ÿ”’ **Production Grade** - Comprehensive error handling and health monitoring --- ## ๐Ÿ”ง **Quick Start for MCP Clients** ### **Claude Desktop Integration** ```bash # 1. Clone the repository git clone https://github.com/MCP/llm-fusion-mcp.git cd llm-fusion-mcp # 2. Configure API keys cp .env.example .env # Edit .env with your API keys # 3. Add to Claude Desktop claude mcp add -s local -- llm-fusion-mcp /path/to/llm-fusion-mcp/run_server.sh ``` ### **Manual Launch** ```bash # Install dependencies and start server ./run_server.sh ``` The launcher script will: - โœ… Validate dependencies and install if needed - โœ… Check API key configuration - โœ… Start the server with proper error handling - โœ… Provide colored logs for easy debugging --- ## ๐Ÿค– **Supported AI Providers** | Provider | Models | Context Window | Status | Special Features | |----------|--------|----------------|--------|------------------| | **๐ŸŸข Gemini** | 64+ models | **1M tokens** | โœ… Production Ready | Video, thinking modes, native audio | | **๐Ÿ”ต OpenAI** | 90+ models | **1M tokens** | โœ… Production Ready | GPT-5, O3, Assistants API, DALL-E | | **๐ŸŸฃ Anthropic** | Claude 3.5/4 | **200K tokens** | โœ… Production Ready | Advanced reasoning, code analysis | | **โšซ Grok** | Latest models | **100K tokens** | โœ… Production Ready | Real-time data, conversational AI | --- ## ๐ŸŽฏ **Key Features** ### ๐Ÿš€ **Core Capabilities** - **๐ŸŒ Universal LLM API** - Switch between providers seamlessly - **๐Ÿ“ก Real-time Streaming** - Token-by-token generation across all providers - **๐Ÿ“š Large File Analysis** - Intelligent document processing up to millions of tokens - **๐Ÿ–ผ๏ธ Multimodal AI** - Image analysis and audio transcription - **๐Ÿ”ง OpenAI Integration** - Full Assistants API, DALL-E, Whisper support - **๐ŸŽ›๏ธ Session Management** - Dynamic API key switching without server restart ### โšก **Advanced Features** - **๐Ÿง  Smart Chunking** - Semantic, hierarchical, fixed, and auto strategies - **๐Ÿ” Provider Auto-Selection** - Optimal model choice based on task and context - **๐Ÿ“Š Vector Embeddings** - Semantic similarity and text analysis - **๐Ÿ› ๏ธ Function Calling** - OpenAI-compatible tool integration - **๐Ÿ’พ Caching Support** - Advanced caching for performance - **๐Ÿฅ Health Monitoring** - Real-time provider status and diagnostics --- ## ๐Ÿšฆ **Quick Start** ### 1๏ธโƒฃ **Installation** ```bash # Clone and setup git clone cd llm-fusion-mcp uv install ``` ### 2๏ธโƒฃ **Configure API Keys** ```bash # Copy template and add your keys cp .env.example .env # Edit .env with your API keys GOOGLE_API_KEY=your_google_api_key_here OPENAI_API_KEY=your_openai_api_key_here # Optional ANTHROPIC_API_KEY=your_anthropic_api_key_here # Optional XAI_API_KEY=your_xai_api_key_here # Optional ``` ### 3๏ธโƒฃ **Launch Server** ```bash # Method 1: Direct execution uv run python src/llm_fusion_mcp/server.py # Method 2: Using run script (recommended) ./run_server.sh ``` ### 4๏ธโƒฃ **Connect with Claude Code** ```bash # Add to Claude Code MCP claude mcp add -s local -- llm-fusion-mcp /path/to/llm-fusion-mcp/run_server.sh ``` --- ## ๐Ÿ› ๏ธ **Available Tools** ### ๐ŸŽฏ **Universal LLM Tools** #### ๐Ÿ”‘ **Provider & Key Management** ```python llm_set_provider("gemini") # Switch default provider llm_get_provider() # Get current provider info llm_list_providers() # See all providers + models llm_health_check() # Provider health status llm_set_api_key("openai", "key") # Set session API key llm_list_api_keys() # Check key configuration llm_remove_api_key("openai") # Remove session key ``` #### ๐Ÿ’ฌ **Text Generation** ```python llm_generate( # ๐ŸŒŸ UNIVERSAL GENERATION prompt="Write a haiku about AI", provider="gemini", # Override provider model="gemini-2.5-flash", # Specific model stream=True # Real-time streaming ) llm_analyze_large_file( # ๐Ÿ“š SMART DOCUMENT ANALYSIS file_path="/path/to/document.pdf", prompt="Summarize key findings", chunk_strategy="auto", # Auto-select best strategy max_chunks=10 # Control processing scope ) ``` #### ๐ŸŽจ **Multimodal AI** ```python llm_analyze_image( # ๐Ÿ–ผ๏ธ IMAGE UNDERSTANDING image_path="/path/to/image.jpg", prompt="What's in this image?", provider="gemini" # Best for multimodal ) llm_analyze_audio( # ๐ŸŽต AUDIO PROCESSING audio_path="/path/to/audio.mp3", prompt="Transcribe this audio", provider="gemini" # Native audio support ) ``` #### ๐Ÿ“Š **Embeddings & Similarity** ```python llm_embed_text( # ๐Ÿงฎ VECTOR EMBEDDINGS text="Your text here", provider="openai", # Multiple providers model="text-embedding-3-large" ) llm_similarity( # ๐Ÿ” SEMANTIC SIMILARITY text1="AI is amazing", text2="Artificial intelligence rocks" ) ``` ### ๐Ÿ”ง **OpenAI-Specific Tools** #### ๐Ÿค– **Assistants API** ```python openai_create_assistant( # ๐ŸŽญ CREATE AI ASSISTANT name="Code Review Bot", instructions="Expert code reviewer", model="gpt-4o" ) openai_test_connection() # ๐Ÿ”Œ CONNECTION TEST # Returns: 90 available models, connection status ``` #### ๐ŸŽจ **DALL-E Image Generation** ```python openai_generate_image( # ๐ŸŽจ AI IMAGE CREATION prompt="Futuristic robot coding", model="dall-e-3", size="1024x1024" ) ``` #### ๐ŸŽต **Audio Processing** ```python openai_transcribe_audio( # ๐ŸŽค WHISPER TRANSCRIPTION audio_path="/path/to/speech.mp3", model="whisper-1" ) openai_generate_speech( # ๐Ÿ”Š TEXT-TO-SPEECH text="Hello, world!", voice="alloy" ) ``` --- ## ๐Ÿ“Š **System Testing Results** | Component | Status | Details | |-----------|--------|---------| | ๐ŸŸข **Gemini Provider** | โœ… Perfect | 64 models, 1M tokens, streaming excellent | | ๐Ÿ”ต **OpenAI Provider** | โœ… Working | 90 models, API functional, quota management | | ๐ŸŸฃ **Anthropic Provider** | โš ๏ธ Ready | Needs API key configuration | | โšซ **Grok Provider** | โœ… Perfect | Excellent streaming, fast responses | | ๐Ÿ“ก **Streaming** | โœ… Excellent | Real-time across all providers | | ๐Ÿ“š **Large Files** | โœ… Perfect | Auto provider selection, intelligent chunking | | ๐Ÿ”ง **OpenAI Tools** | โœ… Working | Assistants, DALL-E, connection verified | | ๐Ÿ”‘ **Key Management** | โœ… Perfect | Session override, health monitoring | --- ## ๐ŸŽ›๏ธ **Configuration** ### ๐Ÿ“ **API Key Setup Options** #### Option 1: Environment Variables (System-wide) ```bash export GOOGLE_API_KEY="your_google_api_key" export OPENAI_API_KEY="your_openai_api_key" export ANTHROPIC_API_KEY="your_anthropic_api_key" export XAI_API_KEY="your_xai_api_key" ``` #### Option 2: .env File (Project-specific) ```env # .env file GOOGLE_API_KEY=your_google_api_key_here OPENAI_API_KEY=your_openai_api_key_here ANTHROPIC_API_KEY=your_anthropic_api_key_here XAI_API_KEY=your_xai_api_key_here ``` #### Option 3: Session Keys (Dynamic) ```python # Override keys during MCP session llm_set_api_key("openai", "temporary_key_here") llm_set_api_key("anthropic", "another_temp_key") ``` ### ๐Ÿ”— **Claude Code Integration** #### Recommended: Command Line Setup ```bash claude mcp add -s local -- llm-fusion-mcp /path/to/llm-fusion-mcp/run_server.sh ``` #### Alternative: JSON Configuration ```json { "mcpServers": { "llm-fusion-mcp": { "command": "/path/to/llm-fusion-mcp/run_server.sh", "env": { "GOOGLE_API_KEY": "${GOOGLE_API_KEY}", "OPENAI_API_KEY": "${OPENAI_API_KEY}", "ANTHROPIC_API_KEY": "${ANTHROPIC_API_KEY}", "XAI_API_KEY": "${XAI_API_KEY}" } } } } ``` --- ## ๐Ÿ”ง **Development & Testing** ### ๐Ÿงช **Test Suite** ```bash # Comprehensive testing uv run python test_all_tools.py # All tools uv run python test_providers_direct.py # Provider switching uv run python test_streaming_direct.py # Streaming functionality uv run python test_large_file_analysis.py # Document processing # Code quality uv run ruff format # Format code uv run ruff check # Lint code uv run mypy src/ # Type checking ``` ### ๐Ÿ“‹ **Requirements** - **Python**: 3.10+ - **Dependencies**: FastMCP, OpenAI, Pydantic, python-dotenv - **API Keys**: At least one provider (Gemini recommended) --- ## ๐Ÿ—๏ธ **Architecture** ### ๐ŸŽจ **Design Philosophy** - **๐ŸŒ Provider Agnostic** - OpenAI-compatible APIs for universal access - **๐Ÿ“ก Streaming First** - Real-time responses across all operations - **๐Ÿง  Intelligent Processing** - Smart chunking, auto provider selection - **๐Ÿ”ง Production Ready** - Comprehensive error handling, health monitoring - **โšก Modern Python** - Built with uv, ruff, FastMCP toolchain ### ๐Ÿ“Š **Performance Features** - **Dynamic Model Discovery** - 5-minute cache refresh from provider APIs - **Intelligent Chunking** - Semantic, hierarchical, fixed, auto strategies - **Provider Auto-Selection** - Optimal choice based on context windows - **Session Management** - Hot-swap API keys without server restart - **Health Monitoring** - Real-time provider status and diagnostics --- ## ๐Ÿšจ **Troubleshooting** ### Common Issues #### ๐Ÿ”‘ **API Key Issues** ```python # Check configuration llm_list_api_keys() # Shows key status for all providers llm_health_check() # Tests actual API connectivity # Fix missing keys llm_set_api_key("provider", "your_key") ``` #### ๐Ÿ”„ **Server Issues** ```bash # Kill existing servers pkill -f "python src/llm_fusion_mcp/server.py" # Restart fresh ./run_server.sh ``` #### ๐Ÿ“š **Large File Issues** - Files automatically chunked when exceeding context windows - Use `max_chunks` parameter to control processing scope - Check provider context limits in health check --- ## ๐ŸŽ‰ **What's New** ### โœจ **Latest Features** - ๐Ÿ”ง **OpenAI Integration** - Full Assistants API, DALL-E, Whisper support - ๐Ÿ“Š **Health Monitoring** - Real-time provider diagnostics - ๐ŸŽ›๏ธ **Session Keys** - Dynamic API key management - ๐Ÿ“ก **Enhanced Streaming** - Beautiful real-time progress across all tools - ๐Ÿง  **Smart Processing** - Intelligent provider and strategy selection ### ๐Ÿ”ฎ **Coming Soon** - ๐ŸŽฌ **Video Understanding** - Gemini video analysis - ๐ŸŒ **More Providers** - Cohere, Mistral, and others - ๐Ÿ“Š **Vector Databases** - Pinecone, Weaviate integration - ๐Ÿ”— **Workflow Chains** - Multi-step AI operations --- ## ๐Ÿ“ž **Get Help** - ๐Ÿ“– **Documentation**: Check `INTEGRATION.md` for advanced setup - ๐Ÿงช **Testing**: Run test suite to verify functionality - ๐Ÿ” **Health Check**: Use `llm_health_check()` for diagnostics - โšก **Performance**: Check provider context windows and rate limits ---
## ๐ŸŒŸ **Ready to Launch?** **Experience the future of LLM integration with LLM Fusion MCP!** *Built with โค๏ธ using FastMCP, modern Python tooling, and a passion for AI excellence.*