Skip to content

fix: validate and forward SEP-2243 parameter headers - #109

Open
lucarlig wants to merge 17 commits into
user/luca/add-client-conformancefrom
user/luca/sep2243-rmcp-headers
Open

fix: validate and forward SEP-2243 parameter headers#109
lucarlig wants to merge 17 commits into
user/luca/add-client-conformancefrom
user/luca/sep2243-rmcp-headers

Conversation

@lucarlig

@lucarlig lucarlig commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • validate modern tools/call Mcp-Param-* headers against request-scoped tool schemas published by the control plane
  • return JSON-RPC -32020 for a mismatch or missing published schema
  • forward validated parameter headers unchanged on the outgoing tools/call and protect them from backend header configuration
  • keep plugin handling unchanged: plugins run after validation and do not cause header reconstruction

The dataplane does not call tools/list, reconstruct headers from arguments, or change RMCP. This PR requires IBM/mcp-context-forge#6348 to publish visibility-filtered schemas keyed by original upstream tool name.

The GitHub composed conformance job still pulls the stock control-plane image and therefore fails to deserialize its pre-#6348 payload (missing field tool_schemas). No dataplane fallback is included; the job will pass once #6348 is merged into that image.

Stacked on #107. Related: IBM/mcp-context-forge#6256.

Verification

  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo nextest run --locked --workspace (227 passed, 3 skipped)
  • workspace build, dependency-policy, shear, formatting, generated-schema, and wiki checks
  • conformance adapter, reporter, and baseline unit tests
  • control-plane publisher unit tests (26 passed), Ruff, and Black
  • cross-repo E2E with the official conformance fixture and #6348 publisher: matching plain/Base64 values pass; mismatched, invalid Base64, and missing headers return JSON-RPC -32020

The direct fixture E2E is used because the official server scenario currently reaches the separately baselined stateless tools/list session limitation during setup. Client findings remain limited to the existing four shell-adapter generation IDs.

@lucarlig lucarlig changed the title fix: generate SEP-2243 parameter headers fix: require stateless metadata and generate SEP-2243 headers Aug 21, 2026
@lucarlig lucarlig changed the title fix: require stateless metadata and generate SEP-2243 headers fix: validate and generate SEP-2243 headers Aug 21, 2026
@lucarlig lucarlig changed the title fix: validate and generate SEP-2243 headers fix: validate and forward SEP-2243 headers Aug 21, 2026
@lucarlig lucarlig changed the title fix: validate and forward SEP-2243 headers fix: forward SEP-2243 parameter headers Aug 21, 2026
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from 4005c69 to e3abd7e Compare August 21, 2026 16:42
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from 374730d to 7a65618 Compare August 24, 2026 08:53
@lucarlig lucarlig changed the title fix: forward SEP-2243 parameter headers fix: validate and forward SEP-2243 parameter headers Aug 24, 2026
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from 7a65618 to 752a212 Compare August 24, 2026 13:59
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from 752a212 to 0a81ed1 Compare August 24, 2026 14:29
@lucarlig
lucarlig marked this pull request as ready for review August 25, 2026 12:33
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from a203fcb to d23977d Compare August 26, 2026 08:33
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from d23977d to 618c702 Compare August 26, 2026 09:07

@dawid-nowak dawid-nowak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't see how checking the max body size of the message is a part of header validation logic. Ideally, body size validation should be in a separate layer and re-using layers provided by Axum.

  2. This header validation logic only applies to tools. Not sure if using a layer approach is valid as this is going to be executed on all rmcp calls as well as new and old protocols.

Comment thread crates/contextforge-data-plane-lib/src/layers/mcp_param_validation.rs Outdated
Comment thread crates/contextforge-data-plane-lib/src/layers/mcp_param_validation.rs Outdated
Comment thread crates/contextforge-data-plane-lib/src/layers/mcp_param_validation.rs Outdated
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/sep2243-rmcp-headers branch from 403863c to 0c47a08 Compare August 26, 2026 10:41
@lucarlig
lucarlig requested a review from dawid-nowak August 26, 2026 10:50

@dawid-nowak dawid-nowak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should move validation to tools/call handler.

  1. If something is not right with the request rmcp will validate it anyway.
  2. You can easily get access to all necessary headers via:
    let downstream_headers = cx.extensions.get::().map(|parts| &parts.headers);
  3. Everything related to tool call is in one place.
  4. Not sure if this header is auto propagated to upstream so you might need to do it manually.

Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig

lucarlig commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in ef71cba:

  • moved SEP-2243 parameter validation into the tools/call handler
  • read downstream headers from RMCP request-context Parts
  • removed the parameter-validation middleware and duplicate Axum body-limit handling; RMCP owns envelope/body validation
  • kept explicit transparent Mcp-Param-* forwarding in upstream transport setup
  • covered modern mismatch/missing-schema rejection and the legacy-protocol bypass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants