branch: elpa/gptel
commit c49675e1df4456895309172cb8a7669a57148bac
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel-integrations: Always run server-callback
    
    * gptel-integrations.el (gptel-mcp-connect): Always run the
    server-callback after running this command, even if no new servers
    are started.  This is because the callback may be needed to
    continue a request chain, such as when `gptel-mcp-connect' runs in
    `gptel-prompt-transform-functions'.
---
 gptel-integrations.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gptel-integrations.el b/gptel-integrations.el
index 4f0c712b1a..1da44a73b4 100644
--- a/gptel-integrations.el
+++ b/gptel-integrations.el
@@ -52,7 +52,7 @@ MCP servers are started if required.  If INTERACTIVE is 
non-nil (or
 called interactively), guide the user through setting up mcp, and query
 for servers to retrieve tools from.
 
-Call SERVER-CALLBACK after starting MCP servers, if starting them."
+Call SERVER-CALLBACK after starting MCP servers."
   (interactive (list t))
   (if (locate-library "mcp-hub")
       (unless (require 'mcp-hub nil t)
@@ -107,7 +107,8 @@ Call SERVER-CALLBACK after starting MCP servers, if 
starting them."
                 (mcp-hub-start-all-server
                  add-all-tools (mapcar #'car inactive-servers))
               (funcall add-all-tools)))
-        (message "All MCP tools are already available to gptel!")))))
+        (message "All MCP tools are already available to gptel!")
+        (when (functionp server-callback) (funcall server-callback))))))
 
 (defun gptel-mcp-disconnect (&optional interactive)
   "Unregister gptel tools provided by MCP servers using the mcp package.

Reply via email to