diff --git a/README.md b/README.md index a019212..aa66102 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,14 @@ ensuring safe exploration without risk of data modification or corruption. ## Configuration -The MCP server can be configured using environment variables with the `CORDRA_` prefix: +The MCP server can be configured using environment variables: - `CORDRA_BASE_URL` - Cordra server URL (default: `https://localhost:8443`) - `CORDRA_USERNAME` - Username for authentication (optional) - `CORDRA_PASSWORD` - Password for authentication (optional) - `CORDRA_VERIFY_SSL` - SSL certificate verification (default: `true`) - `CORDRA_TIMEOUT` - Request timeout in seconds (default: `30`) +- `LOGLEVEL` - Logging level (default: `INFO`, options: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`) ## Usage diff --git a/src/cordra_mcp/config.py b/src/cordra_mcp/config.py index c677894..ba8a307 100644 --- a/src/cordra_mcp/config.py +++ b/src/cordra_mcp/config.py @@ -1,6 +1,6 @@ """Configuration settings for the MCP Cordra server.""" -from pydantic import Field +from pydantic import Field, field_validator from pydantic_settings import BaseSettings, SettingsConfigDict @@ -26,3 +26,21 @@ class CordraConfig(BaseSettings): default=True, description="Whether to verify SSL certificates" ) timeout: int = Field(default=30, description="Request timeout in seconds") + log_level: str = Field( + default="INFO", + description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)", + validation_alias="LOGLEVEL", + ) + + @field_validator("log_level", mode="before") + @classmethod + def validate_log_level(cls, v: str) -> str: + """Validate that log_level is a standard logging level.""" + level_str = str(v).upper().strip() + valid_levels = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"} + + if level_str not in valid_levels: + raise ValueError( + f"Invalid log level '{v}'. Must be one of: {', '.join(valid_levels)}" + ) + return level_str diff --git a/src/cordra_mcp/server.py b/src/cordra_mcp/server.py index 501f95a..907a760 100644 --- a/src/cordra_mcp/server.py +++ b/src/cordra_mcp/server.py @@ -23,6 +23,7 @@ config = CordraConfig() cordra_client = CordraClient(config) logger = logging.getLogger(__name__) +logger.setLevel(config.log_level) @mcp.tool(