/ 目錄 / 演練場 / mcphub.nvim
● 社群 ravitemer ⚡ 即開即用

mcphub.nvim

作者 ravitemer · ravitemer/mcphub.nvim

將你的編輯器變成一流 MCP 客戶端的 Neovim 外掛——市集一鍵安裝、Avante/CodeCompanion 整合、OAuth PKCE 支援。

ravitemer/mcphub.nvim 將 MCP 伺服器整合進 Neovim 工作流程。透過已驗證的市集探索並安裝伺服器,透過 Avante/CodeCompanion/CopilotChat 對話,管理 OAuth,以及熱重載開發伺服器。支援 stdio、SSE 與 Streamable HTTP。

為什麼要用

核心特性

即時演示

實際使用效果

mcphub-nvim.replay ▶ 就緒
0/0

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mcphub-nvim": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ravitemer/mcphub.nvim"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "mcphub-nvim": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ravitemer/mcphub.nvim"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "mcphub-nvim": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ravitemer/mcphub.nvim"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "mcphub-nvim": {
      "command": "TODO",
      "args": [
        "See README: https://github.com/ravitemer/mcphub.nvim"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "mcphub-nvim",
      "command": "TODO",
      "args": [
        "See README: https://github.com/ravitemer/mcphub.nvim"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "mcphub-nvim": {
      "command": {
        "path": "TODO",
        "args": [
          "See README: https://github.com/ravitemer/mcphub.nvim"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add mcphub-nvim -- TODO 'See README: https://github.com/ravitemer/mcphub.nvim'

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: mcphub.nvim

如何透過 Avante 或 CodeCompanion 在 Neovim 中使用 MCP 伺服器

👤 Neovim 開發者 ⏱ ~20 min intermediate

何時使用: 你長期使用 Neovim,不想為了 MCP 存取而切換到 VS Code。

前置條件
  • Neovim 0.10+ — brew install neovim
  • 已安裝 Avante.nvim 或 CodeCompanion.nvim — 透過外掛管理器(lazy.nvim/packer)安裝
  • mcphub.nvim 及其 Node 相依套件 — 請參閱 ravitemer.github.io/mcphub.nvim 的安裝說明
步驟
  1. 透過外掛管理器安裝
    將 ravitemer/mcphub.nvim 加入你的 lazy.nvim 設定,並加上 opts = { ... }。✓ 已複製
    → :MCPHub 開啟管理介面
  2. 從市集安裝伺服器
    執行 :MCPHub marketplace,搜尋 'github' 並安裝。✓ 已複製
    → 伺服器啟動,工具完成註冊
  3. 透過 Avante 使用
    在 Avante 聊天介面提問,Avante 會自動載入 MCP 工具。✓ 已複製
    → 工具呼叫結果顯示於 Avante 輸出中

結果: MCP 工具可直接在編輯器內使用,無需切換情境。

注意事項
  • Node 未加入 Neovim 內部的 PATH — 在設定中使用絕對路徑,或確保 Neovim 繼承你的 shell 環境變數

如何設定專案本地 MCP 伺服器並與全域設定合併

👤 不同專案使用不同工具鏈的多語言開發者 ⏱ ~15 min intermediate

何時使用: 某個專案需要 postgres MCP,另一個專案需要內部自訂 MCP。

步驟
  1. 在專案根目錄建立 .mcphub.json5
    在 .mcphub.json5 中定義專案專用的伺服器。✓ 已複製
    → 開啟專案時伺服器自動載入
  2. 確認合併結果
    執行 :MCPHub status,查看哪些伺服器屬於全域、哪些屬於專案。✓ 已複製
    → 顯示合併後的完整檢視

結果: 每個專案皆可依情境載入對應的工具組合。

注意事項
  • 將機密資訊提交至 .mcphub.json5 — 改用環境變數參照,若檔案必須包含 token,請將其加入 gitignore

如何在 Neovim 中迭代開發自訂 MCP 伺服器

👤 MCP 伺服器開發者 ⏱ ~15 min advanced

何時使用: 你正在開發伺服器,需要快速迭代。

步驟
  1. 啟用開發模式
    在 mcphub 設定中為你的伺服器加上 dev=true。✓ 已複製
    → 儲存檔案時觸發熱重載
  2. 持續迭代
    編輯伺服器程式碼;mcphub 會自動重啟伺服器。✓ 已複製
    → 無需重啟 Neovim 即可使用更新後的工具

結果: 在 Neovim 內形成緊湊的開發迴圈。

組合

與其他 MCP 搭配,撬動十倍槓桿

mcphub-nvim + github

在 Neovim 中透過 Avante 聊天使用 GitHub MCP

透過市集安裝 github MCP,然後請 Avante 顯示指派給我的 PR。✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
(plugin) :MCPHub Commands: status, marketplace, install, logs 管理伺服器 free
(plugin) marketplace-install server_name 快速新增已審核的 MCP free
(integration) Avante/CodeCompanion/CopilotChat tools Chat prompts 一般對話使用 1 LLM call + tool calls

成本與限制

運行它的成本

API 配額
無(外掛本身不消耗配額)
每次呼叫 Token 數
會將工具清單加入 Avante/CC 的提示詞中
費用
免費(MIT 授權)
提示
停用未使用的市集伺服器——每個伺服器都會佔用你的提示詞 token 預算。

安全

權限、密鑰、影響範圍

最小權限: Whatever each installed MCP needs
憑證儲存: 在 mcphub 設定中使用環境變數參照
資料出站: 依下游各 MCP 而定
切勿授予: Don't commit .mcphub.json5 with inline secrets

故障排查

常見錯誤與修復

mcphub fails to start Node subprocess

Neovim 的 PATH 可能未包含 Node。請設定 vim.env.PATH 或使用絕對路徑。

驗證: :!which node
Avante doesn't see MCP tools

請確認 Avante 介面卡版本——舊版本不支援 MCP,請更新至最新版。

Marketplace shows empty list

網路或防火牆封鎖了市集 URL,請查看 :MCPHub logs 以確認詳情。

OAuth flow stuck in browser

從 :MCPHub logs 複製 URL 後手動貼至瀏覽器;localhost 重新導向在 Neovim 情境中可能無法正常觸發。

替代方案

mcphub.nvim 對比其他方案

替代方案何時用它替代權衡
CodeCompanion.nvim (native)你只需要 LLM 對話功能,不需要 MCP 管理無市集,也不支援 OAuth 流程
VS Code MCP你偏好使用 VS Code非 Neovim 環境

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills