Sandbox
@linw1995/nvim-mcp

MCP server for Neovim editor connections

nvim-mcp is an MCP server that bridges agent clients and live Neovim instances. It exposes connections, diagnostics, LSP actions, and document lookup through structured resources and tools, so an agent can work with your editor state directly.

69 stars15 forksRustUpdated 8d ago
Who it's for

Builders who want their agent to inspect and act on a live Neovim session.

What it delivers

You can have an agent read diagnostics, trigger LSP actions, and work against the right editor buffer without manual copy-paste.

What it does

Multiple Neovim connections

Tracks more than one Neovim instance at once so agents can work with the right session.

LSP workflow support

Exposes code actions, hover, and diagnostics from Neovim's LSP state.

Universal document identifiers

Lets tools address files by buffer ID, relative path, or absolute path.

Structured MCP resources

Publishes connection-aware diagnostic data through URI schemes.

Stdio and HTTP transport

Runs as either a stdio server or an HTTP server depending on the client setup.

Neovim plugin integration

Includes a plugin for automatic setup inside Neovim.

Dynamic tools

Supports experimental user-extensible custom tools.

How to get it

  1. 1Run
    cargo install nvim-mcp
  2. 2Run it directly, without installing anything
    nix run github:linw1995/nvim-mcp -- --version
  3. 3Or install it imperatively into your profile
    nix profile install github:linw1995/nvim-mcp
  4. 4Run
    git clone https://github.com/linw1995/nvim-mcp.git && cd nvim-mcp
    cargo install --path .
  5. 5Run
    # Auto-connect to current project Neovim instances (recommended)
    claude mcp add -s local nvim -- nvim-mcp --log-file . \
      --log-level debug --connect auto
    
    # Analyze diagnostics in current Neovim instance
    claude "analyze @nvim:nvim-diagnostics://"

README

Neovim MCP Server

codecov GitHub Actions Workflow Status

A Model Context Protocol (MCP) server that provides seamless integration with Neovim instances, enabling AI assistants to interact with your editor through connections and access diagnostic information via structured resources. Supports both stdio and HTTP server transport modes for different integration scenarios.

Features

  • Multi-Connection Support: Manage multiple concurrent Neovim instances
  • LSP Integration: Complete LSP workflow with code actions, hover, and diagnostics
  • Universal Document Identifier: Work with files by buffer ID, relative path, or absolute path
  • MCP Resources: Structured diagnostic data via connection-aware URI schemes
  • Multi-Transport Support: Both stdio and HTTP server transport modes
  • Dynamic Tool System ⚠️ (Experimental): User-extensible custom tools
  • Plugin Integration: Automatic setup through Neovim plugin

Installation

Use Cargo install from crates.io

cargo install nvim-mcp

Using Nix

This repository is a flake that exposes the server as its default package and app.

Run it directly, without installing anything:

nix run github:linw1995/nvim-mcp -- --version

Or install it imperatively into your profile:

nix profile install github:linw1995/nvim-mcp

Declarative setup with home-manager

The snippet below installs the Neovim plugin and the server binary, then registers it with Claude Code declaratively. No cargo install build step and no manual claude mcp add:

# flake.nix
inputs.nvim-mcp.url = "github:linw1995/nvim-mcp";
# home-manager module (inputs must be in scope)
{ pkgs, lib, inputs, ... }:
let
  nvim-mcp = inputs.nvim-mcp.packages.${pkgs.system}.default;
in
{
  programs.neovim = {
    enable = true;
    plugins = [
      (pkgs.vimUtils.buildVimPlugin {
        pname = "nvim-mcp";
        version = inputs.nvim-mcp.shortRev or "unstable";
        src = inputs.nvim-mcp;
      })
    ];
    extraLuaConfig = ''require("nvim-mcp").setup({})'';
  };

  # Requires home-manager's programs.claude-code module.
  programs.claude-code = {
    enable = true;
    mcpServers.nvim = {
      type = "stdio";
      command = lib.getExe nvim-mcp;
      args = [ "--connect" "auto" ];
    };
  };
}

This registers the nvim MCP server for every project, so you can skip the manual claude mcp add step below.

Tip: git spawns throwaway Neovim instances to edit commit, merge and rebase messages. If those load your full config they each call setup() and register an extra socket in the same git root. Guard the call so exactly one socket exists per repository:

local transient = false
for _, arg in ipairs(vim.fn.argv()) do
  if arg:match("COMMIT_EDITMSG$") or arg:match("MERGE_MSG$")
    or arg:match("git%-rebase%-todo$") or arg:match("TAG_EDITMSG$") then
    transient = true
  end
end
if not transient then
  require("nvim-mcp").setup({})
end

From Source

git clone https://github.com/linw1995/nvim-mcp.git && cd nvim-mcp
cargo install --path .

Usage Cases Collection

  • LSP Hover Translation (From #85)
  • Diagnostic Analysis and Code Fixes (From #10)
  • Smart Context Retrieval (From #86)
  • And more in Discussions

Quick Start

1. Setup Neovim Integration

With a plugin manager like lazy.nvim:

return {
    "linw1995/nvim-mcp",
    build = "cargo install --path .",
    opts = {},
}

2. Configure claude or other MCP clients

# Auto-connect to current project Neovim instances (recommended)
claude mcp add -s local nvim -- nvim-mcp --log-file . \
  --log-level debug --connect auto

# Analyze diagnostics in current Neovim instance
claude "analyze @nvim:nvim-diagnostics://"

Documentation

For detailed information, see:

Development

Basic development setup:

# Enter development shell
nix develop .

# Run tests
cargo test -- --show-output

# Build and run
cargo run -- --connect auto

See Development Guide for complete setup instructions, testing procedures, and contribution guidelines.

Files in the repo

Repository payload17 top-level entries
  • .github
  • docs
  • lua
  • scripts
  • src
  • .gitignore
  • .pre-commit-config.yaml
  • build.rs
  • Cargo.lock
  • Cargo.toml
  • CHANGELOG.md
  • CLAUDE.md
  • flake.lock
  • flake.nix
  • LICENSE
  • README.md
  • stylua.toml

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k
t8y2/dbxConnectors

20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 90+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP Server。

19k