SEUyishu commited on
Commit
fbb09f9
·
verified ·
1 Parent(s): 1f6b6df

Update start_mcp.py

Browse files
Files changed (1) hide show
  1. start_mcp.py +3 -4
start_mcp.py CHANGED
@@ -138,12 +138,11 @@ def run_sse_server(host: str, port: int):
138
 
139
  tool = mcp._tool_manager._tools[tool_name]
140
 
141
- # Run in executor if sync to avoid blocking
142
  if tool.is_async:
143
  tool_result = await tool.fn(**tool_args)
144
  else:
145
- loop = asyncio.get_event_loop()
146
- tool_result = await loop.run_in_executor(None, lambda: tool.fn(**tool_args))
147
 
148
  result = {"content": [{"type": "text", "text": json.dumps(tool_result)}]}
149
  logger.info(f"Tool {tool_name} completed")
@@ -165,7 +164,7 @@ def run_sse_server(host: str, port: int):
165
  # Send response via SSE
166
  if session_id in connections:
167
  await connections[session_id].put(response)
168
- logger.info(f"Response sent for {method}")
169
  else:
170
  logger.error(f"Session {session_id} disconnected before response")
171
 
 
138
 
139
  tool = mcp._tool_manager._tools[tool_name]
140
 
141
+ # Call tool directly (don't use executor - it breaks httpx/openai)
142
  if tool.is_async:
143
  tool_result = await tool.fn(**tool_args)
144
  else:
145
+ tool_result = tool.fn(**tool_args)
 
146
 
147
  result = {"content": [{"type": "text", "text": json.dumps(tool_result)}]}
148
  logger.info(f"Tool {tool_name} completed")
 
164
  # Send response via SSE
165
  if session_id in connections:
166
  await connections[session_id].put(response)
167
+ logger.info(f"Response sent for {method}, id={msg_id}")
168
  else:
169
  logger.error(f"Session {session_id} disconnected before response")
170