Fix for: https://github.com/BeehiveInnovations/zen-mcp-server/issues/102

- Removed centralized MODEL_CAPABILITIES_DESC from config.py
- Added model descriptions to individual provider SUPPORTED_MODELS
- Updated _get_available_models() to use ModelProviderRegistry for API key filtering
- Added comprehensive test suite validating bug reproduction and fix
This commit is contained in:
Fahad
2025-06-21 15:07:52 +04:00
parent d12094b536
commit 9079d06941
18 changed files with 445 additions and 338 deletions

View File

@@ -14,7 +14,7 @@ import os
# These values are used in server responses and for tracking releases
# IMPORTANT: This is the single source of truth for version and author info
# Semantic versioning: MAJOR.MINOR.PATCH
__version__ = "5.5.2"
__version__ = "5.5.3"
# Last update date in ISO format
__updated__ = "2025-06-21"
# Primary maintainer
@@ -30,51 +30,15 @@ DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "auto")
# Auto mode detection - when DEFAULT_MODEL is "auto", Claude picks the model
IS_AUTO_MODE = DEFAULT_MODEL.lower() == "auto"
# Model capabilities descriptions for auto mode
# These help Claude choose the best model for each task
# Each provider (gemini.py, openai_provider.py, xai.py) defines its own SUPPORTED_MODELS
# with detailed descriptions. Tools use ModelProviderRegistry.get_available_model_names()
# to get models only from enabled providers (those with valid API keys).
#
# IMPORTANT: These are the built-in natively supported models:
# - When GEMINI_API_KEY is set: Enables "flash", "pro" (and their full names)
# - When OPENAI_API_KEY is set: Enables "o3", "o3mini", "o4-mini", "o4-mini-high"
# - When both are set: All models below are available
# - When neither is set but OpenRouter/Custom API is configured: These model
# aliases will automatically map to equivalent models via the proxy provider
#
# In auto mode (DEFAULT_MODEL=auto), Claude will see these descriptions and
# intelligently select the best model for each task. The descriptions appear
# in the tool schema to guide Claude's selection based on task requirements.
MODEL_CAPABILITIES_DESC = {
# Gemini models - Available when GEMINI_API_KEY is configured
"flash": "Ultra-fast (1M context) - Quick analysis, simple queries, rapid iterations",
"pro": "Deep reasoning + thinking mode (1M context) - Complex problems, architecture, deep analysis",
# OpenAI models - Available when OPENAI_API_KEY is configured
"o3": "Strong reasoning (200K context) - Logical problems, code generation, systematic analysis",
"o3-mini": "Fast O3 variant (200K context) - Balanced performance/speed, moderate complexity",
"o3-pro": "Professional-grade reasoning (200K context) - EXTREMELY EXPENSIVE: Only for the most complex problems requiring universe-scale complexity analysis OR when the user explicitly asks for this model. Use sparingly for critical architectural decisions or exceptionally complex debugging that other models cannot handle.",
"o4-mini": "Latest reasoning model (200K context) - Optimized for shorter contexts, rapid reasoning",
"o4-mini-high": "Enhanced O4 mini (200K context) - Higher reasoning effort for complex tasks",
# X.AI GROK models - Available when XAI_API_KEY is configured
"grok": "GROK-3 (131K context) - Advanced reasoning model from X.AI, excellent for complex analysis",
"grok-3": "GROK-3 (131K context) - Advanced reasoning model from X.AI, excellent for complex analysis",
"grok-3-fast": "GROK-3 Fast (131K context) - Higher performance variant, faster processing but more expensive",
"grok3": "GROK-3 (131K context) - Advanced reasoning model from X.AI, excellent for complex analysis",
"grokfast": "GROK-3 Fast (131K context) - Higher performance variant, faster processing but more expensive",
# Full model names also supported (for explicit specification)
"gemini-2.5-flash": "Ultra-fast (1M context) - Quick analysis, simple queries, rapid iterations",
"gemini-2.5-pro": ("Deep reasoning + thinking mode (1M context) - Complex problems, architecture, deep analysis"),
}
# OpenRouter/Custom API Fallback Behavior:
# When only OpenRouter or Custom API is configured (no native API keys), these
# model aliases automatically map to equivalent models through the proxy:
# - "flash" → "google/gemini-2.5-flash" (via OpenRouter)
# - "pro" → "google/gemini-2.5-pro" (via OpenRouter)
# - "o3" → "openai/o3" (via OpenRouter)
# - "o3mini" → "openai/o3-mini" (via OpenRouter)
# - "o4-mini" → "openai/o4-mini" (via OpenRouter)
# - "o4-mini-high" → "openai/o4-mini-high" (via OpenRouter)
#
# This ensures the same model names work regardless of which provider is configured.
# This architecture ensures:
# - No namespace collisions (models only appear when their provider is enabled)
# - API key-based filtering (prevents wrong models from being shown to Claude)
# - Proper provider routing (models route to the correct API endpoint)
# - Clean separation of concerns (providers own their model definitions)
# Temperature defaults for different tool types