Function: mcp-add-root

mcp-add-root is a natively compiled function defined in mcp.el.

Signature

(mcp-add-root NAME ROOT)

Documentation

Add a ROOT to MCP server NAME.

NAME is the server name (string). 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 adding the root, 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-add-root (name root)
  "Add a ROOT to MCP server NAME.

NAME is the server name (string).
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 adding the root, sends a notification to the server that roots
have changed."
  (when-let* ((connection (gethash name mcp-server-connections)))
    (condition-case err
        (let ((current-roots (mcp--roots connection)))
          (unless (member root current-roots)
            (setf (mcp--roots connection) (append current-roots (list root)))
            (mcp-notify connection :notifications/roots/list_changed)))
      (error
       (message "Warning: Could not add root to %s: %s. Server may need to be restarted." name err)))))