quickstart - lizqwerscott/mcp.el GitHub Wiki
First, configure gptel to use an AI model that can call tools, such as Claude. Then, configure the desired MCP server. For example, let’s use the fetch MCP server, which can retrieve web content and convert it to markdown.
Refer to the official documentation to configure the server you want to start.
This configuration matches the official one. The first parameter is the name of the MCP server, the second is the command, and the last is the arguments.
(require 'mcp-hub)
(setq mcp-hub-servers
'(("fetch" . (:command "uvx" :args ("mcp-server-fetch")))))
Use the command mcp-hub
to launch the server management interface, or use mcp-hub-start-all-server
to start all configured MCP servers.
To integrate with gptel
, you can use the following functions. This function generates a list of tools in the gptel
tool format and registers them with gptel
, so gptel
knows which tools it can call.
(defun gptel-mcp-register-tool ()
(interactive)
(let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
(mapcar #'(lambda (tool)
(apply #'gptel-make-tool
tool))
tools)))
After running this function, you will see the registered MCP tools in the
gptel
tool menu.
There are currently two methods. The first is to use the gptel-menu
in gptel
to activate tools. The second is to use the following functions to activate or deactivate all MCP tools.
;; Activate all MCP tools
(defun gptel-mcp-use-tool ()
(interactive)
(let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
(mapcar #'(lambda (tool)
(let ((path (list (plist-get tool :category)
(plist-get tool :name))))
(push (gptel-get-tool path)
gptel-tools)))
tools)))
;; Deactivate all MCP tools
(defun gptel-mcp-close-use-tool ()
(interactive)
(let ((tools (mcp-hub-get-all-tool :asyncp t :categoryp t)))
(mapcar #'(lambda (tool)
(let ((path (list (plist-get tool :category)
(plist-get tool :name))))
(setq gptel-tools
(cl-remove-if #'(lambda (tool)
(equal path
(list (gptel-tool-category tool)
(gptel-tool-name tool))))
gptel-tools))))
tools)))
Once activated, you can proceed with normal AI conversations. During this process, the AI will decide whether to use tools to retrieve information.