|
|
|
@ -297,8 +297,10 @@ class MCPServerSse:
|
|
|
|
|
"""Connect to the MCP server with proper locking."""
|
|
|
|
|
async with self._connection_lock:
|
|
|
|
|
if not self.client:
|
|
|
|
|
self.client = ClientSession()
|
|
|
|
|
await self.client.connect(self.create_streams())
|
|
|
|
|
transport = await self.create_streams()
|
|
|
|
|
read_stream, write_stream = transport
|
|
|
|
|
self.client = ClientSession(read_stream=read_stream, write_stream=write_stream)
|
|
|
|
|
await self.client.initialize()
|
|
|
|
|
|
|
|
|
|
def create_streams(self, **kwargs) -> AbstractAsyncContextManager[Any]:
|
|
|
|
|
return sse_client(
|
|
|
|
@ -503,5 +505,3 @@ async def _batch(params: List[MCPServerSseParams], payload: dict[str, Any] | str
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logger.error(f"Error in batch processing: {e}")
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|