Function: mcp--parse-http-url

mcp--parse-http-url is a natively compiled function defined in mcp.el.

Signature

(mcp--parse-http-url URL)

Documentation

Parse HTTP/HTTPS URL into connection components.

URL should be a string in format http(s)://host[:port][/path].

Returns a plist with connection parameters:
:tls - Boolean indicating HTTPS (t) or HTTP (nil)
:host - Server hostname (string)
:port - Port number (integer, defaults to 80/443)
:path - URL path component (string)

Returns nil if URL is invalid or not HTTP/HTTPS.

Source Code

;; Defined in /nix/store/5m747x13pb1ddrvbq9raj91c4q1h1kl0-emacs-packages-deps/share/emacs/site-lisp/elpa/mcp-20260615.940/mcp.el
(defun mcp--parse-http-url (url)
  "Parse HTTP/HTTPS URL into connection components.
URL should be a string in format http(s)://host[:port][/path].

Returns a plist with connection parameters:
:tls   - Boolean indicating HTTPS (t) or HTTP (nil)
:host  - Server hostname (string)
:port  - Port number (integer, defaults to 80/443)
:path  - URL path component (string)

Returns nil if URL is invalid or not HTTP/HTTPS."
  (when-let* ((url (url-generic-parse-url url))
              (type (url-type url))
              (host (url-host url))
              (filename (url-filename url)))
    (when (or (string= type "http")
              (string= type "https"))
      (let ((port (url-port url))
            (tls (string= "https" type)))
        (list :tls tls
              :host host
              :port (if port
                        port
                      (if tls
                          443
                        80))
              :path filename)))))