Add MCP header safety guardrails - #86
Conversation
Signed-off-by: Pratik Gandhi <gandhipratik203@gmail.com>
Signed-off-by: Pratik Gandhi <gandhipratik203@gmail.com>
2b0635d to
0369a2d
Compare
lucarlig
left a comment
There was a problem hiding this comment.
Requesting changes for the MCP 2026-07-28-only target:
- Override
supported_protocol_versions()soserver/discoveradvertises only2026-07-28and every other version is rejected. - Remove the downstream
initialize/session dependency. MCP2026-07-28removed both, but routed calls currently requireMcp-Session-Idand backend transports are created only duringinitialize. - Remove
Mcp-Session-Idfrom the standard-header limit classification and documentation; it is not part of the2026-07-28transport.
The header-limit accounting, middleware ordering, and computed-header protection otherwise look good. Fresh library tests and focused Clippy checks pass.
Dismissed because the requested changes were broader MCP 2026-07-28 migration work explicitly excluded from IBM/mcp-context-forge#6146.
lucarlig
left a comment
There was a problem hiding this comment.
Correction after checking the linked issue: modern sessionless routing and 2026-07-28-only enforcement are explicitly out of scope for IBM/mcp-context-forge#6146; they are tracked by #5679, #5680, and #6148.
For this PR’s actual scope—MCP header count/value guardrails, early rejection, protection of computed headers, hop-by-hop coverage, and documentation—the implementation looks good. Fresh library tests and focused Clippy checks pass.
Non-blocking: if Mcp-Session-Id remains covered by the guardrail, describe it as a legacy header rather than a 2026-07-28 standard header.
Summary
Explanatory Diagrams
Context
Closes IBM/mcp-context-forge#6146.
Validation
cargo +1.96 fmtcargo +1.96 test -p contextforge-data-plane-libcargo +1.96 clippy --locked --workspace --all-targets -- -D warningsNote: plain
cargo clippy --locked --workspace --all-targets -- -D warningsuses the local default Rust1.93.1in this checkout and fails before clippy because the workspace requires Rust1.96.