Native Servers - Ashish-Github193/mcphub.nvim GitHub Wiki
MCPHub lets you create MCP servers directly in Lua that run natively within Neovim. This powerful feature enables seamless integration with Neovim's APIs and provides a standardized, plugin-agnostic way to create tools and resources.
Many Neovim chat plugins like Avante and CodeCompanion already provide ways to add custom tools but this leads to several limitations:
π οΈ Avante's Custom Tools
Avante's custom tools are defined in a table with a `custom_tools` key:-- Avante's custom tools
require("avante").setup({
custom_tools = {
get_weather = {
name,
description,
param,
returns,
func
}
}
})
π§© CodeCompanion's Tools
Code Companion's tools are defined in a table with a `chat` key:-- CodeCompanion's tools
require("codecompanion").setup({
chat = {
tools = {
get_weather = {
name,
description,
cmds,
schema,
output,
}
}
}
})
Feature | Regular tools | MCPHub Native Servers |
---|---|---|
Implementation | Needs reimplementing for each plugin | Write once, works everywhere |
API | Needs plugin specific docs | Intuitive chained api res:text():send()
|
Instructions | Can't have long schema.description
|
Tools,Resources converted to system prompt, instructions in one place |
Resources Support | No built-in resource handling | Full URI-based resource system |
Response Types | No standard types | MCP standard types (text, images, blobs) |
State Management | Per-plugin implementation | Centralized lifecycle management |
Plugin Updates | May break tool implementations | Tools isolated from plugin changes |
graph TD
subgraph "MCP Servers"
subgraph "Native MCP Servers"
N1["Buffer (Tools)"]
N2["LSP (Resources)"]
end
subgraph "Community"
C1["GitHub (Tools )"]
C2["Figma (Tools)"]
end
end
H[MCPHub]
M["@mcp tool + MCP Servers in text representation"]
subgraph "Chat Plugins"
A["Avante + @mcp tool"]
CC["CodeCompanion + @mcp tool"]
O[Others + @mcp tool]
end
subgraph "LLM Providers"
OAI[OpenAI]
AC[Claude]
M1[Mistral]
G[Grok]
D[DeepSeek]
end
%% MCP Servers provide capabilities
N1 & N2 --> H
C1 & C2 --> H
%% MCPHub transforms capabilities into system prompt
H --> M
%% Tools to plugins
M --> A
M --> CC
M --> O
%% Plugin to LLM connections
A --> OAI & AC
CC --> M1 & G
O --> D
MCPHub acts as a central hub that brings everything together for you:
-
π Collects Tools & Resources
- Gathers capabilities from both native and community servers
- Manages tool and resource registration
- Handles server lifecycle
-
π Standardizes Access
- Provides a single interface via the
@mcp
tool - Transforms capabilities into LLM-friendly formats
- Ensures consistent and intuitive URI patterns
- Provides a single interface via the
-
π§ Manages State
- Handles server lifecycles automatically
- Registers and unregisters capabilities as needed
- Provides clean and reliable process handling
-
π€ Supports Multiple Clients
- Real-time updates across all connected instances
- Shared state management for consistency
- Clean client registration and automatic cleanup
π¦ In short: MCPHub makes it easy to build, share, and use powerful tools and resources in Neovimβno matter which plugin or LLM you use!
- Creating a Server: Learn how to create native servers
- Server Types: Understand server components
- Example Servers: See real-world implementations