Skip to content

Commit 5a53975

Browse files
committed
gptel-integrations: Guard activate-tools against nil tools list
When `gptel-mcp-connect` is called for specific servers that fail to start or return no tools, the `add-all-tools` callback passes nil to `gptel-mcp--activate-tools`. Its `(unless tools ...)` fallback then fetches tools from ALL connected MCP servers and tries to look them up via `gptel-get-tool`, crashing on tools from servers that were never registered with `gptel-make-tool`. Guard the call with `when` so nil means "nothing to activate" rather than "activate everything".
1 parent 23a0ec9 commit 5a53975

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

gptel-integrations.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ not a function and non-nil, start SERVERS synchronously."
163163
(or server-names (mapcar #'car inactive-servers))))
164164
(now-active (cl-remove-if-not server-active-p mcp-hub-servers)))
165165
(mapc (lambda (tool) (apply #'gptel-make-tool tool)) tools)
166-
(gptel-mcp--activate-tools tools)
166+
(when tools (gptel-mcp--activate-tools tools))
167167
(if-let* ((failed (cl-set-difference inactive-servers now-active
168168
:test #'equal)))
169169
(progn

0 commit comments

Comments
 (0)