|
8 | 8 | [eca.features.tools.shell :as f.tools.shell] |
9 | 9 | [eca.features.tools.util :as tools.util] |
10 | 10 | [eca.logger :as logger] |
11 | | - [eca.messenger :as messenger]) |
| 11 | + [eca.messenger :as messenger] |
| 12 | + [eca.shared :refer [assoc-some]]) |
12 | 13 | (:import |
13 | 14 | [java.util Map])) |
14 | 15 |
|
15 | 16 | (set! *warn-on-reflection* true) |
16 | 17 |
|
17 | 18 | (def ^:private logger-tag "[TOOLS]") |
18 | 19 |
|
19 | | -(defn native-definitions [db config] |
| 20 | +(defn ^:private native-definitions [db config] |
20 | 21 | (into |
21 | 22 | {} |
22 | 23 | (map (fn [[name tool]] |
|
38 | 39 | "Returns all available tools, including both native ECA tools |
39 | 40 | (like filesystem and shell tools) and tools provided by MCP servers." |
40 | 41 | [db config] |
41 | | - (concat |
42 | | - (mapv #(assoc % :origin :native) (native-tools db config)) |
43 | | - (mapv #(assoc % :origin :mcp) (f.mcp/all-tools db)))) |
| 42 | + (let [disabled-tools (set (get-in config [:disabledTools] []))] |
| 43 | + (filterv |
| 44 | + (fn [tool] |
| 45 | + (not (contains? disabled-tools (:name tool)))) |
| 46 | + (concat |
| 47 | + (mapv #(assoc % :origin :native) (native-tools db config)) |
| 48 | + (mapv #(assoc % :origin :mcp) (f.mcp/all-tools db)))))) |
44 | 49 |
|
45 | 50 | (defn call-tool! [^String name ^Map arguments db config] |
46 | 51 | (logger/info logger-tag (format "Calling tool '%s' with args '%s'" name arguments)) |
|
49 | 54 | (f.mcp/call-tool! name arguments db))) |
50 | 55 |
|
51 | 56 | (defn init-servers! [db* messenger config] |
52 | | - (messenger/tool-server-updated messenger {:type :native |
53 | | - :name "ECA" |
54 | | - :status "running" |
55 | | - :tools (native-tools @db* config)}) |
56 | | - (f.mcp/initialize-servers-async! |
57 | | - {:on-server-updated (fn [server] |
58 | | - (messenger/tool-server-updated messenger (assoc server :type :mcp)))} |
59 | | - db* |
60 | | - config)) |
| 57 | + (let [disabled-tools (set (get-in config [:disabledTools] [])) |
| 58 | + with-tool-status (fn [tool] |
| 59 | + (assoc-some tool :disabled (contains? disabled-tools (:name tool))))] |
| 60 | + (messenger/tool-server-updated messenger {:type :native |
| 61 | + :name "ECA" |
| 62 | + :status "running" |
| 63 | + :tools (mapv with-tool-status (native-tools @db* config))}) |
| 64 | + (f.mcp/initialize-servers-async! |
| 65 | + {:on-server-updated (fn [server] |
| 66 | + (messenger/tool-server-updated messenger (-> server |
| 67 | + (assoc :type :mcp) |
| 68 | + (update :tools #(mapv with-tool-status %)))))} |
| 69 | + db* |
| 70 | + config))) |
0 commit comments