@@ -57,6 +57,10 @@ import ToolsTab from "./components/ToolsTab";
5757
5858const DEFAULT_REQUEST_TIMEOUT_MSEC = 10000 ;
5959
60+ const params = new URLSearchParams ( window . location . search ) ;
61+ const PROXY_PORT = params . get ( "proxyPort" ) ?? "3000" ;
62+ const PROXY_SERVER_URL = `http://localhost:${ PROXY_PORT } ` ;
63+
6064const App = ( ) => {
6165 const [ connectionStatus , setConnectionStatus ] = useState <
6266 "disconnected" | "connected" | "error"
@@ -82,7 +86,8 @@ const App = () => {
8286 const [ args , setArgs ] = useState < string > ( ( ) => {
8387 return localStorage . getItem ( "lastArgs" ) || "" ;
8488 } ) ;
85- const [ url , setUrl ] = useState < string > ( "http://localhost:3001/sse" ) ;
89+
90+ const [ sseUrl , setSseUrl ] = useState < string > ( "http://localhost:3001/sse" ) ;
8691 const [ transportType , setTransportType ] = useState < "stdio" | "sse" > ( "stdio" ) ;
8792 const [ requestHistory , setRequestHistory ] = useState <
8893 { request : string ; response ?: string } [ ]
@@ -191,10 +196,7 @@ const App = () => {
191196 } , [ args ] ) ;
192197
193198 useEffect ( ( ) => {
194- const params = new URLSearchParams ( window . location . search ) ;
195- const serverPort = params . get ( 'port' ) || '3000' ;
196-
197- fetch ( `http://localhost:${ serverPort } /config` )
199+ fetch ( `${ PROXY_SERVER_URL } /config` )
198200 . then ( ( response ) => response . json ( ) )
199201 . then ( ( data ) => {
200202 setEnv ( data . defaultEnvironment ) ;
@@ -407,17 +409,15 @@ const App = () => {
407409 } ,
408410 ) ;
409411
410- const params = new URLSearchParams ( window . location . search ) ;
411- const serverPort = params . get ( 'port' ) || '3000' ;
412- const backendUrl = new URL ( `http://localhost:${ serverPort } /sse` ) ;
412+ const backendUrl = new URL ( `${ PROXY_SERVER_URL } /sse` ) ;
413413
414414 backendUrl . searchParams . append ( "transportType" , transportType ) ;
415415 if ( transportType === "stdio" ) {
416416 backendUrl . searchParams . append ( "command" , command ) ;
417417 backendUrl . searchParams . append ( "args" , args ) ;
418418 backendUrl . searchParams . append ( "env" , JSON . stringify ( env ) ) ;
419419 } else {
420- backendUrl . searchParams . append ( "url" , url ) ;
420+ backendUrl . searchParams . append ( "url" , sseUrl ) ;
421421 }
422422
423423 const clientTransport = new SSEClientTransport ( backendUrl ) ;
@@ -474,8 +474,8 @@ const App = () => {
474474 setCommand = { setCommand }
475475 args = { args }
476476 setArgs = { setArgs }
477- url = { url }
478- setUrl = { setUrl }
477+ sseUrl = { sseUrl }
478+ setSseUrl = { setSseUrl }
479479 env = { env }
480480 setEnv = { setEnv }
481481 onConnect = { connectMcpServer }
0 commit comments