Feature 285/pydantic v2 config validation #1110
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary: Enhanced Configuration Validation and Schema Export
Epic / Issue - #285
Overview
This PR implements comprehensive configuration validation and schema export capabilities for MCP Gateway. It provides operators with machine-readable configuration metadata and enforces stronger runtime validation for environment inputs, surfacing actionable errors early.
Key Changes
1. JSON Schema Export (
mcpgateway/config.py
)generate_settings_schema()
function to export the Pydantic model schema.--schema
flag to emit machine-readable configuration metadata.2. Strengthened Field Validation
Literal
types for finite option sets (e.g.,log_level
,cache_type
,transport_type
).HttpUrl
validation for URL fields (APP_DOMAIN
,FEDERATION_PEERS
).PositiveInt
constraints for numeric ranges (e.g.,PORT: 1-65535
).SecretStr
for sensitive fields to prevent accidental logging.3. Dedicated Environment Validation CLI (
mcpgateway/scripts/validate_env.py
)make check-env
workflow..env
file paths.4. Enhanced Makefile Integration
make check-env
to use the new validation script for.env.example
.make check-env-dev
for validating development.env
files.Testing & Documentation
docs/docs/operations/config-validation.md
with usage examples and best practices.