Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ isMaximal: {
};

assistant = {
mcphub-nvim.enable = isMaximal;
chatgpt.enable = false;
copilot = {
enable = false;
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/rl-0.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@
- Fix [render-markdown.nvim] file_types option type to list, to accept merging.
- Add [avante.nvim] plugin under `vim.assistant.avante-nvim`.

[mcphub-nvim]: https://github.com/ravitemer/mcphub.nvim

- Add [mcphub.nvim] plugin under `vim.assistant.mcphub-nvim`.

[poz](https://poz.pet):

[everforest]: https://github.com/sainnhe/everforest
Expand Down
25 changes: 25 additions & 0 deletions flake/pkgs/by-name/mcphub-nvim/bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
pins,
pkgs,
...
}: let
pin = pins.mcp-hub;
src = pkgs.fetchFromGitHub {
inherit (pin.repository) owner repo;
tag = pin.version;
sha256 = pin.hash;
};

inherit (pkgs) nodejs;
in
pkgs.buildNpmPackage {
pname = "mcp-hub";
inherit (pin) version;
inherit src nodejs;

nativeBuildInputs = [nodejs];
npmDeps = pkgs.importNpmLock {
npmRoot = src;
};
inherit (pkgs.importNpmLock) npmConfigHook;
}
26 changes: 26 additions & 0 deletions flake/pkgs/by-name/mcphub-nvim/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
pins,
vimUtils,
pkgs,
...
}: let
mcp-hub = import ./bin.nix {inherit pins pkgs;};
pin = pins.mcphub-nvim;
version = pin.branch;
src = pkgs.fetchFromGitHub {
inherit (pin.repository) owner repo;
rev = pin.revision;
sha256 = pin.hash;
};
in
vimUtils.buildVimPlugin {
pname = "mcphub-nvim";
inherit src version;

doCheck = false;

postInstall = ''
mkdir -p $out/bundled/mcp-hub/node_modules/.bin
ln -s ${mcp-hub}/bin/mcp-hub $out/bundled/mcp-hub/node_modules/.bin/mcp-hub
'';
}
1 change: 1 addition & 0 deletions modules/plugins/assistant/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
./codecompanion
./supermaven-nvim
./avante
./mcphub
];
}
104 changes: 104 additions & 0 deletions modules/plugins/assistant/mcphub/config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;

cfg = config.vim.assistant.mcphub-nvim;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"plenary-nvim"
];

lazy.plugins = {
mcphub-nvim = {
package = "mcphub-nvim";
setupModule = "mcphub";
inherit (cfg) setupOpts;
event = ["DeferredUIEnter"];
};
};

# avante-nvim
assistant.avante-nvim.setupOpts = {
system_prompt = lib.generators.mkLuaInline ''
function()
local hub = require("mcphub").get_hub_instance()
return hub and hub:get_active_servers_prompt() or ""
end
'';
custom_tools = lib.generators.mkLuaInline ''
function()
return {
require("mcphub.extensions.avante").mcp_tool(),
}
end
'';
};

# codecompanion-nvim
assistant.codecompanion-nvim.setupOpts.extensions.mcphub = {
callback = "mcphub.extensions.codecompanion";
opts = {
## MCP Tools
make_tools = true;
show_server_tools_in_chat = true;
add_mcp_prefix_to_tool_names = false;
show_result_in_chat = true;
format_tool = null;
## MCP Resources
make_vars = true;
## MCP Prompts
make_slash_commands = true;
};
};

# lualine
statusline.lualine.setupOpts.sections.lualine_x = lib.generators.mkLuaInline ''
{{
function()
-- Check if MCPHub is loaded
if not vim.g.loaded_mcphub then
return "󰐻 -"
end

local count = vim.g.mcphub_servers_count or 0
local status = vim.g.mcphub_status or "stopped"
local executing = vim.g.mcphub_executing

-- Show "-" when stopped
if status == "stopped" then
return "󰐻 -"
end

-- Show spinner when executing, starting, or restarting
if executing or status == "starting" or status == "restarting" then
local frames = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
local frame = math.floor(vim.loop.now() / 100) % #frames + 1
return "󰐻 " .. frames[frame]
end

return "󰐻 " .. count
end,
color = function()
if not vim.g.loaded_mcphub then
return { fg = "#6c7086" } -- Gray for not loaded
end

local status = vim.g.mcphub_status or "stopped"
if status == "ready" or status == "restarted" then
return { fg = "#50fa7b" } -- Green for connected
elseif status == "starting" or status == "restarting" then
return { fg = "#ffb86c" } -- Orange for connecting
else
return { fg = "#ff5555" } -- Red for error/stopped
end
end,
},}
'';
};
};
}
6 changes: 6 additions & 0 deletions modules/plugins/assistant/mcphub/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
imports = [
./config.nix
./mcphub-nvim.nix
];
}
Loading