-
|
Hey thanks for the fabulous gptel. I was wondering if there is a standard way to have a preset connect to an mcp tool and disconnect after the completion is finished. I tried to do define the preset with but it doesn't enable them in time and the @preset completion fails to use the tool. Some of the mcp contains many tools and adding them all globally will just confuse the model. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
A couple of misconceptions here.
To solve your timing issue, you just have to start the MCP server synchronously. :pre (lambda () (gptel-mcp-connect '("mcptool") 'sync))You can set the specific tools you want with (Be sure to update the gptel and mcp packages before you try this.) To solve the adding-tools-globally issue... there is nothing to solve. When you use @preset, all changes happen in a buffer-local environment. If you activate this preset from the transient menu, you are explicitly requesting some/all tools to be included. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @karthink,
Follow-up question,
Lets say I have 2 presets ***@***.***` and ***@***.***` and I have `:pre (lambda () (gptel-mcp-connect '("memory") 'get_memory)` configured in both the presets.
I'm not sure why you're using 'get_memory there -- it's not meaningful in that position, see the documentation of gptel-mcp-connect.
When I call ***@***.***` and later ***@***.***`, will the server restart or open a different instance?
Because I intend to use ***@***.***` and ***@***.***` in the same `gptel-buffer` multiple times.
gptel-mcp-connect starts a server if required and adds all the server tools to gptel-tools. (Your preset can selective specify tools afterwards via the :tools key.)
If the server is already running, it skips the start step and just adds all the tools again.
|
Beta Was this translation helpful? Give feedback.
A couple of misconceptions here.
:preruns before setting the variables defined in the preset,:postruns after. Both these things happen when the preset is applied, well before the request is sent. So:postdoesn't do what you think.The tools that are sent with a request to an LLM depend only on
gptel-tools, whose value you can set in many ways (transient menu, elisp) and is not controlled by what MCP servers are connected.To solve your timing issue, you just have to start the MCP server synchronously.
You can set the specific tools you want with
:toolsin the preset, as usual.(Be sure to update the gptel and mcp packages b…