Control Neovim with AI Commands
Neovim MCP Server connects Claude to a running Neovim session for buffer editing, search, macros, and window management.
Why it matters
Integrate Claude Desktop with Neovim for AI-powered text editing. Leverage native Vim commands and workflows to enhance your coding and editing experience.
Outcomes
What it gets done
Execute Vim commands for navigation and editing
Manage Neovim buffers, windows, and selections
Perform project-wide searches using vimgrep
Automate repetitive editing tasks with macros
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-neovim | bash Capabilities
Tools your agent gets
Get buffer contents with line numbers, supports filename parameter
Send a command to VIM for navigation, precision editing, and line deletion
Get full Neovim status including cursor position, mode, filename, visual selection, windows
Edit lines using insert, replace, or replaceAll modes
Manage Neovim windows (split, vsplit, close, navigate)
Set named marks at specific positions
Set register contents
Create selections in visual mode
Overview
Neovim MCP Server
An MCP server connecting Claude to a live Neovim session via socket: buffer editing, search/replace, macros, and window/tab/fold management across 19 tools. Use it when Claude needs to interact directly with an already-open Neovim session - requires a socket connection, not plain vim.
What it does
Neovim MCP Server connects Claude Desktop (or any MCP client) to a running Neovim instance via the official neovim/node-client library and a socket connection, using Vim's native commands and workflows to give Claude a lightweight text-editing layer for code or general writing. Errors surface through three dedicated error classes for clearer diagnosis: NeovimConnectionError for socket connection failures, NeovimCommandError for command execution failures with the failing command included, and NeovimValidationError for bad input - every tool wraps calls in try-catch handling that returns a properly formatted MCP error rather than an opaque failure.
When to use - and when NOT to
Use it when you want Claude to interact directly with a real Neovim session you already have open - viewing and switching buffers, editing lines, running searches and regex replacements, project-wide grep, recording and playing macros, or managing windows, tabs, and folds. Start Neovim with a socket exposed (e.g. --listen /tmp/nvim) before connecting. Do not expect it to work with standard Vim - a socket connection is required, so plain vim is unsupported - and shell command execution (! prefix) is disabled by default for security, requiring ALLOW_SHELL_COMMANDS=true to enable. It may also not interact well with complex Neovim configurations or plugins.
Capabilities
19 tools across several areas:
- Core editing:
vim_buffer(view buffer contents),vim_command(run Vim/shell commands),vim_status(cursor, mode, visual selection, window layout, LSP client info),vim_edit(insert/replace/replaceAll),vim_window(split/vsplit/close/navigate),vim_mark,vim_register,vim_visual. - Buffer management:
vim_buffer_switch,vim_buffer_save,vim_file_open. - Search and replace:
vim_search(regex),vim_search_replace,vim_grep(project-wide, quickfix-integrated). - Advanced workflow:
vim_macro(record/stop/play),vim_tab,vim_fold,vim_jump. - System:
vim_health(connection diagnostics).
Resources: nvim://session (current session) and nvim://buffers (all open buffers with metadata). A neovim_workflow prompt gives step-by-step guidance for common editing, navigation, and buffer-management tasks.
How to install
Easiest via the .dxt package: download the latest release and drag it into Claude Desktop. Or configure manually in claude_desktop_config.json:
{
"mcpServers": {
"MCP Neovim Server": {
"command": "npx",
"args": ["-y", "mcp-neovim-server"],
"env": {
"ALLOW_SHELL_COMMANDS": "true",
"NVIM_SOCKET_PATH": "/tmp/nvim"
}
}
}
}
NVIM_SOCKET_PATH defaults to /tmp/nvim; ALLOW_SHELL_COMMANDS defaults to false. Start Neovim with a matching --listen socket path before connecting.
Who it's for
Developers who live in Neovim and want Claude to navigate, edit, search, and manipulate their actual editor session directly instead of working from a separate file view. vim_status in particular returns a comprehensive snapshot on demand - cursor position, mode, filename, an enhanced visual-selection report (character/line/block detection with accurate selection text and start/end positions), window layout, current tab, marks, registers, working directory, and LSP client info. Licensed MIT.
Source README
Neovim MCP Server
Connect Claude Desktop (or any Model Context Protocol client) to Neovim using MCP and the official neovim/node-client JavaScript library. This server leverages Vim's native text editing commands and workflows, which Claude already understands, to create a lightweight code or general purpose AI text assistance layer.
Features
- Connects to your nvim instance if you expose a socket file, for example
--listen /tmp/nvim, when starting nvim - Views your current buffers and manages buffer switching
- Gets cursor location, mode, file name, marks, registers, and visual selections
- Runs vim commands and optionally shell commands through vim
- Can make edits using insert, replace, or replaceAll modes
- Search and replace functionality with regex support
- Project-wide grep search with quickfix integration
- Comprehensive window management
- Health monitoring and connection diagnostics
API
Resources
nvim://session: Current neovim text editor sessionnvim://buffers: List of all open buffers in the current Neovim session with metadata including modified status, syntax, and window IDs
Tools
Core Tools
- vim_buffer
- Get buffer contents with line numbers (supports filename parameter)
- Input
filename(string, optional) - Get specific buffer by filename - Returns numbered lines with buffer content
- vim_command
- Send a command to VIM for navigation, spot editing, and line deletion
- Input
command(string) - Runs vim commands with
nvim.replaceTermcodes. Multiple commands work with newlines - Shell commands supported with
!prefix whenALLOW_SHELL_COMMANDS=true - On error,
'nvim:errmsg'contents are returned
- vim_status
- Get comprehensive Neovim status
- Returns cursor position, mode, filename, visual selection with enhanced detection, window layout, current tab, marks, registers, working directory, LSP client info, and plugin detection
- Enhanced visual selection reporting: detects visual mode type (character/line/block), provides accurate selection text, start/end positions, and last visual selection marks
- vim_edit
- Edit lines using insert, replace, or replaceAll modes
- Input
startLine(number),mode("insert"|"replace"|"replaceAll"),lines(string) - insert: insert lines at startLine
- replace: replace lines starting at startLine
- replaceAll: replace entire buffer contents
- vim_window
- Manipulate Neovim windows (split, vsplit, close, navigate)
- Input
command(string: "split", "vsplit", "only", "close", "wincmd h/j/k/l")
- vim_mark
- Set named marks at specific positions
- Input
mark(string: a-z),line(number),column(number)
- vim_register
- Set content of registers
- Input
register(string: a-z or "),content(string)
- vim_visual
- Create visual mode selections
- Input
startLine(number),startColumn(number),endLine(number),endColumn(number)
Enhanced Buffer Management
- vim_buffer_switch
- Switch between buffers by name or number
- Input
identifier(string | number) - Buffer name or number
- vim_buffer_save
- Save current buffer or save to specific filename
- Input
filename(string, optional) - Save to specific file
- vim_file_open
- Open files into new buffers
- Input
filename(string) - File to open
Search and Replace
- vim_search
- Search within current buffer with regex support
- Input
pattern(string),ignoreCase(boolean, optional),wholeWord(boolean, optional)
- vim_search_replace
- Find and replace with advanced options
- Input
pattern(string),replacement(string),global(boolean, optional),ignoreCase(boolean, optional),confirm(boolean, optional)
- vim_grep
- Project-wide search using vimgrep with quickfix list
- Input
pattern(string),filePattern(string, optional) - File pattern to search
Advanced Workflow Tools
- vim_macro
- Record, stop, and play Vim macros
- Input
action("record" | "stop" | "play"),register(string, a-z),count(number, optional)
- vim_tab
- Complete tab management
- Input
action("new" | "close" | "next" | "prev" | "first" | "last" | "list"),filename(string, optional)
- vim_fold
- Code folding operations
- Input
action("create" | "open" | "close" | "toggle" | "openall" | "closeall" | "delete"),startLine/endLine(numbers, for create)
- vim_jump
- Jump list navigation
- Input
direction("back" | "forward" | "list")
System Tools
- vim_health
- Check Neovim connection health and socket status
Using this comprehensive set of 19 tools, Claude can peer into your neovim session, navigate buffers, perform searches, make edits, record macros, manage tabs and folds, and handle your complete development workflow with standard Neovim features.
Prompts
- neovim_workflow: Get contextual help and guidance for common Neovim workflows including editing, navigation, search, buffer management, window operations, and macro usage. Provides step-by-step instructions for accomplishing tasks with the available MCP tools.
Error Handling
The server implements comprehensive error handling with custom error classes and consistent error responses:
- NeovimConnectionError: Socket connection failures with detailed messages
- NeovimCommandError: Command execution failures with command context
- NeovimValidationError: Input validation failures
New in v0.5.2: All tools now include robust try-catch error handling that returns meaningful error messages in proper MCP format. Features include connection health monitoring, graceful error propagation, and actionable error messages to help diagnose issues.
Limitations
- May not interact well with complex neovim configurations or plugins
- Shell command execution is disabled by default for security
- Socket connection required - won't work with standard vim
Configuration
Environment Variables
ALLOW_SHELL_COMMANDS: Set to 'true' to enable shell command execution (e.g.!ls). Defaults to false for security.NVIM_SOCKET_PATH: Set to the path of your Neovim socket. Defaults to '/tmp/nvim' if not specified.
Installation
Option 1: DXT Package (Recommended)
- Download the latest
.dxtfile from Releases - Drag the file to Claude Desktop
Option 2: Manual Installation
Add this to your claude_desktop_config.json:
{
"mcpServers": {
"MCP Neovim Server": {
"command": "npx",
"args": [
"-y",
"mcp-neovim-server"
],
"env": {
"ALLOW_SHELL_COMMANDS": "true",
"NVIM_SOCKET_PATH": "/tmp/nvim"
}
}
}
}
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.