Skip to main content

MCP server for AI-assisted control of Neovim via msgpack-RPC

Project description

nvim-mcp

PyPI

nvim-mcp is an MCP server that lets AI assistants (Cursor, Claude, and others) control a running Neovim session: open buffers, move the cursor, run LSP actions, inspect layout, and more. It talks to Neovim directly over its default Unix socket using msgpack-RPC, discovers instances automatically, and exposes four tools.

Platforms: Linux and macOS only.

https://github.com/user-attachments/assets/a546b3d5-082e-4f3d-aaaf-e94d997d506a

Install

uv tool install nvim-mcp

Or run without installing:

uvx nvim-mcp

Quick start

  1. Start Neovim (it listens on an RPC socket by default) — this works in any terminal, including the integrated terminal in Cursor, VS Code, or similar editors.
  2. Set up your MCP client and agent rules — see config/ for everything you need.
  3. The assistant can now control Neovim through 4 tools.

Tools

Tool Purpose
nvim_send The universal interface. Send any ex command, Vimscript expression, or key sequence to Neovim. Three modes: command, eval, keys. Returns {"result": ..., "state": {...}} by default (state matches nvim_state); set return_state=false for the result string only.
nvim_state Structured snapshot: current file, cursor, mode, windows, modified buffers, cwd, and more — plus context lines around the cursor or selection, each prefixed with its absolute line number. In visual mode, also includes a selection range (start_line, start_col, end_line, end_col).
nvim_connect Connect to a Neovim instance. Auto-connects when only one exists; lists all when multiple are found.
nvim_recipes Browse operation recipes by category (files, navigation, buffers, windows, marks, registers, folds, LSP).

Multi-instance

One Neovim instance running? Tools auto-connect. Multiple? nvim_connect lists them — pick by index, socket_path, or terminal_pid. Set NVIM_SOCKET_PATH to skip discovery entirely.

Environment

Variable Default Description
NVIM_SOCKET_PATH (auto-discover) Skip discovery; connect directly to this socket.
NVIM_MCP_CONTEXT_LINES 20 Lines above/below cursor included in state. Set to 0 to disable.

Setup

See config/ for MCP client registration (Cursor, Claude Desktop, Claude CLI) and example agent rule files.

Demo

Open a file in Neovim, then paste this into your AI assistant:

Run through these one at a time. After each step, tell me what happened
and wait for my OK before moving on.

1. What file am I in and what code is around my cursor?
2. I'm going to highlight some lines — tell me what I selected and what it does.
3. Add a docstring or comment above the function my cursor is in, save, and show me the result.
4. Open a vertical split with a new file, write a short helper function in it, and save.
5. Switch back to the original window — what's on screen now?
6. Rename a variable in the current function (edit on disk, reload) and confirm the change.
7. Jump to the last function in the file and explain what it does.
8. Show me the LSP recipes.

Requirements

  • Python ≥ 3.10
  • Linux or macOS
  • Neovim with RPC socket enabled (default)

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nvim_mcp-0.4.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nvim_mcp-0.4.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file nvim_mcp-0.4.0.tar.gz.

File metadata

  • Download URL: nvim_mcp-0.4.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nvim_mcp-0.4.0.tar.gz
Algorithm Hash digest
SHA256 617984a9c5d66eae136edde9037cd9dc894f4f855ccedbb7be9d6d18ebc764d3
MD5 60f6c4427b5d4273922ddd7538cf4745
BLAKE2b-256 0d6ba8e2ceac0748d5b4609ea22b0ae3b61080ab8a61ba6f28bcd6e0fafd01f0

See more details on using hashes here.

File details

Details for the file nvim_mcp-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: nvim_mcp-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nvim_mcp-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2542cb7efea91c6e933b965a35a5af0aa80917d6c36311a28a28ef755112826
MD5 5efa7a3c5b9a3d35e49692fb566bad9e
BLAKE2b-256 ecc6aa7edeb8ea96af3fdd53340e4fc7df2c99081e191ca5af8b723d55ae2e73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page