@@ -21,7 +21,7 @@ interface MCPConnection {
2121
2222interface McpContextType {
2323 connections : MCPConnection [ ]
24- addConnection : ( url : string , name ?: string , proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > } ) => void
24+ addConnection : ( url : string , name ?: string , proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > } , transportType ?: 'http' | 'sse' ) => void
2525 removeConnection : ( id : string ) => void
2626 getConnection : ( id : string ) => MCPConnection | undefined
2727}
@@ -33,12 +33,14 @@ interface SavedConnection {
3333 url : string
3434 name : string
3535 proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > }
36+ transportType ?: 'http' | 'sse'
3637}
3738
38- function McpConnectionWrapper ( { url, name, proxyConfig, onUpdate, onRemove : _onRemove } : {
39+ function McpConnectionWrapper ( { url, name, proxyConfig, transportType , onUpdate, onRemove : _onRemove } : {
3940 url : string
4041 name : string
4142 proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > }
43+ transportType ?: 'http' | 'sse'
4244 onUpdate : ( connection : MCPConnection ) => void
4345 onRemove : ( ) => void
4446} ) {
@@ -79,6 +81,7 @@ function McpConnectionWrapper({ url, name, proxyConfig, onUpdate, onRemove: _onR
7981 url : finalUrl ,
8082 callbackUrl,
8183 customHeaders : Object . keys ( customHeaders ) . length > 0 ? customHeaders : undefined ,
84+ transportType : transportType || 'http' , // Default to 'http' for Streamable HTTP
8285 } )
8386 const onUpdateRef = useRef ( onUpdate )
8487 const prevConnectionRef = useRef < MCPConnection | null > ( null )
@@ -194,12 +197,21 @@ export function McpProvider({ children }: { children: ReactNode }) {
194197 && typeof conn . id === 'string'
195198 && typeof conn . url === 'string'
196199 && typeof conn . name === 'string'
200+ } ) . map ( ( conn : any ) => {
201+ // Migrate existing connections to include transportType
202+ if ( ! conn . transportType ) {
203+ conn . transportType = 'http' // Default to 'http' for Streamable HTTP
204+ }
205+ return conn
197206 } )
198207 : [ ]
199208
200- // If we filtered out any invalid connections, update localStorage
201- if ( validConnections . length !== parsed . length ) {
202- console . warn ( 'Cleaned up invalid connections from localStorage' )
209+ // If we filtered out any invalid connections or migrated transport types, update localStorage
210+ const hasChanges = validConnections . length !== parsed . length
211+ || validConnections . some ( ( conn : any ) => conn . transportType === 'http' && ! parsed . find ( ( p : any ) => p . id === conn . id && p . transportType ) )
212+
213+ if ( hasChanges ) {
214+ console . warn ( 'Updated connections in localStorage with transport type migration' )
203215 localStorage . setItem ( 'mcp-inspector-connections' , JSON . stringify ( validConnections ) )
204216 }
205217
@@ -218,13 +230,14 @@ export function McpProvider({ children }: { children: ReactNode }) {
218230 setConnectionVersion ( v => v + 1 )
219231 } , [ ] )
220232
221- const addConnection = useCallback ( ( url : string , name ?: string , proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > } ) => {
233+ const addConnection = useCallback ( ( url : string , name ?: string , proxyConfig ?: { proxyAddress ?: string , proxyToken ?: string , customHeaders ?: Record < string , string > } , transportType ?: 'http' | 'sse' ) => {
222234 const connectionName = name || url
223235 const newConnection : SavedConnection = {
224236 id : url ,
225237 url,
226238 name : connectionName ,
227239 proxyConfig,
240+ transportType : transportType || 'http' , // Default to 'http' for Streamable HTTP
228241 }
229242
230243 setSavedConnections ( ( prev ) => {
@@ -289,6 +302,7 @@ export function McpProvider({ children }: { children: ReactNode }) {
289302 url = { saved . url }
290303 name = { saved . name }
291304 proxyConfig = { saved . proxyConfig }
305+ transportType = { saved . transportType }
292306 onUpdate = { updateConnection }
293307 onRemove = { ( ) => removeConnection ( saved . id ) }
294308 />
0 commit comments