Skip to content

[BUG]: Local payload classes missing extensions field support - incompatible with cpex 0.1.0 API #51

@vcostin-dev

Description

@vcostin-dev

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

  1. Version: main@latest (mcp-context-forge)
  2. Runtime: Python 3.11.9, 3.12.4, 3.13.0
  3. OS: Linux (Ubuntu), Windows
  4. cpex version: 0.1.0

Additional Context (optional)

Affected payload classes:

  1. mcpgateway/plugins/framework/hooks/http.py: HttpPreRequestPayload, HttpPostRequestPayload, HttpAuthResolveUserPayload
  2. mcpgateway/plugins/framework/hooks/tools.py: ToolPreInvokePayload
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions