@@ -877,4 +877,129 @@ describe("useConnection", () => {
877877 } ) ;
878878 } ) ;
879879 } ) ;
880+
881+ describe ( "MCP_PROXY_FULL_ADDRESS Configuration" , ( ) => {
882+ beforeEach ( ( ) => {
883+ jest . clearAllMocks ( ) ;
884+ // Reset the mock transport objects
885+ mockSSETransport . url = undefined ;
886+ mockSSETransport . options = undefined ;
887+ mockStreamableHTTPTransport . url = undefined ;
888+ mockStreamableHTTPTransport . options = undefined ;
889+ } ) ;
890+
891+ test ( "sends proxyFullAddress query parameter for stdio transport when configured" , async ( ) => {
892+ const propsWithProxyFullAddress = {
893+ ...defaultProps ,
894+ transportType : "stdio" as const ,
895+ command : "test-command" ,
896+ args : "test-args" ,
897+ env : { } ,
898+ config : {
899+ ...DEFAULT_INSPECTOR_CONFIG ,
900+ MCP_PROXY_FULL_ADDRESS : {
901+ ...DEFAULT_INSPECTOR_CONFIG . MCP_PROXY_FULL_ADDRESS ,
902+ value : "https://example.com/inspector/mcp_proxy" ,
903+ } ,
904+ } ,
905+ } ;
906+
907+ const { result } = renderHook ( ( ) =>
908+ useConnection ( propsWithProxyFullAddress ) ,
909+ ) ;
910+
911+ await act ( async ( ) => {
912+ await result . current . connect ( ) ;
913+ } ) ;
914+
915+ // Check that the URL contains the proxyFullAddress parameter
916+ expect ( mockSSETransport . url ?. searchParams . get ( "proxyFullAddress" ) ) . toBe (
917+ "https://example.com/inspector/mcp_proxy" ,
918+ ) ;
919+ } ) ;
920+
921+ test ( "sends proxyFullAddress query parameter for sse transport when configured" , async ( ) => {
922+ const propsWithProxyFullAddress = {
923+ ...defaultProps ,
924+ transportType : "sse" as const ,
925+ sseUrl : "http://localhost:8080" ,
926+ config : {
927+ ...DEFAULT_INSPECTOR_CONFIG ,
928+ MCP_PROXY_FULL_ADDRESS : {
929+ ...DEFAULT_INSPECTOR_CONFIG . MCP_PROXY_FULL_ADDRESS ,
930+ value : "https://example.com/inspector/mcp_proxy" ,
931+ } ,
932+ } ,
933+ } ;
934+
935+ const { result } = renderHook ( ( ) =>
936+ useConnection ( propsWithProxyFullAddress ) ,
937+ ) ;
938+
939+ await act ( async ( ) => {
940+ await result . current . connect ( ) ;
941+ } ) ;
942+
943+ // Check that the URL contains the proxyFullAddress parameter
944+ expect ( mockSSETransport . url ?. searchParams . get ( "proxyFullAddress" ) ) . toBe (
945+ "https://example.com/inspector/mcp_proxy" ,
946+ ) ;
947+ } ) ;
948+
949+ test ( "does not send proxyFullAddress parameter when MCP_PROXY_FULL_ADDRESS is empty" , async ( ) => {
950+ const propsWithEmptyProxy = {
951+ ...defaultProps ,
952+ transportType : "stdio" as const ,
953+ command : "test-command" ,
954+ args : "test-args" ,
955+ env : { } ,
956+ config : {
957+ ...DEFAULT_INSPECTOR_CONFIG ,
958+ MCP_PROXY_FULL_ADDRESS : {
959+ ...DEFAULT_INSPECTOR_CONFIG . MCP_PROXY_FULL_ADDRESS ,
960+ value : "" ,
961+ } ,
962+ } ,
963+ } ;
964+
965+ const { result } = renderHook ( ( ) => useConnection ( propsWithEmptyProxy ) ) ;
966+
967+ await act ( async ( ) => {
968+ await result . current . connect ( ) ;
969+ } ) ;
970+
971+ // Check that the URL does not contain the proxyFullAddress parameter
972+ expect (
973+ mockSSETransport . url ?. searchParams . get ( "proxyFullAddress" ) ,
974+ ) . toBeNull ( ) ;
975+ } ) ;
976+
977+ test ( "does not send proxyFullAddress parameter for streamable-http transport" , async ( ) => {
978+ const propsWithStreamableHttp = {
979+ ...defaultProps ,
980+ transportType : "streamable-http" as const ,
981+ sseUrl : "http://localhost:8080" ,
982+ config : {
983+ ...DEFAULT_INSPECTOR_CONFIG ,
984+ MCP_PROXY_FULL_ADDRESS : {
985+ ...DEFAULT_INSPECTOR_CONFIG . MCP_PROXY_FULL_ADDRESS ,
986+ value : "https://example.com/inspector/mcp_proxy" ,
987+ } ,
988+ } ,
989+ } ;
990+
991+ const { result } = renderHook ( ( ) =>
992+ useConnection ( propsWithStreamableHttp ) ,
993+ ) ;
994+
995+ await act ( async ( ) => {
996+ await result . current . connect ( ) ;
997+ } ) ;
998+
999+ // Check that streamable-http transport doesn't get proxyFullAddress parameter
1000+ expect (
1001+ mockStreamableHTTPTransport . url ?. searchParams . get ( "proxyFullAddress" ) ,
1002+ ) . toBeNull ( ) ;
1003+ } ) ;
1004+ } ) ;
8801005} ) ;
0 commit comments