feat: centralized environment handling, ensures ZEN_MCP_FORCE_ENV_OVERRIDE is honored correctly

fix: updated tests to override env variables they need instead of relying on the current values from .env
This commit is contained in:
Fahad
2025-10-04 14:28:56 +04:00
parent 4015e917ed
commit 2c534ac06e
24 changed files with 300 additions and 179 deletions

View File

@@ -1,9 +1,10 @@
"""OpenRouter provider implementation."""
import logging
import os
from typing import Optional
from utils.env import get_env
from .openai_compatible import OpenAICompatibleProvider
from .openrouter_registry import OpenRouterModelRegistry
from .shared import (
@@ -35,8 +36,9 @@ class OpenRouterProvider(OpenAICompatibleProvider):
# Custom headers required by OpenRouter
DEFAULT_HEADERS = {
"HTTP-Referer": os.getenv("OPENROUTER_REFERER", "https://github.com/BeehiveInnovations/zen-mcp-server"),
"X-Title": os.getenv("OPENROUTER_TITLE", "Zen MCP Server"),
"HTTP-Referer": get_env("OPENROUTER_REFERER", "https://github.com/BeehiveInnovations/zen-mcp-server")
or "https://github.com/BeehiveInnovations/zen-mcp-server",
"X-Title": get_env("OPENROUTER_TITLE", "Zen MCP Server") or "Zen MCP Server",
}
# Model registry for managing configurations and aliases