About mcpserver.nvim
mcpserver.nvim is a Neovim plugin that lets external MCP clients access the current buffer through a Unix socket. It also provides a standalone stdio server that forwards requests to a running Neovim instance.
Key features
- 01Read the current buffer content
- 02Communicate through a Unix socket
- 03Run a standalone stdio server
- 04Auto-detect Neovim server sockets
- 05Start and stop the server with commands
Use cases
- 01Provide buffer text to an MCP client
- 02Connect stdio clients to a running Neovim instance
- 03Run MCP servers for multiple Neovim instances
MCP support
Exposes the `get_buffer_content` tool to MCP clients, returning the current buffer's filename, text, and line count. Clients can connect through a Unix socket or through the standalone stdio server.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEmcpserver.nvim
A Neovim plugin that implements an MCP (Model Context Protocol) server, allowing external MCP clients to interact with Neovim through a Unix socket.
Features
- get_buffer_content: Fetch the contents of the current buffer
Installation
Using lazy.nvim:
{
dir = "/path/to/mcpserver.nvim", -- Use your local path
-- Server starts automatically on VimEnter
}
Usage
Neovim Plugin
Manual Control
Start the MCP server:
:MCPServerStart
Stop the MCP server:
:MCPServerStop
Get Socket Path
local mcpserver = require('mcpserver')
local socket_path = mcpserver.get_socket_path()
print(socket_path) -- e.g., "/tmp/nvim-mcp-server-12345.sock"
Socket Location
The server creates a unique Unix socket at /tmp/nvim-mcp-server-<PID>.sock where <PID> is the Neovim process ID. This allows multiple Neovim instances to run MCP servers simultaneously.
Standalone MCP Server
For use with external MCP clients that communicate via stdio:
# Auto-detect running Neovim instance
lua standalone.lua
# Specify Neovim socket path
lua standalone.lua /tmp/nvim-mcp-server-12345.sock
The standalone server:
- Communicates via stdio (JSON-RPC over stdin/stdout)
- Auto-detects running Neovim MCP server sockets
- Forwards requests to the Neovim instance
- Works with any MCP client that supports stdio transport
Available Tools
get_buffer_content
Returns JSON with:
filename: Path to the current buffer filecontent: Full text content of the bufferline_count: Number of lines in the buffer
MCP Client Usage
Direct Socket Connection
Connect to the Unix socket at /tmp/nvim-mcp-server-<PID>.sock and use standard MCP protocol:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_buffer_content",
"arguments": {}
}
}
Stdio Connection
Use the standalone server for stdio-based MCP clients:
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_buffer_content","arguments":{}}}' | lua standalone.lua
Development
The plugin structure:
lua/mcpserver/init.lua: Core MCP server implementationlua/mcpserver/tools.lua: Tool implementationsplugin/mcpserver.lua: Plugin setup and commandsstandalone.lua: Standalone MCP server for stdio communication
Requirements
- Neovim with Lua support
- For standalone mode:
netcat(nc) for Unix socket communication
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.