nvim-mcp
nvim-mcp is an MCP server that gives AI agents full programmatic access to a running Neovim session via its native msgpack-RPC socket, enabling them to view, edit, and manipulate code as if directly using the editor.
Connect to Neovim: Auto-discover and connect to one or more running Neovim instances by index, socket path, or terminal PID.
Run Ex commands: Execute any Vim/Neovim ex command (e.g.,
:w,:vsplit,:lua ...), single or batched.Send keystrokes: Send raw key sequences for navigation, mode switching, and triggering mappings.
Get session state: Retrieve a full snapshot including mode, CWD, open buffers, window layout, cursor position, folds, visual selections, marks, diagnostics summary, and active highlights.
Read buffer contents: Read an entire in-memory buffer or a specific line range, with line numbers.
Edit buffers: Perform find-and-replace (must match exactly once) or overwrite entire buffer contents — all in-memory with full undo support, nothing written to disk until explicitly saved.
Get LSP diagnostics: Retrieve errors, warnings, hints, and info from LSP for all buffers or a specific file.
Highlight lines: Annotate specific line ranges with colored extmarks (without modifying content), apply multiple highlights simultaneously, and clear them when done.
Allows AI assistants to control a running Neovim session by sending ex commands, Vimscript expressions, and key sequences; retrieving structured state snapshots including current file, cursor position, mode, window layout, and modified buffers; managing connections to specific instances; and browsing operation recipes for files, navigation, buffers, windows, marks, registers, folds, and LSP actions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nvim-mcpgo to definition of the function under cursor"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
nvim-mcp
An MCP server that gives AI agents first-class access to your running Neovim session. It connects through Neovim's native msgpack-RPC socket — no plugins required.
Works with Cursor, Claude Code, Codex, OpenCode, and any MCP-compatible client.
Before you connect an agent to Neovim, please read Working safely.
What agents can do
See what you see — editor mode, working directory, open buffers, window layout, cursor context, folds, selections, marks, and diagnostics.
Edit buffers in memory — find-and-replace or full rewrites with immediate feedback and full undo support. Nothing touches disk until you save.
Run any Vim command —
:w,:e,:vsplit, macros, or anything else you could type at the command line.Send keystrokes — navigate, enter insert mode, trigger mappings.
Query LSP diagnostics — errors, warnings, and hints across one buffer or the whole session.
Annotate code with highlights and virtual text — colored line highlights and inline/above/below text notes that never touch the buffer's real content.
Work with multiple instances — auto-discovers running sessions and connects to the right one. See multiple instances.
Anything you can do in Neovim, the agent can too. See the full tool reference for details.
Demos
Quick start
nvim-mcp runs via uv (recommended) or Nix.
Cursor users: A Marketplace plugin is pending review — once available, it installs the MCP server and agent rule together (you can skip to step 4). To activate the rule, start chats with something like "Connect to my Neovim instance" — or set the rule to "Always" in Settings → Rules to apply it on every turn.
Install a launcher.
curl -LsSf https://astral.sh/uv/install.sh | shInstall Nix — flakes must be enabled.
Register the MCP server with your client. Example for Cursor (
.cursor/mcp.json):{ "mcpServers": { "nvim-mcp": { "command": "uvx", "args": ["nvim-mcp"] } } }{ "mcpServers": { "nvim-mcp": { "command": "nix", "args": ["run", "github:paulburgess1357/nvim-mcp"] } } }For Claude Code, Codex, Claude Desktop, OpenCode, and other clients, see the configuration guide.
Add agent rules — do not skip this. Without rules, the agent has the tools but doesn't know when or how to use them, and behavior will be unreliable. See the configuration guide for setup.
Start Neovim — on most Linux systems it listens on a Unix socket automatically and is discovered by nvim-mcp. If auto-discovery doesn't work, see environment variables. Running multiple instances? See multiple instances.
Verify it works
Open a file in Neovim and paste this into your AI agent:
For each step: explain what you're about to do, then do it, then tell me
what happened. Wait for me to say "next" before moving on.
1. What file am I in? Highlight the function my cursor is in.
2. Are there any diagnostics? Highlight any lines with errors or warnings.
3. Add a docstring above the function, then show me the diff.
4. Open a vertical split, write a short test for that function, and save both files.Working safely
The tools and agent rules are designed to use non-destructive operations — edits happen in memory, undo history is preserved, and the agent is steered toward buffer operations. But LLMs are non-deterministic, have full access to Neovim's API, and you should assume they will make mistakes. Work in a version-controlled directory.
Requirements
Linux
Python ≥ 3.10
Neovim ≥ 0.11 (older versions work with
--listenandNVIM_ADDRESS)
License
MIT — see LICENSE.
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/paulburgess1357/nvim-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server