Skip to content

Commit 351a92b

Browse files
committed
Merge branch 'main' into feat/per-project-hub
2 parents ba6b6e4 + e704fa3 commit 351a92b

56 files changed

Lines changed: 8405 additions & 1051 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,31 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9-
## [5.12.0] - 2025-07-09
9+
## [5.13.0] - 2025-07-14
10+
11+
### Added
12+
13+
- **Granular Tool Access for CodeCompanion**: Individual MCP servers and tools now available as separate CodeCompanion function tools
14+
- Server groups (e.g., `@github`, `@neovim`) and individual tools (e.g., `@github__create_issue`)
15+
- Per-tool auto-approval control from Hub UI
16+
- Custom tool combinations through CodeCompanion groups
17+
- Eliminates system prompt pollution for better model performance
18+
19+
- **Advanced `edit_file` Tool**: Interactive SEARCH/REPLACE block system with real-time diff preview
20+
- Intelligent fuzzy matching and comprehensive feedback for LLM learning
21+
- Configurable keybindings and behavior through `builtin_tools.edit_file` config
22+
- Extensive test suite with 3000+ test cases
23+
24+
### Enhanced
25+
26+
- **JSON Formatting**: Added `jq` support for prettier configuration file formatting
27+
- **MCP Tool Prompts**: Improved markdown formatting and structure for better LLM consumption
28+
29+
### Fixed
30+
31+
- **Avante Integration**: Fixed tool input formatting for Gemini model compatibility with `use_ReAct_prompt`
1032

33+
## [5.12.0] - 2025-07-09
1134

1235
### Enhanced
1336
- **MCP Registry Migration**: Updated to support mcp-hub v4.0.0 with new MCP Registry system

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ Please read the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
119119

120120
Thanks to:
121121

122-
- [cline/mcp-marketplace](https://github.com/cline/mcp-marketplace) for providing the marketplace api
123122
- [nui.nvim](https://github.com/MunifTanjim/nui.nvim) for inspiring our text highlighting utilities
123+
- [ravitemer/mcp-registry](https://github.com/ravitemer/mcp-registry) for providing the marketplace api
124124

doc/.vitepress/config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ export default withMermaid(
9797
collapsed: false,
9898
items: [
9999
{ text: "servers.json", link: "/mcp/servers_json" },
100+
{
101+
text: "Builtin Servers",
102+
collapsed: true,
103+
items: [
104+
{ text: "Neovim Server", link: "/mcp/builtin/neovim" },
105+
{ text: "MCPHub Server", link: "/mcp/builtin/mcphub" },
106+
],
107+
},
100108
{
101109
text: "Lua MCP Servers",
102110
collapsed: true,

doc/configuration.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ All options are optional with sensible defaults. See below for each option in de
3333

3434
--- Plugin specific options-------------------
3535
native_servers = {}, -- add your custom lua native servers here
36+
builtin_tools = {
37+
edit_file = {
38+
parser = {
39+
track_issues = true,
40+
extract_inline_content = true,
41+
},
42+
locator = {
43+
fuzzy_threshold = 0.8,
44+
enable_fuzzy_matching = true,
45+
},
46+
ui = {
47+
go_to_origin_on_complete = true,
48+
keybindings = {
49+
accept = ".",
50+
reject = ",",
51+
next = "n",
52+
prev = "p",
53+
accept_all = "ga",
54+
reject_all = "gr",
55+
},
56+
},
57+
},
58+
},
3659
ui = {
3760
window = {
3861
width = 0.8, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
@@ -257,6 +280,21 @@ Default: `{}`
257280

258281
Define custom Lua native MCP servers that run directly in Neovim without external processes. Each server can provide tools, resources, and prompts. Please see [native servers guide](/mcp/native/index) to create MCP Servers in lua.
259282

283+
### builtin_tools
284+
285+
Default:
286+
287+
```lua
288+
{
289+
builtin_tools = {
290+
edit_file = {
291+
},
292+
},
293+
}
294+
```
295+
296+
Configuration options for MCPHub's builtin tools like `edit_file` tool. View complete [Builtin Tools Documentation](/mcp/builtin/neovim) for all available tools and their configuration options.
297+
260298
### ui
261299

262300
Default:

doc/extensions/codecompanion.md

Lines changed: 140 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# CodeCompanion Integration
22

33
<p>
4-
<video muted controls src="https://github.com/user-attachments/assets/70181790-e949-4df6-a690-c5d7a212e7d1"></video>
4+
<video muted controls src="https://github.com/user-attachments/assets/1a10ad50-5832-4627-bcc3-be49e7941105"></video>
55
</p>
66

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

99
## Features
1010

11-
- Access MCP tools via the `@mcp` tool in the chat buffer.
12-
- Utilize MCP resources as context variables using the `#` prefix (e.g., `#resource_name`).
13-
- Execute MCP prompts directly using `/mcp:prompt_name` slash commands.
14-
- Supports 🖼 images as shown in the demo.
15-
- Receive real-time updates in CodeCompanion when MCP servers change.
11+
- **Flexible Tool Access**: Multiple ways to use MCP tools - from broad `@mcp` access to granular individual tools
12+
- **Server Groups**: Access all tools from a specific server (e.g., `@neovim`, `@github`, `@tree_sitter`)
13+
- **Individual Tools**: Use specific tools with clear namespacing (e.g., `@neovim__read_file`, `@github__create_issue`)
14+
- **Custom Tool Groups**: Create your own tool combinations for specific workflows
15+
- **Resource Variables**: Utilize MCP resources as context variables using the `#` prefix (e.g., `#mcp:resource_name`)
16+
- **Slash Commands**: Execute MCP prompts directly using `/mcp:prompt_name` slash commands
17+
- **Rich Media Support**: Supports 🖼 images and other media types as shown in the demo
18+
- **Real-time Updates**: Automatic updates in CodeCompanion when MCP servers change
1619

1720
## MCP Hub Extension
1821

@@ -24,9 +27,16 @@ require("codecompanion").setup({
2427
mcphub = {
2528
callback = "mcphub.extensions.codecompanion",
2629
opts = {
27-
show_result_in_chat = true, -- Show mcp tool results in chat
28-
make_vars = true, -- Convert resources to #variables
29-
make_slash_commands = true, -- Add prompts as /slash commands
30+
-- MCP Tools
31+
make_tools = true, -- Make individual tools (@server__tool) and server groups (@server) from MCP servers
32+
show_server_tools_in_chat = true, -- Show individual tools in chat completion (when make_tools=true)
33+
add_mcp_prefix_to_tool_names = false, -- Add mcp__ prefix (e.g `@mcp__github`, `@mcp__neovim__list_issues`)
34+
show_result_in_chat = true, -- Show tool results directly in chat buffer
35+
format_tool = nil, -- function(tool_name:string, tool: CodeCompanion.Agent.Tool) : string Function to format tool names to show in the chat buffer
36+
-- MCP Resources
37+
make_vars = true, -- Convert MCP resources to #variables for prompts
38+
-- MCP Prompts
39+
make_slash_commands = true, -- Add MCP prompts as /slash commands
3040
}
3141
}
3242
}
@@ -35,52 +45,128 @@ require("codecompanion").setup({
3545

3646
## Usage
3747

38-
Once configured, you can interact with MCP Hub within the CodeCompanion chat buffer:
48+
MCP Hub provides multiple ways to access MCP tools in CodeCompanion, giving you flexibility from broad access to fine-grained control:
3949

40-
- **Tool Access:** Type `@mcp` to add available MCP servers to the system prompt, enabling the LLM to use registered MCP tools.
41-
- **Resources as Variables:** If `make_vars = true`, MCP resources become available as variables prefixed with `#`. You can include these in your prompts (e.g., `Summarize the issues in #mcp:lsp:get_diagnostics`):
50+
### Tool Access
4251

43-
*Example: Accessing LSP diagnostics*:
52+
#### 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.
54+
```
55+
@{mcp} What files are in the current directory?
56+
```
4457

45-
![image](https://github.com/user-attachments/assets/fb04393c-a9da-4704-884b-2810ff69f59a)
58+
#### 2. Server Groups (when `make_tools = true`)
59+
You can add all the enabled tools from a specific server with server groups. Unlike the `@mcp` group where all the running servers are converted and added to the system prompt, the tools added with server groups are pure function tools and hence depend on model support. The available groups depend on your connected MCP servers:
4660

47-
**Prompts as Slash Commands:** If `make_slash_commands = true`, MCP prompts are available as slash commands (e.g., `/mcp:prompt_name`). Arguments are handled via `vim.ui.input`.
61+
```
62+
@{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
65+
```
4866

49-
*Example: Using an MCP prompt via slash command*:
67+
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.
5068

51-
![image](https://github.com/user-attachments/assets/678a06a5-ada9-4bb5-8f49-6e58549c8f32)
69+
MCPHub includes powerful [builtin servers](/mcp/builtin/neovim) like `@neovim` (file operations, terminal, LSP) and `@mcphub` (server management) that are always available.
5270

71+
#### 3. Individual Tools (when `make_tools = true`)
72+
You can just provide a single tool from a server for fine-grained functionality. Tool names depend on your connected servers:
73+
```
74+
@{neovim__read_file} Show me the config file
75+
@{fetch__fetch} Get this webpage content
76+
@{github__create_issue} File a bug report
77+
```
5378

79+
Use the MCP Hub UI or CodeCompanion's tool completion to discover available tools.
5480

81+
#### 4. Custom Tool Sets
82+
Create your own tool combinations by mixing MCP tools with existing CodeCompanion tools:
5583

56-
## Auto-Approval
84+
Example configuration for custom tool groups:
5785

58-
By default, whenever codecompanion calls `use_mcp_tool` or `access_mcp_resource` tool, it shows a confirm dialog with tool name, server name and arguments.
86+
```lua
87+
require("codecompanion").setup({
88+
strategies = {
89+
chat = {
90+
tools = {
91+
groups = {
92+
["github_pr_workflow"] = {
93+
description = "GitHub operations from issue to PR",
94+
tools = {
95+
-- File operations
96+
"neovim__read_multiple_files", "neovim__write_file", "neovim__edit_file",
97+
-- GitHub operations
98+
"github__list_issues", "github__get_issue", "github__get_issue_comments",
99+
"github__create_issue", "github__create_pull_request", "github__get_file_contents",
100+
"github__create_or_update_file", "github__search_code"
101+
},
102+
},
103+
},
104+
},
105+
},
106+
},
107+
extensions = {
108+
mcphub = {
109+
callback = "mcphub.extensions.codecompanion",
110+
opts = {
111+
make_tools = true, -- Required for individual tools
112+
-- ... other options
113+
}
114+
}
115+
}
116+
})
117+
```
59118

60-
![Image](https://github.com/user-attachments/assets/201a5804-99b6-4284-9351-348899e62467)
61119

62-
### Global Auto-Approval
120+
Then use your custom groups:
121+
```
122+
@{github_pr_workflow} Fix this bug, create tests, and submit a PR with proper documentation
123+
```
63124

64-
You can set `auto_approve` to `true` to automatically approve all MCP tool calls without user confirmation:
125+
**Important Notes:**
126+
- Tool names depend on your connected MCP servers
127+
- Use MCP Hub UI or Codecompanion's tool completion to see available servers and tools
128+
- Tool names follow the pattern `servername__toolname`
129+
- Mix MCP tools with CodeCompanion's built-in tools (`cmd_runner`, `editor`, `files`, etc.)
130+
- Each MCP tool can be individually auto-approved for fine-grained control (see Auto-Approval section)
131+
132+
### Resources as Variables
133+
If `make_vars = true`, MCP resources become available as variables prefixed with `#`:
65134

66-
```lua
67-
require("mcphub").setup({
68-
-- This sets vim.g.mcphub_auto_approve to true by default (can also be toggled from the HUB UI with `ga`)
69-
auto_approve = true,
70-
})
135+
```
136+
Fix diagnostics in the file #{mcp:neovim://diagnostics/buffer}
137+
Analyze the current buffer #{mcp:neovim:buffer}
71138
```
72139

73-
This also sets `vim.g.mcphub_auto_approve` variable to `true`. You can also toggle this option in the MCP Hub UI with `ga` keymap. You can see the current auto approval status in the Hub UI.
140+
*Example: Accessing LSP diagnostics*:
74141

75-
![Image](https://github.com/user-attachments/assets/64708065-3428-4eb3-82a5-e32d2d1f98c6)
142+
![image](https://github.com/user-attachments/assets/fb04393c-a9da-4704-884b-2810ff69f59a)
76143

77-
### Fine-Grained Auto-Approval
144+
### Slash Commands
145+
If `make_slash_commands = true`, MCP prompts are available as slash commands:
78146

79-
![Image](https://github.com/user-attachments/assets/131bfed2-c4e7-4e2e-ba90-c86e6ca257fd)
147+
```
148+
/mcp:code_review
149+
/mcp:explain_function
150+
/mcp:generate_tests
151+
```
80152

81-
![Image](https://github.com/user-attachments/assets/befd1d44-bca3-41f6-a99a-3d15c6c8a5f5)
153+
*Example: Using an MCP prompt via slash command*:
154+
155+
![image](https://github.com/user-attachments/assets/678a06a5-ada9-4bb5-8f49-6e58549c8f32)
156+
157+
158+
159+
## Auto-Approval
82160

83-
For more control, configure auto-approval per server or per tool in your `servers.json`:
161+
By default, whenever codecompanion calls `use_mcp_tool` or `access_mcp_resource` tool or a specific tool on some MCP server, it shows a confirm dialog with tool name, server name and arguments.
162+
163+
![Image](https://github.com/user-attachments/assets/201a5804-99b6-4284-9351-348899e62467)
164+
165+
166+
#### Fine-Grained Auto-Approval
167+
168+
169+
For fine-grained control, configure auto-approval per server or per tool in your `servers.json`:
84170

85171
```json
86172
{
@@ -104,7 +190,26 @@ You can also toggle auto-approval from the Hub UI:
104190
- Press `a` on an individual tool to toggle auto-approval for just that tool
105191
- Resources are always auto-approved (no configuration needed)
106192

107-
### Function-Based Auto-Approval
193+
![Image](https://github.com/user-attachments/assets/131bfed2-c4e7-4e2e-ba90-c86e6ca257fd)
194+
195+
![Image](https://github.com/user-attachments/assets/befd1d44-bca3-41f6-a99a-3d15c6c8a5f5)
196+
197+
#### Global Auto-Approval
198+
199+
You can set `auto_approve` to `true` to automatically approve all MCP tool calls without user confirmation:
200+
201+
```lua
202+
require("mcphub").setup({
203+
-- 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,
205+
})
206+
```
207+
208+
This also sets `vim.g.mcphub_auto_approve` variable to `true`. You can also toggle this option in the MCP Hub UI with `ga` keymap. You can see the current auto approval status in the Hub UI.
209+
210+
![Image](https://github.com/user-attachments/assets/64708065-3428-4eb3-82a5-e32d2d1f98c6)
211+
212+
#### Function-Based Auto-Approval
108213

109214
For maximum control, provide a function that decides approval based on the specific tool call:
110215

@@ -158,13 +263,9 @@ require("mcphub").setup({
158263
- `string` - Deny with error message
159264
- `nil` - Show confirmation prompt (same as false)
160265

161-
### Auto-Approval Priority
266+
#### Auto-Approval Priority
162267

163268
The system checks auto-approval in this order:
164269
1. **Function**: Custom `auto_approve` function (if provided)
165270
2. **Server-specific**: `autoApprove` field in server config
166271
3. **Default**: Show confirmation dialog
167-
168-
169-
170-

doc/index.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ Just configure them to use MCP Hub's unified endpoint:
8383
- Toggle servers, tools, and resources etc
8484
- Test tools and resources directly in Neovim
8585

86+
### Builtin Native Servers
87+
88+
MCPHub includes two native servers that run directly within Neovim:
89+
90+
- **Neovim Server**: Comprehensive file operations, terminal access, LSP integration, and buffer management
91+
- **MCPHub Server**: Plugin management utilities, server lifecycle control, and documentation access
92+
93+
These servers provide essential functionality without external dependencies and offer deep Neovim integration.
94+
8695
### Chat Integrations
8796

8897
- MCP Hub provides integrations with popular chat plugins like [Avante](https://github.com/yetone/avante.nvim), [CodeCompanion](https://github.com/olimorris/codecompanion.nvim), [CopilotChat](https://github.com/CopilotC-Nvim/CopilotChat.nvim).
@@ -131,8 +140,3 @@ Just configure them to use MCP Hub's unified endpoint:
131140

132141
- [Installation Guide](/installation) - Set up MCPHub in your Neovim
133142
- [Configuration Guide](/configuration) - Learn about configuring MCP Hub
134-
135-
136-
137-
138-

0 commit comments

Comments
 (0)