Function: mcp-request-dispatcher

mcp-request-dispatcher is a natively compiled function defined in mcp.el.

Signature

(mcp-request-dispatcher NAME METHOD PARAMS)

Documentation

Default handler for MCP server requests.

NAME identifies the server connection. METHOD is the requested method name. PARAMS contains the method parameters.

This basic implementation just logs the request. Applications should override this to implement actual request handling.

Source Code

;; Defined in /nix/store/5m747x13pb1ddrvbq9raj91c4q1h1kl0-emacs-packages-deps/share/emacs/site-lisp/elpa/mcp-20260615.940/mcp.el
(defun mcp-request-dispatcher (name method params)
  "Default handler for MCP server requests.
NAME identifies the server connection. METHOD is the requested
method name. PARAMS contains the method parameters.

This basic implementation just logs the request. Applications
should override this to implement actual request handling."
  (pcase method
    ('roots/list
     (if-let* ((connection (gethash name mcp-server-connections)))
         (let ((roots (condition-case nil
                          (mcp--roots connection)
                        (error nil))))
           (list :roots (if roots
                            (vconcat (mapcar (lambda (root)
                                               (if (stringp root)
                                                   (list :uri (concat "file://" (expand-file-name root))
                                                         :name (file-name-nondirectory (directory-file-name root)))
                                                 root))
                                             roots))
                          [])))
       (list :roots [])))
    (_
     (message "%s Received request: method=%s, params=%s" name method params))))