Skip to content

Commit d737dd1

Browse files
committed
Support server__tool_name in disabledTools config as well.
1 parent c5ee8e7 commit d737dd1

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Add dynamic model discovery via `fetchModels` provider config for OpenAI-compatible `/models` endpoints
66
- Improve error handling for incompatible models messages in chat. #209
7+
- Support `server__tool_name` in `disabledTools` config as well.
78

89
## 0.87.2
910

src/eca/features/tools.clj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@
3232
(get-in config [:behavior behavior :disabledTools] [])
3333
[]))))
3434

35+
(defn ^:private tool-disabled? [tool disabled-tools]
36+
(or (contains? disabled-tools (str (:name (:server tool)) "__" (:name tool)))
37+
(contains? disabled-tools (:name tool))))
38+
3539
(defn make-tool-status-fn
3640
"Returns a function that marks tools as disabled based on config and behavior.
3741
If behavior is nil, only uses global disabledTools."
3842
[config behavior]
3943
(let [disabled-tools (get-disabled-tools config behavior)]
4044
(fn [tool]
41-
(assoc-some tool :disabled (contains? disabled-tools (:name tool))))))
45+
(assoc-some tool :disabled (tool-disabled? tool disabled-tools)))))
4246

4347
(defn ^:private replace-string-values-with-vars
4448
"walk through config parsing dynamic string contents if value is a string."
@@ -76,7 +80,7 @@
7680
(let [disabled-tools (get-disabled-tools config behavior)]
7781
(filterv
7882
(fn [tool]
79-
(and (not (contains? disabled-tools (:name tool)))
83+
(and (not (tool-disabled? tool disabled-tools))
8084
;; check for enabled-fn if present
8185
((or (:enabled-fn tool) (constantly true))
8286
{:behavior behavior
@@ -142,8 +146,8 @@
142146
:status "running"
143147
:tools (->> (native-tools @db* config)
144148
(remove #(= "compact_chat" (:name %)))
145-
(mapv #(select-keys % [:name :description :parameters]))
146-
(mapv tool-status-fn))})
149+
(mapv tool-status-fn)
150+
(mapv #(select-keys % [:name :description :parameters :disabled])))})
147151
(f.mcp/initialize-servers-async!
148152
{:on-server-updated (partial notify-server-updated metrics messenger tool-status-fn)}
149153
db*
@@ -280,8 +284,8 @@
280284
:name "ECA"
281285
:status "running"
282286
:tools (->> (native-tools @db* config)
283-
(mapv #(select-keys % [:name :description :parameters]))
284-
(mapv tool-status-fn))})
287+
(mapv tool-status-fn)
288+
(mapv #(select-keys % [:name :description :parameters :disabled])))})
285289
(doseq [[server-name {:keys [tools status]}] (:mcp-clients @db*)]
286290
(messenger/tool-server-updated messenger {:type :mcp
287291
:name server-name

0 commit comments

Comments
 (0)