forked from ravitemer/mcphub.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcphub.txt
More file actions
3344 lines (2544 loc) · 105 KB
/
Copy pathmcphub.txt
File metadata and controls
3344 lines (2544 loc) · 105 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*mcphub.nvim.txt* For NVIM v0.10.0 Last change: 2025 July 10
==============================================================================
Table of Contents *mcphub.nvim-table-of-contents*
1. What is MCP HUB? |mcphub.nvim-what-is-mcp-hub?|
- How does MCP Hub work?|mcphub.nvim-what-is-mcp-hub?-how-does-mcp-hub-work?|
- Feature Support Matrix|mcphub.nvim-what-is-mcp-hub?-feature-support-matrix|
- Next Steps |mcphub.nvim-what-is-mcp-hub?-next-steps|
2. Installation |mcphub.nvim-installation|
- Requirements |mcphub.nvim-installation-requirements|
- Lazy.nvim |mcphub.nvim-installation-lazy.nvim|
- NixOS |mcphub.nvim-installation-nixos|
3. Configuration |mcphub.nvim-configuration|
- Default Configuration |mcphub.nvim-configuration-default-configuration|
- Binary mcp-hub Options |mcphub.nvim-configuration-binary-mcp-hub-options|
- Chat-Plugin Related Options|mcphub.nvim-configuration-chat-plugin-related-options|
- Plugin Options |mcphub.nvim-configuration-plugin-options|
4. MCP Servers |mcphub.nvim-mcp-servers|
- MCP Config File |mcphub.nvim-mcp-servers-mcp-config-file|
- Lua MCP Servers |mcphub.nvim-mcp-servers-lua-mcp-servers|
5. Extensions |mcphub.nvim-extensions|
- Avante Integration |mcphub.nvim-extensions-avante-integration|
- CodeCompanion Integration|mcphub.nvim-extensions-codecompanion-integration|
- CopilotChat Integration |mcphub.nvim-extensions-copilotchat-integration-|
- Lualine Integration |mcphub.nvim-extensions-lualine-integration|
6. Other |mcphub.nvim-other|
7. Links |mcphub.nvim-links|
==============================================================================
1. What is MCP HUB? *mcphub.nvim-what-is-mcp-hub?*
MCPHub.nvim is a MCP client for neovim that seamlessly integrates MCP (Model
Context Protocol) <https://modelcontextprotocol.io/> servers into your editing
workflow. It provides an intuitive interface for managing, testing, and using
MCP servers with your favorite chat plugins.
[!IMPORTANT] It is recommended to read this page before going through the rest
of the documentation.
HOW DOES MCP HUB WORK? *mcphub.nvim-what-is-mcp-hub?-how-does-mcp-hub-work?*
Let’s break down how MCP Hub operates in simple terms:
MCP CONFIG FILE ~
Like any MCP client, MCP Hub requires a configuration file to define the MCP
servers you want to use. This file is typically located at
`~/.config/mcphub/servers.json`. MCP Hub supports local `stdio` servers as well
as remote `streamable-http` or `sse` servers. This is similar to
`claude_desktop_config.json` file for Claude desktop or `mcp.json` file used by
VSCode. In fact you can use the same file for MCP Hub as well with some
additional benefits. It looks something like:
>js
// Example: ~/.config/mcphub/servers.json
{
"mcpServers": {
"fetch": {
"command": "uvx",
"args": [
"mcp-server-fetch"
]
},
"remote-server": {
"url": "https://api.example.com/mcp"
}
}
}
<
SERVERS MANAGER ~
- When MCP Hub’s `setup()` is called typically when Neovim starts, it launches the nodejs binary, mcp-hub <https://github.com/ravitemer/mcp-hub> with the `servers.json` file.
- The `mcp-hub` binary reads `servers.json` file and starts the MCP servers.
- It provides two key interfaces:
1. **Management API** (default: `http://localhost:37373/api`):- Used by this plugin to manage MCP servers
- Start/stop servers, execute tools, access resources
- Handle real-time server events
2. **Unified MCP Endpoint** (`http://localhost:37373/mcp`):- A single MCP server that other MCP clients can connect to
- Exposes ALL capabilities from ALL managed servers
- Automatically namespaces capabilities to prevent conflicts
- Use this endpoint in Claude Desktop, Cline, or any MCP client
For example, instead of configuring each MCP client with multiple servers:
>json
{
"mcpServers" : {
"filesystem": { ... },
"search": { ... },
"database": { ... }
}
}
<
Just configure them to use MCP Hub’s unified endpoint:
>json
{
"mcpServers" : {
"Hub": {
"url" : "http://localhost:37373/mcp"
}
}
}
<
USAGE ~
- Use `:MCPHub` command to open the interface
- Adding (`<A>`), editing (`<e>`), deleting (`<d>`) MCP servers in easy and intuitive with MCP Hub. You don’t need to edit the `servers.json` file directly.
- Install servers from the Marketplace (`M`)
- Toggle servers, tools, and resources etc
- Test tools and resources directly in Neovim
BUILTIN NATIVE SERVERS ~
MCPHub includes two native servers that run directly within Neovim:
- **Neovim Server**: Comprehensive file operations, terminal access, LSP integration, and buffer management
- **MCPHub Server**: Plugin management utilities, server lifecycle control, and documentation access
These servers provide essential functionality without external dependencies and
offer deep Neovim integration.
CHAT INTEGRATIONS ~
- 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>.
- LLMs can use MCP servers through our `@mcp` tool.
- Resources show up as `#variables` in chat.
- Prompts become `/slash_commands`.
FEATURE SUPPORT MATRIX *mcphub.nvim-what-is-mcp-hub?-feature-support-matrix*
---------------------------------------------------------------------------------
Category Feature Support Details
-------------------- -------------------- ------------------ --------------------
Capabilities
Tools ✅ Full support
🔔 Tool List Changed ✅ Real-time updates
Resources ✅ Full support
🔔 Resource List ✅ Real-time updates
Changed
Resource Templates ✅ URI templates
Prompts ✅ Full support
🔔 Prompts List ✅ Real-time updates
Changed
Roots ❌ Not supported
Sampling ❌ Not supported
MCP Server
Transports
Streamable-HTTP ✅ Primary transport
protocol for remote
servers
SSE ✅ Fallback transport
for remote servers
STDIO ✅ For local servers
Authentication for
remote servers
OAuth ✅ With PKCE flow
Headers ✅ For API keys/tokens
Chat Integration
Avante.nvim ✅ Tools, resources,
resourceTemplates,
prompts(as
slash_commands)
CodeCompanion.nvim ✅ Tools, resources,
templates, prompts
(as slash_commands),
🖼 image responses
CopilotChat.nvim ✅ In-built support
Draft
Marketplace
Server Discovery ✅ Browse from verified
MCP servers
Installation ✅ Manual and auto
install with AI
Configuration
Universal ${} Syntax ✅ Environment
variables and
command execution
across all fields
Advanced
Smart File-watching ✅ Smart updates with
config file watching
Multi-instance ✅ All neovim instances
stay in sync
Shutdown-delay ✅ Can run as systemd
service with
configure delay
before stopping the
hub
Lua Native MCP ✅ Write once , use
Servers everywhere. Can
write tools,
resources, prompts
directly in lua
Dev Mode ✅ Hot reload MCP
servers on file
changes for
development
---------------------------------------------------------------------------------
NEXT STEPS *mcphub.nvim-what-is-mcp-hub?-next-steps*
- Installation Guide </installation> - Set up MCPHub in your Neovim
- Configuration Guide </configuration> - Learn about configuring MCP Hub
==============================================================================
2. Installation *mcphub.nvim-installation*
Please read the getting started </index> guide before reading this.
REQUIREMENTS *mcphub.nvim-installation-requirements*
- Neovim >= 0.8.0
- Node.js >= 18.0.0
- plenary.nvim <https://github.com/nvim-lua/plenary.nvim>
- mcp-hub <https://github.com/ravitemer/mcp-hub> (automatically installed via build command)
LAZY.NVIM *mcphub.nvim-installation-lazy.nvim*
MCPHub.nvim requires mcp-hub <https://github.com/ravitemer/mcp-hub> to manage
MCP Servers. You can make `mcp-hub` binary available in three ways:
1. |mcphub.nvim-global-installation| (Recommended)
2. |mcphub.nvim-local-installation|
3. |mcphub.nvim-dev-installation|
DEFAULT INSTALLATION ~
Install `mcp-hub` node binary globally using `npm`, `yarn`, or `bun` any other
node package manager using the `build` command. The `build` command will run
everytime the plugin is updated.
>lua
{
"ravitemer/mcphub.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
build = "npm install -g mcp-hub@latest", -- Installs `mcp-hub` node binary globally
config = function()
require("mcphub").setup()
end
}
<
Please see configuration </configuration> for default plugin config and on how
to configure the plugin.
LOCAL INSTALLATION ~
Ideal for environments where global binary installations aren’t possible.
Download `mcp-hub` binary alongside the neovim plugin using `bundled_build.lua`
for the `build` command. We need to explicitly set `use_bundled_binary` to
`true` to let the plugin use the locally available `mcp-hub` binary.
>lua
{
"ravitemer/mcphub.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
build = "bundled_build.lua", -- Bundles `mcp-hub` binary along with the neovim plugin
config = function()
require("mcphub").setup({
use_bundled_binary = true, -- Use local `mcp-hub` binary
})
end,
}
<
DEV INSTALLATION ~
Ideal for development. You can provide the command that our plugin should use
to start the `mcp-hub` server. You can clone the `mcp-hub` repo locally using
`gh clone ravitemer/mcp-hub` and provide the path to the `cli.js` as shown
below:
>lua
{
"ravitemer/mcphub.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
require("mcphub").setup({
cmd = "node",
cmdArgs = {"/path/to/mcp-hub/src/utils/cli.js"},
})
end,
}
<
See Contributing
<https://github.com/ravitemer/mcphub.nvim/blob/main/CONTRIBUTING.md> guide for
detailed development setup.
NIXOS *mcphub.nvim-installation-nixos*
Flake install ~
Just add it to your NixOS flake.nix or home-manager:
>nix
inputs = {
mcphub-nvim.url = "github:ravitemer/mcphub.nvim";
...
}
<
To integrate mcphub.nvim to your NixOS/Home Manager nvim configs, add the
following to your neovim.plugins
<https://nixos.wiki/wiki/Neovim#Installing_Plugins> or your neovim.packages
<https://nixos.wiki/wiki/Neovim#System-wide_2>
>nix
inputs.mcphub-nvim.packages."${system}".default
<
and add the setup function in lua code
<https://nixos.wiki/wiki/Neovim#Note_on_Lua_plugins>
NIXVIM EXAMPLE ~
Nixvim <https://github.com/nix-community/nixvim> example:
>nix
{ mcphub-nvim, ... }:
{
extraPlugins = [mcphub-nvim];
extraConfigLua = ''
require("mcphub").setup()
'';
}
# where
{
# For nixpkgs (not available yet)
# ...
# For flakes
mcphub-nvim = inputs.mcphub-nvim.packages."${system}".default;
}
<
Nixpkgs install ~
coming…
==============================================================================
3. Configuration *mcphub.nvim-configuration*
Please read the getting started </index> guide before reading this.
DEFAULT CONFIGURATION *mcphub.nvim-configuration-default-configuration*
All options are optional with sensible defaults. See below for each option in
detail.
>lua
{
"ravitemer/mcphub.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
build = "npm install -g mcp-hub@latest", -- Installs `mcp-hub` node binary globally
config = function()
require("mcphub").setup({
--- `mcp-hub` binary related options-------------------
config = vim.fn.expand("~/.config/mcphub/servers.json"), -- Absolute path to MCP Servers config file (will create if not exists)
port = 37373, -- The port `mcp-hub` server listens to
shutdown_delay = 60 * 10 * 000, -- Delay in ms before shutting down the server when last instance closes (default: 10 minutes)
use_bundled_binary = false, -- Use local `mcp-hub` binary (set this to true when using build = "bundled_build.lua")
mcp_request_timeout = 60000, --Max time allowed for a MCP tool or resource to execute in milliseconds, set longer for long running tasks
---Chat-plugin related options-----------------
auto_approve = false, -- Auto approve mcp tool calls
auto_toggle_mcp_servers = true, -- Let LLMs start and stop MCP servers automatically
extensions = {
avante = {
make_slash_commands = true, -- make /slash commands from MCP server prompts
}
},
--- Plugin specific options-------------------
native_servers = {}, -- add your custom lua native servers here
builtin_tools = {
edit_file = {
parser = {
track_issues = true,
extract_inline_content = true,
},
locator = {
fuzzy_threshold = 0.8,
enable_fuzzy_matching = true,
},
ui = {
go_to_origin_on_complete = true,
keybindings = {
accept = ".",
reject = ",",
next = "n",
prev = "p",
accept_all = "ga",
reject_all = "gr",
},
},
},
},
ui = {
window = {
width = 0.8, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
height = 0.8, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
align = "center", -- "center", "top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right"
relative = "editor",
zindex = 50,
border = "rounded", -- "none", "single", "double", "rounded", "solid", "shadow"
},
wo = { -- window-scoped options (vim.wo)
winhl = "Normal:MCPHubNormal,FloatBorder:MCPHubBorder",
},
},
on_ready = function(hub)
-- Called when hub is ready
end,
on_error = function(err)
-- Called on errors
end,
log = {
level = vim.log.levels.WARN,
to_file = false,
file_path = nil,
prefix = "MCPHub",
},
})
end
}
<
BINARY MCP-HUB OPTIONS *mcphub.nvim-configuration-binary-mcp-hub-options*
On calling `require("mcphub").setup()`, MCPHub.nvim starts the `mcp-hub`
process with the given arguments. Internally the default command looks
something like:
>bash
mcp-hub --config ~/.config/mcphub/servers.json --port 37373 --auto-shutdown --shutdown-delay 600000 --watch
<
We can configure how the `mcp-hub` process starts and stops as follows:
CONFIG ~
Default: `~/.config/mcphub/servers.json`
Absolute path to the MCP Servers configuration file. The plugin will create
this file if it doesn’t exist. See servers.json </mcp/servers_json> page to
see how `servers.json` should look like, how to safely add it to source control
and more
PORT ~
Default: `37373`
The port number that the `mcp-hub`’s express server should listen on.
MCPHub.nvim sends curl requests to `http://localhost:37373/` endpoint to manage
MCP servers. We first check if `mcp-hub` is already running before trying to
start a new one.
SERVER_URL ~
Default: `nil`
By default, we send curl requests to `http://localhost:37373/` to manage MCP
servers. However, in cases where you want to run `mcp-hub` on another machine
in your local network or remotely you can override the endpoint by setting this
to the server URL e.g `http://mydomain.com:customport` or
`https://url_without_need_for_port.com`
SHUTDOWN_DELAY ~
Default: `600000` (10 minutes)
Time in milliseconds to wait before shutting down the `mcp-hub` server when the
last Neovim instance closes. The `mcp-hub` server stays up for 10 minutes after
exiting neovim. On entering, MCPHub.nvim checks for the running server and
connects to it. This makes the MCP servers readily available. You can set it to
a longer time to keep `mcp-hub` running.
USE_BUNDLED_BINARY ~
Default: `false`
Uses local `mcp-hub` binary. Enable this when using `build =
"bundled_build.lua"` in your plugin configuration.
MCP_REQUEST_TIMEOUT ~
Default: `60000` (1 minute)
Maximum time allowed for a MCP tool or resource or prompt to execute in
milliseconds. If exceeded, an McpError with code `RequestTimeout` will be
raised. Set longer if you have longer running tools.
CMD, CMDARGS ~
Default: `nil`
Internally `cmd` points to the `mcp-hub` binary. e.g for global installations
it is `mcp-hub`. When `use_bundled_binary` is `true` it is
`~/.local/share/nvim/lazy/mcphub.nvim/bundled/mcp-hub/node_modules/mcp-hub/dist/cli.js`.
You can set this to something else so that MCPHub.nvim uses `cmd` and `cmdArgs`
to start the `mcp-hub` server. You can clone the `mcp-hub` repo locally using
`gh clone ravitemer/mcp-hub` and provide the path to the `cli.js` as shown
below:
>lua
require("mcphub").setup({
cmd = "node",
cmdArgs = {"/path/to/mcp-hub/src/utils/cli.js"},
})
<
See Contributing
<https://github.com/ravitemer/mcphub.nvim/blob/main/CONTRIBUTING.md> guide for
detailed development setup.
CHAT-PLUGIN RELATED OPTIONS*mcphub.nvim-configuration-chat-plugin-related-options*
AUTO_APPROVE ~
Default: `false`
By default when the LLM calls a tool or resource on a MCP server, we show a
confirmation window like below.
BOOLEAN AUTO-APPROVAL
Set it to `true` to automatically approve all MCP tool calls without user
confirmation:
>lua
require("mcphub").setup({
auto_approve = true, -- Auto approve all MCP tool calls
})
<
This also sets `vim.g.mcphub_auto_approve` variable to `true`. You can toggle
this option in the MCP Hub UI with `ga` keymap. You can see the current auto
approval status in the Hub UI.
FUNCTION-BASED AUTO-APPROVAL
For maximum control, provide a function that decides approval based on the
specific tool call:
>lua
require("mcphub").setup({
auto_approve = function(params)
-- Auto-approve GitHub issue reading
if params.server_name == "github" and params.tool_name == "get_issue" then
return true -- Auto approve
end
-- Block access to private repos
if params.arguments.repo == "private" then
return "You can't access my private repo" -- Error message
end
-- Auto-approve safe file operations in current project
if params.tool_name == "read_file" then
local path = params.arguments.path or ""
if path:match("^" .. vim.fn.getcwd()) then
return true -- Auto approve
end
end
-- Check if tool is configured for auto-approval in servers.json
if params.is_auto_approved_in_server then
return true -- Respect servers.json configuration
end
return false -- Show confirmation prompt
end,
})
<
**Parameters available in the function:** - `params.server_name` - Name of the
MCP server - `params.tool_name` - Name of the tool being called (nil for
resources) - `params.arguments` - Table of arguments passed to the tool -
`params.action` - Either "use_mcp_tool" or "access_mcp_resource" - `params.uri`
- Resource URI (for resource access) - `params.is_auto_approved_in_server` -
Boolean indicating if tool is configured for auto-approval in servers.json
**Return values:** - `true` - Auto-approve the call - `false` - Show
confirmation prompt - `string` - Deny with error message - `nil` - Show
confirmation prompt (same as false)
SERVER-LEVEL AUTO-APPROVAL
For fine-grained control per server or tool, configure auto-approval using the
`autoApprove` field in your `servers.json`. You can also toggle auto-approval
from the Hub UI using the `a` keymap on individual servers or tools. See
servers.json configuration </mcp/servers_json#auto-approval-configuration> for
detailed examples and configuration options.
AUTO-APPROVAL PRIORITY
The system checks auto-approval in this order: 1. **Function**: Custom
`auto_approve` function (if provided) 2. **Server-specific**: `autoApprove`
field in server config 3. **Default**: Show confirmation dialog
AUTO_TOGGLE_MCP_SERVERS ~
Default: `true`
Allow LLMs to automatically start and stop MCP servers as needed. Disable to
require manual server management. The following demo shows avante auto starting
a disabled MCP server to acheive it’s objective. See discussion
<https://github.com/ravitemer/mcphub.nvim/discussions/88> for details.
EXTENSIONS ~
Default:
>lua
{
extensions = {
avante = {
enabled = true,
make_slash_commands = true
}
}
}
<
Avante <https://github.com/yetone/avante.nvim> integration options: -
`make_slash_commands`: Convert MCP server prompts to slash commands in Avante
chat - Please visit Avante </extensions/avante> for full integration
documentation
Also see CodeCompanion </extensions/codecompanion>, CopilotChat
</extensions/copilotchat> pages for detailed setup guides.
PLUGIN OPTIONS *mcphub.nvim-configuration-plugin-options*
NATIVE_SERVERS ~
Default: `{}`
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.
BUILTIN_TOOLS ~
Default:
>lua
{
builtin_tools = {
edit_file = {
},
},
}
<
Configuration options for MCPHub’s builtin tools like `edit_file` tool. View
complete Builtin Tools Documentation </mcp/builtin/> for all available tools
and their configuration options.
UI ~
Default:
>lua
{
ui = {
window = {
width = 0.85, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
height = 0.85, -- 0-1 (ratio); "50%" (percentage); 50 (raw number)
align = "center", -- "center", "top-left", "top-right", "bottom-left", "bottom-right", "top", "bottom", "left", "right"
border = "rounded", -- "none", "single", "double", "rounded", "solid", "shadow"
relative = "editor",
zindex = 50,
},
wo = { -- window-scoped options (vim.wo)
winhl = "Normal:MCPHubNormal,FloatBorder:MCPHubBorder",
},
},
}
<
Controls the appearance and behavior of the MCPHub UI window: - `width`: Window
width (0-1 for ratio, "50%" for percentage, or raw number) - `height`: Window
height (same format as width) - `align`: Window alignment position. Options: -
`"center"`: Center the window (default) - `"top-left"`, `"top-right"`,
`"bottom-left"`, `"bottom-right"`: Corner positions - `"top"`, `"bottom"`:
Top/bottom edge, centered horizontally - `"left"`, `"right"`: Left/right edge,
centered vertically - `relative`: Window placement relative to ("editor",
"win", or "cursor") - `zindex`: Window stacking order - `border`: Border style
("none", "single", "double", "rounded", "solid", "shadow")
ON_READY ~
Default: `function(hub) end`
Callback function executed when the MCP Hub server is ready and connected.
Receives the hub instance as an argument.
ON_ERROR ~
Default: `function(err) end`
Callback function executed when an error occurs in the MCP Hub server. Receives
the error message as an argument.
LOG ~
Default:
>lua
{
level = vim.log.levels.WARN,
to_file = false,
file_path = nil,
prefix = "MCPHub"
}
<
Logging configuration options: - `level`: Log level (vim.log.levels.ERROR,
WARN, INFO, DEBUG, TRACE) - `to_file`: Whether to write logs to file -
`file_path`: Custom log file path - `prefix`: Prefix for log messages
==============================================================================
4. MCP Servers *mcphub.nvim-mcp-servers*
MCP CONFIG FILE *mcphub.nvim-mcp-servers-mcp-config-file*
MCPHub.nvim like other MCP clients uses a JSON configuration file to manage MCP
servers. This `config` file is located at `~/.config/mcphub/servers.json` by
default and supports real-time updates across all Neovim instances. You can set
`config` option to a custom location.
[!NOTE] You can use a single config file for any MCP client like VSCode,
Cursor, Cline, Zed etc as long as the config file follows the below structure.
With MCPHub.nvim, `config` file can be safely added to source control as it
supports **universal ${} placeholder syntax** for environment variables and
command execution across all configuration fields.
MANAGE SERVERS ~
Adding, editing, deleting and securing MCP servers in easy and intuitive with
MCP Hub. You don’t need to edit the `servers.json` file directly. Everything
can be done right from the UI.
FROM MARKETPLACE
BROWSE, SORT, FILTER , SEARCH FROM AVAILABLE MCP SERVERS.
ONE CLICK INSTALL/UNINSTALL
Choose from different install options:
FROM HUB VIEW
Add (`<A>`), edit (`<e>`), delete (`<d>`) MCP servers from the (`H`) Hub view.
BASIC SCHEMA ~
The `config` file should have a `mcpServers` key. This contains `stdio` and
`remote` MCP servers. There is also another top level MCPHub specific field
`nativeMCPServers` to store any disabled tools, custom instructions etc that
the plugin updates internally. See Lua MCP Servers </mcp/native/index> for more
about Lua native MCP servers
>json
{
"mcpServers": {
// Add stdio and remote MCP servers here
},
"nativeMCPServers": { // MCPHub specific
// To store disabled tools, custom instructions etc
}
}
<
SERVER TYPES ~
LOCAL (STDIO) SERVERS
>json
{
"mcpServers": {
"local-server": {
"command": "${MCP_BINARY_PATH}/server",
"args": [
"--token", "${API_TOKEN}",
"--secret", "${cmd: op read op://vault/secret}"
],
"env": {
"API_TOKEN": "${cmd: aws ssm get-parameter --name /app/token --query Parameter.Value --output text}",
"DB_URL": "postgresql://user:${DB_PASSWORD}@localhost/myapp",
"DB_PASSWORD": "password123",
"FALLBACK_VAR": null
},
"cwd": "/home/ubuntu/server-dir/"
}
}
}
<
REQUIRED FIELDS:
- `command`: The executable to start the server (supports `${VARIABLE}` and `${cmd: command}`)
OPTIONAL FIELDS:
- `args`: Array of command arguments (supports `${VARIABLE}` and `${cmd: command}` placeholders)
- `env`: Environment variables with placeholder resolution and system fallback
- `cwd`: The current working directory for the MCP server process (supports `${VARIABLE}` and `${cmd: command}` placeholders)
- `dev`: Development mode configuration for auto-restart on file changes
- `name`: Display name that will be shown in the UI
- `description`: Short description about the server (useful when the server is disabled and `auto_toggle_mcp_servers` is `true`)
UNIVERSAL ${} PLACEHOLDER SYNTAX
**All fields** support the universal placeholder syntax: - **${ENV_VAR}** -
Resolves environment variables - **${cmd: command args}** - Executes commands
and uses output - **null or ""** - Falls back to `process.env`
Given `API_KEY=secret` in the environment:
-------------------------------------------------------------------------------------------------------
Example Becomes Description
--------------------------------------------- ------------------------- -------------------------------
"API_KEY": "" "API_KEY": "secret" Empty string falls back to
process.env.API_KEY
"API_KEY": null "API_KEY": "secret" null falls back to
process.env.API_KEY
"AUTH": "Bearer ${API_KEY}" "AUTH": "Bearer secret" ${} Placeholder values are
replaced
"TOKEN": "${cmd: op read op://vault/token}" "TOKEN": "secret" Commands are executed and
output used
"HOME": "/home/ubuntu" "HOME": "/home/ubuntu" Used as-is
-------------------------------------------------------------------------------------------------------
⚠️ **Legacy Syntax**: `$VAR` (args) and `$: command` (env) are deprecated
but still supported with warnings. Use `${VAR}` and `${cmd: command}` instead.
CWD EXAMPLE:
The `cwd` field is particularly useful when your MCP server needs to run in a
specific directory context. Here’s a practical example:
>json
{
"mcpServers": {
"project-server": {
"command": "npm",
"args": ["start"],
"cwd": "/home/ubuntu/my-mcp-project/",
"env": {
"NODE_ENV": "development"
}
}
}
}
<
**Use cases for cwd:** - When the MCP server needs to access relative files in
its project directory - When using npm/yarn scripts that depend on being in the
project root
**Note**: The top-level `cwd` field sets the working directory for the server
process itself, while `dev.cwd` (used in development mode) sets the directory
for file watching. These serve different purposes and can be used together.
DEV DEVELOPMENT MODE
The `dev` field enables automatic server restarts when files change during
development:
>json
{
"mcpServers": {
"dev-server": {
"command": "npx",
"args": [
"tsx",
"path/to/src/index.ts"
],
"dev": {
"watch": [
"src/**/*.ts",
"package.json"
],
"enabled": true,
"cwd": "/path/to/dev-server/"
}
}
}
}
<