@@ -11,15 +11,15 @@ def fastmcp_app():
1111 return app
1212
1313def test_streamable_http_mount_dual_paths (fastmcp_app ):
14- # Use httpx.ASGITransport to avoid DeprecationWarning
15- transport = httpx . ASGITransport ( app = fastmcp_app )
16- client = httpx .Client ( transport = transport , base_url = "http://testserver" )
17- for path in ["/mcp" , "/mcp/" ]:
18- # Should return 406 because Accept header is missing, but proves route exists
19- resp = client . post (
20- path , json = { "jsonrpc" : "2.0" , "method" : "initialize" , "id" : 1 }
21- )
22- assert resp . status_code in ( 400 , 406 ) # 406 Not Acceptable or 400 Bad Request
23- # Optionally, test GET as well
24- resp_get = client . get ( path )
25- assert resp_get . status_code in ( 400 , 406 , 405 )
14+ # Use httpx.AsyncClient with ASGITransport for async test
15+ async def do_test ():
16+ async with httpx .AsyncClient ( app = fastmcp_app , base_url = "http://testserver" ) as client :
17+ for path in ["/mcp" , "/mcp/" ]:
18+ resp = await client . post (
19+ path , json = { "jsonrpc" : "2.0" , "method" : "initialize" , "id" : 1 }
20+ )
21+ assert resp . status_code in ( 400 , 406 )
22+ resp_get = await client . get ( path )
23+ assert resp_get . status_code in ( 400 , 406 , 405 )
24+ import anyio
25+ anyio . run ( do_test )
0 commit comments