@@ -57,6 +57,10 @@ import ToolsTab from "./components/ToolsTab";
57
57
58
58
const DEFAULT_REQUEST_TIMEOUT_MSEC = 10000 ;
59
59
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
+
60
64
const App = ( ) => {
61
65
const [ connectionStatus , setConnectionStatus ] = useState <
62
66
"disconnected" | "connected" | "error"
@@ -82,7 +86,8 @@ const App = () => {
82
86
const [ args , setArgs ] = useState < string > ( ( ) => {
83
87
return localStorage . getItem ( "lastArgs" ) || "" ;
84
88
} ) ;
85
- const [ url , setUrl ] = useState < string > ( "http://localhost:3001/sse" ) ;
89
+
90
+ const [ sseUrl , setSseUrl ] = useState < string > ( "http://localhost:3001/sse" ) ;
86
91
const [ transportType , setTransportType ] = useState < "stdio" | "sse" > ( "stdio" ) ;
87
92
const [ requestHistory , setRequestHistory ] = useState <
88
93
{ request : string ; response ?: string } [ ]
@@ -191,10 +196,7 @@ const App = () => {
191
196
} , [ args ] ) ;
192
197
193
198
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` )
198
200
. then ( ( response ) => response . json ( ) )
199
201
. then ( ( data ) => {
200
202
setEnv ( data . defaultEnvironment ) ;
@@ -407,17 +409,15 @@ const App = () => {
407
409
} ,
408
410
) ;
409
411
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` ) ;
413
413
414
414
backendUrl . searchParams . append ( "transportType" , transportType ) ;
415
415
if ( transportType === "stdio" ) {
416
416
backendUrl . searchParams . append ( "command" , command ) ;
417
417
backendUrl . searchParams . append ( "args" , args ) ;
418
418
backendUrl . searchParams . append ( "env" , JSON . stringify ( env ) ) ;
419
419
} else {
420
- backendUrl . searchParams . append ( "url" , url ) ;
420
+ backendUrl . searchParams . append ( "url" , sseUrl ) ;
421
421
}
422
422
423
423
const clientTransport = new SSEClientTransport ( backendUrl ) ;
@@ -474,8 +474,8 @@ const App = () => {
474
474
setCommand = { setCommand }
475
475
args = { args }
476
476
setArgs = { setArgs }
477
- url = { url }
478
- setUrl = { setUrl }
477
+ sseUrl = { sseUrl }
478
+ setSseUrl = { setSseUrl }
479
479
env = { env }
480
480
setEnv = { setEnv }
481
481
onConnect = { connectMcpServer }
0 commit comments