Implement configuration loader module

This commit implements a robust configuration loader using Pydantic Settings that handles:

Features:
- Environment variable loading with .env file support
- Type validation and field constraints
- Gitea configuration (URL, token, owner, repo)
- HTTP server configuration (host, port)
- Optional HTTP authentication token
- Optional tool filtering (enabled/disabled tool lists)

Implementation:
- GiteaSettings class with Pydantic validation
- URL validation ensuring http:// or https:// prefix
- Helper properties for parsing comma-separated tool lists
- get_gitea_mcp_env() method to pass config to wrapped MCP server
- load_settings() factory function with optional env_file path

Documentation:
- .env.example template with all configuration options
- Comprehensive docstrings and type hints

This module unblocks both the tool filtering (#12) and HTTP authentication middleware (#13) implementations.

Closes #11

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 16:07:40 -05:00
parent b041d1568a
commit 6c8e6b4b0a
3 changed files with 132 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
"""Configuration loader module."""
__all__ = []
from .settings import GiteaSettings, load_settings
__all__ = ["GiteaSettings", "load_settings"]