fenix-mcp 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Configuration helpers for the Fênix MCP server."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from functools import lru_cache
7
+ from typing import Literal
8
+
9
+ from pydantic import Field, HttpUrl, field_validator
10
+ from pydantic_settings import BaseSettings, SettingsConfigDict
11
+
12
+
13
+ class Settings(BaseSettings):
14
+ """All configuration knobs consumed by the server."""
15
+
16
+ api_url: str = Field(
17
+ default="https://fenix-api-production-7619.up.railway.app",
18
+ description="Base URL for the Fênix Cloud API.",
19
+ )
20
+ http_timeout: float = Field(default=30.0, description="Default HTTP timeout in seconds.")
21
+ log_level: str = Field(default="INFO", description="Root log level.")
22
+ transport_mode: Literal["stdio", "http", "both"] = Field(
23
+ default="stdio",
24
+ description="Active transport mode: stdio, http or both.",
25
+ )
26
+ http_host: str = Field(default="127.0.0.1", description="HTTP bind host.")
27
+ http_port: int = Field(default=3000, description="HTTP port when running with network transport.")
28
+
29
+ model_config = SettingsConfigDict(
30
+ populate_by_name=True,
31
+ env_prefix="FENIX_",
32
+ env_file=".env",
33
+ env_file_encoding="utf-8",
34
+ )
35
+
36
+ @field_validator("log_level")
37
+ @classmethod
38
+ def _validate_level(cls, value: str) -> str:
39
+ upper = value.upper()
40
+ allowed = {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"}
41
+ if upper not in allowed:
42
+ raise ValueError(f"Invalid log level '{value}'. Allowed: {sorted(allowed)}")
43
+ return upper
44
+
45
+ @field_validator("api_url")
46
+ @classmethod
47
+ def _validate_api_url(cls, value: str) -> str:
48
+ HttpUrl(value)
49
+ return value
50
+
51
+
52
+ @lru_cache(maxsize=1)
53
+ def load_settings() -> Settings:
54
+ """Load settings from environment / .env file (cached)."""
55
+
56
+ return Settings() # type: ignore[call-arg]
@@ -0,0 +1,20 @@
1
+ # SPDX-License-Identifier: MIT
2
+ """Shared context dependency injected into tools."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from dataclasses import dataclass
7
+ from logging import Logger
8
+
9
+ from fenix_mcp.infrastructure.config import Settings
10
+ from fenix_mcp.infrastructure.fenix_api.client import FenixApiClient
11
+
12
+
13
+ @dataclass(slots=True)
14
+ class AppContext:
15
+ """Runtime dependencies shared by tools."""
16
+
17
+ settings: Settings
18
+ logger: Logger
19
+ api_client: FenixApiClient
20
+