MCPSERV.CLUB
calebfroese

Neovim MCP Server

MCP Server

Expose Neovim to external tools via Unix socket

Stale(45)
0stars
1views
Updated Jun 4, 2025

About

A Neovim plugin that implements an MCP server, allowing external clients to interact with Neovim over a Unix socket or stdio. It provides tools like fetching buffer content and supports multiple simultaneous instances.

Capabilities

Resources
Access data sources
Tools
Execute functions
Prompts
Pre-built templates
Sampling
AI model interactions

Overview

The mcpserver.nvim plugin turns Neovim into a fully‑featured Model Context Protocol (MCP) server, enabling external AI assistants to query and manipulate the editor’s state over a Unix socket. By exposing Neovim as an MCP endpoint, developers can build AI workflows that treat the editor like a first‑class data source—retrieving buffer contents, executing commands, or extending functionality through custom tools—all while keeping the assistant’s logic separate from the editor itself.

At its core, the server implements a minimal yet powerful set of tools. The flagship feature is , which returns the current buffer’s file name, full text, and line count in JSON. This simple yet essential capability allows an AI assistant to reason about code context, generate completions, or perform static analysis without needing direct access to the file system. The server’s design is intentionally lightweight: it runs as a background process, listening on , and can be started or stopped with dedicated Vim commands. Multiple Neovim instances each spawn their own socket, ensuring isolation and preventing port clashes.

For clients that prefer the standard MCP stdio transport—common in many language‑model tooling stacks—the plugin ships a standalone Lua script. This wrapper auto‑detects active Neovim MCP sockets, forwards JSON‑RPC requests, and bridges the communication gap between a stdio‑based client and Neovim’s Unix socket. The result is a single, coherent MCP interface that works seamlessly with any client supporting either transport layer.

Typical use cases include:

  • AI‑powered code completion that fetches the current file’s content, analyzes it with a language model, and injects suggestions back into Neovim.
  • Contextual documentation lookup where the assistant pulls the buffer, queries an external knowledge base, and displays relevant snippets.
  • Automated refactoring triggered by the assistant, which first reads the buffer, proposes changes, and then applies them through Neovim’s command interface.

Integrating mcpserver.nvim into a workflow is straightforward: an AI assistant connects to the socket, calls , processes the data, and then optionally sends back commands or updated content. Because the server is written in Lua and leverages Neovim’s built‑in RPC mechanisms, latency remains low and the editor’s responsiveness is preserved. Developers benefit from a clean separation of concerns—Neovim handles editing, while the assistant focuses on intelligence—making it easier to compose complex AI‑enhanced development pipelines.