Skip to content

Commit 5193329

Browse files
authored
feat: support CodeCompanion v18.0.0 (#261)
1 parent 8ff40b5 commit 5193329

File tree

9 files changed

+338
-222
lines changed

9 files changed

+338
-222
lines changed

doc/extensions/codecompanion.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<video muted controls src="https://github.com/user-attachments/assets/1a10ad50-5832-4627-bcc3-be49e7941105"></video>
55
</p>
66

7-
Add MCP capabilities to [CodeCompanion.nvim](https://github.com/olimorris/codecompanion.nvim) by adding it as an extension.
7+
Add MCP capabilities to [CodeCompanion.nvim](https://github.com/olimorris/codecompanion.nvim) by adding it as an extension.
88

99
## Features
1010

@@ -27,15 +27,15 @@ require("codecompanion").setup({
2727
mcphub = {
2828
callback = "mcphub.extensions.codecompanion",
2929
opts = {
30-
-- MCP Tools
30+
-- MCP Tools
3131
make_tools = true, -- Make individual tools (@server__tool) and server groups (@server) from MCP servers
3232
show_server_tools_in_chat = true, -- Show individual tools in chat completion (when make_tools=true)
3333
add_mcp_prefix_to_tool_names = false, -- Add mcp__ prefix (e.g `@mcp__github`, `@mcp__neovim__list_issues`)
3434
show_result_in_chat = true, -- Show tool results directly in chat buffer
3535
format_tool = nil, -- function(tool_name:string, tool: CodeCompanion.Agent.Tool) : string Function to format tool names to show in the chat buffer
3636
-- MCP Resources
3737
make_vars = true, -- Convert MCP resources to #variables for prompts
38-
-- MCP Prompts
38+
-- MCP Prompts
3939
make_slash_commands = true, -- Add MCP prompts as /slash commands
4040
}
4141
}
@@ -50,7 +50,7 @@ MCP Hub provides multiple ways to access MCP tools in CodeCompanion, giving you
5050
### Tool Access
5151

5252
#### 1. Universal MCP Access (`@mcp`)
53-
Adds all available MCP servers to the system prompt and provides LLM with `@mcp` tool group which has `use_mcp_tool` and `access_mcp_resource` tools.
53+
Adds all available MCP servers to the system prompt and provides LLM with `@mcp` tool group which has `use_mcp_tool` and `access_mcp_resource` tools.
5454
```
5555
@{mcp} What files are in the current directory?
5656
```
@@ -60,8 +60,8 @@ You can add all the enabled tools from a specific server with server groups. Unl
6060

6161
```
6262
@{neovim} Read the main.lua file # All tools from the neovim server will be added as function tools
63-
@{github} Create an issue
64-
@{fetch} Get this webpage
63+
@{github} Create an issue
64+
@{fetch} Get this webpage
6565
```
6666

6767
Server groups are automatically created based on your connected MCP servers when enabled via `make_tools`. Check your MCP Hub UI to see which servers you have connected.
@@ -85,7 +85,7 @@ Example configuration for custom tool groups:
8585

8686
```lua
8787
require("codecompanion").setup({
88-
strategies = {
88+
interactions = {
8989
chat = {
9090
tools = {
9191
groups = {
@@ -97,7 +97,7 @@ require("codecompanion").setup({
9797
-- GitHub operations
9898
"github__list_issues", "github__get_issue", "github__get_issue_comments",
9999
"github__create_issue", "github__create_pull_request", "github__get_file_contents",
100-
"github__create_or_update_file", "github__search_code"
100+
"github__create_or_update_file", "github__search_code"
101101
},
102102
},
103103
},
@@ -124,7 +124,7 @@ Then use your custom groups:
124124

125125
**Important Notes:**
126126
- Tool names depend on your connected MCP servers
127-
- Use MCP Hub UI or Codecompanion's tool completion to see available servers and tools
127+
- Use MCP Hub UI or Codecompanion's tool completion to see available servers and tools
128128
- Tool names follow the pattern `servername__toolname`
129129
- Mix MCP tools with CodeCompanion's built-in tools (`cmd_runner`, `editor`, `files`, etc.)
130130
- Each MCP tool can be individually auto-approved for fine-grained control (see Auto-Approval section)
@@ -177,7 +177,7 @@ For fine-grained control, configure auto-approval per server or per tool in your
177177
"autoApprove": true // Auto-approve all tools on this server
178178
},
179179
"partially-trusted": {
180-
"command": "npx",
180+
"command": "npx",
181181
"args": ["some-mcp-server"],
182182
"autoApprove": ["read_file", "list_files"] // Only auto-approve specific tools
183183
}
@@ -201,7 +201,7 @@ You can set `auto_approve` to `true` to automatically approve all MCP tool calls
201201
```lua
202202
require("mcphub").setup({
203203
-- This sets vim.g.mcphub_auto_approve to true by default (can also be toggled from the HUB UI with `ga`)
204-
auto_approve = true,
204+
auto_approve = true,
205205
})
206206
```
207207

@@ -220,30 +220,30 @@ require("mcphub").setup({
220220
if vim.g.codecompanion_auto_tool_mode == true then
221221
return true -- Auto approve when CodeCompanion auto-tool mode is on
222222
end
223-
223+
224224
-- Auto-approve GitHub issue reading
225225
if params.server_name == "github" and params.tool_name == "get_issue" then
226226
return true -- Auto approve
227227
end
228-
228+
229229
-- Block access to private repos
230230
if params.arguments.repo == "private" then
231231
return "You can't access my private repo" -- Error message
232232
end
233-
233+
234234
-- Auto-approve safe file operations in current project
235235
if params.tool_name == "read_file" then
236236
local path = params.arguments.path or ""
237237
if path:match("^" .. vim.fn.getcwd()) then
238238
return true -- Auto approve
239239
end
240240
end
241-
241+
242242
-- Check if tool is configured for auto-approval in servers.json
243243
if params.is_auto_approved_in_server then
244244
return true -- Respect servers.json configuration
245245
end
246-
246+
247247
return false -- Show confirmation prompt
248248
end,
249249
})

0 commit comments

Comments
 (0)