@@ -613,6 +613,8 @@ def test_accept_header_wildcard(basic_server: None, basic_server_url: str, accep
613613 [
614614 ("application/json" , "application/json" ),
615615 ("text/event-stream" , "text/event-stream" ),
616+ ("application/json;q=0.9, text/event-stream;q=0" , "application/json" ),
617+ ("text/event-stream;q=0.9, application/json;q=0" , "text/event-stream" ),
616618 ],
617619)
618620def test_accept_header_single_media_type_negotiates_response (
@@ -659,6 +661,7 @@ def test_accept_header_single_media_type_negotiates_response(
659661 "text/html" ,
660662 "text/plain" ,
661663 "application/xml" ,
664+ "application/json;q=0, text/event-stream;q=0" ,
662665 ],
663666)
664667def test_accept_header_incompatible (basic_server : None , basic_server_url : str , accept_header : str ):
@@ -933,14 +936,22 @@ def test_json_response_missing_accept_header(json_response_server: None, json_se
933936 assert "Not Acceptable" in response .text
934937
935938
936- def test_json_response_incorrect_accept_header (json_response_server : None , json_server_url : str ):
939+ @pytest .mark .parametrize (
940+ "accept_header" ,
941+ [
942+ "text/event-stream" ,
943+ "application/json;q=0, text/event-stream;q=1" ,
944+ ],
945+ )
946+ def test_json_response_incorrect_accept_header (
947+ json_response_server : None , json_server_url : str , accept_header : str
948+ ):
937949 """Test that json_response servers reject requests with incorrect Accept header."""
938950 mcp_url = f"{ json_server_url } /mcp"
939- # Test with only text/event-stream (wrong for JSON server)
940951 response = requests .post (
941952 mcp_url ,
942953 headers = {
943- "Accept" : "text/event-stream" ,
954+ "Accept" : accept_header ,
944955 "Content-Type" : "application/json" ,
945956 },
946957 json = INIT_REQUEST ,
0 commit comments