Function: mcp-set-roots
mcp-set-roots is a natively compiled function defined in mcp.el.
Signature
(mcp-set-roots NAME ROOTS)
Documentation
Set the roots for MCP server NAME to ROOTS.
NAME is the server name (string).
ROOTS is a list of directory paths or root specifications.
Each root can be either:
- A string path (e.g., "/home/user/project")
- A plist with :uri and :name
(e.g., (:uri "file:///home/user/project" :name "Project"))
After setting roots, sends a notification to the server that roots have changed.
Source Code
;; Defined in /nix/store/5m747x13pb1ddrvbq9raj91c4q1h1kl0-emacs-packages-deps/share/emacs/site-lisp/elpa/mcp-20260615.940/mcp.el
(defun mcp-set-roots (name roots)
"Set the roots for MCP server NAME to ROOTS.
NAME is the server name (string).
ROOTS is a list of directory paths or root specifications.
Each root can be either:
- A string path (e.g., \"/home/user/project\")
- A plist with :uri and :name
(e.g., (:uri \"file:///home/user/project\" :name \"Project\"))
After setting roots, sends a notification to the server that roots
have changed."
(when-let* ((connection (gethash name mcp-server-connections)))
(condition-case err
(progn
(setf (mcp--roots connection) roots)
(mcp-notify connection :notifications/roots/list_changed))
(error
(message "Warning: Could not set roots for %s: %s. Server may need to be restarted." name err)))))