Skip to content

Commit a24173f

Browse files
FrauH0llekarthink
authored andcommitted
gptel-integrations: Add sync mcp server init
This change requires `mcp.el` commit 5f06a78fe74f58888f115bf30838ede5e013f4af or later. See lizqwerscott/mcp.el@5f06a78. * gptel-integrations.el (gptel-mcp-connect): Allow servers to be started synchronously when the SERVER-CALLBACK argument is a non-nil symbol instead of a function.
1 parent dd5e717 commit a24173f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

gptel-integrations.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ considered.
5858
If INTERACTIVE is non-nil (or called interactively), guide the user
5959
through setting up mcp, and query for servers to retrieve tools from.
6060
61-
Call SERVER-CALLBACK after starting MCP servers."
61+
Call SERVER-CALLBACK after starting MCP servers. If SERVER-CALLBACK is
62+
not a function and non-nil, start SERVERS synchronously."
6263
(interactive (list nil nil t))
6364
(if (locate-library "mcp-hub")
6465
(unless (require 'mcp-hub nil t)
@@ -119,8 +120,9 @@ Call SERVER-CALLBACK after starting MCP servers."
119120
(when (functionp server-callback) (funcall server-callback))))))
120121

121122
(if inactive-servers ;start servers
122-
(mcp-hub-start-all-server
123-
add-all-tools (mapcar #'car inactive-servers))
123+
(let ((syncp (and server-callback (not (functionp server-callback)) t)))
124+
(mcp-hub-start-all-server
125+
add-all-tools (mapcar #'car inactive-servers) syncp))
124126
(funcall add-all-tools (mapcar #'car servers))))
125127
(message "All MCP tools are already available to gptel!")
126128
(when (functionp server-callback) (funcall server-callback))))))

0 commit comments

Comments
 (0)