44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
from functools import cache
|
|
from pathlib import Path
|
|
|
|
from pydantic import BaseModel
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic_settings import SettingsConfigDict
|
|
|
|
DEFAULT_ENV_FILE = Path(".env").resolve()
|
|
DEFAULT_SITE_DIR = Path("site").resolve()
|
|
|
|
|
|
class Mounts(BaseModel):
|
|
docs: str = "/docs"
|
|
mcp: str = "/mcp"
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Runtime settings for the HTTP MCP and docs server."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=DEFAULT_ENV_FILE,
|
|
env_prefix="PERSONAL_MCP_",
|
|
extra="ignore",
|
|
cli_implicit_flags=True,
|
|
)
|
|
|
|
debug: bool = False
|
|
log_level: str = "info"
|
|
mounts: Mounts = Field(default_factory=Mounts)
|
|
host: str = "localhost"
|
|
port: int = 8080
|
|
reload: bool = True
|
|
|
|
|
|
@cache
|
|
def get_settings(*, cli: bool = False, **overrides) -> Settings:
|
|
return Settings(**overrides, _cli_parse_args=cli) # pyright: ignore[reportCallIssue]
|
|
|
|
|
|
def refresh_settings(**overrides):
|
|
get_settings.cache_clear()
|
|
return get_settings(**overrides)
|