66import sys
77from collections .abc import AsyncIterator
88from pathlib import Path
9- from typing import (
10- TypedDict ,
11- )
12- from typing import Any
9+ from typing import Any , TypedDict
10+
1311from exceptiongroup import BaseExceptionGroup , catch
1412from mcp import ClientSession , McpError , StdioServerParameters
1513from mcp .client .session import (
@@ -449,17 +447,19 @@ def infer_transport(
449447 # the transport is a websocket URL
450448 elif isinstance (transport , AnyUrl | str ) and str (transport ).startswith ("ws" ):
451449 return WSTransport (url = transport )
452-
450+
453451 ## if the transport is a config dict
454452 elif isinstance (transport , dict ):
455453 if "mcpServers" not in transport :
456454 raise ValueError ("Invalid transport dictionary: missing 'mcpServers' key" )
457455 else :
458456 server = transport ["mcpServers" ]
459457 if len (list (server .keys ())) > 1 :
460- raise ValueError ("Invalid transport dictionary: multiple servers found - only one expected" )
458+ raise ValueError (
459+ "Invalid transport dictionary: multiple servers found - only one expected"
460+ )
461461 server_name = list (server .keys ())[0 ]
462- # Stdio transport
462+ # Stdio transport
463463 if "command" in server [server_name ] and "args" in server [server_name ]:
464464 return StdioTransport (
465465 command = server [server_name ]["command" ],
@@ -482,7 +482,7 @@ def infer_transport(
482482 )
483483
484484 raise ValueError ("Cannot determine transport type from dictionary" )
485-
485+
486486 # the transport is an unknown type
487487 else :
488488 raise ValueError (f"Could not infer a valid transport from: { transport } " )
0 commit comments