@@ -55,9 +55,15 @@ import RootsTab from "./components/RootsTab";
5555import SamplingTab , { PendingRequest } from "./components/SamplingTab" ;
5656import Sidebar from "./components/Sidebar" ;
5757import ToolsTab from "./components/ToolsTab" ;
58- import { DEFAULT_INSPECTOR_CONFIG } from "./lib/constants" ;
5958import { InspectorConfig } from "./lib/configurationTypes" ;
60- import { getMCPProxyAddress } from "./utils/configUtils" ;
59+ import {
60+ getMCPProxyAddress ,
61+ getInitialSseUrl ,
62+ getInitialTransportType ,
63+ getInitialCommand ,
64+ getInitialArgs ,
65+ initializeInspectorConfig ,
66+ } from "./utils/configUtils" ;
6167
6268const CONFIG_LOCAL_STORAGE_KEY = "inspectorConfig_v1" ;
6369
@@ -77,26 +83,13 @@ const App = () => {
7783 prompts : null ,
7884 tools : null ,
7985 } ) ;
80- const [ command , setCommand ] = useState < string > ( ( ) => {
81- return localStorage . getItem ( "lastCommand" ) || "mcp-server-everything" ;
82- } ) ;
83- const [ args , setArgs ] = useState < string > ( ( ) => {
84- return localStorage . getItem ( "lastArgs" ) || "" ;
85- } ) ;
86+ const [ command , setCommand ] = useState < string > ( getInitialCommand ) ;
87+ const [ args , setArgs ] = useState < string > ( getInitialArgs ) ;
8688
87- const [ sseUrl , setSseUrl ] = useState < string > ( ( ) => {
88- return localStorage . getItem ( "lastSseUrl" ) || "http://localhost:3001/sse" ;
89- } ) ;
89+ const [ sseUrl , setSseUrl ] = useState < string > ( getInitialSseUrl ) ;
9090 const [ transportType , setTransportType ] = useState <
9191 "stdio" | "sse" | "streamable-http"
92- > ( ( ) => {
93- return (
94- ( localStorage . getItem ( "lastTransportType" ) as
95- | "stdio"
96- | "sse"
97- | "streamable-http" ) || "stdio"
98- ) ;
99- } ) ;
92+ > ( getInitialTransportType ) ;
10093 const [ logLevel , setLogLevel ] = useState < LoggingLevel > ( "debug" ) ;
10194 const [ notifications , setNotifications ] = useState < ServerNotification [ ] > ( [ ] ) ;
10295 const [ stdErrNotifications , setStdErrNotifications ] = useState <
@@ -105,27 +98,9 @@ const App = () => {
10598 const [ roots , setRoots ] = useState < Root [ ] > ( [ ] ) ;
10699 const [ env , setEnv ] = useState < Record < string , string > > ( { } ) ;
107100
108- const [ config , setConfig ] = useState < InspectorConfig > ( ( ) => {
109- const savedConfig = localStorage . getItem ( CONFIG_LOCAL_STORAGE_KEY ) ;
110- if ( savedConfig ) {
111- // merge default config with saved config
112- const mergedConfig = {
113- ...DEFAULT_INSPECTOR_CONFIG ,
114- ...JSON . parse ( savedConfig ) ,
115- } as InspectorConfig ;
116-
117- // update description of keys to match the new description (in case of any updates to the default config description)
118- Object . entries ( mergedConfig ) . forEach ( ( [ key , value ] ) => {
119- mergedConfig [ key as keyof InspectorConfig ] = {
120- ...value ,
121- label : DEFAULT_INSPECTOR_CONFIG [ key as keyof InspectorConfig ] . label ,
122- } ;
123- } ) ;
124-
125- return mergedConfig ;
126- }
127- return DEFAULT_INSPECTOR_CONFIG ;
128- } ) ;
101+ const [ config , setConfig ] = useState < InspectorConfig > ( ( ) =>
102+ initializeInspectorConfig ( CONFIG_LOCAL_STORAGE_KEY ) ,
103+ ) ;
129104 const [ bearerToken , setBearerToken ] = useState < string > ( ( ) => {
130105 return localStorage . getItem ( "lastBearerToken" ) || "" ;
131106 } ) ;
@@ -683,11 +658,24 @@ const App = () => {
683658 { ! serverCapabilities ?. resources &&
684659 ! serverCapabilities ?. prompts &&
685660 ! serverCapabilities ?. tools ? (
686- < div className = "flex items-center justify-center p-4" >
687- < p className = "text-lg text-gray-500" >
688- The connected server does not support any MCP capabilities
689- </ p >
690- </ div >
661+ < >
662+ < div className = "flex items-center justify-center p-4" >
663+ < p className = "text-lg text-gray-500" >
664+ The connected server does not support any MCP
665+ capabilities
666+ </ p >
667+ </ div >
668+ < PingTab
669+ onPingClick = { ( ) => {
670+ void sendMCPRequest (
671+ {
672+ method : "ping" as const ,
673+ } ,
674+ EmptyResultSchema ,
675+ ) ;
676+ } }
677+ />
678+ </ >
691679 ) : (
692680 < >
693681 < ResourcesTab
@@ -755,6 +743,7 @@ const App = () => {
755743 setSelectedPrompt = { ( prompt ) => {
756744 clearError ( "prompts" ) ;
757745 setSelectedPrompt ( prompt ) ;
746+ setPromptContent ( "" ) ;
758747 } }
759748 handleCompletion = { handleCompletion }
760749 completionsSupported = { completionsSupported }
0 commit comments