feat: add ENABLE_OVERWRITE_BASE_HEADERS environment variable and docu… #1080
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.
Add ENABLE_OVERWRITE_BASE_HEADERS configuration for advanced header passthrough
Summary
This PR introduces the
ENABLE_OVERWRITE_BASE_HEADERSenvironment variable to provide advanced control over HTTP header passthrough behavior. When enabled, this allows client-provided headers to override gateway base headers likeContent-TypeandAuthorizationfor specialized use cases.What's Changed
Core Implementation
ENABLE_OVERWRITE_BASE_HEADERSinconfig.pyENABLE_HEADER_PASSTHROUGHpassthrough_headers.pyConfiguration & Documentation
.env.examplewithENABLE_OVERWRITE_BASE_HEADERSconfigurationvalues.yaml) with new environment variabledocs/overview/passthrough.md)docs/deployment/proxy-auth.md,docs/manage/proxy.md)docs/index.md)Testing
Quality Improvements
Security Considerations
Use Cases
This feature enables:
AuthorizationheadersContent-TypeoverrideBreaking Changes
None - this is a purely additive feature with secure defaults.
Testing
All existing tests pass, plus new tests covering:
Implementation Details
Environment Variable Configuration
# Enable the advanced feature (disabled by default) ENABLE_OVERWRITE_BASE_HEADERS=trueCode Changes
mcpgateway/config.py: Added proper environment variable mappingmcpgateway/utils/passthrough_headers.py: Implemented override logicmcpgateway/main.py: Added startup loggingtests/unit/mcpgateway/utils/test_passthrough_headers.py: Comprehensive test coverageConfiguration Hierarchy
Checklist
Ready for Review
This PR is ready for review and addresses the issue where
ENABLE_OVERWRITE_BASE_HEADERSwas not being read from environment variables, while adding the full advanced header override functionality requested.Reference: #1046
Closes #1046