Skip to content

Commit 57111f1

Browse files
committed
Avoid errors on multiple same MCP server calls in parallel.
1 parent 6c60acb commit 57111f1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Avoid errors on multiple same MCP server calls in parallel.
6+
57
## 0.54.2
68

79
- Fix openai cache tokens cost calculation.

src/eca/features/tools/mcp.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@
224224
(when (some #(= name (:name %)) tools)
225225
client)))
226226
first)
227-
result (.callTool ^McpSyncClient mcp-client
228-
(McpSchema$CallToolRequest. name arguments))]
227+
;; Synchronize on the client to prevent concurrent tool calls to the same MCP server
228+
result (locking mcp-client
229+
(.callTool ^McpSyncClient mcp-client
230+
(McpSchema$CallToolRequest. name arguments)))]
229231
{:error (.isError result)
230232
:contents (mapv ->content (.content result))}))
231233

0 commit comments

Comments
 (0)