-
-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add CopilotChat extension support #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hey @deathbeam! 👋 Two quick notes about the implementation: Auto-Approval LogicI've commented out the auto-approval logic in the CopilotChat extension because, as we discussed in #216, CopilotChat needs users to explicitly approve tool calls. This means users are already making deliberate choices when selecting functions, so additional confirmation dialogs might be redundant. The commented code is still there if we decide to enable it later: -- TODO: Handle auto-approval logic if possible
-- local result = shared.handle_auto_approval_decision(params)
-- if result.error then
-- error(result.error)
-- endResource TemplatesI haven't implemented resource templates yet because they require URI parameters to be filled in (e.g., Question: How do you think we should handle this in CopilotChat's function interface? Should we:
The infrastructure is ready - just need to figure out the UX for parameter input. Let me know your thoughts on both points! |
|
For auto approval, yea as I said currently its very explicit in CopilotChat so for now I guess it makes sense if it just stays commented out. For resource templates, the issue is mostly parsing the resource template URI to inputSchema for manual input. No need for any custom implementation, as long as there is valid inputSchema, the URI template can be built from it and reconstructed as well. But I think servers can return resource template as response as well which means the uri part at least needs to be loaded without inputSchema for that scenario regardless. For example with test://static/resource/{id} so when that is registered this will get parsed still and recognized when typed manually: ##test://static/resource/11 |
|
Thanks for the feedback @deathbeam! Naming Convention Change ✅I've updated the naming from My original reasoning for Resource Templates Issue 🚧Regarding resource templates, the code you shared at CopilotC-Nvim/CopilotChat.nvim#1204 won't actually work: -- This won't work for templates
for _, resource in ipairs(resources) do
local name = resource.server_name .. '_' .. resource.name:lower():gsub(' ', '_'):gsub(':', '')
chat.config.functions[name] = {
_mcphub = true,
uri = resource.uri or resource.uriTemplate, -- Problem: uriTemplate has {placeholders}
description = type(resource.description) == 'string' and resource.description or '',
resolve = function()
local res, err = access_resource(resource.server_name, resource.uri) -- This tries to access literal "{id}"
-- ...
end,
}
endThe issue is that Resource templates need parameter extraction and schema generation for user input, which requires more complex implementation. ProposalIf the current integration without resource templates looks good to you, I can merge this PR as-is. Then if you find resource templates useful later, you could open a separate PR to implement them since you're more familiar with CopilotChat's codebase. What do you think? |
|
Ah yea you are right. Yes that makes sense, I will PR the resource templates later this week then probably. |
|
Perfect! Thanks @deathbeam. I'm going to merge this now. One thing I didn't implement was converting MCP prompts to CopilotChat slash commands (like we do for Avante/CodeCompanion) - not sure if that's possible/useful in CopilotChat, but could be a nice feature for later. Looking forward to your resource templates PR later this week! 🚀 |
For the MCP prompts, i remember i was looking at it before, but the prompts do not support input like functions do in CopilotChat so at least atm its not rly possible to convert those properly (I also personally dont find that very useful so did not spent much time on it as it has pretty high overlap with resources already) |

Overview
Adds native CopilotChat.nvim integration with function calling support, allowing MCP tools and resources to be used directly as CopilotChat functions.
Features
Usage
Then in CopilotChat:
@server__tool_nameto call MCP tools as functions#variablesand@functionsImplementation
get_servers()approach for proper conflict handlingFiles Added
lua/mcphub/extensions/copilotchat/init.lua- Main extension setuplua/mcphub/extensions/copilotchat/functions.lua- Function registration logicdoc/extensions/copilotchat.md- Complete documentationTesting
@deathbeam Would love to get your feedback on this integration! The implementation leverages CopilotChat's native function calling support and should work seamlessly with your recent improvements.