Current Behavior
Local payload definitions in mcpgateway/plugins/framework/hooks/ do not support the new extensions API that is present in the published cpex 0.1.0 package. This causes deprecation warnings when running tests with -W error::DeprecationWarning:
DeprecationWarning: ToolPreInvokePayload.headers is deprecated; use extensions.http.headers instead. This field will be removed in a future release.
test-env3/lib/python3.13/site-packages/cpex/framework/hooks/tools.py:79: DeprecationWarning
Expected Behavior
Local payload definitions should match the cpex 0.1.0 API:
Support both old API (headers=HttpHeaderPayload(...)) and new API (extensions={'http': {'headers': HttpHeaderPayload(...)}}))
Automatically synchronize between headers and extensions fields for backward compatibility
Emit deprecation warnings when the old headers field is used directly
This would allow:
Consumers to migrate to the new extensions API without breaking existing code
Plugin authors to access headers via either payload.headers.root (deprecated) or payload.extensions['http']['headers'].root (new)
Gradual migration path with clear deprecation warnings
Steps to Reproduce
# Set Python version
pyenv local 3.11.9 # or 3.12.4, 3.13.0
# Verify version
python --version
# Create fresh environment
python -m venv test-env
source test-env/bin/activate
# Install package
pip install -e ".[dev]"
pip install uv
uv pip install --group dev -e .
uv pip install --group dev -e ".[plugins]"
# Run test suite
pytest tests/ -v --tb=short
# Check for deprecation warnings
`pytest tests/ -W error::DeprecationWarning 2>&1 | grep -i deprecat`
Logs / Error Output
deprecationWarning_3_11_9.txt
deprecationWarnings_3_13_0.txt
deprecationWarningv_3_12_4.txt
Environment
- Version: main@latest (mcp-context-forge)
- Runtime: Python 3.11.9, 3.12.4, 3.13.0
- OS: Linux (Ubuntu), Windows
- cpex version: 0.1.0
Additional Context (optional)
Affected payload classes:
- mcpgateway/plugins/framework/hooks/http.py: HttpPreRequestPayload, HttpPostRequestPayload, HttpAuthResolveUserPayload
- mcpgateway/plugins/framework/hooks/tools.py: ToolPreInvokePayload
- mcpgateway/plugins/framework/hooks/agents.py: AgentPreInvokePayload
Proposed solution:
Add extensions field and @model_validator to synchronize with headers field, similar to cpex 0.1.0 implementation. This maintains backward compatibility while enabling migration to the new API.
Current Behavior
Local payload definitions in mcpgateway/plugins/framework/hooks/ do not support the new extensions API that is present in the published cpex 0.1.0 package. This causes deprecation warnings when running
tests with -W error::DeprecationWarning:Expected Behavior
Local payload definitions should match the cpex 0.1.0 API:
Support both old API
(headers=HttpHeaderPayload(...))and new API(extensions={'http': {'headers': HttpHeaderPayload(...)}}))Automatically synchronize between headers and extensions fields for backward compatibility
Emit deprecation warnings when the old headers field is used directly
This would allow:
Consumers to migrate to the new extensions API without breaking existing code
Plugin authors to access headers via either
payload.headers.root(deprecated) orpayload.extensions['http']['headers'].root (new)Gradual migration path with clear deprecation warnings
Steps to Reproduce
Logs / Error Output
deprecationWarning_3_11_9.txt
deprecationWarnings_3_13_0.txt
deprecationWarningv_3_12_4.txt
Environment
Additional Context (optional)
Affected payload classes:
Proposed solution:
Add extensions field and @model_validator to synchronize with headers field, similar to cpex 0.1.0 implementation. This maintains backward compatibility while enabling migration to the new API.