mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-06 21:11:24 +02:00
mcp fix (+1 squashed commits)
Squashed commits: [c5a959a07] mcp fix
This commit is contained in:
+14
-8
@@ -588,15 +588,21 @@ class MCPStdioClient:
|
||||
raise ValueError("Cannot await response for a message without an 'id' field")
|
||||
|
||||
response_q = queue.Queue()
|
||||
if await_response and msg_id is not None:
|
||||
with self._pending_lock:
|
||||
self._pending[msg_id] = response_q
|
||||
|
||||
with self.lock: # write lock only now
|
||||
if self.process.stdin.closed:
|
||||
raise RuntimeError("MCP server stdin is closed")
|
||||
self.process.stdin.write(line + "\n")
|
||||
self.process.stdin.flush()
|
||||
try:
|
||||
with self._pending_lock:
|
||||
if await_response and msg_id is not None:
|
||||
self._pending[msg_id] = response_q
|
||||
with self.lock:
|
||||
if self.process.stdin.closed:
|
||||
raise RuntimeError("MCP server stdin is closed")
|
||||
self.process.stdin.write(line + "\n")
|
||||
self.process.stdin.flush()
|
||||
except Exception:
|
||||
if await_response and msg_id is not None:
|
||||
with self._pending_lock:
|
||||
self._pending.pop(msg_id, None)
|
||||
raise
|
||||
|
||||
if not await_response:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user