11import asyncio
2- from mcp import ClientSession , StdioServerParameters , stdio_client
2+ from mcp import StdioServerParameters , stdio_client
33
44from mcp_bridge .config import config
5+ from mcp_bridge .mcp_clients .session import McpClientSession
56from .AbstractClient import GenericMcpClient
67from loguru import logger
78import shutil
@@ -17,24 +18,28 @@ class StdioClient(GenericMcpClient):
1718 def __init__ (self , name : str , config : StdioServerParameters ) -> None :
1819 super ().__init__ (name = name )
1920
21+ # logger.debug(f"initializing settings for {name}: {config.command} {" ".join(config.args)}")
22+
23+ own_config = config .model_copy (deep = True )
24+
2025 env = dict (os .environ .copy ())
2126
2227 env = {
2328 key : value for key , value in env .items ()
2429 if not any (key .startswith (keyword ) for keyword in venv_keywords )
2530 }
2631
27- # logger.debug(f"env: {env}")
28-
2932 if config .env is not None :
3033 env .update (config .env )
3134
35+ own_config .env = env
36+
3237 command = shutil .which (config .command )
3338 if command is None :
3439 logger .error (f"could not find command { config .command } " )
3540 exit (1 )
3641
37- own_config = config . model_copy ( deep = True )
42+ own_config . command = command
3843
3944 # this changes the default to ignore
4045 if "encoding_error_handler" not in config .model_fields_set :
@@ -48,7 +53,7 @@ async def _maintain_session(self):
4853 logger .debug (f"entered stdio_client context manager for { self .name } " )
4954 assert client [0 ] is not None , f"missing read stream for { self .name } "
5055 assert client [1 ] is not None , f"missing write stream for { self .name } "
51- async with ClientSession (* client ) as session :
56+ async with McpClientSession (* client ) as session :
5257 logger .debug (f"entered client session context manager for { self .name } " )
5358 await session .initialize ()
5459 logger .debug (f"finished initialise session for { self .name } " )
0 commit comments