Neovim MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
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 session
- nvim://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 when ALLOW_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