Skip to content

Commit 87d8fc3

Browse files
committed
Adds missing client-side root utility functions.
1 parent aa58203 commit 87d8fc3

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/mcp_toolkit/client.cljc

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@
219219
(json-rpc/send-message context (json-rpc/notification "cancelled"
220220
{:requestId request-id})))
221221

222-
(defn notify-root-list-updated
223-
"Notifies the MCP server that the client's root list has been updated.
222+
(defn notify-root-list-changed
223+
"Notifies the MCP server that the client's root list has been changed.
224224
(see https://modelcontextprotocol.io/specification/2025-06-18/client/roots#root-list-changes)
225225
226226
Args:
@@ -231,6 +231,36 @@
231231
[context]
232232
(json-rpc/send-message context (json-rpc/notification "roots/list_changed")))
233233

234+
(defn add-root
235+
"Adds a root to the client's root registry and notifies the server.
236+
237+
Args:
238+
context - The client session context
239+
root - Root map with :uri key and other root configuration
240+
241+
Returns:
242+
nil"
243+
[context root]
244+
(let [{:keys [session]} context]
245+
(swap! session update :root-by-uri assoc (:uri root) root)
246+
(notify-root-list-changed context))
247+
nil)
248+
249+
(defn remove-root
250+
"Removes a root from the client's root registry and notifies the server.
251+
252+
Args:
253+
context - The client session context
254+
root - Root map with :uri key to identify which root to remove
255+
256+
Returns:
257+
nil"
258+
[context root]
259+
(let [{:keys [session]} context]
260+
(swap! session update :root-by-uri dissoc (:uri root))
261+
(notify-root-list-changed context))
262+
nil)
263+
234264
(defn send-first-handshake-message
235265
"Sends the initial handshake message to establish the MCP connection.
236266
Initializes the session with server capabilities and triggers the on-initialized callback

0 commit comments

Comments
 (0)