Skip to content

Commit 7271553

Browse files
committed
Pin union-typed x-mcp-header annotations as invalidating the whole tool's validation
1 parent b40eb78 commit 7271553

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/shared/test_inbound.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,3 +817,16 @@ def test_decode_header_value_returns_none_for_non_canonical_base64(value: str) -
817817
"""The decoder requires canonical base64: a payload that decodes but does not re-encode
818818
byte-identically (or lacks padding) is malformed, not a lenient near-miss."""
819819
assert decode_header_value(value) is None
820+
821+
822+
def test_validate_mcp_param_headers_union_typed_annotation_invalidates_the_whole_tool() -> None:
823+
"""A union-typed annotated property (e.g. `["integer", "null"]`) fails the
824+
integer/string/boolean-only constraint, so the whole schema validates nothing —
825+
symmetric with conforming clients dropping the tool from `tools/list`."""
826+
union_schema = {
827+
"type": "object",
828+
"properties": {"n": {"type": ["integer", "null"], "x-mcp-header": "N"}},
829+
}
830+
assert find_invalid_x_mcp_header(union_schema) is not None
831+
assert validate_mcp_param_headers(union_schema, {"n": 42}, {"Mcp-Param-N": "999"}) is None
832+
assert validate_mcp_param_headers(union_schema, {"n": 42}, {}) is None

0 commit comments

Comments
 (0)