@@ -93,6 +93,7 @@ const App = () => {
9393 const [ mcpClient , setMcpClient ] = useState < Client | null > ( null ) ;
9494 const [ notifications , setNotifications ] = useState < ServerNotification [ ] > ( [ ] ) ;
9595 const [ roots , setRoots ] = useState < Root [ ] > ( [ ] ) ;
96+ const [ env , setEnv ] = useState < Record < string , string > > ( { } ) ;
9697
9798 const [ pendingSampleRequests , setPendingSampleRequests ] = useState <
9899 Array <
@@ -145,6 +146,15 @@ const App = () => {
145146 localStorage . setItem ( "lastArgs" , args ) ;
146147 } , [ args ] ) ;
147148
149+ useEffect ( ( ) => {
150+ fetch ( "http://localhost:3000/default-environment" )
151+ . then ( ( response ) => response . json ( ) )
152+ . then ( ( data ) => setEnv ( data ) )
153+ . catch ( ( error ) =>
154+ console . error ( "Error fetching default environment:" , error ) ,
155+ ) ;
156+ } , [ ] ) ;
157+
148158 const pushHistory = ( request : object , response : object ) => {
149159 setRequestHistory ( ( prev ) => [
150160 ...prev ,
@@ -284,6 +294,7 @@ const App = () => {
284294 if ( transportType === "stdio" ) {
285295 backendUrl . searchParams . append ( "command" , command ) ;
286296 backendUrl . searchParams . append ( "args" , args ) ;
297+ backendUrl . searchParams . append ( "env" , JSON . stringify ( env ) ) ;
287298 } else {
288299 backendUrl . searchParams . append ( "url" , url ) ;
289300 }
@@ -371,6 +382,50 @@ const App = () => {
371382 Connect
372383 </ Button >
373384 </ div >
385+ { transportType === "stdio" && (
386+ < div className = "mt-4" >
387+ < h3 className = "text-md font-semibold mb-2" >
388+ Environment Variables
389+ </ h3 >
390+ { Object . entries ( env ) . map ( ( [ key , value ] ) => (
391+ < div key = { key } className = "flex space-x-2 mb-2" >
392+ < Input
393+ placeholder = "Key"
394+ value = { key }
395+ onChange = { ( e ) =>
396+ setEnv ( ( prev ) => ( {
397+ ...prev ,
398+ [ e . target . value ] : value ,
399+ } ) )
400+ }
401+ />
402+ < Input
403+ placeholder = "Value"
404+ value = { value }
405+ onChange = { ( e ) =>
406+ setEnv ( ( prev ) => ( { ...prev , [ key ] : e . target . value } ) )
407+ }
408+ />
409+ < Button
410+ onClick = { ( ) =>
411+ setEnv ( ( prev ) => {
412+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
413+ const { [ key ] : _ , ...rest } = prev ;
414+ return rest ;
415+ } )
416+ }
417+ >
418+ Remove
419+ </ Button >
420+ </ div >
421+ ) ) }
422+ < Button
423+ onClick = { ( ) => setEnv ( ( prev ) => ( { ...prev , "" : "" } ) ) }
424+ >
425+ Add Environment Variable
426+ </ Button >
427+ </ div >
428+ ) }
374429 </ div >
375430 { mcpClient ? (
376431 < Tabs defaultValue = "resources" className = "w-full p-4" >
0 commit comments