nvim-mcp
v1.1.1MCP server for AI-assisted control of Neovim via msgpack-RPC
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
connect
Connect to a running Neovim instance over its Unix socket or TCP address. Call this before any other tool if the agent is not yet connected. Connection is persistent for the session; you only need to call it once unless you want to switch instances. Called with no arguments: auto-connects when exactly one instance is running; returns a list of instances when multiple are found. Optional selection (provide at most one): - index: pick from the listed instances (1-based). - socket_path: connect directly to a known Unix socket or host:port. - terminal_pid: fi…
| Parameter | Type | Description |
|---|---|---|
index | ||
socket_path | ||
terminal_pid |
send_command
Run one or more Vim ex commands in Neovim. This is a mutation tool — commands can modify buffers, files on disk, windows, and editor state. command: a single command string or a list of strings, without the leading ':'. E.g. "w", "e src/main.py", "42", "wincmd v", "lua vim.print(...)", or ["wincmd p", "e file.py", "wincmd p"]. Use this for editor operations that don't have a dedicated tool (e.g. saving, opening files, splitting windows, setting options). Use `send_keys` instead when you need normal-mode motions or operator sequences. Use `find_and_replac…
| Parameter | Type | Description |
|---|---|---|
command * |
send_keys
Send raw keystrokes to Neovim as if typed by the user. This is a mutation tool — keystrokes can modify buffers, change mode, and trigger editor actions. keys: a string of Vim keystrokes. Esc is prepended automatically, so input always begins in normal mode. Multi-mode sequences must be sent in a single call (e.g. "17GVG", not "17GV" then "G"). Use Vim notation for special keys (e.g. "<CR>", "<C-w>v", "<Tab>"). Use this for normal-mode motions, visual selections, or operator sequences. Use `send_command` for ex commands, and `find_and_replace_buf` o…
| Parameter | Type | Description |
|---|---|---|
keys * | string |
send_to_terminal
Type text into a terminal buffer's running program (usually a shell) by writing to its job channel. This is a mutation tool — the text reaches the program's stdin as if typed, but is not executed unless submit is true. text: the text to send, raw. In most shells an embedded newline acts like pressing Enter, so multi-line text may execute line by line. When submit is false, trailing newlines are stripped so nothing runs by accident. terminal: which terminal to target — a buffer number or buffer name, as listed under `terminals` in `get_state` / `…
| Parameter | Type | Description |
|---|---|---|
text * | string | |
submit | boolean | |
terminal |
get_all_diagnostics
Get LSP diagnostics from all open buffers in Neovim. Read-only. Use this for a project-wide overview of errors and warnings. Use `get_buf_diagnostics` instead when you only need diagnostics for a specific file — it is more focused and returns less data. Returns a list of {file, line, col, severity, message, source}. severity is one of "error", "warning", "info", "hint". Returns an empty list when there are no diagnostics. Results depend on which LSP servers are attached and which buffers are loaded in Neovim.
get_buf_diagnostics
Get LSP diagnostics for a single Neovim buffer. Read-only. file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. Use this when you need diagnostics for one specific file. Use `get_all_diagnostics` instead for a project-wide overview. Returns a list of {file, line, col, severity, message, source}. severity is one of "error", "warning", "info", "hint". Returns an empty list when the buffer has no diagnostics.
| Parameter | Type | Description |
|---|---|---|
file * | string |
find_and_replace_buf
Find and replace text in a Neovim buffer. The edit happens in-memory and is fully undoable — nothing is written to disk until the user saves. file: path relative to Neovim's cwd (as shown in `get_state` buffers). old_string: the exact text to find. Must match exactly once in the buffer; returns an error if not found or if it matches multiple locations. Include surrounding lines to disambiguate. new_string: the replacement text. Creates the buffer if it doesn't already exist. Use this for targeted edits. Use `write_full_buf` instead when replacing the ent…
| Parameter | Type | Description |
|---|---|---|
file * | string | |
new_string * | string | |
old_string * | string |
write_full_buf
Replace the entire content of a Neovim buffer. The edit happens in-memory and is fully undoable — nothing is written to disk until the user saves. file: path relative to Neovim's cwd (as shown in `get_state` buffers). content: the full new text for the buffer. Creates the buffer if it doesn't already exist. Use this when you need to rewrite the whole file. Use `find_and_replace_buf` instead for targeted edits that preserve surrounding content. Returns {total_lines} with the new line count.
| Parameter | Type | Description |
|---|---|---|
content * | string | |
file * | string |
read_full_buf
Read the full content of a Neovim buffer. Read-only; reads from Neovim's in-memory buffer, which may differ from the file on disk if there are unsaved changes. file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. Use this when you need to see the entire file. Use `read_buf_range` instead when you only need a specific section — it returns less data. Returns {lines, total_lines}. lines is a list of strings, each prefixed with its 1-based line number (e.g. "1: first line…
| Parameter | Type | Description |
|---|---|---|
file * | string |
read_buf_range
Read a specific line range from a Neovim buffer. Read-only; reads from Neovim's in-memory buffer, which may differ from the file on disk if there are unsaved changes. file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. start_line: first line to read (1-indexed, inclusive). end_line: last line to read (1-indexed, inclusive). Out-of-range values are clamped to the buffer bounds. If start_line > end_line they are swapped automatically. Use this when you only need a…
| Parameter | Type | Description |
|---|---|---|
end_line * | integer | |
file * | string | |
start_line * | integer |
get_state
Full snapshot of the current Neovim session. Read-only — does not modify any editor state. Use `get_state_brief` for quick orientation at the start of a turn. Use this when you need the complete picture: all window details, folds, marks, diagnostics summaries, highlights, virtual text, and indent settings. Returns: mode (normal/insert/visual/etc.), cwd, buffers (relative paths of all listed buffers), modified_buffers, current_tab, tab_count, and terminals — a list of open terminal buffers as {buf, name, visible}, present only when at least one exists (…
get_state_brief
Lightweight snapshot of the Neovim session for quick orientation. Read-only — does not modify any editor state. Use this when a turn depends on what the user is working on: before reading or editing files, acting on the editor, or answering about the current view. One call per turn is enough; skip it for turns that don't touch the editor or files. Use `get_state` instead when you need the full picture: all windows, folds, marks, diagnostics summaries, highlights, virtual text, and indent settings. Returns: mode (normal/insert/visual/etc.), cwd, buffers (…
highlight_range
Add a colored line highlight to a Neovim buffer. This is a visual annotation only — it does not modify buffer content and is not persisted to disk. Highlights stack; calling this multiple times adds more highlights without removing previous ones. file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. start_line: first line to highlight (1-indexed, inclusive). end_line: last line to highlight (1-indexed, inclusive). Out-of-range values are clamped. If start_line > end_li…
| Parameter | Type | Description |
|---|---|---|
end_line * | integer | |
file * | string | |
start_line * | integer | |
color | string |
highlight_ranges
Add colored line highlights to one or more Neovim buffers in a single call. This is a visual annotation only — it does not modify buffer content and is not persisted to disk. Highlights stack; calling this adds more highlights without removing previous ones. highlights: a list of dicts. Each dict requires: - file: path relative to Neovim's cwd (as shown in `get_state`). The buffer must be open in Neovim. - start_line: first line (1-indexed, inclusive). - end_line: last line (1-indexed, inclusive). - color (optional): hex color (e.g. "#5f3a3a")…
| Parameter | Type | Description |
|---|---|---|
highlights * | array |
clear_highlights
Remove all MCP highlights from a Neovim buffer. Only removes highlights added by `highlight_range` or `highlight_ranges` — does not affect syntax highlighting, LSP highlights, or other plugins. Does not modify buffer content. Safe to call even if no highlights are present (returns {cleared: true} either way). file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. Use this to clean up highlights after an annotation workflow. Use `highlight_range` or `highlight_ranges` to…
| Parameter | Type | Description |
|---|---|---|
file * | string |
add_virtual_text
Add a virtual text annotation to a Neovim buffer. Visual only — the buffer's actual content is unchanged and nothing is written to disk. Annotations stack; multiple calls accumulate. file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. line: 1-indexed anchor line. Out-of-range values are clamped. text: list of strings, one per virtual line. Must be non-empty. When position is "eol", exactly one item is allowed. position: where the annotation appears relative to the an…
| Parameter | Type | Description |
|---|---|---|
file * | string | |
line * | integer | |
text * | array | |
color | string | |
position | string |
add_virtual_texts
Add multiple virtual text annotations to Neovim buffers in a single call. Visual only — buffer content is unchanged. Annotations stack; calling this adds more without removing previous ones. items: a list of dicts. Each dict requires: - file: path relative to Neovim's cwd. Buffer must be open. - line: 1-indexed anchor line. Out-of-range values are clamped. - text: list of strings, one per virtual line. Non-empty. EOL position requires exactly one item. And optionally: - position: "eol" (default), "above", or "below". - color: hex color…
| Parameter | Type | Description |
|---|---|---|
items * | array |
clear_virtual_texts
Remove all MCP virtual text annotations from a Neovim buffer. Only removes annotations added by `add_virtual_text` or `add_virtual_texts` — does not affect highlights, LSP virtual text, inlay hints, or other plugins. Does not modify buffer content. Safe to call even if no annotations are present (returns {cleared: true} either way). file: path relative to Neovim's cwd (as shown in `get_state` buffers). The buffer must already be open in Neovim; returns an error otherwise. Use this to clean up after an annotation workflow. Use `add_virtual_text` or `add…
| Parameter | Type | Description |
|---|---|---|
file * | string |