fix(mcp): resolve client initialization and update server configuration in mcp integration

pull/819/head
Pavan Kumar 3 months ago committed by ascender1729
parent d46da9c8bb
commit 925709de6e

@ -7,8 +7,9 @@ from loguru import logger
mcp = FastMCP(
host="0.0.0.0",
port=8000,
transport="sse",
require_session_id=False,
transport="sse" # Explicitly specify SSE transport
timeout=30.0
)
@mcp.tool()

@ -43,6 +43,7 @@ async def _execute_mcp_tool(
method: Literal["stdio", "sse"] = "sse",
parameters: Dict[Any, Any] = None,
output_type: Literal["str", "dict"] = "str",
timeout: float = 30.0,
*args,
**kwargs,
) -> Dict[Any, Any]:

@ -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 []

Loading…
Cancel
Save