Skip to content

Commit f4a0442

Browse files
committed
Minor improvement to mcp initialization
1 parent a6b7723 commit f4a0442

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/eca/features/tools/mcp.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
McpSchema$ClientCapabilities
1616
McpSchema$Content
1717
McpSchema$GetPromptRequest
18+
McpSchema$LoggingMessageNotification
1819
McpSchema$Prompt
1920
McpSchema$PromptArgument
2021
McpSchema$PromptMessage
@@ -67,12 +68,15 @@
6768
(getProcessBuilder [] (-> (ProcessBuilder. ^List pb-init-args)
6869
(.directory (io/file work-dir)))))))
6970

70-
(defn ^:private ->client ^McpSyncClient [transport config]
71+
(defn ^:private ->client ^McpSyncClient [transport config workspaces]
7172
(-> (McpClient/sync transport)
7273
(.requestTimeout (Duration/ofSeconds (:mcpTimeoutSeconds config)))
7374
(.capabilities (-> (McpSchema$ClientCapabilities/builder)
7475
(.roots true)
7576
(.build)))
77+
(.roots ^List (mapv #(McpSchema$Root. (:uri %) (:name %)) workspaces))
78+
(.loggingConsumer (fn [^McpSchema$LoggingMessageNotification notification]
79+
(logger/info logger-tag (.data notification))))
7680
(.build)))
7781

7882
(defn ^:private ->server [mcp-name server-config status db]
@@ -150,11 +154,9 @@
150154
obj-mapper (ObjectMapper.)]
151155
(try
152156
(let [transport (->transport server-config workspaces)
153-
client (->client transport config)]
157+
client (->client transport config workspaces)]
154158
(on-server-updated (->server name server-config :starting db))
155159
(swap! db* assoc-in [:mcp-clients name] {:client client})
156-
(doseq [{:keys [name uri]} workspaces]
157-
(.addRoot client (McpSchema$Root. uri name)))
158160
(.initialize client)
159161
(swap! db* assoc-in [:mcp-clients name :tools] (list-server-tools obj-mapper client))
160162
(swap! db* assoc-in [:mcp-clients name :prompts] (list-server-prompts client))

0 commit comments

Comments
 (0)