Sponsored by Deepsite.site

Vim MCP Server

Created By
bregglesa month ago
An MCP server for driving Vim. Connect your coding agent to show you changed files in Vim, or get it to advise you on the code in your open buffers. Can also set your quickfix/location list to direct you to multiple points in your code.
Overview

vim-mcp-server

An MCP (Model Context Protocol) server embedded in Vim. It exposes tools over HTTP that let MCP-compatible clients — such as AI coding agents — read and modify buffers, move the cursor, retrieve visual selections, manage quickfix and location lists, open side-by-side diffs, read message history, and run Ex commands.

Requirements

  • Vim compiled with +python3

Installation

Use your preferred plugin manager.

vim-plug

Plug 'breggles/vim-mcp-server'

Vundle

Plugin 'breggles/vim-mcp-server'

Manual

Clone the repository into your Vim packages directory:

git clone https://github.com/breggles/vim-mcp-server.git \
    ~/.vim/pack/plugins/start/vim-mcp-server

Usage

Start the server

In Vim, run:

:McpServerStart

Auto-start the server on Vim launch by adding this to your vimrc:

let g:mcp_server_autostart = 1

MCP Client Configuration

Point your MCP client at http://127.0.0.1:8765/mcp (or whichever port you chose).

For example, for opencode add the server to your opencode.jsonc:

"mcp": {
  "vim": {
    "type": "remote",
    "url": "http://localhost:8765/mcp",
    "enabled": true
  }
}

Commands

CommandDescription
:McpServerStart [port]Start the server (default port 8765)
:McpServerStopStop the server
:McpServerStatusPrint server status and URL

Options

VariableDefaultDescription
g:mcp_server_port8765Port the server listens on
g:mcp_server_autostart0Start the server automatically on VimEnter
g:mcp_server_allow_execute0Enable the execute_command tool
g:mcp_server_allow_save0Enable the save_buffer tool
g:mcp_server_allow_edit0Enable the edit_buffer tool

Tools

The server exposes the following tools to MCP clients:

ToolDescription
list_buffersList all open buffers
get_bufferRead buffer contents (optionally a line range)
edit_bufferReplace, insert, or delete lines in a buffer
open_fileOpen a file via :edit
save_bufferSave a buffer via :write (opt-in, see above)
close_bufferClose a buffer via :bdelete
get_cursorGet current cursor position
set_cursorMove cursor to a line and column
get_visual_selectionGet the current visual selection, if any
execute_commandRun an arbitrary Ex command (opt-in, see above)
get_quickfix_listGet the current quickfix list entries
set_quickfix_listSet the quickfix list
get_location_listGet the location list for the current window
set_location_listSet the location list for the current window
get_messagesGet Vim's message history (:messages output)
show_diffOpen a side-by-side diff view in a new tab (files or content)

When a tool accepts a buffer argument it can be specified by number (buffer_id) or by file path (buffer_path). When both are omitted, the current buffer is used.

OpenCode Plan Mode

By default, OpenCode's plan mode disables all MCP tools. To allow read-only vim tools in plan mode, add the following to your opencode.jsonc:

{
  "agent": {
    "plan": {
      "tools": {
        "vim_*": false,
        "vim_list_buffers": true,
        "vim_get_buffer": true,
        "vim_get_cursor": true,
        "vim_get_visual_selection": true,
        "vim_open_file": true,
        "vim_set_cursor": true,
        "vim_get_quickfix_list": true,
        "vim_set_quickfix_list": true,
        "vim_get_location_list": true,
        "vim_set_location_list": true,
        "vim_get_messages": true,
        "vim_show_diff": true
      }
    }
  }
}

This disables all vim_* tools first, then re-enables specific ones. Adjust the list to suit your workflow.

Development

To work on the plugin without installing it, clone the repository and add it to Vim's runtime path:

set rtp+=~/path/to/vim-mcp-server

Add this to your vimrc or run it manually. Changes take effect the next time Vim is started.

Generate the help tags with:

:helptags ~/path/to/vim-mcp-server/doc

License

MIT

Server Config

{
  "mcpServers": {
    "vim": {
      "type": "remote",
      "url": "http://localhost:8765/mcp",
      "enabled": true
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Tavily Mcp
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Amap Maps高德地图官方 MCP Server
DeepChatYour AI Partner on Desktop