Skip to content

fix: support nested MCP header property paths - #1111

Open
nolankhoingo wants to merge 1 commit into
modelcontextprotocol:mainfrom
Midwess:fix/nested-mcp-header-v3.1.0
Open

fix: support nested MCP header property paths#1111
nolankhoingo wants to merge 1 commit into
modelcontextprotocol:mainfrom
Midwess:fix/nested-mcp-header-v3.1.0

Conversation

@nolankhoingo

Copy link
Copy Markdown

Summary

  • accept primitive x-mcp-header annotations reached through plain properties chains
  • emit and validate Mcp-Param headers from the corresponding nested argument path
  • reject annotations reached through arrays, composition, conditionals, or references

Why

MCP 2026-07-28 permits statically reachable primitive annotations under plain properties chains. The current top-level-only cache rejects otherwise valid tools.

Specification: https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http

Validation

cargo test -p rmcp --lib --features client,transport-streamable-http-client,server-side-http transport::common::mcp_headers::tests

All 36 focused header tests pass.

@nolankhoingo
nolankhoingo requested a review from a team as a code owner August 1, 2026 10:09
@github-actions github-actions Bot added T-core Core library changes T-transport Transport layer changes labels Aug 1, 2026
Comment on lines +223 to +229
fn contains_annotation(value: &Value) -> bool {
match value {
Value::Object(object) => {
object.contains_key("x-mcp-header") || object.values().any(contains_annotation)
}
Value::Array(values) => values.iter().any(contains_annotation),
_ => false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How could this distinguish subschemas from ordinary JSON values so that something like default: {"x-mcp-header":"literal"} does not cause a valid tool to be rejected?

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

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants