branch: elpa/gptel
commit ae97c23f7f18f345c103b4038b88ec17920e7e48
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-integrations: Fix tool retrieval from MCP servers, part 1
`gptel-mcp-connect' has an annoying bug: when you connect to an MCP
server, its tools are optionally added to gptel-tools. This is
for convenience in interactive use. However, tools from _all_
MCP servers registered with gptel are added at the same time.
This bug isn't fixed yet, but this commit is part of a fix: using
`gptel-mcp-connect' noninteractively should work correctly.
* gptel-integrations.el (gptel-mcp-connect): Partial fix for all
MCP tools getting added when adding tools from one server.
---
gptel-integrations.el | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gptel-integrations.el b/gptel-integrations.el
index e840ef683e8..65b7de382b5 100644
--- a/gptel-integrations.el
+++ b/gptel-integrations.el
@@ -99,7 +99,8 @@ not a function and non-nil, start SERVERS synchronously."
(add-all-tools
(lambda (&optional server-names)
"Register and add tools from servers. Report failures."
- (let ((tools (gptel-mcp--get-tools server-names))
+ (let ((tools (gptel-mcp--get-tools
+ (or server-names (mapcar #'car
inactive-servers))))
(now-active (cl-remove-if-not server-active-p
mcp-hub-servers)))
(mapc (lambda (tool) (apply #'gptel-make-tool tool))
tools)
(gptel-mcp--activate-tools tools)
@@ -124,7 +125,7 @@ not a function and non-nil, start SERVERS synchronously."
(mcp-hub-start-all-server
add-all-tools (mapcar #'car inactive-servers) syncp))
(funcall add-all-tools (mapcar #'car servers))))
- (message "All MCP tools are already available to gptel!")
+ (when interactive (message "All MCP tools are already available to
gptel!"))
(when (functionp server-callback) (funcall server-callback))))))
(defun gptel-mcp-disconnect (&optional servers interactive)